diff --git a/modules/l4ssh/matcher.go b/modules/l4ssh/matcher.go index af8aa07..931e252 100644 --- a/modules/l4ssh/matcher.go +++ b/modules/l4ssh/matcher.go @@ -40,9 +40,9 @@ func (MatchSSH) CaddyModule() caddy.ModuleInfo { // Match returns true if the connection looks like SSH. func (m MatchSSH) Match(cx *layer4.Connection) (bool, error) { p := make([]byte, len(sshPrefix)) - n, err := io.ReadFull(cx, p) - if err != nil || n < len(sshPrefix) { - return false, nil + _, err := io.ReadFull(cx, p) + if err != nil { + return false, err } return bytes.Equal(p, sshPrefix), nil } diff --git a/modules/l4xmpp/matcher.go b/modules/l4xmpp/matcher.go index b9a2d45..a244583 100644 --- a/modules/l4xmpp/matcher.go +++ b/modules/l4xmpp/matcher.go @@ -40,15 +40,15 @@ func (MatchXMPP) CaddyModule() caddy.ModuleInfo { // Match returns true if the connection looks like XMPP. func (m MatchXMPP) Match(cx *layer4.Connection) (bool, error) { p := make([]byte, minXmppLength) - n, err := io.ReadFull(cx, p) - if err != nil || n < minXmppLength { // needs at least 50 (fix for adium/pidgin) - return false, nil + _, err := io.ReadFull(cx, p) + if err != nil { + return false, err } return strings.Contains(string(p), xmppWord), nil } var xmppWord = "jabber" -var minXmppLength = 50 +var minXmppLength = 50 // needs at least 50 (fix for adium/pidgin) // Interface guard var _ layer4.ConnMatcher = (*MatchXMPP)(nil)