aboutsummaryrefslogtreecommitdiff
path: root/src/transport/zerotier
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-03-04 17:04:11 -0800
committerGarrett D'Amore <garrett@damore.org>2018-03-04 19:42:17 -0800
commit23a38d766780f4749945d84316b4e0a71e707b15 (patch)
tree336cf1bfc7c7e32999653a4c4014232d2b735a3e /src/transport/zerotier
parent0094f83a9e3b54d6cbfc1ea1885036366b87b991 (diff)
downloadnng-23a38d766780f4749945d84316b4e0a71e707b15.tar.gz
nng-23a38d766780f4749945d84316b4e0a71e707b15.tar.bz2
nng-23a38d766780f4749945d84316b4e0a71e707b15.zip
fixes #262 NNG_OPT_URL should be resolved
This causes TCP, TLS, and ZT endpoints to resolve any wildcards, and even IP addresses, when reporting the listen URL. The dialer URL is reported unresolved. Test cases for this are added as well, and nngcat actually reports this if --verbose is supplied.
Diffstat (limited to 'src/transport/zerotier')
-rw-r--r--src/transport/zerotier/zerotier.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/transport/zerotier/zerotier.c b/src/transport/zerotier/zerotier.c
index f8ed4626..4a846301 100644
--- a/src/transport/zerotier/zerotier.c
+++ b/src/transport/zerotier/zerotier.c
@@ -230,7 +230,6 @@ struct zt_ep {
uint64_t ze_nwid;
int ze_mode;
int ze_running;
- nni_sockaddr ze_addr;
uint64_t ze_raddr; // remote node address
uint64_t ze_laddr; // local node address
uint16_t ze_proto;
@@ -2557,6 +2556,21 @@ zt_ep_getopt_home(void *arg, void *data, size_t *szp)
}
static int
+zt_ep_getopt_url(void *arg, void *data, size_t *szp)
+{
+ char ustr[64]; // more than plenty
+ zt_ep * ep = arg;
+ uint64_t addr;
+
+ addr = ep->ze_mode == NNI_EP_MODE_DIAL ? ep->ze_raddr : ep->ze_laddr;
+ snprintf(ustr, sizeof(ustr), "zt://%llx.%llx:%u",
+ (unsigned long long) addr >> zt_port_shift,
+ (unsigned long long) ep->ze_nwid,
+ (unsigned) (addr & zt_port_mask));
+ return (nni_getopt_str(ustr, data, szp));
+}
+
+static int
zt_ep_setopt_orbit(void *arg, const void *data, size_t sz)
{
uint64_t moonid;
@@ -2725,6 +2739,11 @@ static nni_tran_ep_option zt_ep_options[] = {
.eo_setopt = zt_ep_setopt_recvmaxsz,
},
{
+ .eo_name = NNG_OPT_URL,
+ .eo_getopt = zt_ep_getopt_url,
+ .eo_setopt = NULL,
+ },
+ {
.eo_name = NNG_OPT_ZT_HOME,
.eo_getopt = zt_ep_getopt_home,
.eo_setopt = zt_ep_setopt_home,