1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-13 05:03:45 -04:00

Make proxy messages include more detail and add status command

This commit is contained in:
Hans Nielsen 2014-06-24 23:45:35 -07:00
parent d27c54486f
commit aaa0f73eac
3 changed files with 44 additions and 6 deletions

View File

@ -45,8 +45,8 @@ static void remove_client(CLIENT_REC *rec)
rec->listen->clients = g_slist_remove(rec->listen->clients, rec);
signal_emit("proxy client disconnected", 1, rec);
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
"Proxy: Client disconnected from %s", rec->host);
printtext(rec->server, NULL, MSGLEVEL_CLIENTNOTICE,
"Proxy: Client %s:%d disconnected", rec->host, rec->port);
g_free(rec->proxy_address);
net_sendbuffer_destroy(rec->handle, TRUE);
@ -127,8 +127,9 @@ static void handle_client_connect_cmd(CLIENT_REC *client,
remove_client(client);
} else {
signal_emit("proxy client connected", 1, client);
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
"Proxy: Client finished connecting from %s", client->host);
printtext(client->server, NULL, MSGLEVEL_CLIENTNOTICE,
"Proxy: Client %s:%d connected",
client->host, client->port);
client->connected = TRUE;
proxy_dump_data(client);
}
@ -350,6 +351,7 @@ static void sig_listen(LISTEN_REC *listen)
rec->listen = listen;
rec->handle = sendbuf;
rec->host = g_strdup(host);
rec->port = port;
if (strcmp(listen->ircnet, "*") == 0) {
rec->proxy_address = g_strdup("irc.proxy");
rec->server = servers == NULL ? NULL : IRC_SERVER(servers->data);
@ -365,8 +367,9 @@ static void sig_listen(LISTEN_REC *listen)
rec->listen->clients = g_slist_prepend(rec->listen->clients, rec);
signal_emit("proxy client connecting", 1, rec);
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
"Proxy: Client connecting from %s", rec->host);
printtext(rec->server, NULL, MSGLEVEL_CLIENTNOTICE,
"Proxy: New client %s:%d on port %d (%s)",
rec->host, rec->port, listen->port, listen->ircnet);
}
static void sig_incoming(IRC_SERVER_REC *server, const char *line)

View File

@ -23,6 +23,37 @@
#include "settings.h"
#include "levels.h"
#include "fe-common/core/printtext.h"
static void cmd_proxy_status(const char *data, IRC_SERVER_REC *server)
{
GSList *tmp;
printtext(server, NULL, MSGLEVEL_CLIENTNOTICE,
"Proxy: Currently connected clients: %d",
g_slist_length(proxy_clients));
for (tmp = proxy_clients; tmp != NULL; tmp = tmp->next) {
CLIENT_REC *rec = tmp->data;
printtext(server, NULL, MSGLEVEL_CLIENTNOTICE,
" %s:%d connect%s to %d (%s)",
rec->host, rec->port,
rec->connected ? "ed" : "ing",
rec->listen->port, rec->listen->ircnet);
}
}
static void cmd_proxy(const char *data, IRC_SERVER_REC *server, void *item)
{
if (*data == '\0') {
cmd_proxy_status(data, server);
return;
}
command_runsub("proxy", data, server, item);
}
void irc_proxy_init(void)
{
settings_add_str("irssiproxy", "irssiproxy_ports", "");
@ -43,6 +74,9 @@ void irc_proxy_init(void)
"... to set them.");
}
command_bind("proxy", NULL, (SIGNAL_FUNC) cmd_proxy);
command_bind("proxy status", NULL, (SIGNAL_FUNC) cmd_proxy_status);
proxy_listen_init();
settings_check();
module_register("proxy", "irc");

View File

@ -19,6 +19,7 @@ typedef struct {
typedef struct {
char *nick, *host;
int port;
NET_SENDBUF_REC *handle;
int recv_tag;
char *proxy_address;