Skip to content

Commit

Permalink
fix: ssh & xmpp not reporting ErrConsumedAllPrefetchedBytes errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ydylla committed Jul 16, 2024
1 parent 3e5b068 commit 36ad3a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions modules/l4ssh/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions modules/l4xmpp/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 36ad3a7

Please sign in to comment.