Selaa lähdekoodia

Show real IP in WHOWAS to opers with ban capability.

tags/v2.8.0-rc1
Alex Jaspersen 2 vuotta sitten
vanhempi
commit
e5c2588eab
4 muutettua tiedostoa jossa 11 lisäystä ja 4 poistoa
  1. 5
    0
      irc/client.go
  2. 1
    0
      irc/getters.go
  3. 4
    4
      irc/handlers.go
  4. 1
    0
      irc/numerics.go

+ 5
- 0
irc/client.go Näytä tiedosto

@@ -269,6 +269,7 @@ type WhoWas struct {
269 269
 	username       string
270 270
 	hostname       string
271 271
 	realname       string
272
+	realIP         net.IP
272 273
 	// technically not required for WHOWAS:
273 274
 	account     string
274 275
 	accountName string
@@ -598,6 +599,10 @@ func (client *Client) IP() net.IP {
598 599
 	client.stateMutex.RLock()
599 600
 	defer client.stateMutex.RUnlock()
600 601
 
602
+	return client.getIPNoMutex()
603
+}
604
+
605
+func (client *Client) getIPNoMutex() net.IP {
601 606
 	if client.proxiedIP != nil {
602 607
 		return client.proxiedIP
603 608
 	}

+ 1
- 0
irc/getters.go Näytä tiedosto

@@ -436,6 +436,7 @@ func (client *Client) detailsNoMutex() (result ClientDetails) {
436 436
 	result.username = client.username
437 437
 	result.hostname = client.hostname
438 438
 	result.realname = client.realname
439
+	result.realIP = client.getIPNoMutex()
439 440
 	result.nickMask = client.nickMaskString
440 441
 	result.nickMaskCasefolded = client.nickMaskCasefolded
441 442
 	result.account = client.account

+ 4
- 4
irc/handlers.go Näytä tiedosto

@@ -3416,11 +3416,8 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respo
3416 3416
 			count = 0
3417 3417
 		}
3418 3418
 	}
3419
-	//var target string
3420
-	//if len(msg.Params) > 2 {
3421
-	//	target = msg.Params[2]
3422
-	//}
3423 3419
 	cnick := client.Nick()
3420
+	canSeeIP := client.Oper().HasRoleCapab("ban")
3424 3421
 	for _, nickname := range nicknames {
3425 3422
 		if len(nickname) == 0 {
3426 3423
 			continue
@@ -3431,6 +3428,9 @@ func whowasHandler(server *Server, client *Client, msg ircmsg.Message, rb *Respo
3431 3428
 		} else {
3432 3429
 			for _, whoWas := range results {
3433 3430
 				rb.Add(nil, server.name, RPL_WHOWASUSER, cnick, whoWas.nick, whoWas.username, whoWas.hostname, "*", whoWas.realname)
3431
+				if canSeeIP {
3432
+					rb.Add(nil, server.name, RPL_WHOWASIP, cnick, whoWas.nick, fmt.Sprintf(client.t("was connecting from %s"), utils.IPStringToHostname(whoWas.realIP.String())))
3433
+				}
3434 3434
 			}
3435 3435
 		}
3436 3436
 		rb.Add(nil, server.name, RPL_ENDOFWHOWAS, cnick, utils.SafeErrorParam(nickname), client.t("End of WHOWAS"))

+ 1
- 0
irc/numerics.go Näytä tiedosto

@@ -168,6 +168,7 @@ const (
168 168
 	ERR_USERSDONTMATCH            = "502"
169 169
 	ERR_HELPNOTFOUND              = "524"
170 170
 	ERR_CANNOTSENDRP              = "573"
171
+	RPL_WHOWASIP                  = "652"
171 172
 	RPL_WHOISSECURE               = "671"
172 173
 	RPL_YOURLANGUAGESARE          = "687"
173 174
 	ERR_INVALIDMODEPARAM          = "696"

Loading…
Peruuta
Tallenna