瀏覽代碼

Merge pull request #1317 from slingamn/hidden_userhost

USERHOST needs to respect hidden operators as well
tags/v2.4.0-rc1
Shivaram Lingamneni 3 年之前
父節點
當前提交
4336f56204
No account linked to committer's email address
共有 3 個文件被更改,包括 20 次插入10 次删除
  1. 0
    5
      irc/config.go
  2. 15
    2
      irc/handlers.go
  3. 5
    3
      irc/server.go

+ 0
- 5
irc/config.go 查看文件

728
 	Modes     []modes.ModeChange
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
 // Operators returns a map of operator configs from the given OperClass and config.
731
 // Operators returns a map of operator configs from the given OperClass and config.
737
 func (conf *Config) Operators(oc map[string]*OperClass) (map[string]*Oper, error) {
732
 func (conf *Config) Operators(oc map[string]*OperClass) (map[string]*Oper, error) {
738
 	operators := make(map[string]*Oper)
733
 	operators := make(map[string]*Oper)

+ 15
- 2
irc/handlers.go 查看文件

2878
 	return false
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
 // USERHOST <nickname>{ <nickname>}
2893
 // USERHOST <nickname>{ <nickname>}
2882
 func userhostHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
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
 	returnedClients := make(ClientSet)
2896
 	returnedClients := make(ClientSet)
2884
 
2897
 
2885
 	var tl utils.TokenLineBuilder
2898
 	var tl utils.TokenLineBuilder
2901
 
2914
 
2902
 		var isOper, isAway string
2915
 		var isOper, isAway string
2903
 
2916
 
2904
-		if target.HasMode(modes.Operator) {
2917
+		if operStatusVisible(client, target, hasPrivs) {
2905
 			isOper = "*"
2918
 			isOper = "*"
2906
 		}
2919
 		}
2907
 		if away, _ := target.Away(); away {
2920
 		if away, _ := target.Away(); away {
3061
 			flags.WriteRune('H') // Here
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
 			flags.WriteRune('*')
3078
 			flags.WriteRune('*')
3066
 		}
3079
 		}
3067
 
3080
 

+ 5
- 3
irc/server.go 查看文件

439
 	if whoischannels != nil {
439
 	if whoischannels != nil {
440
 		rb.Add(nil, client.server.name, RPL_WHOISCHANNELS, cnick, tnick, strings.Join(whoischannels, " "))
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
 	if client == target || hasPrivs {
448
 	if client == target || hasPrivs {
447
 		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"))
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…
取消
儲存