Add Server.getUser
This commit is contained in:
parent
3b2bb58c60
commit
3586ca3d26
@ -167,11 +167,8 @@ func (c *downstreamConn) handleMessageUnregistered(msg *irc.Message) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *downstreamConn) register() error {
|
func (c *downstreamConn) register() error {
|
||||||
c.srv.lock.Lock()
|
u := c.srv.getUser(c.username)
|
||||||
u, ok := c.srv.users[c.username]
|
if u == nil {
|
||||||
c.srv.lock.Unlock()
|
|
||||||
|
|
||||||
if !ok {
|
|
||||||
c.messages <- &irc.Message{
|
c.messages <- &irc.Message{
|
||||||
Prefix: c.srv.prefix(),
|
Prefix: c.srv.prefix(),
|
||||||
Command: irc.ERR_PASSWDMISMATCH,
|
Command: irc.ERR_PASSWDMISMATCH,
|
||||||
|
@ -106,6 +106,13 @@ func (s *Server) Run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) getUser(name string) *user {
|
||||||
|
s.lock.Lock()
|
||||||
|
u := s.users[name]
|
||||||
|
s.lock.Unlock()
|
||||||
|
return u
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) Serve(ln net.Listener) error {
|
func (s *Server) Serve(ln net.Listener) error {
|
||||||
for {
|
for {
|
||||||
netConn, err := ln.Accept()
|
netConn, err := ln.Accept()
|
||||||
|
Loading…
Reference in New Issue
Block a user