ProxySwitcher/proxy/set.go

30 lines
552 B
Go
Raw Normal View History

2024-08-31 16:01:58 +00:00
package proxy
import (
"github.com/Baipyrus/ProxySwitcher/util"
)
2024-08-31 16:01:58 +00:00
func Set() {
stdin, closeFunc, _ := util.ReadyCmd()
proxy, _ := ReadSystemProxy()
// Set system proxy, if not already
if !proxy.Enabled {
SetSystemProxy(true)
}
configs, _ := util.ReadConfigs()
for _, config := range configs {
configCmd := config.Name
// Use command instead of name, if given
if config.Cmd != "" {
configCmd = config.Cmd
}
commands := generateCommands(config.Set, configCmd, proxy.Server)
util.ExecCmds(commands, stdin)
}
closeFunc()
2024-08-31 16:01:58 +00:00
}