Allow port to be specified in Address statements.

This allows one to connect to use more than one port number to connect to
another node. The syntax is now:

Address = <hostname> [<port>]
This commit is contained in:
Guus Sliepen 2009-12-23 19:49:38 +01:00
parent 43e34d8180
commit a9a803d566
3 changed files with 17 additions and 6 deletions

View file

@ -331,7 +331,7 @@ void finish_connecting(connection_t *c) {
}
void do_outgoing_connection(connection_t *c) {
char *address, *port;
char *address, *port, *space;
int result;
if(!c->outgoing) {
@ -352,8 +352,14 @@ begin:
get_config_string(c->outgoing->cfg, &address);
if(!get_config_string(lookup_config(c->config_tree, "Port"), &port))
xasprintf(&port, "655");
space = strchr(address, ' ');
if(space) {
port = xstrdup(space + 1);
*space = 0;
} else {
if(!get_config_string(lookup_config(c->config_tree, "Port"), &port))
port = xstrdup("655");
}
c->outgoing->ai = str2addrinfo(address, port, SOCK_STREAM);
free(address);