Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions launcher/jnlp/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ func (launcher *Launcher) command() (*exec.Cmd, error) {
if splash := launcher.getSplashScreen(); splash != "" {
javaArgs = append(javaArgs, fmt.Sprintf("-splash:%s", splash))
}
javaArgs = append(javaArgs, launcher.getProxyArgs()...)
if jnlp.AppDescription != nil {
javaArgs = append(javaArgs, jnlp.AppDescription.MainClass)
for _, appArg := range jnlp.AppDescription.Arguments {
Expand All @@ -290,6 +291,55 @@ func (launcher *Launcher) command() (*exec.Cmd, error) {
return cmd, nil
}

func (launcher *Launcher) getProxyArgs() []string {
args := []string{}
if !settings.UseHttpProxyEnvironmentVariable() {
return args
}

args = append(args, launcher.getHttpProxyArgs()...)
args = append(args, launcher.getHttpsProxyArgs()...)
return args
}

func (launcher *Launcher) getHttpProxyArgs() []string {
args := []string{}
httpProxy := os.Getenv("HTTP_PROXY")
uri, err := url.Parse(httpProxy)
if err != nil {
return args
}

if uri.Hostname() != "" {
args = append(args, fmt.Sprintf("-Dhttp.proxyHost=%s", uri.Hostname()))
}

if uri.Port() != "" {
args = append(args, fmt.Sprintf("-Dhttp.proxyPort=%s", uri.Port()))
}

return args
}

func (launcher *Launcher) getHttpsProxyArgs() []string {
args := []string{}
httpsProxy := os.Getenv("HTTPS_PROXY")
uri, err := url.Parse(httpsProxy)
if err != nil {
return args
}

if uri.Hostname() != "" {
args = append(args, fmt.Sprintf("-Dhttps.proxyHost=%s", uri.Hostname()))
}

if uri.Port() != "" {
args = append(args, fmt.Sprintf("-Dhttps.proxyPort=%s", uri.Port()))
}

return args
}

func (launcher *Launcher) exec() error {
cmd, err := launcher.command()
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ func UseHttpProxyEnvironmentVariable() bool {
return useHttpProxyEnvironmentVariable
}

// SetUseHttpProxyEnvironmentVariable allows overriding the default determined by the OS
func SetUseHttpProxyEnvironmentVariable(use bool) {
useHttpProxyEnvironmentVariable = use
}

func init() {
javaExecutable = getJavaExecutable()
jarSignerExecutable = getJARSignerExecutable()
Expand Down