Skip to content

Commit 153d9f7

Browse files
committed
Merge pull request #10 from ziontab/master
Connection methods LocalAddr and RemoteAddr
2 parents b0b36c9 + ea1aef3 commit 153d9f7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

connection.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@ func (conn *Connection) Close() (err error) {
7575
return
7676
}
7777

78+
func (conn *Connection) RemoteAddr() string {
79+
conn.mutex.Lock()
80+
defer conn.mutex.Unlock()
81+
if conn.c == nil {
82+
return ""
83+
}
84+
return conn.c.RemoteAddr().String()
85+
}
86+
87+
func (conn *Connection) LocalAddr() string {
88+
conn.mutex.Lock()
89+
defer conn.mutex.Unlock()
90+
if conn.c == nil {
91+
return ""
92+
}
93+
return conn.c.LocalAddr().String()
94+
}
95+
7896
func (conn *Connection) dial() (err error) {
7997
connection, err := net.Dial("tcp", conn.addr)
8098
if err != nil {

0 commit comments

Comments
 (0)