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
}
conn.register()
u.lock.Lock()
u.upstreamConns = append(u.upstreamConns, conn)
u.lock.Unlock()

View File

@ -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()