mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
Merge pull request #1002 from oragono/ident
upgrade go-ident to fix parsing issue
This commit is contained in:
commit
21958768d8
2
go.mod
2
go.mod
@ -13,7 +13,7 @@ require (
|
|||||||
github.com/onsi/ginkgo v1.12.0 // indirect
|
github.com/onsi/ginkgo v1.12.0 // indirect
|
||||||
github.com/onsi/gomega v1.9.0 // indirect
|
github.com/onsi/gomega v1.9.0 // indirect
|
||||||
github.com/oragono/confusables v0.0.0-20190624102032-fe1cf31a24b0
|
github.com/oragono/confusables v0.0.0-20190624102032-fe1cf31a24b0
|
||||||
github.com/oragono/go-ident v0.0.0-20170110123031-337fed0fd21a
|
github.com/oragono/go-ident v0.0.0-20200511222032-830550b1d775
|
||||||
github.com/stretchr/testify v1.4.0 // indirect
|
github.com/stretchr/testify v1.4.0 // indirect
|
||||||
github.com/tidwall/buntdb v1.1.2
|
github.com/tidwall/buntdb v1.1.2
|
||||||
github.com/toorop/go-dkim v0.0.0-20191019073156-897ad64a2eeb
|
github.com/toorop/go-dkim v0.0.0-20191019073156-897ad64a2eeb
|
||||||
|
2
go.sum
2
go.sum
@ -46,6 +46,8 @@ github.com/oragono/confusables v0.0.0-20190624102032-fe1cf31a24b0 h1:4qw57EiWD2M
|
|||||||
github.com/oragono/confusables v0.0.0-20190624102032-fe1cf31a24b0/go.mod h1:+uesPRay9e5tW6zhw4CJkRV3QOEbbZIJcsuo9ZnC+hE=
|
github.com/oragono/confusables v0.0.0-20190624102032-fe1cf31a24b0/go.mod h1:+uesPRay9e5tW6zhw4CJkRV3QOEbbZIJcsuo9ZnC+hE=
|
||||||
github.com/oragono/go-ident v0.0.0-20170110123031-337fed0fd21a h1:tZApUffT5QuX4XhJLz2KfBJT8JgdwjLUBWtvmRwgFu4=
|
github.com/oragono/go-ident v0.0.0-20170110123031-337fed0fd21a h1:tZApUffT5QuX4XhJLz2KfBJT8JgdwjLUBWtvmRwgFu4=
|
||||||
github.com/oragono/go-ident v0.0.0-20170110123031-337fed0fd21a/go.mod h1:r5Fk840a4eu3ii1kxGDNSJupQu9Z1UC1nfJOZZXC24c=
|
github.com/oragono/go-ident v0.0.0-20170110123031-337fed0fd21a/go.mod h1:r5Fk840a4eu3ii1kxGDNSJupQu9Z1UC1nfJOZZXC24c=
|
||||||
|
github.com/oragono/go-ident v0.0.0-20200511222032-830550b1d775 h1:AMAsAn/i4AgsmWQYdMoze9omwtHpbxrKuT+AT1LmhtI=
|
||||||
|
github.com/oragono/go-ident v0.0.0-20200511222032-830550b1d775/go.mod h1:r5Fk840a4eu3ii1kxGDNSJupQu9Z1UC1nfJOZZXC24c=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
@ -27,8 +27,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// IdentTimeoutSeconds is how many seconds before our ident (username) check times out.
|
// IdentTimeout is how long before our ident (username) check times out.
|
||||||
IdentTimeoutSeconds = 1.5
|
IdentTimeout = time.Second + 500*time.Millisecond
|
||||||
IRCv3TimestampFormat = utils.IRCv3TimestampFormat
|
IRCv3TimestampFormat = utils.IRCv3TimestampFormat
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ func (client *Client) doIdentLookup(conn net.Conn) {
|
|||||||
clientPort := remoteTCPAddr.Port
|
clientPort := remoteTCPAddr.Port
|
||||||
|
|
||||||
client.Notice(client.t("*** Looking up your username"))
|
client.Notice(client.t("*** Looking up your username"))
|
||||||
resp, err := ident.Query(remoteTCPAddr.IP.String(), serverPort, clientPort, IdentTimeoutSeconds)
|
resp, err := ident.Query(remoteTCPAddr.IP.String(), serverPort, clientPort, IdentTimeout)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err := client.SetNames(resp.Identifier, "", true)
|
err := client.SetNames(resp.Identifier, "", true)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
43
vendor/github.com/oragono/go-ident/client.go
generated
vendored
43
vendor/github.com/oragono/go-ident/client.go
generated
vendored
@ -37,49 +37,46 @@ func (e ProtocolError) Error() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Query makes an Ident query, if timeout is >0 the query is timed out after that many seconds.
|
// 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 float64) (Response, error) {
|
func Query(ip string, portOnServer, portOnClient int, timeout time.Duration) (response Response, err error) {
|
||||||
var (
|
var conn net.Conn
|
||||||
conn net.Conn
|
|
||||||
err error
|
|
||||||
fields []string
|
|
||||||
r *bufio.Reader
|
|
||||||
resp string
|
|
||||||
)
|
|
||||||
|
|
||||||
if timeout > 0 {
|
if timeout > 0 {
|
||||||
conn, err = net.DialTimeout("tcp", net.JoinHostPort(ip, "113"), time.Duration(timeout)*time.Second)
|
conn, err = net.DialTimeout("tcp", net.JoinHostPort(ip, "113"), timeout)
|
||||||
} else {
|
} else {
|
||||||
conn, err = net.Dial("tcp", net.JoinHostPort(ip, "113"))
|
conn, err = net.Dial("tcp", net.JoinHostPort(ip, "113"))
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Response{}, err
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop the ident read after <timeout> seconds
|
// stop the ident read after <timeout> seconds
|
||||||
if timeout > 0 {
|
if timeout > 0 {
|
||||||
conn.SetDeadline(time.Now().Add(time.Second * time.Duration(timeout)))
|
conn.SetDeadline(time.Now().Add(timeout))
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = conn.Write([]byte(fmt.Sprintf("%d, %d", portOnClient, portOnServer) + "\r\n"))
|
_, err = conn.Write([]byte(fmt.Sprintf("%d, %d", portOnClient, portOnServer) + "\r\n"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Response{}, err
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
r = bufio.NewReader(conn)
|
r := bufio.NewReaderSize(conn, 1024)
|
||||||
resp, err = r.ReadString('\n')
|
respBytes, err := r.ReadSlice('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Response{}, err
|
return
|
||||||
}
|
}
|
||||||
|
resp := string(respBytes)
|
||||||
|
|
||||||
fields = strings.SplitN(strings.TrimSpace(resp), " : ", 4)
|
fields := strings.SplitN(resp, ":", 4)
|
||||||
if len(fields) < 3 {
|
if len(fields) < 3 {
|
||||||
return Response{}, ProtocolError{resp}
|
return response, ProtocolError{resp}
|
||||||
|
}
|
||||||
|
for i, field := range fields {
|
||||||
|
fields[i] = strings.TrimSpace(field)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch fields[1] {
|
switch fields[1] {
|
||||||
case "USERID":
|
case "USERID":
|
||||||
if len(fields) != 4 {
|
if len(fields) != 4 {
|
||||||
return Response{}, ProtocolError{resp}
|
return response, ProtocolError{resp}
|
||||||
}
|
}
|
||||||
|
|
||||||
var os, charset string
|
var os, charset string
|
||||||
@ -99,10 +96,12 @@ func Query(ip string, portOnServer, portOnClient int, timeout float64) (Response
|
|||||||
}, nil
|
}, nil
|
||||||
case "ERROR":
|
case "ERROR":
|
||||||
if len(fields) != 3 {
|
if len(fields) != 3 {
|
||||||
return Response{}, ProtocolError{resp}
|
return response, ProtocolError{resp}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response{}, ResponseError{fields[2]}
|
return response, ResponseError{fields[2]}
|
||||||
|
default:
|
||||||
|
err = ProtocolError{resp}
|
||||||
}
|
}
|
||||||
return Response{}, err
|
return
|
||||||
}
|
}
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -30,7 +30,7 @@ github.com/goshuirc/irc-go/ircmsg
|
|||||||
# github.com/oragono/confusables v0.0.0-20190624102032-fe1cf31a24b0
|
# github.com/oragono/confusables v0.0.0-20190624102032-fe1cf31a24b0
|
||||||
## explicit
|
## explicit
|
||||||
github.com/oragono/confusables
|
github.com/oragono/confusables
|
||||||
# github.com/oragono/go-ident v0.0.0-20170110123031-337fed0fd21a
|
# github.com/oragono/go-ident v0.0.0-20200511222032-830550b1d775
|
||||||
## explicit
|
## explicit
|
||||||
github.com/oragono/go-ident
|
github.com/oragono/go-ident
|
||||||
# github.com/stretchr/testify v1.4.0
|
# github.com/stretchr/testify v1.4.0
|
||||||
|
Loading…
Reference in New Issue
Block a user