mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-22 08:48:43 +02:00
fix(stream): nil panic when logging error
This commit is contained in:
@@ -70,7 +70,14 @@ func (s *TCPTCPStream) LocalAddr() net.Addr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *TCPTCPStream) MarshalZerologObject(e *zerolog.Event) {
|
func (s *TCPTCPStream) MarshalZerologObject(e *zerolog.Event) {
|
||||||
e.Str("protocol", "tcp-tcp").Str("listen", s.listener.Addr().String()).Str("dst", s.dst.String())
|
e.Str("protocol", "tcp-tcp")
|
||||||
|
|
||||||
|
if s.listener != nil {
|
||||||
|
e.Str("listen", s.listener.Addr().String())
|
||||||
|
}
|
||||||
|
if s.dst != nil {
|
||||||
|
e.Str("dst", s.dst.String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TCPTCPStream) listen(ctx context.Context) {
|
func (s *TCPTCPStream) listen(ctx context.Context) {
|
||||||
|
|||||||
@@ -113,7 +113,13 @@ func (s *UDPUDPStream) LocalAddr() net.Addr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *UDPUDPStream) MarshalZerologObject(e *zerolog.Event) {
|
func (s *UDPUDPStream) MarshalZerologObject(e *zerolog.Event) {
|
||||||
e.Str("protocol", "udp-udp").Str("name", s.name).Str("dst", s.dst.String())
|
e.Str("protocol", "udp-udp")
|
||||||
|
if s.name != "" {
|
||||||
|
e.Str("name", s.name)
|
||||||
|
}
|
||||||
|
if s.dst != nil {
|
||||||
|
e.Str("dst", s.dst.String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *UDPUDPStream) listen(ctx context.Context) {
|
func (s *UDPUDPStream) listen(ctx context.Context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user