mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-25 12:11:46 +00:00
Merge pull request #18 from Baipyrus/variant-surround-char
Default Config - Environment Variable Proxy Setters
This commit is contained in:
commit
a957fdcc8d
@ -7,11 +7,13 @@
|
||||
"args": [
|
||||
"http_proxy"
|
||||
],
|
||||
"surround": "\"",
|
||||
"type": "variable"
|
||||
}, {
|
||||
"args": [
|
||||
"https_proxy"
|
||||
],
|
||||
"surround": "\"",
|
||||
"type": "variable"
|
||||
}
|
||||
],
|
||||
|
@ -2,6 +2,7 @@ package proxy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Baipyrus/ProxySwitcher/util"
|
||||
@ -31,6 +32,11 @@ func applyProxy(configArgs []string, configCmd, proxyServer string, variant *uti
|
||||
return configArgs, configCmd
|
||||
}
|
||||
|
||||
// Surround 'proxyServer' with any given string, if provided
|
||||
if variant.Surround != "" {
|
||||
proxyServer = fmt.Sprintf("%[1]s%[2]s%[1]s", variant.Surround, proxyServer)
|
||||
}
|
||||
|
||||
// Insert proxy only on last VARIABLE type
|
||||
if variant.Type == util.VARIABLE && strings.Count(configCmd, "$PRSW_ARG") == 1 {
|
||||
configCmd = strings.Replace(configCmd, "$PRSW_ARG", proxyServer, 1)
|
||||
|
@ -18,6 +18,7 @@ type Variant struct {
|
||||
Arguments []string `json:"args"`
|
||||
Type VariantType `json:"type,omitempty"`
|
||||
Equator string `json:"equator,omitempty"`
|
||||
Surround string `json:"surround,omitempty"`
|
||||
DiscardProxy bool `json:"discard,omitempty"`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user