SpoofDPI/proxy/http.go

28 lines
560 B
Go
Raw Normal View History

2021-12-29 17:08:30 +00:00
package proxy
import (
"fmt"
"net"
2022-01-08 06:35:32 +00:00
"github.com/xvzc/SpoofDPI/packet"
2021-12-29 17:08:30 +00:00
"github.com/xvzc/SpoofDPI/util"
)
2022-01-08 06:35:32 +00:00
func HandleHttp(clientConn net.Conn, ip string, p *packet.HttpRequest) {
2022-01-07 17:03:46 +00:00
remoteConn, err := net.Dial("tcp", ip+":80") // create connection to server
if err != nil {
util.Debug(err)
return
}
defer remoteConn.Close()
2021-12-29 17:08:30 +00:00
2022-01-07 17:03:46 +00:00
util.Debug("[HTTP] Connected to the server.")
2021-12-29 17:08:30 +00:00
2022-01-07 17:03:46 +00:00
go Serve(remoteConn, clientConn, "HTTP")
2021-12-29 17:08:30 +00:00
2022-01-07 17:03:46 +00:00
util.Debug("[HTTP] Sending request to the server")
2022-01-08 06:35:32 +00:00
fmt.Fprintf(remoteConn, string(*p.Raw))
2021-12-29 17:08:30 +00:00
2022-01-07 17:03:46 +00:00
Serve(clientConn, remoteConn, "HTTP")
2021-12-29 17:08:30 +00:00
}