Add detailed error reporting for REALITY invalid connections (#24)

Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
Jesus
2025-10-14 19:56:29 +00:00
committed by GitHub
co-authored by RPRX
parent dab26e77fc
commit e4eec45205
+16 -1
View File
@@ -443,8 +443,23 @@ func Server(ctx context.Context, conn net.Conn, config *Config) (*Conn, error) {
if hs.c.isHandshakeComplete.Load() { if hs.c.isHandshakeComplete.Load() {
return hs.c, nil return hs.c, nil
} }
conn.Close() conn.Close()
return nil, errors.New("REALITY: processed invalid connection") // TODO: Add details. var failureReason string
if hs.clientHello == nil {
failureReason = "failed to read client hello"
} else if hs.c.vers != VersionTLS13 {
failureReason = fmt.Sprintf("unsupported TLS version: %x", hs.c.vers)
} else if !config.ServerNames[hs.clientHello.serverName] {
failureReason = fmt.Sprintf("server name mismatch: %s", hs.clientHello.serverName)
} else if hs.c.conn != conn {
failureReason = "authentication failed or validation criteria not met"
} else if hs.c.out.handshakeLen[0] == 0 {
failureReason = "target sent incorrect server hello or handshake incomplete"
} else {
failureReason = "handshake did not complete successfully"
}
return nil, fmt.Errorf("REALITY: processed invalid connection from %s: %s", remoteAddr, failureReason)
/* /*
c := &Conn{ c := &Conn{