mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2024-12-22 06:15:51 +00:00
update structure names in module packet
This commit is contained in:
parent
11ed1fd681
commit
5e1222054c
@ -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"
|
||||
}
|
||||
|
||||
|
@ -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}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user