diff --git a/server.go b/server.go index 4aac62e..c57102a 100644 --- a/server.go +++ b/server.go @@ -106,6 +106,8 @@ func (s *Server) Run() { return } + conn.register() + u.lock.Lock() u.upstreamConns = append(u.upstreamConns, conn) u.lock.Unlock() diff --git a/upstream.go b/upstream.go index 42f9554..e3bd487 100644 --- a/upstream.go +++ b/upstream.go @@ -317,9 +317,7 @@ func (c *upstreamConn) handleMessage(msg *irc.Message) error { return nil } -func (c *upstreamConn) readMessages() error { - defer c.Close() - +func (c *upstreamConn) register() { c.nick = c.upstream.Nick c.messages <- &irc.Message{ Command: "NICK", @@ -329,6 +327,10 @@ func (c *upstreamConn) readMessages() error { Command: "USER", Params: []string{c.upstream.Username, "0", "*", c.upstream.Realname}, } +} + +func (c *upstreamConn) readMessages() error { + defer c.Close() for { msg, err := c.irc.ReadMessage()