diff --git a/go.mod b/go.mod index 90422a6a..379efbd9 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1 - github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775 + github.com/ergochat/go-ident v0.0.0-20230911071154-8c30606d6881 github.com/ergochat/irc-go v0.4.0 github.com/go-sql-driver/mysql v1.7.0 github.com/go-test/deep v1.0.6 // indirect diff --git a/go.sum b/go.sum index cd853995..11fb6681 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,8 @@ github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1 h1:WLHTOodthV github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1/go.mod h1:mov+uh1DPWsltdQnOdzn08UO9GsJ3MEvhtu0Ci37fdk= github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775 h1:QSJIdpr3HOzJDPwxT7hp7WbjoZcS+5GqVvsBscqChk0= github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775/go.mod h1:d2qvgjD0TvGNSvUs+mZgX090RiJlrzUYW6vtANGOy3A= +github.com/ergochat/go-ident v0.0.0-20230911071154-8c30606d6881 h1:+J5m88nvybxB5AnBVGzTXM/yHVytt48rXBGcJGzSbms= +github.com/ergochat/go-ident v0.0.0-20230911071154-8c30606d6881/go.mod h1:ASYJtQujNitna6cVHsNQTGrfWvMPJ5Sa2lZlmsH65uM= github.com/ergochat/irc-go v0.4.0 h1:0YibCKfAAtwxQdNjLQd9xpIEPisLcJ45f8FNsMHAuZc= github.com/ergochat/irc-go v0.4.0/go.mod h1:2vi7KNpIPWnReB5hmLpl92eMywQvuIeIIGdt/FQCph0= github.com/ergochat/scram v1.0.2-ergo1 h1:2bYXiRFQH636pT0msOG39fmEYl4Eq+OuutcyDsCix/g= diff --git a/vendor/github.com/ergochat/go-ident/client.go b/vendor/github.com/ergochat/go-ident/client.go index 256bde7a..412147a8 100644 --- a/vendor/github.com/ergochat/go-ident/client.go +++ b/vendor/github.com/ergochat/go-ident/client.go @@ -38,6 +38,12 @@ func (e ProtocolError) Error() string { // Query makes an Ident query, if timeout is >0 the query is timed out after that many seconds. func Query(ip string, portOnServer, portOnClient int, timeout time.Duration) (response Response, err error) { + // if a timeout is set, respect it from the beginning of the query, including the dial time + var deadline time.Time + if timeout > 0 { + deadline = time.Now().Add(timeout) + } + var conn net.Conn if timeout > 0 { conn, err = net.DialTimeout("tcp", net.JoinHostPort(ip, "113"), timeout) @@ -47,13 +53,12 @@ func Query(ip string, portOnServer, portOnClient int, timeout time.Duration) (re if err != nil { return } + defer conn.Close() - // stop the ident read after seconds - if timeout > 0 { - conn.SetDeadline(time.Now().Add(timeout)) - } + // if timeout is 0, `deadline` is the empty time.Time{} which means no deadline: + conn.SetDeadline(deadline) - _, err = conn.Write([]byte(fmt.Sprintf("%d, %d", portOnClient, portOnServer) + "\r\n")) + _, err = conn.Write([]byte(fmt.Sprintf("%d, %d\r\n", portOnClient, portOnServer))) if err != nil { return } diff --git a/vendor/modules.txt b/vendor/modules.txt index afcc30eb..3367348b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -13,8 +13,8 @@ github.com/docopt/docopt-go # github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1 ## explicit github.com/ergochat/confusables -# github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775 -## explicit +# github.com/ergochat/go-ident v0.0.0-20230911071154-8c30606d6881 +## explicit; go 1.18 github.com/ergochat/go-ident # github.com/ergochat/irc-go v0.4.0 ## explicit; go 1.15