mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2025-01-31 05:39:03 +00:00
update signal handling
This commit is contained in:
parent
cf869fe9cd
commit
281a86dd32
@ -4,49 +4,57 @@ import (
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/xvzc/SpoofDPI/config"
|
||||
"github.com/xvzc/SpoofDPI/proxy"
|
||||
"github.com/xvzc/SpoofDPI/util"
|
||||
"github.com/xvzc/SpoofDPI/util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
port := flag.String("port", "8080", "port")
|
||||
dns := flag.String("dns", "8.8.8.8", "DNS server")
|
||||
debug := flag.Bool("debug", false, "true | false")
|
||||
port := flag.String("port", "8080", "port")
|
||||
dns := flag.String("dns", "8.8.8.8", "DNS server")
|
||||
debug := flag.Bool("debug", false, "true | false")
|
||||
|
||||
flag.Parse()
|
||||
flag.Parse()
|
||||
|
||||
err := config.InitConfig(*port, *dns, *debug)
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
err := config.InitConfig(*port, *dns, *debug)
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
util.PrintWelcome()
|
||||
util.PrintWelcome()
|
||||
|
||||
err = config.SetOsProxy()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = config.SetOsProxy()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
go proxy.Start()
|
||||
go proxy.Start()
|
||||
|
||||
sigs := make(chan os.Signal, 1)
|
||||
sigs := make(chan os.Signal, 1)
|
||||
done := make(chan bool, 1)
|
||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
signal.Notify(
|
||||
sigs,
|
||||
syscall.SIGKILL,
|
||||
syscall.SIGINT,
|
||||
syscall.SIGTERM,
|
||||
syscall.SIGQUIT,
|
||||
syscall.SIGCONT,
|
||||
syscall.SIGHUP)
|
||||
|
||||
go func() {
|
||||
_ = <-sigs
|
||||
done <- true
|
||||
}()
|
||||
|
||||
<-done
|
||||
err = config.UnSetOsProxy()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
<-done
|
||||
err = config.UnSetOsProxy()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user