aboutsummaryrefslogtreecommitdiff
path: root/network.go
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2019-06-29 16:35:32 -0400
committerDeterminant <ted.sybil@gmail.com>2019-06-29 16:35:32 -0400
commitbbd7fad4b9fc657780fa35dcdc979e72200eb053 (patch)
tree5c7b21a079258fbce618dfb03943414510b22a7e /network.go
parent63ec65887ed90427c54b9b056a347600bd612744 (diff)
fix the cgo bug
Diffstat (limited to 'network.go')
-rw-r--r--network.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/network.go b/network.go
index 71e0ffa..e97821b 100644
--- a/network.go
+++ b/network.go
@@ -33,7 +33,6 @@ func MsgNetworkConnFromC(ptr CMsgNetworkConn) MsgNetworkConn {
var (
CONN_MODE_ACTIVE = MsgNetworkConnMode(C.CONN_MODE_ACTIVE)
CONN_MODE_PASSIVE = MsgNetworkConnMode(C.CONN_MODE_PASSIVE)
- CONN_MODE_DEAD = MsgNetworkConnMode(C.CONN_MODE_DEAD)
)
// The connection mode. CONN_MODE_ACTIVE: a connection established from the
@@ -386,6 +385,13 @@ func (self PeerNetworkConn) Copy() PeerNetworkConn {
return res
}
+// Get the listening address of the remote peer (no Copy() is needed).
+func (self PeerNetworkConn) GetPeerAddr() NetAddr {
+ res := NetAddrFromC(C.peernetwork_conn_get_peer_addr(self.inner))
+ runtime.SetFinalizer(res, func(self NetAddr) { self.free() })
+ return res
+}
+
func (self PeerNetworkConn) free() { C.peernetwork_conn_free(self.inner) }
// Listen to the specified network address. Notice that this method overrides