sing-box/common/settings/proxy_windows.go

18 lines
439 B
Go
Raw Normal View History

package settings
import (
2022-08-04 14:01:20 +00:00
"github.com/sagernet/sing-box/adapter"
F "github.com/sagernet/sing/common/format"
2022-07-17 07:11:26 +00:00
"github.com/sagernet/sing/common/wininet"
)
2022-08-04 14:01:20 +00:00
func SetSystemProxy(router adapter.Router, port uint16, isMixed bool) (func() error, error) {
2022-08-06 09:28:51 +00:00
err := wininet.SetSystemProxy(F.ToString("http://127.0.0.1:", port), "<local>")
2022-08-04 14:01:20 +00:00
if err != nil {
return nil, err
}
return func() error {
return wininet.ClearSystemProxy()
}, nil
}