@@ -10,6 +10,10 @@ import (
1010 "github.com/clovapi/switcher/internal/profile"
1111)
1212
13+ func boolPtr (v bool ) * bool {
14+ return & v
15+ }
16+
1317type UIModel struct {
1418 ID string `json:"id"`
1519 Label string `json:"label"`
@@ -33,9 +37,10 @@ type UIVendor struct {
3337}
3438
3539type UIProxyConfig struct {
36- Enabled bool `json:"enabled"`
37- Host string `json:"host"`
38- Port int `json:"port"`
40+ Enabled bool `json:"enabled"`
41+ Host string `json:"host"`
42+ Port int `json:"port"`
43+ DebugLocalOnly * bool `json:"debugLocalOnly,omitempty"`
3944}
4045
4146type LoadResult struct {
@@ -145,9 +150,10 @@ func storeToUI(s *profile.Store) LoadResult {
145150 Version : s .Version ,
146151 Active : active ,
147152 Proxy : UIProxyConfig {
148- Enabled : s .Proxy .Enabled ,
149- Host : s .Proxy .Host ,
150- Port : s .Proxy .Port ,
153+ Enabled : s .Proxy .Enabled ,
154+ Host : s .Proxy .Host ,
155+ Port : s .Proxy .Port ,
156+ DebugLocalOnly : boolPtr (s .Proxy .DebugLocalOnly ),
151157 },
152158 Profiles : profiles ,
153159 }
@@ -197,9 +203,13 @@ func SaveProfiles(input SaveInput) SaveResult {
197203 }
198204 if input .Proxy != nil {
199205 current .Proxy = profile.ProxyConfig {
200- Enabled : input .Proxy .Enabled ,
201- Host : strings .TrimSpace (input .Proxy .Host ),
202- Port : input .Proxy .Port ,
206+ Enabled : input .Proxy .Enabled ,
207+ Host : strings .TrimSpace (input .Proxy .Host ),
208+ Port : input .Proxy .Port ,
209+ DebugLocalOnly : current .Proxy .DebugLocalOnly ,
210+ }
211+ if input .Proxy .DebugLocalOnly != nil {
212+ current .Proxy .DebugLocalOnly = * input .Proxy .DebugLocalOnly
203213 }
204214 }
205215 return true , nil
@@ -229,9 +239,10 @@ func proxyConfigFromStore(s *profile.Store) UIProxyConfig {
229239 return UIProxyConfig {}
230240 }
231241 return UIProxyConfig {
232- Enabled : s .Proxy .Enabled ,
233- Host : s .Proxy .Host ,
234- Port : s .Proxy .Port ,
242+ Enabled : s .Proxy .Enabled ,
243+ Host : s .Proxy .Host ,
244+ Port : s .Proxy .Port ,
245+ DebugLocalOnly : boolPtr (s .Proxy .DebugLocalOnly ),
235246 }
236247}
237248
@@ -248,9 +259,13 @@ func LoadProxyConfig() ProxyConfigResult {
248259func SaveProxyConfig (input UIProxyConfig ) ProxyConfigResult {
249260 saved , err := profile .WithLockedDesktopStore (func (current * profile.Store ) (bool , error ) {
250261 current .Proxy = profile.ProxyConfig {
251- Enabled : input .Enabled ,
252- Host : strings .TrimSpace (input .Host ),
253- Port : input .Port ,
262+ Enabled : input .Enabled ,
263+ Host : strings .TrimSpace (input .Host ),
264+ Port : input .Port ,
265+ DebugLocalOnly : current .Proxy .DebugLocalOnly ,
266+ }
267+ if input .DebugLocalOnly != nil {
268+ current .Proxy .DebugLocalOnly = * input .DebugLocalOnly
254269 }
255270 return true , nil
256271 })
0 commit comments