Sfoglia il codice sorgente

Merge pull request #1317 from slingamn/hidden_userhost

USERHOST needs to respect hidden operators as well
tags/v2.4.0-rc1
Shivaram Lingamneni 3 anni fa
parent
commit
4336f56204
Nessun account collegato all'indirizzo email del committer
3 ha cambiato i file con 20 aggiunte e 10 eliminazioni
  1. 0
    5
      irc/config.go
  2. 15
    2
      irc/handlers.go
  3. 5
    3
      irc/server.go

+ 0
- 5
irc/config.go Vedi File

@@ -728,11 +728,6 @@ type Oper struct {
728 728
 	Modes     []modes.ModeChange
729 729
 }
730 730
 
731
-// returns whether this is a publicly visible operator, for WHO/WHOIS purposes
732
-func (oper *Oper) Visible(hasPrivs bool) bool {
733
-	return oper != nil && (hasPrivs || !oper.Hidden)
734
-}
735
-
736 731
 // Operators returns a map of operator configs from the given OperClass and config.
737 732
 func (conf *Config) Operators(oc map[string]*OperClass) (map[string]*Oper, error) {
738 733
 	operators := make(map[string]*Oper)

+ 15
- 2
irc/handlers.go Vedi File

@@ -2878,8 +2878,21 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
2878 2878
 	return false
2879 2879
 }
2880 2880
 
2881
+// does `target` have an operator status that is visible to `client`?
2882
+func operStatusVisible(client, target *Client, hasPrivs bool) bool {
2883
+	targetOper := target.Oper()
2884
+	if targetOper == nil {
2885
+		return false
2886
+	}
2887
+	if client == target || hasPrivs {
2888
+		return true
2889
+	}
2890
+	return !targetOper.Hidden
2891
+}
2892
+
2881 2893
 // USERHOST <nickname>{ <nickname>}
2882 2894
 func userhostHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
2895
+	hasPrivs := client.HasMode(modes.Operator) // TODO(#1176) figure out the right capab for this
2883 2896
 	returnedClients := make(ClientSet)
2884 2897
 
2885 2898
 	var tl utils.TokenLineBuilder
@@ -2901,7 +2914,7 @@ func userhostHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *
2901 2914
 
2902 2915
 		var isOper, isAway string
2903 2916
 
2904
-		if target.HasMode(modes.Operator) {
2917
+		if operStatusVisible(client, target, hasPrivs) {
2905 2918
 			isOper = "*"
2906 2919
 		}
2907 2920
 		if away, _ := target.Away(); away {
@@ -3061,7 +3074,7 @@ func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *Response
3061 3074
 			flags.WriteRune('H') // Here
3062 3075
 		}
3063 3076
 
3064
-		if target.HasMode(modes.Operator) && target.Oper().Visible(hasPrivs) {
3077
+		if target.HasMode(modes.Operator) && operStatusVisible(client, target, hasPrivs) {
3065 3078
 			flags.WriteRune('*')
3066 3079
 		}
3067 3080
 

+ 5
- 3
irc/server.go Vedi File

@@ -439,9 +439,11 @@ func (client *Client) getWhoisOf(target *Client, hasPrivs bool, rb *ResponseBuff
439 439
 	if whoischannels != nil {
440 440
 		rb.Add(nil, client.server.name, RPL_WHOISCHANNELS, cnick, tnick, strings.Join(whoischannels, " "))
441 441
 	}
442
-	tOper := target.Oper()
443
-	if tOper.Visible(hasPrivs) {
444
-		rb.Add(nil, client.server.name, RPL_WHOISOPERATOR, cnick, tnick, tOper.WhoisLine)
442
+	if target.HasMode(modes.Operator) && operStatusVisible(client, target, hasPrivs) {
443
+		tOper := target.Oper()
444
+		if tOper != nil {
445
+			rb.Add(nil, client.server.name, RPL_WHOISOPERATOR, cnick, tnick, tOper.WhoisLine)
446
+		}
445 447
 	}
446 448
 	if client == target || hasPrivs {
447 449
 		rb.Add(nil, client.server.name, RPL_WHOISACTUALLY, cnick, tnick, fmt.Sprintf("%s@%s", targetInfo.username, target.RawHostname()), target.IPString(), client.t("Actual user@host, Actual IP"))

Loading…
Annulla
Salva