mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2024-12-22 14:26:31 +00:00
add removal of proxy header
This commit is contained in:
parent
8bda470afd
commit
1e16a454ca
@ -83,6 +83,28 @@ func (p *HttpPacket) IsConnectMethod() bool {
|
|||||||
return p.Method() == "CONNECT"
|
return p.Method() == "CONNECT"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *HttpPacket) RemoveProxyHeader() {
|
||||||
|
s := string(p.raw)
|
||||||
|
|
||||||
|
lines := strings.Split(s, "\n")
|
||||||
|
for i := 0; i < len(lines); i++ {
|
||||||
|
if strings.HasPrefix(lines[i], "Proxy-Connection") {
|
||||||
|
lines[i] = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result := ""
|
||||||
|
for i := 0; i < len(lines); i++ {
|
||||||
|
if lines[i] == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
result += lines[i] + "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
p.raw = []byte(result)
|
||||||
|
}
|
||||||
|
|
||||||
func parse(raw []byte) (string, string, string) {
|
func parse(raw []byte) (string, string, string) {
|
||||||
var firstLine string
|
var firstLine string
|
||||||
for i := 0; i < len(raw); i++ {
|
for i := 0; i < len(raw); i++ {
|
||||||
|
@ -48,13 +48,16 @@ func (p *Proxy) Start() {
|
|||||||
log.Debug("Client sent data: ", len(b))
|
log.Debug("Client sent data: ", len(b))
|
||||||
|
|
||||||
pkt := packet.NewHttpPacket(b)
|
pkt := packet.NewHttpPacket(b)
|
||||||
log.Debug("New request: \n\n" + string(pkt.Raw()))
|
|
||||||
|
|
||||||
if !pkt.IsValidMethod() {
|
if !pkt.IsValidMethod() {
|
||||||
log.Println("Unsupported method: ", pkt.Method())
|
log.Println("Unsupported method: ", pkt.Method())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pkt.RemoveProxyHeader()
|
||||||
|
|
||||||
|
log.Debug("New request: \n\n" + string(pkt.Raw()))
|
||||||
|
|
||||||
if pkt.IsConnectMethod() {
|
if pkt.IsConnectMethod() {
|
||||||
log.Debug("[HTTPS] Start")
|
log.Debug("[HTTPS] Start")
|
||||||
go conn.HandleHttps(pkt)
|
go conn.HandleHttps(pkt)
|
||||||
|
Loading…
Reference in New Issue
Block a user