SpoofDPI/proxy/http.go

27 lines
559 B
Go
Raw Normal View History

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