Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tls handshake error #93

Closed
baixiaoshi opened this issue Jul 27, 2022 · 2 comments
Closed

tls handshake error #93

baixiaoshi opened this issue Jul 27, 2022 · 2 comments

Comments

@baixiaoshi
Copy link

baixiaoshi commented Jul 27, 2022

image

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
image

i think you wrap listener runing after the golang source code tls handshake

@pires
Copy link
Owner

pires commented Nov 14, 2022

Can you try what is suggested in #89 (comment)?

@pires
Copy link
Owner

pires commented Mar 15, 2023

Closing due to lack of response by issue creator.

@pires pires closed this as completed Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants