Add upstreamConn.register

This commit is contained in:
Simon Ser 2020-02-07 12:37:44 +01:00
parent 96653499dc
commit e17c0b3aca
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 7 additions and 3 deletions

View File

@ -106,6 +106,8 @@ func (s *Server) Run() {
return return
} }
conn.register()
u.lock.Lock() u.lock.Lock()
u.upstreamConns = append(u.upstreamConns, conn) u.upstreamConns = append(u.upstreamConns, conn)
u.lock.Unlock() u.lock.Unlock()

View File

@ -317,9 +317,7 @@ func (c *upstreamConn) handleMessage(msg *irc.Message) error {
return nil return nil
} }
func (c *upstreamConn) readMessages() error { func (c *upstreamConn) register() {
defer c.Close()
c.nick = c.upstream.Nick c.nick = c.upstream.Nick
c.messages <- &irc.Message{ c.messages <- &irc.Message{
Command: "NICK", Command: "NICK",
@ -329,6 +327,10 @@ func (c *upstreamConn) readMessages() error {
Command: "USER", Command: "USER",
Params: []string{c.upstream.Username, "0", "*", c.upstream.Realname}, Params: []string{c.upstream.Username, "0", "*", c.upstream.Realname},
} }
}
func (c *upstreamConn) readMessages() error {
defer c.Close()
for { for {
msg, err := c.irc.ReadMessage() msg, err := c.irc.ReadMessage()