update log format

This commit is contained in:
xvzc 2022-01-12 03:06:14 +09:00
parent 410dc24eb1
commit 0e11629360
3 changed files with 19 additions and 14 deletions

View File

@ -5,6 +5,7 @@ import (
"os/signal" "os/signal"
"syscall" "syscall"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/xvzc/SpoofDPI/doh" "github.com/xvzc/SpoofDPI/doh"
"github.com/xvzc/SpoofDPI/proxy" "github.com/xvzc/SpoofDPI/proxy"
@ -22,6 +23,10 @@ func main() {
log.SetLevel(log.InfoLevel) log.SetLevel(log.InfoLevel)
} }
log.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
util.PrintWelcome(port, dns, debug) util.PrintWelcome(port, dns, debug)
if err := util.SetOsProxy(port); err != nil { if err := util.SetOsProxy(port); err != nil {

View File

@ -77,7 +77,7 @@ func (lConn *Conn) HandleHttp(p packet.HttpPacket) {
// Create connection to server // Create connection to server
rConn, err := Dial("tcp", ip+":80") rConn, err := Dial("tcp", ip+":80")
if err != nil { if err != nil {
log.Debug(err) log.Debug("[HTTPS] ", err)
return return
} }
defer rConn.Close() defer rConn.Close()
@ -98,14 +98,14 @@ func (lConn *Conn) HandleHttp(p packet.HttpPacket) {
func (lConn *Conn) HandleHttps(p packet.HttpPacket) { func (lConn *Conn) HandleHttps(p packet.HttpPacket) {
ip, err := doh.Lookup(p.Domain()) ip, err := doh.Lookup(p.Domain())
if err != nil { 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) log.Debug("[HTTPS] Found ip over HTTPS: ", ip)
// Create a connection to the requested server // Create a connection to the requested server
rConn, err := Dial("tcp", ip+":443") rConn, err := Dial("tcp", ip+":443")
if err != nil { if err != nil {
log.Debug(err) log.Debug("[HTTPS] ", err)
return return
} }
defer rConn.Close() defer rConn.Close()
@ -122,10 +122,10 @@ func (lConn *Conn) HandleHttps(p packet.HttpPacket) {
clientHello, err := lConn.ReadBytes() clientHello, err := lConn.ReadBytes()
if err != nil { if err != nil {
log.Debug("[HTTPS] Error reading client hello: ", err) 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 // Generate a go routine that reads from the server
go rConn.Serve(lConn, "HTTPS") go rConn.Serve(lConn, "HTTPS")
@ -146,17 +146,17 @@ func (from *Conn) Serve(to *Conn, proto string) {
for { for {
buf, err := from.ReadBytes() buf, err := from.ReadBytes()
if err != nil { if err != nil {
log.Debug("["+proto+"]"+" Error reading from ", from.RemoteAddr()) log.Debug("["+proto+"] "+"Error reading from ", from.RemoteAddr())
log.Debug("["+proto+"]", err) log.Debug("["+proto+"] ", err)
log.Debug("[" + proto + "]" + " Exiting Serve() method. ") log.Debug("[" + proto + "] " + "Exiting Serve() method. ")
break 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 { if _, err := to.Write(buf); err != nil {
log.Debug("["+proto+"]"+"Error Writing to ", to.RemoteAddr()) log.Debug("["+proto+"] "+"Error Writing to ", to.RemoteAddr())
log.Debug("["+proto+"]", err) log.Debug("["+proto+"] ", err)
log.Debug("[" + proto + "]" + " Exiting Serve() method. ") log.Debug("[" + proto + "] " + "Exiting Serve() method. ")
break break
} }
} }

View File

@ -58,10 +58,10 @@ func (p *Proxy) Start() {
} }
if pkt.IsConnectMethod() { if pkt.IsConnectMethod() {
log.Debug("HTTPS Requested") log.Debug("[HTTPS] Start")
conn.HandleHttps(pkt) conn.HandleHttps(pkt)
} else { } else {
log.Debug("HTTP Requested.") log.Debug("[HTTP] Start")
conn.HandleHttp(pkt) conn.HandleHttp(pkt)
} }
}() }()