mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
[FIXED] Possible panic when server accepts TLS leafnode connection
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
@@ -1204,6 +1204,39 @@ func TestLeafNodeTLS(t *testing.T) {
|
||||
checkLeafNodeConnected(t, s)
|
||||
}
|
||||
|
||||
func TestLeafNodeTLSConnCloseEarly(t *testing.T) {
|
||||
content := `
|
||||
listen: "127.0.0.1:-1"
|
||||
|
||||
leafnodes {
|
||||
listen: "127.0.0.1:-1"
|
||||
tls {
|
||||
cert_file: "./configs/certs/server-cert.pem"
|
||||
key_file: "./configs/certs/server-key.pem"
|
||||
timeout: 2.0
|
||||
}
|
||||
}
|
||||
`
|
||||
conf := createConfFile(t, []byte(content))
|
||||
defer os.Remove(conf)
|
||||
|
||||
s, opts := RunServerWithConfig(conf)
|
||||
defer s.Shutdown()
|
||||
|
||||
lc, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", opts.LeafNode.Port))
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to connect: %v", err)
|
||||
}
|
||||
// Then close right away
|
||||
lc.Close()
|
||||
|
||||
// Check server does not crash...
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
if s.ID() == "" {
|
||||
t.Fatalf("should not happen")
|
||||
}
|
||||
}
|
||||
|
||||
type captureLeafNodeErrLogger struct {
|
||||
dummyLogger
|
||||
ch chan string
|
||||
|
||||
Reference in New Issue
Block a user