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;
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 *
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);
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] = {
/* 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;
}
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;
}
}
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);
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);
/* 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;
}
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++) {
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);
}
}
}
-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
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);
sockcheck_conf.local_addr_len = 0;
sockcheck_conf.local_addr = NULL;
if (str)
- log_module(PC_LOG, LOG_ERROR, "Error: Unable to get host named `%s', not checking a specific address.", str);
+ log_module(PC_LOG, LOG_ERROR, "Error: Unable to get host named `%s', not checking from a specific address.", str);
}
}
}