diff options
| -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 # |
