static unsigned int clients_count = 0;
static struct client *client_fd_proxies = NULL;
+static unsigned int client_fd_proxies_count = 0;
struct login_client_module_hooks {
struct module *module;
if (client->iostream_fd_proxy != NULL) {
client->fd_proxying = TRUE;
DLLIST_PREPEND(&client_fd_proxies, client);
+ client_fd_proxies_count++;
}
}
iostream_proxy_unref(&client->iostream_fd_proxy);
if (client->fd_proxying) {
DLLIST_REMOVE(&client_fd_proxies, client);
+ i_assert(client_fd_proxies_count > 0);
+ client_fd_proxies_count--;
}
i_stream_unref(&client->input);
o_stream_unref(&client->output);
return clients_count;
}
+unsigned int clients_get_fd_proxies_count(void)
+{
+ return client_fd_proxies_count;
+}
+
+struct client *clients_get_first_fd_proxy(void)
+{
+ return client_fd_proxies;
+}
+
void client_add_forward_field(struct client *client, const char *key,
const char *value)
{
struct client *client = client_fd_proxies;
client_unref(&client);
}
+ i_assert(client_fd_proxies_count == 0);
}
void client_common_deinit(void)
int client_get_plaintext_fd(struct client *client, int *fd_r, bool *close_fd_r);
unsigned int clients_get_count(void) ATTR_PURE;
+unsigned int clients_get_fd_proxies_count(void);
+struct client *clients_get_first_fd_proxy(void);
void client_add_forward_field(struct client *client, const char *key,
const char *value);
static struct login_proxy *login_proxies_pending = NULL;
static struct login_proxy *login_proxies_disconnecting = NULL;
static struct ipc_server *login_proxy_ipc_server;
+static unsigned int detached_login_proxies_count = 0;
static int login_proxy_connect(struct login_proxy *proxy);
static void login_proxy_disconnect(struct login_proxy *proxy);
ipstr != NULL ? ipstr : "",
reason == NULL ? "" : t_strdup_printf(" (%s)", reason),
delay_ms == 0 ? "" : t_strdup_printf(" - disconnecting client in %ums", delay_ms)));
+
+ i_assert(detached_login_proxies_count > 0);
+ detached_login_proxies_count--;
} else {
i_assert(proxy->client_input == NULL);
i_assert(proxy->client_output == NULL);
DLLIST_REMOVE(&login_proxies_pending, proxy);
DLLIST_PREPEND(&login_proxies, proxy);
+ detached_login_proxies_count++;
client->login_proxy = NULL;
}
ipc_cmd_fail(&cmd, "Unknown command");
}
+unsigned int login_proxies_get_detached_count(void)
+{
+ return detached_login_proxies_count;
+}
+
+struct client *login_proxies_get_first_detached_client(void)
+{
+ return login_proxies == NULL ? NULL : login_proxies->client;
+}
+
void login_proxy_init(const char *proxy_notify_pipe_path)
{
proxy_state = login_proxy_state_init(proxy_notify_pipe_path);
proxy = login_proxies;
login_proxy_free_reason(&proxy, KILLED_BY_SHUTDOWN_REASON);
}
+ i_assert(detached_login_proxies_count == 0);
+
while (login_proxies_disconnecting != NULL)
login_proxy_free_final(login_proxies_disconnecting);
if (login_proxy_ipc_server != NULL)
void login_proxy_kill_idle(void);
+unsigned int login_proxies_get_detached_count(void);
+struct client *login_proxies_get_first_detached_client(void);
+
void login_proxy_init(const char *proxy_notify_pipe_path);
void login_proxy_deinit(void);
#include "login-common.h"
#include "ioloop.h"
#include "array.h"
+#include "str.h"
#include "randgen.h"
#include "module-dir.h"
#include "process-title.h"
static void login_access_lookup_next(struct login_access_lookup *lookup);
-void login_refresh_proctitle(void)
+static bool get_first_client(struct client **client_r)
{
struct client *client = clients;
+
+ if (client == NULL)
+ client = login_proxies_get_first_detached_client();
+ if (client == NULL)
+ client = clients_get_first_fd_proxy();
+ *client_r = client;
+ return client != NULL;
+}
+
+void login_refresh_proctitle(void)
+{
+ struct client *client;
const char *addr;
if (!global_login_settings->verbose_proctitle)
return;
+ /* clients_get_count() includes all the clients being served.
+ Inside that there are 3 groups:
+ 1. pre-login clients
+ 2. post-login clients being proxied to remote hosts
+ 3. post-login clients being proxied to post-login processes
+ Currently the post-login proxying is done only for SSL/TLS
+ connections, so we're assuming that they're the same. */
+ string_t *str = t_str_new(64);
if (clients_get_count() == 0) {
- process_title_set("");
- } else if (clients_get_count() > 1 || client == NULL) {
- process_title_set(t_strdup_printf("[%u connections (%u TLS)]",
- clients_get_count(), ssl_proxy_get_count()));
+ /* no clients */
+ } else if (clients_get_count() > 1 || !get_first_client(&client)) {
+ str_printfa(str, "[%u pre-login", clients_get_count() -
+ login_proxies_get_detached_count() -
+ clients_get_fd_proxies_count());
+ if (login_proxies_get_detached_count() > 0) {
+ /* show detached proxies only if they exist, so
+ non-proxy servers don't unnecessarily show them. */
+ str_printfa(str, " + %u proxies",
+ login_proxies_get_detached_count());
+ }
+ if (clients_get_fd_proxies_count() > 0) {
+ /* show post-login proxies only if they exist, so
+ proxy-only servers don't unnecessarily show them. */
+ str_printfa(str, " + %u TLS proxies",
+ clients_get_fd_proxies_count());
+ }
+ str_append_c(str, ']');
} else {
+ str_append_c(str, '[');
addr = net_ip2addr(&client->ip);
- if (addr[0] != '\0') {
- process_title_set(t_strdup_printf(client->tls ?
- "[%s TLS]" : "[%s]", addr));
- } else {
- process_title_set(client->tls ? "[TLS]" : "");
- }
+ if (addr[0] != '\0')
+ str_printfa(str, "%s ", addr);
+ if (client->fd_proxying)
+ str_append(str, "TLS proxy");
+ else if (client->destroyed)
+ str_append(str, "proxy");
+ else
+ str_append(str, "pre-login");
+ str_append_c(str, ']');
}
+ process_title_set(str_c(str));
}
static void auth_client_idle_timeout(struct auth_client *auth_client)