From 8cec9de7bd591154cf508650c4338b20292e5880 Mon Sep 17 00:00:00 2001 From: Mark Pashmfouroush Date: Thu, 14 Mar 2024 11:02:56 +0000 Subject: [PATCH] deps: remove conjure Signed-off-by: Mark Pashmfouroush --- go.mod | 2 +- go.sum | 7 +---- psiphon/p.go | 4 +-- psiphon/relay.go | 77 ------------------------------------------------ 4 files changed, 4 insertions(+), 86 deletions(-) delete mode 100644 psiphon/relay.go diff --git a/go.mod b/go.mod index 4753d111c..3c30b5842 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,6 @@ require ( github.com/hashicorp/golang-lru v1.0.2 github.com/peterbourgon/ff/v4 v4.0.0-alpha.4 github.com/quic-go/quic-go v0.40.1 - github.com/refraction-networking/conjure v0.7.11-0.20240130155008-c8df96195ab2 github.com/refraction-networking/utls v1.3.3 github.com/rodaine/table v1.1.1 golang.org/x/crypto v0.21.0 @@ -67,6 +66,7 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/quic-go/qpack v0.4.0 // indirect github.com/quic-go/qtls-go1-20 v0.4.1 // indirect + github.com/refraction-networking/conjure v0.7.11-0.20240130155008-c8df96195ab2 // indirect github.com/refraction-networking/ed25519 v0.1.2 // indirect github.com/refraction-networking/gotapdance v1.7.10 // indirect github.com/refraction-networking/obfs4 v0.1.2 // indirect diff --git a/go.sum b/go.sum index 5a8d48289..730a87232 100644 --- a/go.sum +++ b/go.sum @@ -214,8 +214,6 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 h1:Di6/M8l0O2lCLc6VVRWhgCiApHV8MnQurBnFSHsQtNY= @@ -233,8 +231,6 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -266,9 +262,8 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= diff --git a/psiphon/p.go b/psiphon/p.go index 4ea7fff64..3f2d6759d 100644 --- a/psiphon/p.go +++ b/psiphon/p.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "log" "net" "path/filepath" "strings" @@ -12,7 +13,6 @@ import ( "time" "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon" - "github.com/refraction-networking/conjure/pkg/station/log" ) // Parameters provide an easier way to modify the tunnel config at runtime. @@ -380,7 +380,7 @@ func RunPsiphon(wgBind, localSocksPort, country string, ctx context.Context) err log.Println("Psiphon started successfully on port", tunnel.SOCKSProxyPort, "handshake operation took", int64(time.Since(startTime)/time.Millisecond), "milliseconds") return nil } - log.Error("Unable to start psiphon", err, "reconnecting...") + log.Println("Unable to start psiphon", err, "reconnecting...") time.Sleep(1 * time.Second) } } diff --git a/psiphon/relay.go b/psiphon/relay.go deleted file mode 100644 index 0b9b77442..000000000 --- a/psiphon/relay.go +++ /dev/null @@ -1,77 +0,0 @@ -package psiphon - -import ( - "encoding/hex" - "fmt" - "net" - "net/http" - "time" -) - -func handleRequest(w http.ResponseWriter, r *http.Request) { - // Combine URL query parameters and POST form values - params := r.URL.Query() - if err := r.ParseForm(); err == nil { - for k, v := range r.PostForm { - params[k] = v - } - } - - // Find the first valid hex string in parameters - var packetHex string - for _, v := range params { - if len(v) > 0 && isHex(v[0]) { - packetHex = v[0] - break - } - } - - if packetHex == "" { - fmt.Fprintln(w, "No valid hex packet found in request") - return - } - - // Assuming remote host and port are provided - remoteHost := "engage.cloudflareclient.com" - remotePort := "2408" - - response, err := sendUdpPacket(remoteHost, remotePort, packetHex) - if err != nil { - fmt.Fprintf(w, "Error: %v\n", err) - } else { - fmt.Fprintf(w, "Response: %s\n", response) - } -} - -func sendUdpPacket(remoteHost, remotePort, packetHex string) (string, error) { - packet, err := hex.DecodeString(packetHex) - if err != nil { - return "", fmt.Errorf("invalid hex string: %w", err) - } - - remoteAddr := net.JoinHostPort(remoteHost, remotePort) - conn, err := net.Dial("udp", remoteAddr) - if err != nil { - return "", fmt.Errorf("dial error: %w", err) - } - defer conn.Close() - - if _, err = conn.Write(packet); err != nil { - return "", fmt.Errorf("write error: %w", err) - } - - conn.SetReadDeadline(time.Now().Add(5 * time.Second)) - - buffer := make([]byte, 1024) - n, err := conn.Read(buffer) - if err != nil { - return "", fmt.Errorf("read error: %w", err) - } - - return hex.EncodeToString(buffer[:n]), nil -} - -func isHex(s string) bool { - _, err := hex.DecodeString(s) - return err == nil -}