Skip to content

Commit e39a510

Browse files
author
Leonty Chudinov
committed
Introduce UseHttpProxyEnvironmentVariable Windows Registry Key
1 parent 9770171 commit e39a510

File tree

5 files changed

+45
-9
lines changed

5 files changed

+45
-9
lines changed

bootstrap/bootstrap.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ func Run(productName, productTitle, productVersion string) {
4141
}
4242
}
4343
}
44-
os.Setenv("HTTP_PROXY", "")
45-
os.Setenv("HTTPS_PROXY", "")
4644
userConfigDir, err := os.UserConfigDir()
4745

4846
userConfigDir = filepath.Join(userConfigDir, "Rocket Software")
@@ -73,6 +71,15 @@ func Run(productName, productTitle, productVersion string) {
7371
log.SetOutput(logFile)
7472
log.Printf("starting %s %s with arguments %v\n", productTitle, productVersion, os.Args)
7573
log.Printf("current platform is OS=%q Architecture=%q\n", runtime.GOOS, runtime.GOARCH)
74+
log.Printf("proxy settings are HTTP_PROXY=%s HTTPS_PROXY=%s NO_PROXY=%s UseHttpProxyEnvironmentVariable is %v\n",
75+
os.Getenv("HTTP_PROXY"), os.Getenv("HTTPS_PROXY"), os.Getenv("NO_PROXY"),
76+
settings.UseHttpProxyEnvironmentVariable(),
77+
)
78+
if !settings.UseHttpProxyEnvironmentVariable() {
79+
os.Setenv("HTTP_PROXY", "")
80+
os.Setenv("HTTPS_PROXY", "")
81+
os.Setenv("NO_PROXY", "")
82+
}
7683
flag.BoolVar(&showConsole, "showconsole", false, "show Java console")
7784
flag.BoolVar(&showConsole, "showConsole", false, "show Java console")
7885
flag.StringVar(&javaDir, "javadir", "", "Java folder that should be used for starting a Java Web Start application")

settings/settings.go

+13-7
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ import (
1717
)
1818

1919
var (
20-
javaExecutable string
21-
javaSource string
22-
jarSignerExecutable string
23-
disableVerification bool
24-
disableVerificationSameOrigin bool
25-
addAppToControlPanel bool
26-
currentJavaVersion *JavaVersion
20+
javaExecutable string
21+
javaSource string
22+
jarSignerExecutable string
23+
disableVerification bool
24+
disableVerificationSameOrigin bool
25+
addAppToControlPanel bool
26+
currentJavaVersion *JavaVersion
27+
useHttpProxyEnvironmentVariable bool
2728
)
2829

2930
func EnsureJavaExecutableAvailability() error {
@@ -239,10 +240,15 @@ func DisableVerificationSameOrigin() {
239240
disableVerificationSameOrigin = true
240241
}
241242

243+
func UseHttpProxyEnvironmentVariable() bool {
244+
return useHttpProxyEnvironmentVariable
245+
}
246+
242247
func init() {
243248
javaExecutable = getJavaExecutable()
244249
jarSignerExecutable = getJARSignerExecutable()
245250
disableVerification = getDisableVerificationSetting()
246251
disableVerificationSameOrigin = getDisableVerificationSameOriginSetting()
247252
addAppToControlPanel = getAddAppToControlPanelSetting()
253+
useHttpProxyEnvironmentVariable = getUseHttpProxyEnvironmentVariableSetting()
248254
}

settings/settings_darwin.go

+4
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,7 @@ func decodeSettings() (*Settings, error) {
8888
}
8989
return &settings, nil
9090
}
91+
92+
func getUseHttpProxyEnvironmentVariableSetting() bool {
93+
return true
94+
}

settings/settings_linux.go

+4
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ func getDisableVerificationSameOriginSetting() bool {
3333
func getAddAppToControlPanelSetting() bool {
3434
return false
3535
}
36+
37+
func getUseHttpProxyEnvironmentVariableSetting() bool {
38+
return true
39+
}

settings/settings_windows.go

+15
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func getAddAppToControlPanelSettingFromRootKey(rootKey registry.Key) (uint64, er
5555
return getUInt64ValueFromRootKey(rootKey, "AddToControlPanel")
5656
}
5757

58+
func getUseHttpProxyEnvironmentVariableSettingFromRootKey(rootKey registry.Key) (uint64, error) {
59+
return getUInt64ValueFromRootKey(rootKey, "UseHttpProxyEnvironmentVariable")
60+
}
61+
5862
func getDisableVerificationSettingFromRootKey(rootKey registry.Key) (uint64, error) {
5963
return getUInt64ValueFromRootKey(rootKey, "DisableVerification")
6064
}
@@ -239,3 +243,14 @@ func getAddAppToControlPanelSetting() bool {
239243
}
240244
return addAppToControlPanel == 1
241245
}
246+
247+
func getUseHttpProxyEnvironmentVariableSetting() bool {
248+
useHttpProxyEnvVar, err := getUseHttpProxyEnvironmentVariableSettingFromRootKey(registry.CURRENT_USER)
249+
if err != nil {
250+
useHttpProxyEnvVar, err = getUseHttpProxyEnvironmentVariableSettingFromRootKey(registry.LOCAL_MACHINE)
251+
}
252+
if err != nil {
253+
return true
254+
}
255+
return useHttpProxyEnvVar == 1
256+
}

0 commit comments

Comments
 (0)