ProxySwitcher/proxy/set.go

36 lines
706 B
Go
Raw Permalink Normal View History

//go:build windows
2024-08-31 16:01:58 +00:00
package proxy
import (
"log"
"github.com/Baipyrus/ProxySwitcher/util"
)
func Set(cfgPath string) {
proxy, _ := ReadSystemProxy()
// Set system proxy, if not already
if !proxy.Enabled {
SetSystemProxy(true)
}
var failed bool
configs, _ := util.ReadConfigs(cfgPath)
for _, config := range configs {
configCmd := config.Name
// Use command instead of name, if given
if config.Cmd != "" {
configCmd = config.Cmd
}
commands := generateCommands(configCmd, config.Set, proxy.Server)
failed = util.ExecCmds(commands)
}
// Additional feedback on error
if failed {
log.Printf("One or more commands failed to execute. Run command 'debug' to see more.\n")
}
2024-08-31 16:01:58 +00:00
}