@@ -6,11 +6,12 @@ package proxy
66
77import (
88 "fmt"
9- "github.com/godbus/dbus"
109 "os"
1110 "strconv"
1211 "strings"
1312
13+ "github.com/godbus/dbus"
14+
1415 "github.com/linuxdeepin/go-gir/gio-2.0"
1516 "github.com/linuxdeepin/go-lib/gsettings"
1617 "github.com/linuxdeepin/go-lib/log"
@@ -51,10 +52,13 @@ const (
5152 proxyModeManual = "manual"
5253 proxyModeAuto = "auto"
5354
54- gkeyProxyAuto = "autoconfig-url"
55- gkeyProxyIgnoreHosts = "ignore-hosts"
56- gkeyProxyHost = "host"
57- gkeyProxyPort = "port"
55+ gkeyProxyAuto = "autoconfig-url"
56+ gkeyProxyIgnoreHosts = "ignore-hosts"
57+ gkeyProxyHost = "host"
58+ gkeyProxyPort = "port"
59+ gkeyProxyUseAuthentication = "use-authentication"
60+ gkeyProxyAuthenticationUser = "authentication-user"
61+ gkeyProxyAuthenticationPassword = "authentication-password"
5862
5963 gchildProxyHttp = "http"
6064 gchildProxyHttps = "https"
@@ -139,6 +143,7 @@ func updateProxyEnvs() {
139143 doSetEnv (envHttpProxy , getProxyValue (proxyTypeHttp , proxyTypeHttp ))
140144 doSetEnv (envHttpsProxy , getProxyValue (proxyTypeHttps , proxyTypeHttp ))
141145 doSetEnv (envFtpProxy , getProxyValue (proxyTypeFtp , proxyTypeHttp ))
146+ doSetEnv (envAllProxy , getProxyValue (proxyTypeSocks , proxyTypeSocks ))
142147 doSetEnv (envSocksProxy , getProxyValue (proxyTypeSocks , proxyTypeSocks ))
143148
144149 arrayIgnoreHosts := proxySettings .GetStrv (gkeyProxyIgnoreHosts )
@@ -215,7 +220,18 @@ func getProxyValue(proxyType string, protocol string) (proxyValue string) {
215220 return
216221 }
217222 port := strconv .Itoa (int (childSettings .GetInt (gkeyProxyPort )))
218- proxyValue = fmt .Sprintf ("%s://%s:%s" , protocol , host , port )
223+
224+ useAuthentication := false
225+ if childSettings .GetSchema ().HasKey (gkeyProxyUseAuthentication ) {
226+ useAuthentication = childSettings .GetBoolean (gkeyProxyUseAuthentication )
227+ }
228+ if useAuthentication {
229+ user := childSettings .GetString (gkeyProxyAuthenticationUser )
230+ password := childSettings .GetString (gkeyProxyAuthenticationPassword )
231+ proxyValue = fmt .Sprintf ("%s://%s:%s@%s:%s" , protocol , user , password , host , port )
232+ } else {
233+ proxyValue = fmt .Sprintf ("%s://%s:%s" , protocol , host , port )
234+ }
219235 return
220236}
221237
0 commit comments