3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-01-03 16:42:38 +01:00

Merge pull request #1340 from slingamn/coerce_ident

replace suppress-ident with coerce-ident; make coerce-ident a recommended default
This commit is contained in:
Shivaram Lingamneni 2020-10-20 15:31:13 -07:00 committed by GitHub
commit f019f62167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 14 deletions

View File

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

View File

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

View File

@ -416,6 +416,11 @@ func (server *Server) AddAlwaysOnClient(account ClientAccount, chnames []string,
cloakedHostname = config.Server.Cloaks.ComputeAccountCloak(account.Name) cloakedHostname = config.Server.Cloaks.ComputeAccountCloak(account.Name)
} }
username := "~u"
if config.Server.CoerceIdent != "" {
username = config.Server.CoerceIdent
}
client := &Client{ client := &Client{
lastSeen: lastSeen, lastSeen: lastSeen,
lastActive: now, lastActive: now,
@ -424,7 +429,7 @@ func (server *Server) AddAlwaysOnClient(account ClientAccount, chnames []string,
languages: server.Languages().Default(), languages: server.Languages().Default(),
server: server, server: server,
username: "~user", username: username,
cloakedHostname: cloakedHostname, cloakedHostname: cloakedHostname,
rawHostname: rawHostname, rawHostname: rawHostname,
realIP: utils.IPv4LoopbackAddress, realIP: utils.IPv4LoopbackAddress,
@ -1118,8 +1123,8 @@ func (client *Client) SetNames(username, realname string, fromIdent bool) error
return errInvalidUsername return errInvalidUsername
} }
if config.Server.SuppressIdent { if config.Server.CoerceIdent != "" {
username = "~user" username = config.Server.CoerceIdent
} else if !fromIdent { } else if !fromIdent {
username = "~" + username username = "~" + username
} }

View File

@ -505,9 +505,9 @@ type Config struct {
STS STSConfig STS STSConfig
LookupHostnames *bool `yaml:"lookup-hostnames"` LookupHostnames *bool `yaml:"lookup-hostnames"`
lookupHostnames bool lookupHostnames bool
ForwardConfirmHostnames bool `yaml:"forward-confirm-hostnames"` ForwardConfirmHostnames bool `yaml:"forward-confirm-hostnames"`
CheckIdent bool `yaml:"check-ident"` CheckIdent bool `yaml:"check-ident"`
SuppressIdent bool `yaml:"suppress-ident"` CoerceIdent string `yaml:"coerce-ident"`
MOTD string MOTD string
motdLines []string motdLines []string
MOTDFormatting bool `yaml:"motd-formatting"` MOTDFormatting bool `yaml:"motd-formatting"`
@ -913,8 +913,16 @@ func LoadConfig(filename string) (config *Config, err error) {
} }
} }
if config.Server.CheckIdent && config.Server.SuppressIdent { if config.Server.CoerceIdent != "" {
return nil, errors.New("Can't configure both check-ident and suppress-ident") if config.Server.CheckIdent {
return nil, errors.New("Can't configure both check-ident and coerce-ident")
}
if config.Server.CoerceIdent[0] != '~' {
return nil, errors.New("coerce-ident value must start with a ~")
}
if !isIdent(config.Server.CoerceIdent[1:]) {
return nil, errors.New("coerce-ident must be valid as an IRC user/ident field")
}
} }
config.Server.supportedCaps = caps.NewCompleteSet() config.Server.supportedCaps = caps.NewCompleteSet()