mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2024-12-22 06:15:51 +00:00
rename request to packet
This commit is contained in:
parent
539d256146
commit
11ed1fd681
@ -1,4 +1,4 @@
|
||||
package request
|
||||
package packet
|
||||
|
||||
import (
|
||||
"strings"
|
||||
@ -29,8 +29,8 @@ func (r *HttpRequest) IsValidMethod() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *HttpRequest) ToChunks() {
|
||||
|
||||
func (r *HttpRequest) IsConnectMethod() bool {
|
||||
return r.Method == "CONNECT"
|
||||
}
|
||||
|
||||
func parse(raw *[]byte) (string, string, string) {
|
@ -1,4 +1,4 @@
|
||||
package request
|
||||
package packet
|
||||
|
||||
type HttpsRequest struct {
|
||||
Raw *[]byte
|
@ -4,11 +4,11 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/xvzc/SpoofDPI/request"
|
||||
"github.com/xvzc/SpoofDPI/packet"
|
||||
"github.com/xvzc/SpoofDPI/util"
|
||||
)
|
||||
|
||||
func HandleHttp(clientConn net.Conn, ip string, r *request.HttpRequest) {
|
||||
func HandleHttp(clientConn net.Conn, ip string, p *packet.HttpRequest) {
|
||||
remoteConn, err := net.Dial("tcp", ip+":80") // create connection to server
|
||||
if err != nil {
|
||||
util.Debug(err)
|
||||
@ -21,7 +21,7 @@ func HandleHttp(clientConn net.Conn, ip string, r *request.HttpRequest) {
|
||||
go Serve(remoteConn, clientConn, "HTTP")
|
||||
|
||||
util.Debug("[HTTP] Sending request to the server")
|
||||
fmt.Fprintf(remoteConn, string(*r.Raw))
|
||||
fmt.Fprintf(remoteConn, string(*p.Raw))
|
||||
|
||||
Serve(clientConn, remoteConn, "HTTP")
|
||||
}
|
||||
|
@ -4,10 +4,11 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/xvzc/SpoofDPI/packet"
|
||||
"github.com/xvzc/SpoofDPI/util"
|
||||
)
|
||||
|
||||
func HandleHttps(clientConn net.Conn, ip string) {
|
||||
func HandleHttps(clientConn net.Conn, ip string, r *packet.HttpRequest) {
|
||||
// Create a connection to the requested server
|
||||
remoteConn, err := net.Dial("tcp", ip+":443")
|
||||
if err != nil {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/xvzc/SpoofDPI/config"
|
||||
"github.com/xvzc/SpoofDPI/request"
|
||||
"github.com/xvzc/SpoofDPI/packet"
|
||||
"github.com/xvzc/SpoofDPI/util"
|
||||
)
|
||||
|
||||
@ -38,7 +38,7 @@ func Start() {
|
||||
|
||||
util.Debug("Client sent data: ", len(b))
|
||||
|
||||
r := request.NewHttpRequest(&b)
|
||||
r := packet.NewHttpRequest(&b)
|
||||
util.Debug("Request: \n" + string(*r.Raw))
|
||||
|
||||
if !r.IsValidMethod() {
|
||||
@ -55,9 +55,9 @@ func Start() {
|
||||
|
||||
util.Debug("ip: " + ip)
|
||||
|
||||
if r.Method == "CONNECT" {
|
||||
if r.IsConnectMethod() {
|
||||
util.Debug("HTTPS Requested")
|
||||
HandleHttps(clientConn, ip)
|
||||
HandleHttps(clientConn, ip, &r)
|
||||
} else {
|
||||
util.Debug("HTTP Requested.")
|
||||
HandleHttp(clientConn, ip, &r)
|
||||
|
Loading…
Reference in New Issue
Block a user