예제 #1
0
파일: login-proxy.c 프로젝트: bjacke/core
static void login_proxy_free_errstr(struct login_proxy **_proxy,
				    const char *errstr, bool server)
{
	struct login_proxy *proxy = *_proxy;
	string_t *reason = t_str_new(128);

	str_printfa(reason, "Disconnected by %s", server ? "server" : "client");
	if (errstr[0] != '\0')
		str_printfa(reason, ": %s", errstr);

	str_printfa(reason, "(%ds idle, in=%"PRIuUOFF_T", out=%"PRIuUOFF_T,
		    (int)(ioloop_time - proxy->last_io),
		    proxy->server_output->offset, proxy->client_output->offset);
	if (o_stream_get_buffer_used_size(proxy->client_output) > 0) {
		str_printfa(reason, "+%"PRIuSIZE_T,
			    o_stream_get_buffer_used_size(proxy->client_output));
	}
	if (proxy->server_io == NULL)
		str_append(reason, ", client output blocked");
	if (proxy->client_io == NULL)
		str_append(reason, ", server output blocked");
	str_append_c(reason, ')');
	if (server)
		login_proxy_free_delayed(_proxy, str_c(reason));
	else
		login_proxy_free_reason(_proxy, str_c(reason));
}
예제 #2
0
static void
login_proxy_cmd_kick_director_hash(struct ipc_cmd *cmd, const char *const *args)
{
	struct login_proxy *proxy, *next;
	unsigned int hash, count = 0;

	if (args[0] == NULL || str_to_uint(args[0], &hash) < 0) {
		ipc_cmd_fail(&cmd, "Invalid parameters");
		return;
	}

	for (proxy = login_proxies; proxy != NULL; proxy = next) {
		next = proxy->next;

		if (director_username_hash(proxy->client) == hash) {
			login_proxy_free_reason(&proxy, KILLED_BY_ADMIN_REASON);
			count++;
		}
	}
	for (proxy = login_proxies_pending; proxy != NULL; proxy = next) {
		next = proxy->next;

		if (director_username_hash(proxy->client) == hash) {
			client_destroy(proxy->client, "Connection kicked");
			count++;
		}
	}
	ipc_cmd_success_reply(&cmd, t_strdup_printf("%u", count));
}
예제 #3
0
static void
login_proxy_cmd_kick(struct ipc_cmd *cmd, const char *const *args)
{
	struct login_proxy *proxy, *next;
	unsigned int count = 0;

	if (args[0] == NULL) {
		ipc_cmd_fail(&cmd, "Missing parameter");
		return;
	}

	for (proxy = login_proxies; proxy != NULL; proxy = next) {
		next = proxy->next;

		if (strcmp(proxy->client->virtual_user, args[0]) == 0) {
			login_proxy_free_reason(&proxy, KILLED_BY_ADMIN_REASON);
			count++;
		}
	}
	for (proxy = login_proxies_pending; proxy != NULL; proxy = next) {
		next = proxy->next;

		if (strcmp(proxy->client->virtual_user, args[0]) == 0) {
			client_destroy(proxy->client, "Connection kicked");
			count++;
		}
	}
	ipc_cmd_success_reply(&cmd, t_strdup_printf("%u", count));
}
예제 #4
0
static void login_proxy_free_errno(struct login_proxy **proxy,
				   int err, const char *who)
{
	const char *reason;

	reason = err == 0 || err == EPIPE ?
		t_strdup_printf("Disconnected by %s", who) :
		t_strdup_printf("Disconnected by %s: %s", who, strerror(errno));
	login_proxy_free_reason(proxy, reason);
}
예제 #5
0
파일: login-proxy.c 프로젝트: bjacke/core
static void proxy_kill_idle(struct login_proxy *proxy)
{
	login_proxy_free_reason(&proxy, KILLED_BY_SHUTDOWN_REASON);
}
예제 #6
0
파일: login-proxy.c 프로젝트: bjacke/core
void login_proxy_free(struct login_proxy **_proxy)
{
	login_proxy_free_reason(_proxy, NULL);
}