|
@@ -160,13 +160,14 @@ type Session struct {
|
160
|
160
|
idleTimer *time.Timer
|
161
|
161
|
pingSent bool // we sent PING to a putatively idle connection and we're waiting for PONG
|
162
|
162
|
|
163
|
|
- sessionID int64
|
164
|
|
- socket *Socket
|
165
|
|
- realIP net.IP
|
166
|
|
- proxiedIP net.IP
|
167
|
|
- rawHostname string
|
168
|
|
- isTor bool
|
169
|
|
- hideSTS bool
|
|
163
|
+ sessionID int64
|
|
164
|
+ socket *Socket
|
|
165
|
+ realIP net.IP
|
|
166
|
+ proxiedIP net.IP
|
|
167
|
+ rawHostname string
|
|
168
|
+ hostnameFinalized bool
|
|
169
|
+ isTor bool
|
|
170
|
+ hideSTS bool
|
170
|
171
|
|
171
|
172
|
fakelag Fakelag
|
172
|
173
|
deferredFakelagCount int
|
|
@@ -488,12 +489,21 @@ func (client *Client) resizeHistory(config *Config) {
|
488
|
489
|
}
|
489
|
490
|
}
|
490
|
491
|
|
491
|
|
-// resolve an IP to an IRC-ready hostname, using reverse DNS, forward-confirming if necessary,
|
492
|
|
-// and sending appropriate notices to the client
|
493
|
|
-func (client *Client) lookupHostname(session *Session, overwrite bool) {
|
|
492
|
+// once we have the final IP address (from the connection itself or from proxy data),
|
|
493
|
+// compute the various possibilities for the hostname:
|
|
494
|
+// * In the default/recommended configuration, via the cloak algorithm
|
|
495
|
+// * If hostname lookup is enabled, via (forward-confirmed) reverse DNS
|
|
496
|
+// * If WEBIRC was used, possibly via the hostname passed on the WEBIRC line
|
|
497
|
+func (client *Client) finalizeHostname(session *Session) {
|
|
498
|
+ // only allow this once, since registration can fail (e.g. if the nickname is in use)
|
|
499
|
+ if session.hostnameFinalized {
|
|
500
|
+ return
|
|
501
|
+ }
|
|
502
|
+ session.hostnameFinalized = true
|
|
503
|
+
|
494
|
504
|
if session.isTor {
|
495
|
505
|
return
|
496
|
|
- } // else: even if cloaking is enabled, look up the real hostname to show to operators
|
|
506
|
+ }
|
497
|
507
|
|
498
|
508
|
config := client.server.Config()
|
499
|
509
|
ip := session.realIP
|
|
@@ -501,30 +511,27 @@ func (client *Client) lookupHostname(session *Session, overwrite bool) {
|
501
|
511
|
ip = session.proxiedIP
|
502
|
512
|
}
|
503
|
513
|
|
504
|
|
- var hostname string
|
505
|
|
- lookupSuccessful := false
|
506
|
|
- if config.Server.lookupHostnames {
|
507
|
|
- session.Notice("*** Looking up your hostname...")
|
508
|
|
- hostname, lookupSuccessful = utils.LookupHostname(ip, config.Server.ForwardConfirmHostnames)
|
509
|
|
- if lookupSuccessful {
|
510
|
|
- session.Notice("*** Found your hostname")
|
|
514
|
+ // even if cloaking is enabled, we may want to look up the real hostname to show to operators:
|
|
515
|
+ if session.rawHostname == "" {
|
|
516
|
+ var hostname string
|
|
517
|
+ lookupSuccessful := false
|
|
518
|
+ if config.Server.lookupHostnames {
|
|
519
|
+ session.Notice("*** Looking up your hostname...")
|
|
520
|
+ hostname, lookupSuccessful = utils.LookupHostname(ip, config.Server.ForwardConfirmHostnames)
|
|
521
|
+ if lookupSuccessful {
|
|
522
|
+ session.Notice("*** Found your hostname")
|
|
523
|
+ } else {
|
|
524
|
+ session.Notice("*** Couldn't look up your hostname")
|
|
525
|
+ }
|
511
|
526
|
} else {
|
512
|
|
- session.Notice("*** Couldn't look up your hostname")
|
|
527
|
+ hostname = utils.IPStringToHostname(ip.String())
|
513
|
528
|
}
|
514
|
|
- } else {
|
515
|
|
- hostname = utils.IPStringToHostname(ip.String())
|
|
529
|
+ session.rawHostname = hostname
|
516
|
530
|
}
|
517
|
531
|
|
518
|
|
- session.rawHostname = hostname
|
519
|
|
- cloakedHostname := config.Server.Cloaks.ComputeCloak(ip)
|
520
|
|
- client.stateMutex.Lock()
|
521
|
|
- defer client.stateMutex.Unlock()
|
522
|
|
- // update the hostname if this is a new connection, but not if it's a reattach
|
523
|
|
- if overwrite || client.rawHostname == "" {
|
524
|
|
- client.rawHostname = hostname
|
525
|
|
- client.cloakedHostname = cloakedHostname
|
526
|
|
- client.updateNickMaskNoMutex()
|
527
|
|
- }
|
|
532
|
+ // these will be discarded if this is actually a reattach:
|
|
533
|
+ client.rawHostname = session.rawHostname
|
|
534
|
+ client.cloakedHostname = config.Server.Cloaks.ComputeCloak(ip)
|
528
|
535
|
}
|
529
|
536
|
|
530
|
537
|
func (client *Client) doIdentLookup(conn net.Conn) {
|