Add identd

This commit is contained in:
Ken-Håvard Lieng 2020-06-16 11:26:07 +02:00
parent 67fe5d263d
commit e0d2243248
9 changed files with 140 additions and 6 deletions

View file

@ -195,6 +195,19 @@ func (c *Client) Host() string {
return c.Config.Host
}
func (c *Client) LocalPort() string {
c.lock.Lock()
defer c.lock.Unlock()
if c.conn != nil {
_, local, err := net.SplitHostPort(c.conn.LocalAddr().String())
if err == nil {
return local
}
}
return ""
}
func (c *Client) MOTD() []string {
return c.state.getMOTD()
}

View file

@ -22,7 +22,6 @@ type Dialer interface {
}
func (c *Client) Connect() {
c.connChange(false, nil)
go c.run()
}
@ -147,7 +146,7 @@ func (c *Client) connect() error {
c.scan = bufio.NewScanner(c.conn)
c.scan.Buffer(c.recvBuf, cap(c.recvBuf))
c.register()
go c.register()
c.sendRecv.Add(1)
go c.recv()
@ -185,7 +184,7 @@ func (c *Client) recv() {
return
default:
c.connChange(false, nil)
c.connChange(false, c.scan.Err())
close(c.reconnect)
return
}
@ -198,8 +197,8 @@ func (c *Client) recv() {
msg := ParseMessage(string(b))
if msg == nil {
close(c.quit)
c.connChange(false, ErrBadProtocol)
close(c.quit)
return
}