[PD1] log fixing

This commit is contained in:
Tiago Sousa 2024-04-28 17:42:43 +01:00
parent d6b8ed48a6
commit f5b3726673
Signed by: tiago
SSH key fingerprint: SHA256:rOmjD81ZIhKdCkFWS9UIKdBi4UByF5x3hRH/0YeXsPI
6 changed files with 79 additions and 37 deletions

View file

@ -20,7 +20,7 @@ func NewServer[T any](serverTLSConfigProvider ServerTLSConfigProvider, port int)
listener, err := tls.Listen("tcp", fmt.Sprintf("0.0.0.0:%d", port), serverTLSConfigProvider.GetServerTLSConfig())
if err != nil {
panic("Server could not bind to address")
log.Fatalln("Server could not bind to address")
}
return Server[T]{
listener: listener,
@ -33,17 +33,17 @@ func (s *Server[T]) ListenLoop() {
for {
listenerConn, err := s.listener.Accept()
if err != nil {
panic("Server could not accept connection")
log.Fatalln("Server could not accept connection")
}
tlsConn, ok := listenerConn.(*tls.Conn)
if !ok {
panic("Connection is not a TLS connection")
log.Fatalln("Connection is not a TLS connection")
}
tlsConn.Handshake()
state := tlsConn.ConnectionState()
if len(state.PeerCertificates) == 0 {
log.Panicln("Client did not provide a certificate")
log.Fatalln("Client did not provide a certificate")
}
conn := NewConnection[T](tlsConn)
s.C <- conn