mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2024-12-22 14:26:31 +00:00
refactor
This commit is contained in:
parent
cb122ff3da
commit
1581f9c4d1
@ -1,15 +1,15 @@
|
||||
package config
|
||||
package config
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"runtime"
|
||||
"runtime"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Port string
|
||||
DNS string
|
||||
OS string
|
||||
Debug bool
|
||||
Port string
|
||||
DNS string
|
||||
OS string
|
||||
Debug bool
|
||||
}
|
||||
|
||||
var config *Config
|
||||
@ -17,21 +17,21 @@ var once sync.Once
|
||||
var err error
|
||||
|
||||
func InitConfig(port string, dns string, debug bool) error {
|
||||
err = nil
|
||||
err = nil
|
||||
|
||||
once.Do(func() {
|
||||
once.Do(func() {
|
||||
|
||||
config = &Config{
|
||||
Port : port,
|
||||
DNS : dns,
|
||||
OS : runtime.GOOS,
|
||||
Debug : debug,
|
||||
}
|
||||
})
|
||||
config = &Config{
|
||||
Port: port,
|
||||
DNS: dns,
|
||||
OS: runtime.GOOS,
|
||||
Debug: debug,
|
||||
}
|
||||
})
|
||||
|
||||
return err
|
||||
return err
|
||||
}
|
||||
|
||||
func GetConfig() (*Config) {
|
||||
return config
|
||||
func GetConfig() *Config {
|
||||
return config
|
||||
}
|
||||
|
@ -7,20 +7,20 @@ import (
|
||||
"github.com/xvzc/SpoofDPI/util"
|
||||
)
|
||||
|
||||
func HandleHttp(clientConn net.Conn, ip string, message []byte) {
|
||||
remoteConn, err := net.Dial("tcp", ip+":80") // create connection to server
|
||||
if err != nil {
|
||||
util.Debug(err)
|
||||
return
|
||||
}
|
||||
defer remoteConn.Close()
|
||||
func HandleHttp(clientConn net.Conn, ip string, message []byte) {
|
||||
remoteConn, err := net.Dial("tcp", ip+":80") // create connection to server
|
||||
if err != nil {
|
||||
util.Debug(err)
|
||||
return
|
||||
}
|
||||
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")
|
||||
fmt.Fprintf(remoteConn, string(message))
|
||||
util.Debug("[HTTP] Sending request to the server")
|
||||
fmt.Fprintf(remoteConn, string(message))
|
||||
|
||||
Serve(clientConn, remoteConn, "HTTP")
|
||||
Serve(clientConn, remoteConn, "HTTP")
|
||||
}
|
||||
|
@ -5,15 +5,14 @@ import (
|
||||
"github.com/xvzc/SpoofDPI/config"
|
||||
)
|
||||
|
||||
|
||||
func PrintWelcome() {
|
||||
cyan := pterm.NewLettersFromStringWithStyle("Spoof", pterm.NewStyle(pterm.FgCyan))
|
||||
purple := pterm.NewLettersFromStringWithStyle("DPI", pterm.NewStyle(pterm.FgLightMagenta))
|
||||
pterm.DefaultBigText.WithLetters(cyan, purple).Render()
|
||||
cyan := pterm.NewLettersFromStringWithStyle("Spoof", pterm.NewStyle(pterm.FgCyan))
|
||||
purple := pterm.NewLettersFromStringWithStyle("DPI", pterm.NewStyle(pterm.FgLightMagenta))
|
||||
pterm.DefaultBigText.WithLetters(cyan, purple).Render()
|
||||
|
||||
pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
|
||||
{Level: 0, Text: "PORT : " + config.GetConfig().Port},
|
||||
{Level: 0, Text: "DNS : " + config.GetConfig().DNS},
|
||||
}).Render()
|
||||
pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
|
||||
{Level: 0, Text: "PORT : " + config.GetConfig().Port},
|
||||
{Level: 0, Text: "DNS : " + config.GetConfig().DNS},
|
||||
}).Render()
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user