Loglevel cleanups.
This commit is contained in:
parent
199c62bca8
commit
faaeb703fd
@ -785,7 +785,7 @@ void ircize(list_t *ll)
|
|||||||
|
|
||||||
link = hash_get(adm_conn, c->name);
|
link = hash_get(adm_conn, c->name);
|
||||||
if (!link) {
|
if (!link) {
|
||||||
mylog(LOG_DEBUG, "new connection: \"%s\"",
|
mylog(LOG_DEBUGVERB, "new connection: \"%s\"",
|
||||||
c->name);
|
c->name);
|
||||||
link = irc_link_new();
|
link = irc_link_new();
|
||||||
hash_insert(adm_conn, c->name, link);
|
hash_insert(adm_conn, c->name, link);
|
||||||
@ -808,7 +808,7 @@ void ircize(list_t *ll)
|
|||||||
}
|
}
|
||||||
list_add_last(ll, link);
|
list_add_last(ll, link);
|
||||||
} else {
|
} else {
|
||||||
mylog(LOG_DEBUG, "old connection: \"%s\"",
|
mylog(LOG_DEBUGVERB, "old connection: \"%s\"",
|
||||||
c->name);
|
c->name);
|
||||||
#define MAYFREE(a) do { \
|
#define MAYFREE(a) do { \
|
||||||
if (a) { \
|
if (a) { \
|
||||||
|
101
src/connection.c
101
src/connection.c
@ -50,7 +50,8 @@ static void connecting_data_free(struct connecting_data *t)
|
|||||||
|
|
||||||
void connection_close(connection_t *cn)
|
void connection_close(connection_t *cn)
|
||||||
{
|
{
|
||||||
mylog(LOG_DEBUG, "Connection close asked. FD:%d ", (long)cn->handle);
|
mylog(LOG_DEBUGVERB, "Connection close asked. FD:%d ",
|
||||||
|
(long)cn->handle);
|
||||||
if (cn->connected != CONN_DISCONN) {
|
if (cn->connected != CONN_DISCONN) {
|
||||||
cn->connected = CONN_DISCONN;
|
cn->connected = CONN_DISCONN;
|
||||||
shutdown(cn->handle, SHUT_RDWR);
|
shutdown(cn->handle, SHUT_RDWR);
|
||||||
@ -105,7 +106,7 @@ static void connect_trynext(connection_t *cn)
|
|||||||
{
|
{
|
||||||
struct addrinfo *cur;
|
struct addrinfo *cur;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!cn->connecting_data)
|
if (!cn->connecting_data)
|
||||||
fatal("called connect_trynext with a connection not "
|
fatal("called connect_trynext with a connection not "
|
||||||
"connecting\n");
|
"connecting\n");
|
||||||
@ -170,7 +171,7 @@ static X509 *mySSL_get_cert(SSL *ssl)
|
|||||||
X509 *cert;
|
X509 *cert;
|
||||||
|
|
||||||
if (!ssl) {
|
if (!ssl) {
|
||||||
mylog(LOG_WARN, "mySSL_get_cert() No SSL context");
|
mylog(LOG_DEBUGVERB, "mySSL_get_cert() No SSL context");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cert = SSL_get_peer_certificate(ssl);
|
cert = SSL_get_peer_certificate(ssl);
|
||||||
@ -189,7 +190,8 @@ static int _write_socket_SSL(connection_t *cn, char* message)
|
|||||||
if (!cn->client && cn->cert == NULL) {
|
if (!cn->client && cn->cert == NULL) {
|
||||||
cn->cert = mySSL_get_cert(cn->ssl_h);
|
cn->cert = mySSL_get_cert(cn->ssl_h);
|
||||||
if (cn->cert == NULL) {
|
if (cn->cert == NULL) {
|
||||||
mylog(LOG_ERROR, "No certificate in SSL write_socket");
|
mylog(LOG_DEBUGVERB,
|
||||||
|
"No certificate in SSL write_socket");
|
||||||
return WRITE_ERROR;
|
return WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,7 +204,8 @@ static int _write_socket_SSL(connection_t *cn, char* message)
|
|||||||
|| err == SSL_ERROR_WANT_ACCEPT)
|
|| err == SSL_ERROR_WANT_ACCEPT)
|
||||||
return WRITE_KEEP;
|
return WRITE_KEEP;
|
||||||
if (cn_is_connected(cn)) {
|
if (cn_is_connected(cn)) {
|
||||||
mylog(LOG_DEBUG, "fd %d: Connection error", cn->handle);
|
mylog(LOG_DEBUGVERB, "fd %d: Connection error",
|
||||||
|
cn->handle);
|
||||||
cn->connected = CONN_ERROR;
|
cn->connected = CONN_ERROR;
|
||||||
}
|
}
|
||||||
return WRITE_ERROR;
|
return WRITE_ERROR;
|
||||||
@ -424,7 +427,7 @@ static int read_socket_SSL(connection_t *cn)
|
|||||||
static int read_socket(connection_t *cn)
|
static int read_socket(connection_t *cn)
|
||||||
{
|
{
|
||||||
int max, count;
|
int max, count;
|
||||||
|
|
||||||
if (cn == NULL)
|
if (cn == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
max = CONN_BUFFER_SIZE - cn->incoming_end;
|
max = CONN_BUFFER_SIZE - cn->incoming_end;
|
||||||
@ -434,7 +437,7 @@ static int read_socket(connection_t *cn)
|
|||||||
if (errno == EAGAIN || errno == EINTR || errno == EINPROGRESS)
|
if (errno == EAGAIN || errno == EINTR || errno == EINPROGRESS)
|
||||||
return 0;
|
return 0;
|
||||||
if (cn_is_connected(cn)) {
|
if (cn_is_connected(cn)) {
|
||||||
mylog(LOG_DEBUG, "fd %d: Connection error",
|
mylog(LOG_DEBUGVERB, "fd %d: Connection error",
|
||||||
cn->handle);
|
cn->handle);
|
||||||
mylog(LOG_DEBUGTOOMUCH, "fd %d: read() %s", cn->handle,
|
mylog(LOG_DEBUGTOOMUCH, "fd %d: read() %s", cn->handle,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
@ -443,7 +446,8 @@ static int read_socket(connection_t *cn)
|
|||||||
return 1;
|
return 1;
|
||||||
} else if (count == 0) {
|
} else if (count == 0) {
|
||||||
if (cn_is_connected(cn)) {
|
if (cn_is_connected(cn)) {
|
||||||
mylog(LOG_DEBUG, "fd %d: Connection lost", cn->handle);
|
mylog(LOG_DEBUGVERB, "fd %d: Connection lost",
|
||||||
|
cn->handle);
|
||||||
cn->connected = CONN_DISCONN;
|
cn->connected = CONN_DISCONN;
|
||||||
mylog(LOG_DEBUGTOOMUCH, "fd %d: read() %s", cn->handle,
|
mylog(LOG_DEBUGTOOMUCH, "fd %d: read() %s", cn->handle,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
@ -546,10 +550,10 @@ static int check_event_except(fd_set *fds, connection_t *cn)
|
|||||||
cn->handle, cn->connected);
|
cn->handle, cn->connected);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FD_ISSET(cn->handle, fds))
|
if (!FD_ISSET(cn->handle, fds))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
mylog(LOG_DEBUGTOOMUCH,"fd %d is in exceptions list", cn->handle);
|
mylog(LOG_DEBUGTOOMUCH,"fd %d is in exceptions list", cn->handle);
|
||||||
cn->connected = CONN_EXCEPT;
|
cn->connected = CONN_EXCEPT;
|
||||||
return 1;
|
return 1;
|
||||||
@ -581,7 +585,7 @@ static int check_event_read(fd_set *fds, connection_t *cn)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
ret = read_socket(cn);
|
ret = read_socket(cn);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
mylog(LOG_DEBUGVERB, "Error while reading on fd %d",
|
mylog(LOG_DEBUGVERB, "Error while reading on fd %d",
|
||||||
cn->handle);
|
cn->handle);
|
||||||
@ -628,7 +632,7 @@ static int check_event_write(fd_set *fds, connection_t *cn, int *nc)
|
|||||||
(void *)&err, &errSize);
|
(void *)&err, &errSize);
|
||||||
|
|
||||||
if (err2 < 0) {
|
if (err2 < 0) {
|
||||||
mylog(LOG_WARN, "fd:%d getsockopt error: %s",
|
mylog(LOG_DEBUGVERB, "fd:%d getsockopt error: %s",
|
||||||
cn->handle, strerror(errno));
|
cn->handle, strerror(errno));
|
||||||
if (cn->connecting_data)
|
if (cn->connecting_data)
|
||||||
connect_trynext(cn);
|
connect_trynext(cn);
|
||||||
@ -798,7 +802,7 @@ list_t *wait_event(list_t *cn_list, int *msec, int *nc)
|
|||||||
tv.tv_sec = *msec / 1000;
|
tv.tv_sec = *msec / 1000;
|
||||||
tv.tv_usec = (*msec % 1000) * 1000;
|
tv.tv_usec = (*msec % 1000) * 1000;
|
||||||
gettimeofday(&btv, NULL);
|
gettimeofday(&btv, NULL);
|
||||||
mylog(LOG_DEBUGVERB,"msec: %d, sec: %d, usec: %d", *msec, tv.tv_sec,
|
mylog(LOG_DEBUGVERB, "msec: %d, sec: %d, usec: %d", *msec, tv.tv_sec,
|
||||||
tv.tv_usec);
|
tv.tv_usec);
|
||||||
err = select(maxfd + 1, &fds_read, &fds_write, &fds_except, &tv);
|
err = select(maxfd + 1, &fds_read, &fds_write, &fds_except, &tv);
|
||||||
gettimeofday(&etv, NULL);
|
gettimeofday(&etv, NULL);
|
||||||
@ -811,7 +815,7 @@ list_t *wait_event(list_t *cn_list, int *msec, int *nc)
|
|||||||
/* in case we go forward in time */
|
/* in case we go forward in time */
|
||||||
if (*msec < 0)
|
if (*msec < 0)
|
||||||
*msec = 0;
|
*msec = 0;
|
||||||
mylog(LOG_DEBUGVERB,"msec: %d, sec: %d, usec: %d", *msec, tv.tv_sec,
|
mylog(LOG_DEBUGVERB, "msec: %d, sec: %d, usec: %d", *msec, tv.tv_sec,
|
||||||
tv.tv_usec);
|
tv.tv_usec);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
@ -828,7 +832,7 @@ list_t *wait_event(list_t *cn_list, int *msec, int *nc)
|
|||||||
int toadd = 0;
|
int toadd = 0;
|
||||||
|
|
||||||
if (check_event_except(&fds_except, cn)) {
|
if (check_event_except(&fds_except, cn)) {
|
||||||
mylog(LOG_DEBUGVERB,"Notify on FD %d (state %d)",
|
mylog(LOG_DEBUGVERB, "Notify on FD %d (state %d)",
|
||||||
cn->handle, cn->connected);
|
cn->handle, cn->connected);
|
||||||
list_add_first(cn_newdata, cn);
|
list_add_first(cn_newdata, cn);
|
||||||
continue;
|
continue;
|
||||||
@ -865,15 +869,13 @@ static void create_socket(char *dsthostname, char *dstport, char *srchostname,
|
|||||||
cn->connected = CONN_ERROR;
|
cn->connected = CONN_ERROR;
|
||||||
cdata = (struct connecting_data *)
|
cdata = (struct connecting_data *)
|
||||||
malloc(sizeof(struct connecting_data));
|
malloc(sizeof(struct connecting_data));
|
||||||
if (!cdata) {
|
if (!cdata)
|
||||||
mylog(LOG_ERROR, "malloc() : %s", strerror(errno));
|
fatal("Out of memory.")
|
||||||
return;
|
|
||||||
}
|
|
||||||
cdata->dst = cdata->src = cdata->cur = NULL;
|
cdata->dst = cdata->src = cdata->cur = NULL;
|
||||||
|
|
||||||
err = getaddrinfo(dsthostname, dstport, &hint, &cdata->dst);
|
err = getaddrinfo(dsthostname, dstport, &hint, &cdata->dst);
|
||||||
if (err) {
|
if (err) {
|
||||||
mylog(LOG_ERROR, "getaddrinfo(dst): %s", gai_strerror(err));
|
mylog(LOG_DEBUG, "getaddrinfo(dst): %s", gai_strerror(err));
|
||||||
connecting_data_free(cdata);
|
connecting_data_free(cdata);
|
||||||
cdata = NULL;
|
cdata = NULL;
|
||||||
return;
|
return;
|
||||||
@ -883,7 +885,7 @@ static void create_socket(char *dsthostname, char *dstport, char *srchostname,
|
|||||||
if ((err = getaddrinfo(srchostname, srcport, &hint,
|
if ((err = getaddrinfo(srchostname, srcport, &hint,
|
||||||
&cdata->src))) {
|
&cdata->src))) {
|
||||||
/* not fatal ? maybe a config option is needed */
|
/* not fatal ? maybe a config option is needed */
|
||||||
mylog(LOG_WARN, "getaddrinfo(src): %s",
|
mylog(LOG_DEBUG, "getaddrinfo(src): %s",
|
||||||
gai_strerror(err));
|
gai_strerror(err));
|
||||||
cdata->src = NULL;
|
cdata->src = NULL;
|
||||||
}
|
}
|
||||||
@ -913,22 +915,22 @@ static void create_listening_socket(char *hostname, char *port,
|
|||||||
.ai_canonname = 0,
|
.ai_canonname = 0,
|
||||||
.ai_next = 0
|
.ai_next = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
cn->connected = CONN_ERROR;
|
cn->connected = CONN_ERROR;
|
||||||
|
|
||||||
err = getaddrinfo(hostname, port, &hint, &res);
|
err = getaddrinfo(hostname, port, &hint, &res);
|
||||||
if (err) {
|
if (err) {
|
||||||
mylog(LOG_ERROR, "getaddrinfo(): %s", gai_strerror(err));
|
mylog(LOG_DEBUG, "getaddrinfo(): %s", gai_strerror(err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (cur = res ; cur ; cur = cur->ai_next) {
|
for (cur = res ; cur ; cur = cur->ai_next) {
|
||||||
if ((cn->handle = socket(cur->ai_family, cur->ai_socktype,
|
if ((cn->handle = socket(cur->ai_family, cur->ai_socktype,
|
||||||
cur->ai_protocol)) < 0) {
|
cur->ai_protocol)) < 0) {
|
||||||
mylog(LOG_WARN, "socket : %s", strerror(errno));
|
mylog(LOG_WARN, "socket : %s", strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setsockopt(cn->handle, SOL_SOCKET, SO_REUSEADDR,
|
if (setsockopt(cn->handle, SOL_SOCKET, SO_REUSEADDR,
|
||||||
(char *)&multi_client,
|
(char *)&multi_client,
|
||||||
sizeof(multi_client)) < 0) {
|
sizeof(multi_client)) < 0) {
|
||||||
@ -937,9 +939,9 @@ static void create_listening_socket(char *hostname, char *port,
|
|||||||
cn->handle = -1;
|
cn->handle = -1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
socket_set_nonblock(cn->handle);
|
socket_set_nonblock(cn->handle);
|
||||||
|
|
||||||
if (bind(cn->handle, cur->ai_addr, cur->ai_addrlen) < 0) {
|
if (bind(cn->handle, cur->ai_addr, cur->ai_addrlen) < 0) {
|
||||||
mylog(LOG_WARN, "bind() : %s", strerror(errno));
|
mylog(LOG_WARN, "bind() : %s", strerror(errno));
|
||||||
close(cn->handle);
|
close(cn->handle);
|
||||||
@ -954,7 +956,7 @@ static void create_listening_socket(char *hostname, char *port,
|
|||||||
cn->handle = -1;
|
cn->handle = -1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
cn->connected = CONN_OK;
|
cn->connected = CONN_OK;
|
||||||
return;
|
return;
|
||||||
@ -1015,7 +1017,7 @@ connection_t *accept_new(connection_t *cn)
|
|||||||
if (err < 0)
|
if (err < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
socket_set_nonblock(err);
|
socket_set_nonblock(err);
|
||||||
|
|
||||||
conn = connection_init(cn->anti_flood, cn->ssl, cn->timeout, 0);
|
conn = connection_init(cn->anti_flood, cn->ssl, cn->timeout, 0);
|
||||||
conn->connect_time = time(NULL);
|
conn->connect_time = time(NULL);
|
||||||
conn->user_data = cn->user_data;
|
conn->user_data = cn->user_data;
|
||||||
@ -1096,7 +1098,7 @@ static SSL_CTX *SSL_init_context(void)
|
|||||||
flags |= O_NONBLOCK;
|
flags |= O_NONBLOCK;
|
||||||
fd = open("/dev/random", flags);
|
fd = open("/dev/random", flags);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
mylog(LOG_DEBUG, "SSL: /dev/random not ready, unable "
|
mylog(LOG_WARN, "SSL: /dev/random not ready, unable "
|
||||||
"to manually seed PRNG.");
|
"to manually seed PRNG.");
|
||||||
goto prng_end;
|
goto prng_end;
|
||||||
}
|
}
|
||||||
@ -1127,16 +1129,15 @@ prng_end:
|
|||||||
|
|
||||||
ssl_initialized = 1;
|
ssl_initialized = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocated by function */
|
/* allocated by function */
|
||||||
ctx = SSL_CTX_new(SSLv23_method());
|
ctx = SSL_CTX_new(SSLv23_method());
|
||||||
if (!SSL_CTX_use_certificate_chain_file(ctx,conf_ssl_certfile)) {
|
if (!SSL_CTX_use_certificate_chain_file(ctx,conf_ssl_certfile))
|
||||||
mylog(LOG_DEBUG, "SSL: Unable to load certificate file");
|
mylog(LOG_DEBUG, "SSL: Unable to load certificate file");
|
||||||
}
|
|
||||||
if (!SSL_CTX_use_PrivateKey_file(ctx, conf_ssl_certfile,
|
if (!SSL_CTX_use_PrivateKey_file(ctx, conf_ssl_certfile,
|
||||||
SSL_FILETYPE_PEM)) {
|
SSL_FILETYPE_PEM))
|
||||||
mylog(LOG_DEBUG, "SSL: Unable to load key file");
|
mylog(LOG_DEBUG, "SSL: Unable to load key file");
|
||||||
}
|
|
||||||
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_BOTH);
|
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_BOTH);
|
||||||
SSL_CTX_set_timeout(ctx,(long)60);
|
SSL_CTX_set_timeout(ctx,(long)60);
|
||||||
SSL_CTX_set_options(ctx, SSL_OP_ALL);
|
SSL_CTX_set_options(ctx, SSL_OP_ALL);
|
||||||
@ -1171,7 +1172,7 @@ static int bip_ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
|
|||||||
mylog(LOG_INFO, "Issuer: %s", issuer);
|
mylog(LOG_INFO, "Issuer: %s", issuer);
|
||||||
|
|
||||||
result = preverify_ok;
|
result = preverify_ok;
|
||||||
|
|
||||||
/* in basic mode (mode 1), accept a leaf certificate if we can find it
|
/* in basic mode (mode 1), accept a leaf certificate if we can find it
|
||||||
* in the store */
|
* in the store */
|
||||||
if (c->ssl_check_mode == SSL_CHECK_BASIC && depth == 0 && result == 0 &&
|
if (c->ssl_check_mode == SSL_CHECK_BASIC && depth == 0 && result == 0 &&
|
||||||
@ -1179,14 +1180,14 @@ static int bip_ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
|
|||||||
err == X509_V_ERR_CERT_UNTRUSTED ||
|
err == X509_V_ERR_CERT_UNTRUSTED ||
|
||||||
err == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE ||
|
err == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE ||
|
||||||
err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT)) {
|
err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT)) {
|
||||||
|
|
||||||
if (X509_STORE_get_by_subject(ctx, X509_LU_X509,
|
if (X509_STORE_get_by_subject(ctx, X509_LU_X509,
|
||||||
X509_get_subject_name(err_cert), &xobj) > 0 &&
|
X509_get_subject_name(err_cert), &xobj) > 0 &&
|
||||||
!X509_cmp(xobj.data.x509, err_cert)) {
|
!X509_cmp(xobj.data.x509, err_cert)) {
|
||||||
|
|
||||||
mylog(LOG_INFO, "Basic mode; peer certificate found "
|
mylog(LOG_INFO, "Basic mode; peer certificate found "
|
||||||
"in store, accepting it!");
|
"in store, accepting it!");
|
||||||
|
|
||||||
result = 1;
|
result = 1;
|
||||||
err = X509_V_OK;
|
err = X509_V_OK;
|
||||||
X509_STORE_CTX_set_error(ctx, err);
|
X509_STORE_CTX_set_error(ctx, err);
|
||||||
@ -1195,11 +1196,11 @@ static int bip_ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
|
|||||||
"in store, rejecting it!");
|
"in store, rejecting it!");
|
||||||
err = X509_V_ERR_CERT_REJECTED;
|
err = X509_V_ERR_CERT_REJECTED;
|
||||||
X509_STORE_CTX_set_error(ctx, err);
|
X509_STORE_CTX_set_error(ctx, err);
|
||||||
|
|
||||||
link_add_untrusted(c->user_data, X509_dup(err_cert));
|
link_add_untrusted(c->user_data, X509_dup(err_cert));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
/* We have a verify error! Log it */
|
/* We have a verify error! Log it */
|
||||||
mylog(LOG_ERROR, "SSL cert check failed at depth=%d: %s (%d)",
|
mylog(LOG_ERROR, "SSL cert check failed at depth=%d: %s (%d)",
|
||||||
@ -1212,7 +1213,7 @@ static int bip_ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
|
|||||||
static int SSLize(connection_t *cn, int *nc)
|
static int SSLize(connection_t *cn, int *nc)
|
||||||
{
|
{
|
||||||
int err, err2;
|
int err, err2;
|
||||||
|
|
||||||
if (cn == NULL)
|
if (cn == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -1226,7 +1227,7 @@ static int SSLize(connection_t *cn, int *nc)
|
|||||||
cn->connected = CONN_ERROR;
|
cn->connected = CONN_ERROR;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cn->client)
|
if (cn->client)
|
||||||
err = SSL_accept(cn->ssl_h);
|
err = SSL_accept(cn->ssl_h);
|
||||||
else
|
else
|
||||||
@ -1338,7 +1339,7 @@ static connection_t *_connection_new_SSL(char *dsthostname, char *dstport,
|
|||||||
default:
|
default:
|
||||||
fatal("Unknown SSL cert check mode.");
|
fatal("Unknown SSL cert check mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->ssl_h = SSL_new(conn->ssl_ctx_h);
|
conn->ssl_h = SSL_new(conn->ssl_ctx_h);
|
||||||
if (conn->ssl_h == NULL) {
|
if (conn->ssl_h == NULL) {
|
||||||
mylog(LOG_DEBUG, "Unable to allocate SSL structures");
|
mylog(LOG_DEBUG, "Unable to allocate SSL structures");
|
||||||
@ -1391,7 +1392,7 @@ connection_t *connection_new(char *dsthostname, int dstport, char *srchostname,
|
|||||||
tmp, timeout);
|
tmp, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cn_is_listening(connection_t *cn)
|
int cn_is_listening(connection_t *cn)
|
||||||
{
|
{
|
||||||
if (cn == NULL)
|
if (cn == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1463,17 +1464,17 @@ int main(int argc,char* argv[])
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int connection_localport(connection_t *cn)
|
int connection_localport(connection_t *cn)
|
||||||
{
|
{
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
int err;
|
int err;
|
||||||
socklen_t addrlen;
|
socklen_t addrlen;
|
||||||
|
|
||||||
if (cn->handle <= 0)
|
if (cn->handle <= 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
addrlen = sizeof(addr);
|
addrlen = sizeof(addr);
|
||||||
err = getsockname(cn->handle, (struct sockaddr *)&addr, &addrlen);
|
err = getsockname(cn->handle, (struct sockaddr *)&addr, &addrlen);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
@ -1566,7 +1567,7 @@ static char *socket_ip(int fd, int remote)
|
|||||||
break;
|
break;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
addrlen6 = sizeof(addr6);
|
addrlen6 = sizeof(addr6);
|
||||||
|
|
||||||
if (remote) {
|
if (remote) {
|
||||||
err = getpeername(fd, (struct sockaddr *)&addr6,
|
err = getpeername(fd, (struct sockaddr *)&addr6,
|
||||||
&addrlen6);
|
&addrlen6);
|
||||||
|
25
src/irc.c
25
src/irc.c
@ -298,7 +298,7 @@ static int irc_315(struct link_server *server, struct line *l)
|
|||||||
link->who_client->whoc_tstamp = time(NULL);
|
link->who_client->whoc_tstamp = time(NULL);
|
||||||
if (link->who_client->who_count > 0) {
|
if (link->who_client->who_count > 0) {
|
||||||
--link->who_client->who_count;
|
--link->who_client->who_count;
|
||||||
mylog(LOG_INFO,
|
mylog(LOG_DEBUG,
|
||||||
"RPL_ENDOFWHO: "
|
"RPL_ENDOFWHO: "
|
||||||
"Decrementing who count for %p: %d",
|
"Decrementing who count for %p: %d",
|
||||||
link->who_client, link->who_client->who_count);
|
link->who_client, link->who_client->who_count);
|
||||||
@ -312,7 +312,7 @@ static int irc_315(struct link_server *server, struct line *l)
|
|||||||
void rotate_who_client(struct link *link)
|
void rotate_who_client(struct link *link)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
mylog(LOG_INFO, "rotate_who_client %p", link->who_client);
|
mylog(LOG_DEBUG, "rotate_who_client %p", link->who_client);
|
||||||
/* find a client with non-null who_count */
|
/* find a client with non-null who_count */
|
||||||
link->who_client = NULL;
|
link->who_client = NULL;
|
||||||
for (i = 0; i < link->l_clientc; i++) {
|
for (i = 0; i < link->l_clientc; i++) {
|
||||||
@ -469,7 +469,7 @@ int irc_dispatch_server(struct link_server *server, struct line *line)
|
|||||||
}
|
}
|
||||||
if (LINK(server)->who_client &&
|
if (LINK(server)->who_client &&
|
||||||
LINK(server)->who_client->who_count == 0) {
|
LINK(server)->who_client->who_count == 0) {
|
||||||
mylog(LOG_INFO, "OK_COPY_WHO: who_count for %p is nul",
|
mylog(LOG_DEBUG, "OK_COPY_WHO: who_count for %p is nul",
|
||||||
LINK(server)->who_client);
|
LINK(server)->who_client);
|
||||||
rotate_who_client(LINK(server));
|
rotate_who_client(LINK(server));
|
||||||
}
|
}
|
||||||
@ -556,11 +556,11 @@ void unbind_from_link(struct link_client *ic)
|
|||||||
fatal("unbind_from_link");
|
fatal("unbind_from_link");
|
||||||
|
|
||||||
if (l->who_client == ic) {
|
if (l->who_client == ic) {
|
||||||
mylog(LOG_INFO, "unbind_from_link: %p: %d",
|
mylog(LOG_DEBUG, "unbind_from_link: %p: %d",
|
||||||
l->who_client, ic->who_count);
|
l->who_client, ic->who_count);
|
||||||
l->who_client = NULL;
|
l->who_client = NULL;
|
||||||
} else {
|
} else {
|
||||||
mylog(LOG_INFO,
|
mylog(LOG_DEBUG,
|
||||||
"unbind_from_link: nothing to do %p != %p: %d",
|
"unbind_from_link: nothing to do %p != %p: %d",
|
||||||
ic, l->who_client,
|
ic, l->who_client,
|
||||||
ic->who_count);
|
ic->who_count);
|
||||||
@ -855,7 +855,7 @@ static int irc_cli_who(struct link_client *ic, struct line *line)
|
|||||||
++ic->who_count;
|
++ic->who_count;
|
||||||
if (ic->who_count == 1)
|
if (ic->who_count == 1)
|
||||||
ic->whoc_tstamp = time(NULL);
|
ic->whoc_tstamp = time(NULL);
|
||||||
mylog(LOG_INFO, "cli_who: Incrementing who count for %p: %d",
|
mylog(LOG_DEBUG, "cli_who: Incrementing who count for %p: %d",
|
||||||
ic, ic->who_count);
|
ic, ic->who_count);
|
||||||
|
|
||||||
if (l->who_client && l->who_client != ic) {
|
if (l->who_client && l->who_client != ic) {
|
||||||
@ -884,7 +884,7 @@ static int irc_cli_mode(struct link_client *ic, struct line *line)
|
|||||||
++ic->who_count;
|
++ic->who_count;
|
||||||
if (ic->who_count == 1)
|
if (ic->who_count == 1)
|
||||||
ic->whoc_tstamp = time(NULL);
|
ic->whoc_tstamp = time(NULL);
|
||||||
mylog(LOG_INFO, "cli_mode: Incrementing who count for %p: %d",
|
mylog(LOG_DEBUG, "cli_mode: Incrementing who count for %p: %d",
|
||||||
l->who_client, ic->who_count);
|
l->who_client, ic->who_count);
|
||||||
|
|
||||||
if (l->who_client && l->who_client != ic) {
|
if (l->who_client && l->who_client != ic) {
|
||||||
@ -1372,7 +1372,7 @@ static int irc_368(struct link_server *server, struct line *l)
|
|||||||
|
|
||||||
if (link->who_client->who_count > 0) {
|
if (link->who_client->who_count > 0) {
|
||||||
--link->who_client->who_count;
|
--link->who_client->who_count;
|
||||||
mylog(LOG_INFO,
|
mylog(LOG_DEBUG,
|
||||||
"RPL_ENDOFBANLIST: "
|
"RPL_ENDOFBANLIST: "
|
||||||
"Decrementing who count for %p: %d",
|
"Decrementing who count for %p: %d",
|
||||||
link->who_client, link->who_client->who_count);
|
link->who_client, link->who_client->who_count);
|
||||||
@ -2033,11 +2033,8 @@ void oidentd_dump(list_t *connl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
filename = (char *)malloc(strlen(home) + strlen("/.oidentd.conf"));
|
filename = (char *)malloc(strlen(home) + strlen("/.oidentd.conf"));
|
||||||
|
if(filename == NULL)
|
||||||
if(filename == NULL){
|
fatal("Out of memory.");
|
||||||
mylog(LOG_WARN, "oidentd_dump : malloc failed, returning");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(filename, "%s/.oidentd.conf", home);
|
sprintf(filename, "%s/.oidentd.conf", home);
|
||||||
|
|
||||||
@ -2084,7 +2081,7 @@ void oidentd_dump(list_t *connl)
|
|||||||
* completely */
|
* completely */
|
||||||
fseek(f, SEEK_SET, 0);
|
fseek(f, SEEK_SET, 0);
|
||||||
if (ftruncate(fileno(f), 0) == -1) {
|
if (ftruncate(fileno(f), 0) == -1) {
|
||||||
mylog(LOG_WARN, "Can't reset %s size",
|
mylog(LOG_DEBUG, "Can't reset %s size",
|
||||||
filename);
|
filename);
|
||||||
goto clean_oidentd;
|
goto clean_oidentd;
|
||||||
}
|
}
|
||||||
|
11
src/log.c
11
src/log.c
@ -716,7 +716,7 @@ char *log_beautify(char *buf, char *dest)
|
|||||||
int done;
|
int done;
|
||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
mylog(LOG_DEBUG, "BUG!");
|
fatal("BUG log_beautify not called correctly!");
|
||||||
|
|
||||||
p = strchr(buf, ' ');
|
p = strchr(buf, ' ');
|
||||||
if (!p || !p[0] || !p[1])
|
if (!p || !p[0] || !p[1])
|
||||||
@ -908,12 +908,12 @@ next_file:
|
|||||||
/* check the files containing data to backlog */
|
/* check the files containing data to backlog */
|
||||||
lf = list_it_item(&logdata->file_it);
|
lf = list_it_item(&logdata->file_it);
|
||||||
if (lf != list_get_last(&lfg->file_group)) {
|
if (lf != list_get_last(&lfg->file_group)) {
|
||||||
mylog(LOG_DEBUG, "%s not last file!", lf->filename);
|
mylog(LOG_DEBUGVERB, "%s not last file!", lf->filename);
|
||||||
/* if the file is not the current open for logging
|
/* if the file is not the current open for logging
|
||||||
* (it is an old file that has been rotated)
|
* (it is an old file that has been rotated)
|
||||||
* open if necessary, backlog line per line, and close */
|
* open if necessary, backlog line per line, and close */
|
||||||
if (!lf->file) {
|
if (!lf->file) {
|
||||||
mylog(LOG_DEBUG, "opening: %s!", lf->filename);
|
mylog(LOG_DEBUGVERB, "opening: %s!", lf->filename);
|
||||||
lf->file = fopen(lf->filename, "r");
|
lf->file = fopen(lf->filename, "r");
|
||||||
if (!lf->file) {
|
if (!lf->file) {
|
||||||
mylog(LOG_ERROR, "Can't open %s for reading",
|
mylog(LOG_ERROR, "Can't open %s for reading",
|
||||||
@ -923,7 +923,8 @@ next_file:
|
|||||||
return _log_wrap("Error reading logfile",
|
return _log_wrap("Error reading logfile",
|
||||||
destination);
|
destination);
|
||||||
}
|
}
|
||||||
mylog(LOG_DEBUG, "seeking: %d!", lf->backlog_offset);
|
mylog(LOG_DEBUGVERB, "seeking: %d!",
|
||||||
|
lf->backlog_offset);
|
||||||
if (fseek(lf->file, lf->backlog_offset, SEEK_SET)) {
|
if (fseek(lf->file, lf->backlog_offset, SEEK_SET)) {
|
||||||
log_reinit(lfg);
|
log_reinit(lfg);
|
||||||
free(buf);
|
free(buf);
|
||||||
@ -942,7 +943,7 @@ next_file:
|
|||||||
if (pos == LOGLINE_MAXLEN)
|
if (pos == LOGLINE_MAXLEN)
|
||||||
mylog(LOG_DEBUG, "logline too long");
|
mylog(LOG_DEBUG, "logline too long");
|
||||||
if (c == EOF || pos == LOGLINE_MAXLEN) {
|
if (c == EOF || pos == LOGLINE_MAXLEN) {
|
||||||
mylog(LOG_DEBUG, "EOF: %s (%d)!",
|
mylog(LOG_DEBUGVERB, "EOF: %s (%d)!",
|
||||||
lf->filename,
|
lf->filename,
|
||||||
conf_always_backlog);
|
conf_always_backlog);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user