コード例 #1
0
ファイル: doveadm-penalty.c プロジェクト: LTD-Beget/dovecot
static void cmd_penalty(int argc, char *argv[])
{
	struct penalty_context ctx;
	int c;

	memset(&ctx, 0, sizeof(ctx));
	ctx.anvil_path = t_strconcat(doveadm_settings->base_dir, "/anvil", NULL);
	while ((c = getopt(argc, argv, "a:")) > 0) {
		switch (c) {
		case 'a':
			ctx.anvil_path = optarg;
			break;
		default:
			help(&doveadm_cmd_penalty);
		}
	}
	argv += optind-1;

	if (argv[1] != NULL) {
		if (net_parse_range(argv[1], &ctx.net_ip, &ctx.net_bits) == 0)
			argv++;
	}
	if (argv[1] != NULL)
		help(&doveadm_cmd_penalty);

	fprintf(stderr, "%-16s penalty last_penalty        last_update\n", "IP");
	penalty_lookup(&ctx);
}
コード例 #2
0
static bool client_is_trusted(struct client *client)
{
	const char *const *net;
	struct ip_addr net_ip;
	unsigned int bits;

	if (client->set->login_trusted_networks == NULL)
		return FALSE;

	net = t_strsplit_spaces(client->set->login_trusted_networks, ", ");
	for (; *net != NULL; net++) {
		if (net_parse_range(*net, &net_ip, &bits) < 0) {
			i_error("login_trusted_networks: "
				"Invalid network '%s'", *net);
			break;
		}

		if (net_is_in_network(&client->ip, &net_ip, bits))
			return TRUE;
	}
	return FALSE;
}
コード例 #3
0
ファイル: client-export.c プロジェクト: jwm/dovecot-notmuch
static int
mail_export_parse_filter(const char *const *args, pool_t pool,
			 struct mail_export_filter *filter_r,
			 const char **error_r)
{
	unsigned long l;

	/* filters:
	   user=<wildcard> | domain=<wildcard>
	   ip=<ip>[/<mask>]
	   since=<timestamp>
	   connected
	*/
	memset(filter_r, 0, sizeof(*filter_r));
	for (; *args != NULL; args++) {
		if (strncmp(*args, "user="******"domain=", 7) == 0)
			filter_r->domain = p_strdup(pool, *args + 7);
		else if (strncmp(*args, "ip=", 3) == 0) {
			if (net_parse_range(*args + 3, &filter_r->ip,
					    &filter_r->ip_bits) < 0) {
				*error_r = "Invalid ip filter";
				return -1;
			}
		} else if (strncmp(*args, "since=", 6) == 0) {
			if (str_to_ulong(*args + 6, &l) < 0) {
				*error_r = "Invalid since filter";
				return -1;
			}
			filter_r->since = (time_t)l;
		} else if (strcmp(*args, "connected") == 0) {
			filter_r->connected = TRUE;
		}
	}
	return 0;
}