diff --git a/packet/http.go b/packet/http.go index 7757481..f1ea4ac 100644 --- a/packet/http.go +++ b/packet/http.go @@ -4,16 +4,16 @@ import ( "strings" ) -type HttpRequest struct { +type Http struct { Raw *[]byte Method string Domain string Version string } -func NewHttpRequest(raw *[]byte) HttpRequest { +func NewHttp(raw *[]byte) Http { method, domain, version := parse(raw) - return HttpRequest{ + return Http{ Raw: raw, Method: method, Domain: domain, @@ -21,7 +21,7 @@ func NewHttpRequest(raw *[]byte) HttpRequest { } } -func (r *HttpRequest) IsValidMethod() bool { +func (r *Http) IsValidMethod() bool { if _, exists := getValidMethods()[r.Method]; exists { return true } @@ -29,7 +29,7 @@ func (r *HttpRequest) IsValidMethod() bool { return false } -func (r *HttpRequest) IsConnectMethod() bool { +func (r *Http) IsConnectMethod() bool { return r.Method == "CONNECT" } diff --git a/packet/https.go b/packet/https.go index 9d9af71..ec5ad01 100644 --- a/packet/https.go +++ b/packet/https.go @@ -1,16 +1,16 @@ package packet -type HttpsRequest struct { +type Https struct { Raw *[]byte } -func NewHttpsRequest(raw *[]byte) HttpsRequest { - return HttpsRequest{ +func NewHttps(raw *[]byte) Https { + return Https{ Raw: raw, } } -func (r HttpsRequest) SplitInChunks() [][]byte { +func (r Https) SplitInChunks() [][]byte { if len(*r.Raw) < 1 { return [][]byte{*r.Raw} } diff --git a/proxy/http.go b/proxy/http.go index f9343aa..c8c584e 100644 --- a/proxy/http.go +++ b/proxy/http.go @@ -8,7 +8,7 @@ import ( "github.com/xvzc/SpoofDPI/util" ) -func HandleHttp(clientConn net.Conn, ip string, p *packet.HttpRequest) { +func HandleHttp(clientConn net.Conn, ip string, p *packet.Http) { remoteConn, err := net.Dial("tcp", ip+":80") // create connection to server if err != nil { util.Debug(err) diff --git a/proxy/https.go b/proxy/https.go index 5f38b4a..3d30d5e 100644 --- a/proxy/https.go +++ b/proxy/https.go @@ -8,7 +8,7 @@ import ( "github.com/xvzc/SpoofDPI/util" ) -func HandleHttps(clientConn net.Conn, ip string, r *packet.HttpRequest) { +func HandleHttps(clientConn net.Conn, ip string, r *packet.Http) { // Create a connection to the requested server remoteConn, err := net.Dial("tcp", ip+":443") if err != nil { diff --git a/proxy/proxy.go b/proxy/proxy.go index e921aae..bfc07cd 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -38,7 +38,7 @@ func Start() { util.Debug("Client sent data: ", len(b)) - r := packet.NewHttpRequest(&b) + r := packet.NewHttp(&b) util.Debug("Request: \n" + string(*r.Raw)) if !r.IsValidMethod() {