This commit is contained in:
xvzc 2022-01-08 02:03:46 +09:00
parent cb122ff3da
commit 1581f9c4d1
3 changed files with 38 additions and 39 deletions

View File

@ -1,15 +1,15 @@
package config package config
import ( import (
"sync" "runtime"
"runtime" "sync"
) )
type Config struct { type Config struct {
Port string Port string
DNS string DNS string
OS string OS string
Debug bool Debug bool
} }
var config *Config var config *Config
@ -17,21 +17,21 @@ var once sync.Once
var err error var err error
func InitConfig(port string, dns string, debug bool) error { func InitConfig(port string, dns string, debug bool) error {
err = nil err = nil
once.Do(func() { once.Do(func() {
config = &Config{ config = &Config{
Port : port, Port: port,
DNS : dns, DNS: dns,
OS : runtime.GOOS, OS: runtime.GOOS,
Debug : debug, Debug: debug,
} }
}) })
return err return err
} }
func GetConfig() (*Config) { func GetConfig() *Config {
return config return config
} }

View File

@ -7,20 +7,20 @@ import (
"github.com/xvzc/SpoofDPI/util" "github.com/xvzc/SpoofDPI/util"
) )
func HandleHttp(clientConn net.Conn, ip string, message []byte) { func HandleHttp(clientConn net.Conn, ip string, message []byte) {
remoteConn, err := net.Dial("tcp", ip+":80") // create connection to server remoteConn, err := net.Dial("tcp", ip+":80") // create connection to server
if err != nil { if err != nil {
util.Debug(err) util.Debug(err)
return return
} }
defer remoteConn.Close() defer remoteConn.Close()
util.Debug("[HTTP] Connected to the server.") util.Debug("[HTTP] Connected to the server.")
go Serve(remoteConn, clientConn, "HTTP") go Serve(remoteConn, clientConn, "HTTP")
util.Debug("[HTTP] Sending request to the server") util.Debug("[HTTP] Sending request to the server")
fmt.Fprintf(remoteConn, string(message)) fmt.Fprintf(remoteConn, string(message))
Serve(clientConn, remoteConn, "HTTP") Serve(clientConn, remoteConn, "HTTP")
} }

View File

@ -5,15 +5,14 @@ import (
"github.com/xvzc/SpoofDPI/config" "github.com/xvzc/SpoofDPI/config"
) )
func PrintWelcome() { func PrintWelcome() {
cyan := pterm.NewLettersFromStringWithStyle("Spoof", pterm.NewStyle(pterm.FgCyan)) cyan := pterm.NewLettersFromStringWithStyle("Spoof", pterm.NewStyle(pterm.FgCyan))
purple := pterm.NewLettersFromStringWithStyle("DPI", pterm.NewStyle(pterm.FgLightMagenta)) purple := pterm.NewLettersFromStringWithStyle("DPI", pterm.NewStyle(pterm.FgLightMagenta))
pterm.DefaultBigText.WithLetters(cyan, purple).Render() pterm.DefaultBigText.WithLetters(cyan, purple).Render()
pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{ pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
{Level: 0, Text: "PORT : " + config.GetConfig().Port}, {Level: 0, Text: "PORT : " + config.GetConfig().Port},
{Level: 0, Text: "DNS : " + config.GetConfig().DNS}, {Level: 0, Text: "DNS : " + config.GetConfig().DNS},
}).Render() }).Render()
} }