implement review feedback

1. If both fingerprint and hash are specified, require both instead of either
2. Implement auto-oper on connect
This commit is contained in:
Shivaram Lingamneni 2019-12-19 06:33:43 -05:00
parent 6033d9f569
commit b717402b5e
6 changed files with 78 additions and 23 deletions

View file

@ -212,6 +212,7 @@ type OperConfig struct {
WhoisLine string `yaml:"whois-line"`
Password string
Fingerprint string
Auto bool
Modes string
}
@ -461,6 +462,7 @@ type Oper struct {
Vhost string
Pass []byte
Fingerprint string
Auto bool
Modes []modes.ModeChange
}
@ -477,11 +479,18 @@ func (conf *Config) Operators(oc map[string]*OperClass) (map[string]*Oper, error
}
oper.Name = name
oper.Pass, err = decodeLegacyPasswordHash(opConf.Password)
if err != nil {
return nil, err
if opConf.Password != "" {
oper.Pass, err = decodeLegacyPasswordHash(opConf.Password)
if err != nil {
return nil, err
}
}
oper.Fingerprint = opConf.Fingerprint
oper.Auto = opConf.Auto
if oper.Pass == nil && oper.Fingerprint == "" {
return nil, fmt.Errorf("Oper %s has neither a password nor a fingerprint", name)
}
oper.Vhost = opConf.Vhost
class, exists := oc[opConf.Class]