2022-07-14 12:30:57 +00:00
|
|
|
package settings
|
2022-07-14 06:04:57 +00:00
|
|
|
|
|
|
|
import (
|
2022-08-04 14:01:20 +00:00
|
|
|
"github.com/sagernet/sing-box/adapter"
|
2022-07-14 12:30:57 +00:00
|
|
|
F "github.com/sagernet/sing/common/format"
|
2022-07-17 07:11:26 +00:00
|
|
|
"github.com/sagernet/sing/common/wininet"
|
2022-07-14 06:04:57 +00:00
|
|
|
)
|
|
|
|
|
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
|
2022-07-14 06:04:57 +00:00
|
|
|
}
|