update structure names in module packet

This commit is contained in:
xvzc 2022-01-08 15:38:16 +09:00
parent 11ed1fd681
commit 5e1222054c
5 changed files with 12 additions and 12 deletions

View File

@ -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"
}

View File

@ -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}
}

View File

@ -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)

View File

@ -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 {

View File

@ -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() {