2021-12-28 02:28:43 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-12-29 17:08:30 +00:00
|
|
|
"os"
|
2022-01-04 08:38:36 +00:00
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
2021-12-28 06:10:06 +00:00
|
|
|
|
2022-01-11 18:06:14 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2022-01-11 15:05:16 +00:00
|
|
|
log "github.com/sirupsen/logrus"
|
2022-01-10 14:41:31 +00:00
|
|
|
"github.com/xvzc/SpoofDPI/doh"
|
2022-01-03 15:13:42 +00:00
|
|
|
"github.com/xvzc/SpoofDPI/proxy"
|
2022-01-04 08:38:36 +00:00
|
|
|
"github.com/xvzc/SpoofDPI/util"
|
2021-12-28 02:28:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-05-07 05:57:52 +00:00
|
|
|
util.ParseArgs()
|
|
|
|
config := util.GetConfig()
|
2023-04-20 19:41:23 +00:00
|
|
|
|
2023-05-07 05:57:52 +00:00
|
|
|
p := proxy.New(*config.Addr, *config.Port)
|
|
|
|
doh.Init(*config.Dns)
|
|
|
|
if *config.Debug {
|
2022-01-11 15:05:16 +00:00
|
|
|
log.SetLevel(log.DebugLevel)
|
|
|
|
} else {
|
|
|
|
log.SetLevel(log.InfoLevel)
|
|
|
|
}
|
|
|
|
|
2022-01-11 18:06:14 +00:00
|
|
|
log.SetFormatter(&logrus.TextFormatter{
|
|
|
|
FullTimestamp: true,
|
|
|
|
})
|
|
|
|
|
2023-05-07 05:57:52 +00:00
|
|
|
if *config.Banner {
|
|
|
|
util.PrintColoredBanner()
|
2022-11-29 07:54:28 +00:00
|
|
|
} else {
|
2023-05-07 05:57:52 +00:00
|
|
|
util.PrintSimpleInfo()
|
2022-11-29 07:54:28 +00:00
|
|
|
}
|
2022-01-03 15:13:42 +00:00
|
|
|
|
2023-05-07 05:57:52 +00:00
|
|
|
if err := util.SetOsProxy(*config.Port); err != nil {
|
2022-01-04 08:38:36 +00:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2022-01-03 15:13:42 +00:00
|
|
|
|
2022-01-08 15:48:19 +00:00
|
|
|
go p.Start()
|
2022-01-03 17:36:27 +00:00
|
|
|
|
2022-01-08 17:40:05 +00:00
|
|
|
// Handle signals
|
2022-01-04 08:38:36 +00:00
|
|
|
sigs := make(chan os.Signal, 1)
|
2022-01-03 17:36:27 +00:00
|
|
|
done := make(chan bool, 1)
|
|
|
|
|
2022-01-04 08:38:36 +00:00
|
|
|
signal.Notify(
|
|
|
|
sigs,
|
|
|
|
syscall.SIGKILL,
|
|
|
|
syscall.SIGINT,
|
|
|
|
syscall.SIGTERM,
|
|
|
|
syscall.SIGQUIT,
|
|
|
|
syscall.SIGHUP)
|
|
|
|
|
|
|
|
go func() {
|
2022-01-03 17:36:27 +00:00
|
|
|
_ = <-sigs
|
|
|
|
done <- true
|
|
|
|
}()
|
|
|
|
|
2022-01-04 08:38:36 +00:00
|
|
|
<-done
|
2022-01-10 15:14:51 +00:00
|
|
|
if err := util.UnsetOsProxy(); err != nil {
|
2022-01-04 08:38:36 +00:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2021-12-28 02:28:43 +00:00
|
|
|
}
|