42 |
error("imapfilter: create socket; %s\n", strerror(errno)); |
error("imapfilter: create socket; %s\n", strerror(errno)); |
43 |
return ERROR_NETWORK; |
return ERROR_NETWORK; |
44 |
} |
} |
45 |
|
|
46 |
if (!(he = gethostbyname(serv))) { |
if (!(he = gethostbyname(serv))) { |
47 |
error("imapfilter: get network host entry; %s\n", strerror(errno)); |
error("imapfilter: get network host entry; %s\n", strerror(errno)); |
48 |
close_connection(); |
close_connection(); |
52 |
sa.sin_port = htons(port); |
sa.sin_port = htons(port); |
53 |
sa.sin_addr = *(struct in_addr *) he->h_addr; |
sa.sin_addr = *(struct in_addr *) he->h_addr; |
54 |
|
|
55 |
|
xstrncpy(serv, he->h_name, SERVER_LEN - 1); |
56 |
|
|
57 |
if (connect(sock, (struct sockaddr *) & sa, sizeof(struct sockaddr))) { |
if (connect(sock, (struct sockaddr *) & sa, sizeof(struct sockaddr))) { |
58 |
error("imapfilter: initiating connection; %s\n", strerror(errno)); |
error("imapfilter: initiating connection to %s; %s\n", serv, strerror(errno)); |
59 |
close_connection(); |
close_connection(); |
60 |
return ERROR_NETWORK; |
return ERROR_NETWORK; |
61 |
} |
} |
|
xstrncpy(serv, he->h_name, SERVER_LEN - 1); |
|
62 |
|
|
63 |
log_info(LOG_SERVER, serv); |
log_info(LOG_SERVER, serv); |
64 |
|
|
65 |
#ifdef SSL_TLS |
#ifdef SSL_TLS |
66 |
if (protocol != SSL_DISABLED) { |
if (protocol != SSL_DISABLED && !ssl_init(protocol)) { |
67 |
if (!ssl_init(protocol)) { |
info("Connected to %s using %s.\n", serv, SSL_get_cipher(ssl)); |
68 |
info("Connected to %s using %s.\n", serv, SSL_get_cipher(ssl)); |
return 0; |
|
return 0; |
|
|
} |
|
69 |
} else |
} else |
70 |
ssl = NULL; |
ssl = NULL; |
71 |
#endif |
#endif |