|
@@ -7,11 +7,13 @@ package irc
|
7
|
7
|
|
8
|
8
|
import (
|
9
|
9
|
"fmt"
|
|
10
|
+ "log"
|
10
|
11
|
"net"
|
11
|
12
|
"strconv"
|
12
|
13
|
"time"
|
13
|
14
|
|
14
|
15
|
"github.com/DanielOaks/girc-go/ircmsg"
|
|
16
|
+ "github.com/DanielOaks/go-ident"
|
15
|
17
|
)
|
16
|
18
|
|
17
|
19
|
const (
|
|
@@ -67,6 +69,35 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
|
67
|
69
|
if isTLS {
|
68
|
70
|
client.flags[TLS] = true
|
69
|
71
|
}
|
|
72
|
+ if server.checkIdent {
|
|
73
|
+ _, serverPortString, err := net.SplitHostPort(conn.LocalAddr().String())
|
|
74
|
+ serverPort, _ := strconv.Atoi(serverPortString)
|
|
75
|
+ if err != nil {
|
|
76
|
+ log.Fatal(err)
|
|
77
|
+ }
|
|
78
|
+ clientHost, clientPortString, err := net.SplitHostPort(conn.RemoteAddr().String())
|
|
79
|
+ clientPort, _ := strconv.Atoi(clientPortString)
|
|
80
|
+ if err != nil {
|
|
81
|
+ log.Fatal(err)
|
|
82
|
+ }
|
|
83
|
+
|
|
84
|
+ client.Notice("*** Looking up your username")
|
|
85
|
+ resp, err := ident.Query(clientHost, serverPort, clientPort)
|
|
86
|
+ if err == nil {
|
|
87
|
+ username := resp.Identifier
|
|
88
|
+ //TODO(dan): replace this with IsUsername/IsIRCName?
|
|
89
|
+ if Name(username).IsNickname() {
|
|
90
|
+ client.Notice("*** Found your username")
|
|
91
|
+ //TODO(dan): we do a bunch of user replacing in server.go userHandler, do we need that here?
|
|
92
|
+ client.username = Name(username)
|
|
93
|
+ // we don't need to updateNickMask here since nickMask is not used for anything yet
|
|
94
|
+ } else {
|
|
95
|
+ client.Notice("*** Got a malformed username, ignoring")
|
|
96
|
+ }
|
|
97
|
+ } else {
|
|
98
|
+ client.Notice("*** Could not find your username")
|
|
99
|
+ }
|
|
100
|
+ }
|
70
|
101
|
client.Touch()
|
71
|
102
|
go client.run()
|
72
|
103
|
|