mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2025-01-19 09:12:19 +00:00
add unset os-proxy
This commit is contained in:
parent
b8f614d808
commit
cf869fe9cd
@ -4,6 +4,8 @@ import (
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/xvzc/SpoofDPI/config"
|
||||
"github.com/xvzc/SpoofDPI/proxy"
|
||||
@ -30,5 +32,21 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
proxy.Start()
|
||||
go proxy.Start()
|
||||
|
||||
sigs := make(chan os.Signal, 1)
|
||||
done := make(chan bool, 1)
|
||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
_ = <-sigs
|
||||
done <- true
|
||||
}()
|
||||
|
||||
<-done
|
||||
err = config.UnSetOsProxy()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
@ -28,3 +28,26 @@ func SetOsProxy() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func UnSetOsProxy() (error) {
|
||||
if GetConfig().OS != "darwin" {
|
||||
return nil
|
||||
}
|
||||
|
||||
network, err:= exec.Command("sh", "-c", "networksetup -listnetworkserviceorder | grep `route -n get 0.0.0.0 | grep 'interface' | cut -d ':' -f2` -B 1 | head -n 1 | cut -d ' ' -f2").Output()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = exec.Command("sh", "-c", "networksetup -setwebproxystate " + strings.TrimSpace(string(network)) + " off").Output()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = exec.Command("sh", "-c", "networksetup -setsecurewebproxystate " + strings.TrimSpace(string(network)) + " off").Output()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user