From c24380c013d10634540eb9854144508c8d14eaf6 Mon Sep 17 00:00:00 2001 From: krawthekrow Date: Sun, 15 Apr 2018 20:47:28 -0400 Subject: [PATCH] fix parse error for z_sender_sockaddr --- notice.go | 8 +++++++- raw_notice.go | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/notice.go b/notice.go index af1c032..aa8818b 100644 --- a/notice.go +++ b/notice.go @@ -248,7 +248,13 @@ func DecodeRawNotice(r *RawNotice) (*Notice, error) { var senderAddress net.IP if len(r.HeaderFields) > senderSockaddrIndex { - ipBytes, err := DecodeZcode(r.HeaderFields[senderSockaddrIndex]) + sockaddrField := r.HeaderFields[senderSockaddrIndex] + var ipBytes []byte + if len(sockaddrField) != 0 && sockaddrField[0] == 'Z' { + ipBytes, err = DecodeZcode(sockaddrField) + } else { + ipBytes, err = DecodeZAscii(sockaddrField) + } if err != nil { return nil, err } diff --git a/raw_notice.go b/raw_notice.go index 7c37603..6e4ac4d 100644 --- a/raw_notice.go +++ b/raw_notice.go @@ -130,7 +130,7 @@ const ( multipartIndex // string multiuidIndex // 12-byte zascii // Added in 2009; no version bump - senderSockaddrIndex // zcode + senderSockaddrIndex // zcode or zascii charsetIndex // zascii16 little-endian // Other fields numKnownFields