Closed baixiaoshi closed 1 year ago
server code
func main() { cert, err := tls.LoadX509KeyPair("cert/xxxx.crt", "cert/xxx.key") if err != nil { log.Println(err) return } config := &tls.Config{ Certificates: []tls.Certificate{cert}} ln, err := tls.Listen("tcp", ":9090", config) proxyListener := &proxyproto.Listener{ Listener: ln, } conn, err := proxyListener.Accept() if err != nil { log.Fatalf("err: %v", err) } defer conn.Close() addr := conn.RemoteAddr().(*net.TCPAddr) fmt.Println("ip====", addr.IP.String()) if addr.IP.String() != "10.1.1.1" { log.Fatalf("bad: %v", addr) } if addr.Port != 1000 { log.Fatalf("bad: %v", addr) } }
client code
func main() { conn, err := net.Dial("tcp", "127.0.0.1:9090") if err != nil { log.Fatalf("err: %v", err) } defer conn.Close() // Write out the header! header := "PROXY TCP4 10.1.1.1 20.2.2.2 1000 2000\r\n" conn.Write([]byte(header)) }
trigger error
[ERR] Failed to read proxy prefix: tls: first record does not look like a TLS handshake
on golang source code
i think you wrap listener runing after the golang source code tls handshake
Can you try what is suggested in https://github.com/pires/go-proxyproto/issues/89#issuecomment-1296978516?
Closing due to lack of response by issue creator.
server code
client code
trigger error
on golang source code![image](https://user-images.githubusercontent.com/5595933/181145991-0133e684-1a6d-452a-a2aa-c4b6daa2831f.png)
i think you wrap listener runing after the golang source code tls handshake