Browse Source

Merge pull request #1340 from slingamn/coerce_ident

replace suppress-ident with coerce-ident; make coerce-ident a recommended default
tags/v2.4.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
f019f62167
No account linked to committer's email address
4 changed files with 29 additions and 14 deletions
  1. 4
    3
      conventional.yaml
  2. 4
    3
      default.yaml
  3. 8
    3
      irc/client.go
  4. 13
    5
      irc/config.go

+ 4
- 3
conventional.yaml View File

@@ -127,9 +127,10 @@ server:
127 127
     # use ident protocol to get usernames
128 128
     check-ident: true
129 129
 
130
-    # ignore the supplied user/ident string from the USER command; always set the value to
131
-    # `~user` (literally) instead. this can potentially reduce confusion and simplify bans.
132
-    suppress-ident: false
130
+    # ignore the supplied user/ident string from the USER command, always setting user/ident
131
+    # to the following literal value; this can potentially reduce confusion and simplify bans.
132
+    # the value must begin with a '~' character. comment out / omit to disable:
133
+    #coerce-ident: '~u'
133 134
 
134 135
     # password to login to the server
135 136
     # generated using  "oragono genpasswd"

+ 4
- 3
default.yaml View File

@@ -154,9 +154,10 @@ server:
154 154
     # use ident protocol to get usernames
155 155
     check-ident: false
156 156
 
157
-    # ignore the supplied user/ident string from the USER command; always set the value to
158
-    # `~user` (literally) instead. this can potentially reduce confusion and simplify bans.
159
-    suppress-ident: false
157
+    # ignore the supplied user/ident string from the USER command, always setting user/ident
158
+    # to the following literal value; this can potentially reduce confusion and simplify bans.
159
+    # the value must begin with a '~' character. comment out / omit to disable:
160
+    coerce-ident: '~u'
160 161
 
161 162
     # password to login to the server
162 163
     # generated using  "oragono genpasswd"

+ 8
- 3
irc/client.go View File

@@ -416,6 +416,11 @@ func (server *Server) AddAlwaysOnClient(account ClientAccount, chnames []string,
416 416
 		cloakedHostname = config.Server.Cloaks.ComputeAccountCloak(account.Name)
417 417
 	}
418 418
 
419
+	username := "~u"
420
+	if config.Server.CoerceIdent != "" {
421
+		username = config.Server.CoerceIdent
422
+	}
423
+
419 424
 	client := &Client{
420 425
 		lastSeen:   lastSeen,
421 426
 		lastActive: now,
@@ -424,7 +429,7 @@ func (server *Server) AddAlwaysOnClient(account ClientAccount, chnames []string,
424 429
 		languages:  server.Languages().Default(),
425 430
 		server:     server,
426 431
 
427
-		username:        "~user",
432
+		username:        username,
428 433
 		cloakedHostname: cloakedHostname,
429 434
 		rawHostname:     rawHostname,
430 435
 		realIP:          utils.IPv4LoopbackAddress,
@@ -1118,8 +1123,8 @@ func (client *Client) SetNames(username, realname string, fromIdent bool) error
1118 1123
 		return errInvalidUsername
1119 1124
 	}
1120 1125
 
1121
-	if config.Server.SuppressIdent {
1122
-		username = "~user"
1126
+	if config.Server.CoerceIdent != "" {
1127
+		username = config.Server.CoerceIdent
1123 1128
 	} else if !fromIdent {
1124 1129
 		username = "~" + username
1125 1130
 	}

+ 13
- 5
irc/config.go View File

@@ -505,9 +505,9 @@ type Config struct {
505 505
 		STS                     STSConfig
506 506
 		LookupHostnames         *bool `yaml:"lookup-hostnames"`
507 507
 		lookupHostnames         bool
508
-		ForwardConfirmHostnames bool `yaml:"forward-confirm-hostnames"`
509
-		CheckIdent              bool `yaml:"check-ident"`
510
-		SuppressIdent           bool `yaml:"suppress-ident"`
508
+		ForwardConfirmHostnames bool   `yaml:"forward-confirm-hostnames"`
509
+		CheckIdent              bool   `yaml:"check-ident"`
510
+		CoerceIdent             string `yaml:"coerce-ident"`
511 511
 		MOTD                    string
512 512
 		motdLines               []string
513 513
 		MOTDFormatting          bool `yaml:"motd-formatting"`
@@ -913,8 +913,16 @@ func LoadConfig(filename string) (config *Config, err error) {
913 913
 		}
914 914
 	}
915 915
 
916
-	if config.Server.CheckIdent && config.Server.SuppressIdent {
917
-		return nil, errors.New("Can't configure both check-ident and suppress-ident")
916
+	if config.Server.CoerceIdent != "" {
917
+		if config.Server.CheckIdent {
918
+			return nil, errors.New("Can't configure both check-ident and coerce-ident")
919
+		}
920
+		if config.Server.CoerceIdent[0] != '~' {
921
+			return nil, errors.New("coerce-ident value must start with a ~")
922
+		}
923
+		if !isIdent(config.Server.CoerceIdent[1:]) {
924
+			return nil, errors.New("coerce-ident must be valid as an IRC user/ident field")
925
+		}
918 926
 	}
919 927
 
920 928
 	config.Server.supportedCaps = caps.NewCompleteSet()

Loading…
Cancel
Save