2024-10-31 17:04:25 +00:00
|
|
|
//go:build windows
|
|
|
|
|
2024-08-31 16:01:58 +00:00
|
|
|
package proxy
|
|
|
|
|
2024-08-31 16:27:57 +00:00
|
|
|
import (
|
|
|
|
"github.com/Baipyrus/ProxySwitcher/util"
|
|
|
|
)
|
|
|
|
|
2024-09-24 12:40:42 +00:00
|
|
|
func Set(cfgPath string) {
|
2024-08-31 16:27:57 +00:00
|
|
|
stdin, closeFunc, _ := util.ReadyCmd()
|
|
|
|
|
2024-09-12 21:19:57 +00:00
|
|
|
proxy, _ := ReadSystemProxy()
|
2024-08-31 17:13:01 +00:00
|
|
|
// Set system proxy, if not already
|
2024-09-12 21:19:57 +00:00
|
|
|
if !proxy.Enabled {
|
|
|
|
SetSystemProxy(true)
|
2024-08-31 16:27:57 +00:00
|
|
|
}
|
|
|
|
|
2024-09-24 12:40:42 +00:00
|
|
|
configs, _ := util.ReadConfigs(cfgPath)
|
2024-08-31 16:27:57 +00:00
|
|
|
for _, config := range configs {
|
|
|
|
configCmd := config.Name
|
2024-08-31 17:13:01 +00:00
|
|
|
// Use command instead of name, if given
|
2024-08-31 16:27:57 +00:00
|
|
|
if config.Cmd != "" {
|
|
|
|
configCmd = config.Cmd
|
|
|
|
}
|
|
|
|
|
2024-10-01 18:09:54 +00:00
|
|
|
commands := generateCommands(configCmd, config.Set, proxy.Server)
|
2024-08-31 17:13:01 +00:00
|
|
|
util.ExecCmds(commands, stdin)
|
2024-08-31 16:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
closeFunc()
|
2024-08-31 16:01:58 +00:00
|
|
|
}
|