diff options
| author | Anton <anton@picapica> | 2017-12-28 22:23:32 +0400 |
|---|---|---|
| committer | Anton <anton@picapica> | 2017-12-28 22:23:32 +0400 |
| commit | caae4bb3a47fddf97b6b28e5e6eea3420c8b255c (patch) | |
| tree | ae676c67c1df955c521b275c2e484344e1ad4449 | |
| parent | eca4cbf9f76e8e1951d59b812966a074b7b46ca9 (diff) | |
| download | pica-pica-caae4bb3a47fddf97b6b28e5e6eea3420c8b255c.tar.gz pica-pica-caae4bb3a47fddf97b6b28e5e6eea3420c8b255c.zip | |
autoconfigure mode for announced_addr setting, updated default config file; UPNP autoconfiguration is implemented, enumerating network interfaces having global IP is left to be done
| -rw-r--r-- | PICA_node.c | 17 | ||||
| -rw-r--r-- | pica-node.conf | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/PICA_node.c b/PICA_node.c index 48a97b9..a373cb4 100644 --- a/PICA_node.c +++ b/PICA_node.c @@ -3009,6 +3009,23 @@ int main(int argc, char** argv) if (!PICA_node_init()) return -1; + if (strcmp("autoconfigure", nodecfg.announced_addr) == 0) + { + //TOD check interfaces with global IP's assigned first +#ifdef HAVE_LIBMINIUPNPC + char public_ip[64]; + int ret; + + ret = PICA_upnp_autoconfigure_ipv4(atoi(nodecfg.listen_port), atoi(nodecfg.listen_port), public_ip); + if (ret) + { + free(nodecfg.announced_addr); + nodecfg.announced_addr = strdup(public_ip); + PICA_info("autoconfigured announced address %s port %s", nodecfg.announced_addr, nodecfg.listen_port); + } +#endif + } + if (INADDR_NONE == inet_addr(nodecfg.announced_addr) || INADDR_ANY == inet_addr(nodecfg.announced_addr)) { PICA_fatal("announced_addr (%.16s) is invalid or not configured. Please set correct public IP address of your pica-node instance in config file.", diff --git a/pica-node.conf b/pica-node.conf index 55e847d..fc44085 100644 --- a/pica-node.conf +++ b/pica-node.conf @@ -9,9 +9,11 @@ #Address that can be used to reach this instance of pica-node from Internet. #pica-node sends this address to all other nodes. #Set this parameter to your public Internet address (IPv4). IPv6 and DNS format support will be -#added in future releases +#added in future releases. +#Default value is "autoconfigure", pica-node will try to guess suitable public address or use UPNP protocol # #announced_addr = "11.22.33.44"; +#announced_addr = "autoconfigure"; #TCP port for incoming connections that pica-node listens on. Default is 2299 # |
