mirror of
https://github.com/XTLS/REALITY.git
synced 2026-09-22 23:08:01 +03:00
Add detailed error reporting for REALITY invalid connections (#24)
Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
@@ -443,8 +443,23 @@ func Server(ctx context.Context, conn net.Conn, config *Config) (*Conn, error) {
|
||||
if hs.c.isHandshakeComplete.Load() {
|
||||
return hs.c, nil
|
||||
}
|
||||
|
||||
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{
|
||||
|
||||
Reference in New Issue
Block a user