int sock_connect(char *host, char *service)
{
struct in6_addr serveraddr;
- struct addrinfo hints, *res = NULL;
- int rc;
+ struct addrinfo hints;
+ struct addrinfo *res = NULL;
+ struct addrinfo *ai = NULL;
+ int rc = (-1);
int sock = (-1);
if ((host == NULL) || IsEmptyStr(host))
/*
* Try all available addresses until we connect to one or until we run out.
*/
- struct addrinfo *ai;
for (ai = res; ai != NULL; ai = ai->ai_next) {
- /* FIXME display the address to which we are trying to connect */
-
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (sock < 0) {
CtdlLogPrintf(CTDL_ERR, "socket() failed: %s\n", strerror(errno));
return(-1);
}
-
rc = connect(sock, res->ai_addr, res->ai_addrlen);
if (rc >= 0) {
return(sock);
}
if (CitControl.version < 623) {
- strcpy(config.c_ip_addr, "0.0.0.0");
+ strcpy(config.c_ip_addr, "*");
}
if (CitControl.version < 650) {
"Automatically delete committed database logs",
atoi(&sc[43][0]))));
- strprompt("Server IP address (0.0.0.0 for 'any')", &sc[37][0], 15);
+ strprompt("Server IP address (* for 'any')", &sc[37][0], 15);
strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
strprompt("POP3S server port (-1 to disable)", &sc[40][0], 5);
strprompt("IMAP server port (-1 to disable)", &sc[27][0], 5);
static int tcp_connectsock(char *host, char *service)
{
struct in6_addr serveraddr;
- struct addrinfo hints, *res = NULL;
- int rc;
+ struct addrinfo hints;
+ struct addrinfo *res = NULL;
+ struct addrinfo *ai = NULL;
+ int rc = (-1);
int sock = (-1);
if ((host == NULL) || IsEmptyStr(host)) {
if (rc == 1) { /* dotted quad */
hints.ai_family = AF_INET;
hints.ai_flags |= AI_NUMERICHOST;
- } else {
+ }
+ else {
rc = inet_pton(AF_INET6, host, &serveraddr);
if (rc == 1) { /* IPv6 address */
hints.ai_family = AF_INET6;
rc = getaddrinfo(host, service, &hints, &res);
if (rc != 0) {
- // CtdlLogPrintf(CTDL_ERR, "%s: %s\n", host, gai_strerror(rc));
return(-1);
}
/*
* Try all available addresses until we connect to one or until we run out.
*/
- struct addrinfo *ai;
for (ai = res; ai != NULL; ai = ai->ai_next) {
- /* FIXME display the address to which we are trying to connect */
-fprintf(stderr, "TRYING...\n");
-
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (sock < 0) return(-1);
rc = connect(sock, ai->ai_addr, ai->ai_addrlen);
if (rc >= 0) {
-fprintf(stderr, "CONNECTED\n");
- return(sock);
+ return(sock); /* Connected! */
}
else {
-fprintf(stderr, "FAILED: %s\n", strerror(errno));
- // CtdlLogPrintf(CTDL_ERR, "connect() failed: %s\n", strerror(errno));
- close(sock);
+ close(sock); /* Failed. Close the socket to avoid fd leak! */
}
}
"user ID here. You may specify either a user name or a numeric\n"
"UID.\n",
-"Specify the IP address on which your server will run. If you\n"
-"leave this blank, or if you specify 0.0.0.0, Citadel will listen\n"
-"on all addresses. You can usually skip this unless you are\n"
+"Specify the IP address on which your server will run.\n"
+"You can name a specific IPv4 or IPv6 address, or you can specify\n"
+"'*' for 'any address', '::' for 'any IPv6 address', or '0.0.0.0'\n"
+"for 'any IPv4 address'. If you leave this blank, Citadel will\n"
+"listen on all addresses. You can usually skip this unless you are\n"
"running multiple instances of Citadel on the same computer.\n",
"Specify the TCP port number on which your server will run.\n"
"of Citadel on the same computer and there is something else\n"
"already using port 504.\n",
-
-
"Specify which authentication mode you wish to use.\n"
"\n"
" 0. Self contained authentication\n"