mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2024-12-22 14:26:31 +00:00
update structure names in module packet
This commit is contained in:
parent
11ed1fd681
commit
5e1222054c
@ -4,16 +4,16 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HttpRequest struct {
|
type Http struct {
|
||||||
Raw *[]byte
|
Raw *[]byte
|
||||||
Method string
|
Method string
|
||||||
Domain string
|
Domain string
|
||||||
Version string
|
Version string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHttpRequest(raw *[]byte) HttpRequest {
|
func NewHttp(raw *[]byte) Http {
|
||||||
method, domain, version := parse(raw)
|
method, domain, version := parse(raw)
|
||||||
return HttpRequest{
|
return Http{
|
||||||
Raw: raw,
|
Raw: raw,
|
||||||
Method: method,
|
Method: method,
|
||||||
Domain: domain,
|
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 {
|
if _, exists := getValidMethods()[r.Method]; exists {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ func (r *HttpRequest) IsValidMethod() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *HttpRequest) IsConnectMethod() bool {
|
func (r *Http) IsConnectMethod() bool {
|
||||||
return r.Method == "CONNECT"
|
return r.Method == "CONNECT"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package packet
|
package packet
|
||||||
|
|
||||||
type HttpsRequest struct {
|
type Https struct {
|
||||||
Raw *[]byte
|
Raw *[]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHttpsRequest(raw *[]byte) HttpsRequest {
|
func NewHttps(raw *[]byte) Https {
|
||||||
return HttpsRequest{
|
return Https{
|
||||||
Raw: raw,
|
Raw: raw,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r HttpsRequest) SplitInChunks() [][]byte {
|
func (r Https) SplitInChunks() [][]byte {
|
||||||
if len(*r.Raw) < 1 {
|
if len(*r.Raw) < 1 {
|
||||||
return [][]byte{*r.Raw}
|
return [][]byte{*r.Raw}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/xvzc/SpoofDPI/util"
|
"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
|
remoteConn, err := net.Dial("tcp", ip+":80") // create connection to server
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.Debug(err)
|
util.Debug(err)
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/xvzc/SpoofDPI/util"
|
"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
|
// Create a connection to the requested server
|
||||||
remoteConn, err := net.Dial("tcp", ip+":443")
|
remoteConn, err := net.Dial("tcp", ip+":443")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -38,7 +38,7 @@ func Start() {
|
|||||||
|
|
||||||
util.Debug("Client sent data: ", len(b))
|
util.Debug("Client sent data: ", len(b))
|
||||||
|
|
||||||
r := packet.NewHttpRequest(&b)
|
r := packet.NewHttp(&b)
|
||||||
util.Debug("Request: \n" + string(*r.Raw))
|
util.Debug("Request: \n" + string(*r.Raw))
|
||||||
|
|
||||||
if !r.IsValidMethod() {
|
if !r.IsValidMethod() {
|
||||||
|
Loading…
Reference in New Issue
Block a user