diff --git a/cmd/spoof-dpi/main.go b/cmd/spoof-dpi/main.go index b315b7a..e1f2dcb 100644 --- a/cmd/spoof-dpi/main.go +++ b/cmd/spoof-dpi/main.go @@ -5,6 +5,7 @@ import ( "os/signal" "syscall" + "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus" "github.com/xvzc/SpoofDPI/doh" "github.com/xvzc/SpoofDPI/proxy" @@ -22,6 +23,10 @@ func main() { log.SetLevel(log.InfoLevel) } + log.SetFormatter(&logrus.TextFormatter{ + FullTimestamp: true, + }) + util.PrintWelcome(port, dns, debug) if err := util.SetOsProxy(port); err != nil { diff --git a/net/conn.go b/net/conn.go index 5482731..d1bdff9 100644 --- a/net/conn.go +++ b/net/conn.go @@ -77,7 +77,7 @@ func (lConn *Conn) HandleHttp(p packet.HttpPacket) { // Create connection to server rConn, err := Dial("tcp", ip+":80") if err != nil { - log.Debug(err) + log.Debug("[HTTPS] ", err) return } defer rConn.Close() @@ -98,14 +98,14 @@ func (lConn *Conn) HandleHttp(p packet.HttpPacket) { func (lConn *Conn) HandleHttps(p packet.HttpPacket) { ip, err := doh.Lookup(p.Domain()) if err != nil { - log.Debug("[HTTPS] Error looking up for domain: ", err) + log.Debug("[HTTPS] Error looking up for domain: ", p.Domain(), " ", err) } log.Debug("[HTTPS] Found ip over HTTPS: ", ip) // Create a connection to the requested server rConn, err := Dial("tcp", ip+":443") if err != nil { - log.Debug(err) + log.Debug("[HTTPS] ", err) return } defer rConn.Close() @@ -122,10 +122,10 @@ func (lConn *Conn) HandleHttps(p packet.HttpPacket) { clientHello, err := lConn.ReadBytes() if err != nil { log.Debug("[HTTPS] Error reading client hello: ", err) - log.Debug("Closing connection: ", lConn.RemoteAddr()) + log.Debug("[HTTPS] Closing connection: ", lConn.RemoteAddr()) } - log.Debug(lConn.RemoteAddr(), "[HTTPS] Client sent hello: ", len(clientHello), "bytes") + log.Debug("[HTTPS] Client "+lConn.RemoteAddr().String()+" sent hello: ", len(clientHello), "bytes") // Generate a go routine that reads from the server go rConn.Serve(lConn, "HTTPS") @@ -146,17 +146,17 @@ func (from *Conn) Serve(to *Conn, proto string) { for { buf, err := from.ReadBytes() if err != nil { - log.Debug("["+proto+"]"+" Error reading from ", from.RemoteAddr()) - log.Debug("["+proto+"]", err) - log.Debug("[" + proto + "]" + " Exiting Serve() method. ") + log.Debug("["+proto+"] "+"Error reading from ", from.RemoteAddr()) + log.Debug("["+proto+"] ", err) + log.Debug("[" + proto + "] " + "Exiting Serve() method. ") break } - log.Debug(from.RemoteAddr(), " sent data: ", len(buf), "bytes") + log.Debug("["+proto+"] ", from.RemoteAddr(), " sent data: ", len(buf), "bytes") if _, err := to.Write(buf); err != nil { - log.Debug("["+proto+"]"+"Error Writing to ", to.RemoteAddr()) - log.Debug("["+proto+"]", err) - log.Debug("[" + proto + "]" + " Exiting Serve() method. ") + log.Debug("["+proto+"] "+"Error Writing to ", to.RemoteAddr()) + log.Debug("["+proto+"] ", err) + log.Debug("[" + proto + "] " + "Exiting Serve() method. ") break } } diff --git a/proxy/proxy.go b/proxy/proxy.go index 83edca3..07c4ed7 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -58,10 +58,10 @@ func (p *Proxy) Start() { } if pkt.IsConnectMethod() { - log.Debug("HTTPS Requested") + log.Debug("[HTTPS] Start") conn.HandleHttps(pkt) } else { - log.Debug("HTTP Requested.") + log.Debug("[HTTP] Start") conn.HandleHttp(pkt) } }()