mirror of
https://github.com/jeremyd/ergo.git
synced 2026-07-28 09:48:13 -07:00
many changes
- load config sub files relative to config file dir - load config file by name - expect bcrypt for passwords - -genpasswd for generating config-file-safe passwords - block client thread while checking passwords (PASS and OPER)
This commit is contained in:
+6
-35
@@ -34,21 +34,17 @@ func NewServer(config *Config) *Server {
|
||||
server := &Server{
|
||||
channels: make(ChannelNameMap),
|
||||
clients: make(ClientNameMap),
|
||||
commands: make(chan Command),
|
||||
commands: make(chan Command, 16),
|
||||
ctime: time.Now(),
|
||||
idle: make(chan *Client),
|
||||
idle: make(chan *Client, 16),
|
||||
motdFile: config.MOTD,
|
||||
name: config.Name,
|
||||
newConns: make(chan net.Conn),
|
||||
operators: make(map[string][]byte),
|
||||
newConns: make(chan net.Conn, 16),
|
||||
operators: config.OperatorsMap(),
|
||||
password: config.PasswordBytes(),
|
||||
timeout: make(chan *Client),
|
||||
}
|
||||
|
||||
for _, opConf := range config.Operators {
|
||||
server.operators[opConf.Name] = opConf.PasswordBytes()
|
||||
}
|
||||
|
||||
for _, listenerConf := range config.Listeners {
|
||||
go server.listen(listenerConf)
|
||||
}
|
||||
@@ -266,18 +262,7 @@ func (msg *CapCommand) HandleAuthServer(server *Server) {
|
||||
|
||||
func (msg *PassCommand) HandleAuthServer(server *Server) {
|
||||
client := msg.Client()
|
||||
cmd := &CheckPassCommand{
|
||||
hash: server.password,
|
||||
password: []byte(msg.password),
|
||||
}
|
||||
go func() {
|
||||
client.checkPass <- cmd
|
||||
}()
|
||||
}
|
||||
|
||||
func (msg *CheckedPassCommand) HandleAuthServer(server *Server) {
|
||||
client := msg.Client()
|
||||
if !msg.isRight {
|
||||
if msg.err != nil {
|
||||
client.ErrPasswdMismatch()
|
||||
client.Quit("bad password")
|
||||
return
|
||||
@@ -603,21 +588,7 @@ func (msg *WhoCommand) HandleServer(server *Server) {
|
||||
func (msg *OperCommand) HandleServer(server *Server) {
|
||||
client := msg.Client()
|
||||
|
||||
cmd := &CheckOperCommand{}
|
||||
cmd.hash = server.operators[msg.name]
|
||||
if cmd.hash == nil {
|
||||
client.ErrPasswdMismatch()
|
||||
return
|
||||
}
|
||||
cmd.password = []byte(msg.password)
|
||||
go func() {
|
||||
client.checkPass <- cmd
|
||||
}()
|
||||
}
|
||||
|
||||
func (msg *CheckedOperCommand) HandleServer(server *Server) {
|
||||
client := msg.Client()
|
||||
if !msg.isRight {
|
||||
if (msg.hash == nil) || (msg.err != nil) {
|
||||
client.ErrPasswdMismatch()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user