Skip to content

Commit

Permalink
chore: 适配vpn和代理
Browse files Browse the repository at this point in the history
1、增加代理变化信号
2、当IP全为空时,自动设置代理为None

Issue: linuxdeepin/developer-center#9710
linuxdeepin/developer-center#9711
  • Loading branch information
fuleyi committed Jul 19, 2024
1 parent 9c41e3f commit 62e1e8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions network/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ type Manager struct {
ip string
mac string
}
ProxyMethodChanged struct {
method string
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions network/manager_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ func initProxyGsettings() {
proxyChildSettingsHttps = proxySettings.GetChild(gchildProxyHttps)
proxyChildSettingsFtp = proxySettings.GetChild(gchildProxyFtp)
proxyChildSettingsSocks = proxySettings.GetChild(gchildProxySocks)

// 如果ip全为空,则自动设置代理为None
proxyAuto := proxySettings.GetString(gkeyProxyAuto)
http := proxyChildSettingsHttp.GetString(gkeyProxyHost)
https := proxyChildSettingsHttps.GetString(gkeyProxyHost)
ftp := proxyChildSettingsFtp.GetString(gkeyProxyHost)
socks := proxyChildSettingsSocks.GetString(gkeyProxyHost)
if proxyAuto == "" && http == "" && https == "" && ftp == "" && socks == "" {
proxySettings.SetString(gkeyProxyMode, proxyModeNone)
}
}

func getProxyChildSettings(proxyType string) (childSettings *gio.Settings, err error) {
Expand Down Expand Up @@ -110,6 +120,7 @@ func (m *Manager) setProxyMethod(proxyMode string) (err error) {
err = fmt.Errorf("set proxy method through gsettings failed")
return
}
m.service.Emit(m, "ProxyMethodChanged", proxyMode)
switch proxyMode {
case proxyModeNone:
notifyProxyDisabled()
Expand Down

0 comments on commit 62e1e8c

Please sign in to comment.