Add Server.getUser

git-svn-id: file:///srv/svn/repo/suika/trunk@38 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This commit is contained in:
contact 2020-02-07 10:39:56 +00:00
parent 08c05383eb
commit 7afd236470
2 changed files with 9 additions and 5 deletions

View File

@ -167,11 +167,8 @@ func (c *downstreamConn) handleMessageUnregistered(msg *irc.Message) error {
}
func (c *downstreamConn) register() error {
c.srv.lock.Lock()
u, ok := c.srv.users[c.username]
c.srv.lock.Unlock()
if !ok {
u := c.srv.getUser(c.username)
if u == nil {
c.messages <- &irc.Message{
Prefix: c.srv.prefix(),
Command: irc.ERR_PASSWDMISMATCH,

View File

@ -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 {
for {
netConn, err := ln.Accept()