mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2025-01-03 04:50:11 +00:00
update
This commit is contained in:
parent
13190c34f5
commit
76da7260d0
2
off.sh
Normal file
2
off.sh
Normal file
@ -0,0 +1,2 @@
|
||||
networksetup -setwebproxystate Wi-Fi off
|
||||
networksetup -setsecurewebproxystate Wi-Fi off
|
2
on.sh
Normal file
2
on.sh
Normal file
@ -0,0 +1,2 @@
|
||||
networksetup -setwebproxy Wi-Fi 127.0.0.1 8080
|
||||
networksetup -setsecurewebproxy Wi-Fi 127.0.0.1 8080
|
63
proxy/:w
63
proxy/:w
@ -1,63 +0,0 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net"
|
||||
"fmt"
|
||||
// "time"
|
||||
|
||||
"github.com/xvzc/SpoofDPI/util"
|
||||
)
|
||||
|
||||
func HandleHttps(clientConn net.Conn, ip string) {
|
||||
defer clientConn.Close()
|
||||
|
||||
remoteConn, err := net.Dial("tcp", ip+":443") // create connection to server
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
defer remoteConn.Close()
|
||||
log.Println("Connected to the server.")
|
||||
|
||||
// established := []byte("HTTP/1.1 204 No Content\n\n")
|
||||
|
||||
log.Println("Sending 204 No Content to the client..")
|
||||
|
||||
fmt.Fprintf(clientConn, "HTTP/1.1 204 No Content\n\n")
|
||||
clientHello, err := util.ReadMessage(clientConn)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Println("Client sent Client Hello. length:", len(clientHello))
|
||||
|
||||
fmt.Fprintf(remoteConn, string(clientHello))
|
||||
serverHello, err := util.ReadMessage(clientConn)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Println("Client sent Client Hello. length:", len(serverHello))
|
||||
|
||||
fmt.Fprintf(clientConn, string(serverHello))
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
serverHello, err := util.WriteAndRead(remoteConn, clientHello)
|
||||
log.Println("Server sent data. length:", len(serverHello))
|
||||
|
||||
clientFinish, err := util.WriteAndRead(clientConn, serverHello)
|
||||
log.Println("Client sent data. length:", len(clientFinish))
|
||||
|
||||
_, err = remoteConn.Write(clientFinish)
|
||||
if err != nil {
|
||||
log.Fatal("Error writing to client:", err)
|
||||
}
|
||||
|
||||
log.Println("Written")
|
||||
*/
|
||||
|
||||
}
|
@ -42,4 +42,3 @@ func HandleHttp(clientConn net.Conn, ip string, message []byte) {
|
||||
}
|
||||
defer clientConn.(*net.TCPConn).CloseWrite()
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"io"
|
||||
|
||||
// "time"
|
||||
|
||||
@ -11,30 +12,36 @@ import (
|
||||
)
|
||||
|
||||
func HandleHttps(clientConn net.Conn, ip string) {
|
||||
|
||||
remoteConn, err := net.Dial("tcp", ip+":443") // create connection to server
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
defer remoteConn.Close()
|
||||
|
||||
log.Println("Connected to the server.")
|
||||
|
||||
// established := []byte("HTTP/1.1 204 No Content\n\n")
|
||||
|
||||
log.Println("Sending 204 No Content to the client..")
|
||||
log.Println("Sending 200 Connection Estabalished")
|
||||
|
||||
fmt.Fprintf(clientConn, "HTTP/1.1 204 No Content\r\n\r\n")
|
||||
fmt.Fprintf(clientConn, "HTTP/1.1 200 Connection Established\r\n\r\n")
|
||||
|
||||
|
||||
go func() {
|
||||
defer remoteConn.Close()
|
||||
for {
|
||||
buf, err := util.ReadMessage(remoteConn)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
if err != io.EOF {
|
||||
log.Println("Error reading from the server:", err)
|
||||
} else {
|
||||
log.Println("Remote connection Closed: ", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("Server Sent Data", len(buf))
|
||||
|
||||
_, write_err := clientConn.Write(buf)
|
||||
if write_err != nil {
|
||||
log.Println("Error writing to client:", write_err)
|
||||
@ -43,14 +50,18 @@ func HandleHttps(clientConn net.Conn, ip string) {
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
for {
|
||||
defer clientConn.Close()
|
||||
buf, err := util.ReadMessage(clientConn)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
if err != io.EOF {
|
||||
log.Println("Error reading from the client:", err)
|
||||
} else {
|
||||
log.Println("Client connection Closed: ", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
log.Println("Client Sent Data", len(buf))
|
||||
|
||||
_, write_err := remoteConn.Write(buf)
|
||||
if write_err != nil {
|
||||
@ -59,19 +70,4 @@ func HandleHttps(clientConn net.Conn, ip string) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
serverHello, err := util.WriteAndRead(remoteConn, clientHello)
|
||||
log.Println("Server sent data. length:", len(serverHello))
|
||||
|
||||
clientFinish, err := util.WriteAndRead(clientConn, serverHello)
|
||||
log.Println("Client sent data. length:", len(clientFinish))
|
||||
|
||||
_, err = remoteConn.Write(clientFinish)
|
||||
if err != nil {
|
||||
log.Fatal("Error writing to client:", err)
|
||||
}
|
||||
|
||||
log.Println("Written")
|
||||
*/
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ func Start() {
|
||||
|
||||
log.Println("Accepted a new connection.", clientConn.RemoteAddr())
|
||||
|
||||
func() {
|
||||
go func() {
|
||||
defer clientConn.Close()
|
||||
|
||||
message , err := util.ReadMessage(clientConn)
|
||||
|
@ -3,7 +3,6 @@ package util
|
||||
import (
|
||||
"net"
|
||||
"log"
|
||||
"io"
|
||||
"strings"
|
||||
"github.com/babolivier/go-doh-client"
|
||||
)
|
||||
@ -31,10 +30,7 @@ func ReadMessage(conn net.Conn)([]byte, error) {
|
||||
for {
|
||||
n, err := conn.Read(tmp)
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
log.Println("Read error:", err)
|
||||
return nil, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
buf = append(buf, tmp[:n]...)
|
||||
|
||||
@ -84,7 +80,7 @@ func DnsLookupOverHttps(dns string, domain string)(string, error) {
|
||||
log.Println(domain)
|
||||
a, _, err := resolver.LookupA(domain)
|
||||
if err != nil {
|
||||
log.Fatal("Error looking up dns. ", err)
|
||||
log.Println("Error looking up dns. ", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user