Perform DNS lookup of client addresses
This commit is contained in:
parent
398bedcca4
commit
0b56bd0ba4
2
README
2
README
@ -11,7 +11,7 @@ It does not aim to replace full featured mass scalable IRC networks:
|
|||||||
* It can not connect to other servers. Just standalone installation
|
* It can not connect to other servers. Just standalone installation
|
||||||
* It has few basic IRC commands
|
* It has few basic IRC commands
|
||||||
* There is no support for channel operators, modes, votes, invites
|
* There is no support for channel operators, modes, votes, invites
|
||||||
* No ident lookups, reverse DNS queries
|
* No ident lookups
|
||||||
|
|
||||||
But it has some convincing features:
|
But it has some convincing features:
|
||||||
|
|
||||||
|
13
client.go
13
client.go
@ -52,8 +52,19 @@ type Client struct {
|
|||||||
sync.Mutex
|
sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Client) Host() string {
|
||||||
|
addr := c.conn.RemoteAddr().String()
|
||||||
|
if host, _, err := net.SplitHostPort(addr); err == nil {
|
||||||
|
addr = host
|
||||||
|
}
|
||||||
|
if domains, err := net.LookupAddr(addr); err == nil {
|
||||||
|
addr = strings.TrimSuffix(domains[0], ".")
|
||||||
|
}
|
||||||
|
return addr
|
||||||
|
}
|
||||||
|
|
||||||
func (c Client) String() string {
|
func (c Client) String() string {
|
||||||
return *c.nickname + "!" + *c.username + "@" + c.conn.RemoteAddr().String()
|
return *c.nickname + "!" + *c.username + "@" + c.Host()
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(conn *proxyproto.Conn) *Client {
|
func NewClient(conn *proxyproto.Conn) *Client {
|
||||||
|
Loading…
Reference in New Issue
Block a user