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

@ -1354,3 +1354,18 @@ func (client *Client) CheckInvited(casefoldedChannel string) (invited bool) {
delete(client.invitedTo, casefoldedChannel)
return
}
// Implements auto-oper by certfp (scans for an auto-eligible operator block that matches
// the client's cert, then applies it).
func (client *Client) attemptAutoOper(session *Session) {
if client.certfp == "" || client.HasMode(modes.Operator) {
return
}
for _, oper := range client.server.Config().operators {
if oper.Auto && oper.Pass == nil && utils.CertfpsMatch(oper.Fingerprint, client.certfp) {
rb := NewResponseBuffer(session)
applyOper(client, oper, rb)
rb.Send(true)
}
}
}