X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmod-sockcheck.c;h=ab68da07cd558aed9f41112bd544617eee4cd928;hb=HEAD;hp=d5888da4b81e1633cf2d39743aa63789a802b301;hpb=7fe401a165cdfb1f102cf3d545e1dffb3896a2e9;p=srvx.git diff --git a/src/mod-sockcheck.c b/src/mod-sockcheck.c index d5888da..ab68da0 100644 --- a/src/mod-sockcheck.c +++ b/src/mod-sockcheck.c @@ -53,7 +53,7 @@ enum sockcheck_decision { typedef struct { irc_in_addr_t addr; const char *reason; - time_t last_touched; + unsigned long last_touched; enum sockcheck_decision decision; char hostname[IRC_NTOP_MAX_SIZE]; /* acts as key for checked_ip_dict */ } *sockcheck_cache_info; @@ -206,7 +206,7 @@ sockcheck_issue_gline(sockcheck_cache_info sci) char addr[IRC_NTOP_MAX_SIZE + 2] = {'*', '@', '\0'}; irc_ntop(addr + 2, sizeof(addr) - 2, &sci->addr); log_module(PC_LOG, LOG_INFO, "Issuing gline for client at %s: %s", addr + 2, sci->reason); - gline_add("ProxyCheck", addr, sockcheck_conf.gline_duration, sci->reason, now, now, 1); + gline_add("ProxyCheck", addr, sockcheck_conf.gline_duration, sci->reason, now, now, 0, 1); } static struct sockcheck_client * @@ -227,7 +227,7 @@ static void sockcheck_free_client(struct sockcheck_client *client) { if (SOCKCHECK_DEBUG) { - log_module(PC_LOG, LOG_INFO, "Goodbye %s (%p)! I set you free!", client->addr->hostname, client); + log_module(PC_LOG, LOG_INFO, "Goodbye %s (%p)! I set you free!", client->addr->hostname, (void*)client); } verify(client); ioset_close(client->fd, 1); @@ -257,17 +257,18 @@ static void sockcheck_print_client(const struct sockcheck_client *client) { static const char *decs[] = {"CHECKING", "ACCEPT", "REJECT"}; - log_module(PC_LOG, LOG_INFO, "client %p: { addr = %p { decision = %s; last_touched = "FMT_TIME_T"; reason = %s; hostname = \"%s\" }; " + log_module(PC_LOG, LOG_INFO, "client %p: { addr = %p { decision = %s; last_touched = %lu; reason = %s; hostname = \"%s\" }; " "test_index = %d; state = %p { port = %d; type = %s; template = \"%s\"; ... }; " "fd = %p(%d); read = %p; read_size = %d; read_used = %d; read_pos = %d; }", - client, client->addr, decs[client->addr->decision], client->addr->last_touched, + (void*)client, (void*)client->addr, decs[client->addr->decision], + client->addr->last_touched, client->addr->reason, client->addr->hostname, - client->test_index, client->state, + client->test_index, (void*)client->state, (client->state ? client->state->port : 0), (client->state ? decs[client->state->type] : "N/A"), (client->state ? client->state->template : "N/A"), - client->fd, (client->fd ? client->fd->fd : 0), - client->read, client->read_size, client->read_used, client->read_pos); + (void*)client->fd, (client->fd ? client->fd->fd : 0), + (void*)client->read, client->read_size, client->read_used, client->read_pos); } static char hexvals[256] = { @@ -406,7 +407,7 @@ sockcheck_elaborate_state(struct sockcheck_client *client) /* If it doesn't require reading, take it now. */ if (client->resp_state[nn] && !*client->resp_state[nn]) { if (SOCKCHECK_DEBUG) { - log_module(PC_LOG, LOG_INFO, "Skipping straight to easy option %d for %p.", nn, client); + log_module(PC_LOG, LOG_INFO, "Skipping straight to easy option %d for %p.", nn, (void*)client); } sockcheck_advance(client, nn); return; @@ -509,7 +510,7 @@ sockcheck_advance(struct sockcheck_client *client, unsigned int next_state) } break; default: - log_module(PC_LOG, LOG_ERROR, "BUG: unknown next-state type %d (after %p).", ns->type, client->state); + log_module(PC_LOG, LOG_ERROR, "BUG: unknown next-state type %d (after %p).", ns->type, (void*)client->state); break; } } @@ -671,7 +672,7 @@ sockcheck_begin_test(struct sockcheck_client *client) io_fd->readable_cb = sockcheck_readable; timeq_add(now + client->state->timeout, sockcheck_timeout_client, client); if (SOCKCHECK_DEBUG) { - log_module(PC_LOG, LOG_INFO, "Starting proxy check on %s:%d (test %d) with fd %d (%p).", client->addr->hostname, client->state->port, client->test_index, io_fd->fd, io_fd); + log_module(PC_LOG, LOG_INFO, "Starting proxy check on %s:%d (test %d) with fd %d (%p).", client->addr->hostname, client->state->port, client->test_index, io_fd->fd, (void*)io_fd); } return; } while (client->test_index < client->tests->used); @@ -695,7 +696,7 @@ sockcheck_start_client(unsigned int idx) sockcheck_num_clients++; if (!tests) return; client = client_list[idx] = sockcheck_alloc_client(sci); - log_module(PC_LOG, LOG_INFO, "Proxy-checking client at %s as client %d (%p) of %d.", sci->hostname, idx, client, sockcheck_num_clients); + log_module(PC_LOG, LOG_INFO, "Proxy-checking client at %s as client %d (%p) of %d.", sci->hostname, idx, (void*)client, sockcheck_num_clients); client->test_rep = 0; client->client_index = idx; sockcheck_begin_test(client); @@ -715,10 +716,12 @@ sockcheck_queue_address(irc_in_addr_t addr) /* We are already checking this host. */ return; case ACCEPT: - if ((sci->last_touched + sockcheck_conf.max_cache_age) >= (unsigned)now) return; + if (sci->last_touched + sockcheck_conf.max_cache_age >= now) { + return; + } break; case REJECT: - if ((sci->last_touched + sockcheck_conf.gline_duration) >= (unsigned)now) { + if (sci->last_touched + sockcheck_conf.gline_duration >= now) { sockcheck_issue_gline(sci); return; } @@ -970,7 +973,7 @@ sockcheck_clean_cache(UNUSED_ARG(void *data)) string_buffer_append_string(&sb, client_list[nn]->addr->hostname); } string_buffer_append(&sb, '\0'); - log_module(PC_LOG, LOG_INFO, "Cleaning sockcheck cache at "FMT_TIME_T"; current clients: %s.", now, sb.list); + log_module(PC_LOG, LOG_INFO, "Cleaning sockcheck cache at %lu; current clients: %s.", (unsigned long)now, sb.list); string_buffer_clean(&sb); } else { for (curr_clients = dict_new(), nn=0; nn < sockcheck_conf.max_clients; nn++) { @@ -987,7 +990,7 @@ sockcheck_clean_cache(UNUSED_ARG(void *data)) if (((sci->last_touched + max_age) < now) && !dict_find(curr_clients, sci->hostname, NULL)) { if (SOCKCHECK_DEBUG) { - log_module(PC_LOG, LOG_INFO, " .. nuking %s (last touched "FMT_TIME_T").", sci->hostname, sci->last_touched); + log_module(PC_LOG, LOG_INFO, " .. nuking %s (last touched %lu).", sci->hostname, sci->last_touched); } dict_remove(checked_ip_dict, sci->hostname); } @@ -1096,14 +1099,13 @@ static MODCMD_FUNC(cmd_stats_proxycheck) } } -static int +static void sockcheck_new_user(struct userNode *user) { /* If they have a bum IP, or are bursting in, don't proxy-check or G-line them. */ if (irc_in_addr_is_valid(user->ip) && !irc_in_addr_is_loopback(user->ip) && !user->uplink->burst) sockcheck_queue_address(user->ip); - return 0; } static void @@ -1147,7 +1149,8 @@ sockcheck_read_conf(void) if (str) sockcheck_conf.max_cache_age = ParseInterval(str); str = database_get_data(my_node, "gline_duration", RECDB_QSTRING); if (str) sockcheck_conf.gline_duration = ParseInterval(str); - str = database_get_data(my_node, "address", RECDB_QSTRING); + str = database_get_data(my_node, "bind_address", RECDB_QSTRING); + if (!str) str = database_get_data(my_node, "address", RECDB_QSTRING); if (!getaddrinfo(str, NULL, NULL, &ai)) { sockcheck_conf.local_addr_len = ai->ai_addrlen; sockcheck_conf.local_addr = calloc(1, ai->ai_addrlen);