Browse Source

upgrade go-ident

Fixes a socket leak (that doesn't seem to be affecting tilde.town?)
tags/v2.12.0-rc1
Shivaram Lingamneni 8 months ago
parent
commit
3bd3c6a88a
4 changed files with 15 additions and 8 deletions
  1. 1
    1
      go.mod
  2. 2
    0
      go.sum
  3. 10
    5
      vendor/github.com/ergochat/go-ident/client.go
  4. 2
    2
      vendor/modules.txt

+ 1
- 1
go.mod View File

@@ -7,7 +7,7 @@ require (
7 7
 	github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962
8 8
 	github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
9 9
 	github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1
10
-	github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775
10
+	github.com/ergochat/go-ident v0.0.0-20230911071154-8c30606d6881
11 11
 	github.com/ergochat/irc-go v0.4.0
12 12
 	github.com/go-sql-driver/mysql v1.7.0
13 13
 	github.com/go-test/deep v1.0.6 // indirect

+ 2
- 0
go.sum View File

@@ -10,6 +10,8 @@ github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1 h1:WLHTOodthV
10 10
 github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1/go.mod h1:mov+uh1DPWsltdQnOdzn08UO9GsJ3MEvhtu0Ci37fdk=
11 11
 github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775 h1:QSJIdpr3HOzJDPwxT7hp7WbjoZcS+5GqVvsBscqChk0=
12 12
 github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775/go.mod h1:d2qvgjD0TvGNSvUs+mZgX090RiJlrzUYW6vtANGOy3A=
13
+github.com/ergochat/go-ident v0.0.0-20230911071154-8c30606d6881 h1:+J5m88nvybxB5AnBVGzTXM/yHVytt48rXBGcJGzSbms=
14
+github.com/ergochat/go-ident v0.0.0-20230911071154-8c30606d6881/go.mod h1:ASYJtQujNitna6cVHsNQTGrfWvMPJ5Sa2lZlmsH65uM=
13 15
 github.com/ergochat/irc-go v0.4.0 h1:0YibCKfAAtwxQdNjLQd9xpIEPisLcJ45f8FNsMHAuZc=
14 16
 github.com/ergochat/irc-go v0.4.0/go.mod h1:2vi7KNpIPWnReB5hmLpl92eMywQvuIeIIGdt/FQCph0=
15 17
 github.com/ergochat/scram v1.0.2-ergo1 h1:2bYXiRFQH636pT0msOG39fmEYl4Eq+OuutcyDsCix/g=

+ 10
- 5
vendor/github.com/ergochat/go-ident/client.go View File

@@ -38,6 +38,12 @@ func (e ProtocolError) Error() string {
38 38
 
39 39
 // Query makes an Ident query, if timeout is >0 the query is timed out after that many seconds.
40 40
 func Query(ip string, portOnServer, portOnClient int, timeout time.Duration) (response Response, err error) {
41
+	// if a timeout is set, respect it from the beginning of the query, including the dial time
42
+	var deadline time.Time
43
+	if timeout > 0 {
44
+		deadline = time.Now().Add(timeout)
45
+	}
46
+
41 47
 	var conn net.Conn
42 48
 	if timeout > 0 {
43 49
 		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
47 53
 	if err != nil {
48 54
 		return
49 55
 	}
56
+	defer conn.Close()
50 57
 
51
-	// stop the ident read after <timeout> seconds
52
-	if timeout > 0 {
53
-		conn.SetDeadline(time.Now().Add(timeout))
54
-	}
58
+	// if timeout is 0, `deadline` is the empty time.Time{} which means no deadline:
59
+	conn.SetDeadline(deadline)
55 60
 
56
-	_, err = conn.Write([]byte(fmt.Sprintf("%d, %d", portOnClient, portOnServer) + "\r\n"))
61
+	_, err = conn.Write([]byte(fmt.Sprintf("%d, %d\r\n", portOnClient, portOnServer)))
57 62
 	if err != nil {
58 63
 		return
59 64
 	}

+ 2
- 2
vendor/modules.txt View File

@@ -13,8 +13,8 @@ github.com/docopt/docopt-go
13 13
 # github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1
14 14
 ## explicit
15 15
 github.com/ergochat/confusables
16
-# github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775
17
-## explicit
16
+# github.com/ergochat/go-ident v0.0.0-20230911071154-8c30606d6881
17
+## explicit; go 1.18
18 18
 github.com/ergochat/go-ident
19 19
 # github.com/ergochat/irc-go v0.4.0
20 20
 ## explicit; go 1.15

Loading…
Cancel
Save