mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Make proxy messages include more detail and add status command
This commit is contained in:
parent
d27c54486f
commit
aaa0f73eac
@ -45,8 +45,8 @@ static void remove_client(CLIENT_REC *rec)
|
|||||||
rec->listen->clients = g_slist_remove(rec->listen->clients, rec);
|
rec->listen->clients = g_slist_remove(rec->listen->clients, rec);
|
||||||
|
|
||||||
signal_emit("proxy client disconnected", 1, rec);
|
signal_emit("proxy client disconnected", 1, rec);
|
||||||
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
printtext(rec->server, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||||
"Proxy: Client disconnected from %s", rec->host);
|
"Proxy: Client %s:%d disconnected", rec->host, rec->port);
|
||||||
|
|
||||||
g_free(rec->proxy_address);
|
g_free(rec->proxy_address);
|
||||||
net_sendbuffer_destroy(rec->handle, TRUE);
|
net_sendbuffer_destroy(rec->handle, TRUE);
|
||||||
@ -127,8 +127,9 @@ static void handle_client_connect_cmd(CLIENT_REC *client,
|
|||||||
remove_client(client);
|
remove_client(client);
|
||||||
} else {
|
} else {
|
||||||
signal_emit("proxy client connected", 1, client);
|
signal_emit("proxy client connected", 1, client);
|
||||||
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
printtext(client->server, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||||
"Proxy: Client finished connecting from %s", client->host);
|
"Proxy: Client %s:%d connected",
|
||||||
|
client->host, client->port);
|
||||||
client->connected = TRUE;
|
client->connected = TRUE;
|
||||||
proxy_dump_data(client);
|
proxy_dump_data(client);
|
||||||
}
|
}
|
||||||
@ -350,6 +351,7 @@ static void sig_listen(LISTEN_REC *listen)
|
|||||||
rec->listen = listen;
|
rec->listen = listen;
|
||||||
rec->handle = sendbuf;
|
rec->handle = sendbuf;
|
||||||
rec->host = g_strdup(host);
|
rec->host = g_strdup(host);
|
||||||
|
rec->port = port;
|
||||||
if (strcmp(listen->ircnet, "*") == 0) {
|
if (strcmp(listen->ircnet, "*") == 0) {
|
||||||
rec->proxy_address = g_strdup("irc.proxy");
|
rec->proxy_address = g_strdup("irc.proxy");
|
||||||
rec->server = servers == NULL ? NULL : IRC_SERVER(servers->data);
|
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);
|
rec->listen->clients = g_slist_prepend(rec->listen->clients, rec);
|
||||||
|
|
||||||
signal_emit("proxy client connecting", 1, rec);
|
signal_emit("proxy client connecting", 1, rec);
|
||||||
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
printtext(rec->server, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||||
"Proxy: Client connecting from %s", rec->host);
|
"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)
|
static void sig_incoming(IRC_SERVER_REC *server, const char *line)
|
||||||
|
@ -23,6 +23,37 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "levels.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)
|
void irc_proxy_init(void)
|
||||||
{
|
{
|
||||||
settings_add_str("irssiproxy", "irssiproxy_ports", "");
|
settings_add_str("irssiproxy", "irssiproxy_ports", "");
|
||||||
@ -43,6 +74,9 @@ void irc_proxy_init(void)
|
|||||||
"... to set them.");
|
"... to set them.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
command_bind("proxy", NULL, (SIGNAL_FUNC) cmd_proxy);
|
||||||
|
command_bind("proxy status", NULL, (SIGNAL_FUNC) cmd_proxy_status);
|
||||||
|
|
||||||
proxy_listen_init();
|
proxy_listen_init();
|
||||||
settings_check();
|
settings_check();
|
||||||
module_register("proxy", "irc");
|
module_register("proxy", "irc");
|
||||||
|
@ -19,6 +19,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *nick, *host;
|
char *nick, *host;
|
||||||
|
int port;
|
||||||
NET_SENDBUF_REC *handle;
|
NET_SENDBUF_REC *handle;
|
||||||
int recv_tag;
|
int recv_tag;
|
||||||
char *proxy_address;
|
char *proxy_address;
|
||||||
|
Loading…
Reference in New Issue
Block a user