mirror of
https://github.com/irssi/irssi.git
synced 2024-10-27 05:20:20 -04:00
If you're not allowed to connect to server (K-lined, no I-line), Irssi
won't try to reconnect back to the server. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@322 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
e6187b66e9
commit
524a7ca1b9
@ -695,6 +695,7 @@ void fe_events_numeric_init(void)
|
||||
signal_add("event 004", (SIGNAL_FUNC) event_received);
|
||||
signal_add("event 364", (SIGNAL_FUNC) event_received);
|
||||
signal_add("event 365", (SIGNAL_FUNC) event_received);
|
||||
signal_add("event 465", (SIGNAL_FUNC) event_received);
|
||||
}
|
||||
|
||||
void fe_events_numeric_deinit(void)
|
||||
@ -749,4 +750,5 @@ void fe_events_numeric_deinit(void)
|
||||
signal_remove("event 004", (SIGNAL_FUNC) event_received);
|
||||
signal_remove("event 364", (SIGNAL_FUNC) event_received);
|
||||
signal_remove("event 365", (SIGNAL_FUNC) event_received);
|
||||
signal_remove("event 465", (SIGNAL_FUNC) event_received);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ void irc_server_connect_free(IRC_SERVER_CONNECT_REC *rec)
|
||||
g_free_not_null(rec->channels);
|
||||
g_free_not_null(rec->away_reason);
|
||||
g_free_not_null(rec->usermode);
|
||||
g_free(rec->address);
|
||||
g_free_not_null(rec->address);
|
||||
g_free(rec);
|
||||
}
|
||||
|
||||
@ -404,6 +404,22 @@ static void event_server_info(const char *data, IRC_SERVER_REC *server)
|
||||
g_free(params);
|
||||
}
|
||||
|
||||
static void event_server_banned(const char *data, IRC_SERVER_REC *server)
|
||||
{
|
||||
g_return_if_fail(server != NULL);
|
||||
|
||||
server->banned = TRUE;
|
||||
}
|
||||
|
||||
static void event_error(const char *data, IRC_SERVER_REC *server)
|
||||
{
|
||||
g_return_if_fail(server != NULL);
|
||||
|
||||
if (!server->connected && (stristr(data, "Unauthorized") != NULL ||
|
||||
stristr(data, "K-lined") != NULL))
|
||||
server->banned = TRUE;
|
||||
}
|
||||
|
||||
static void event_ping(const char *data, IRC_SERVER_REC *server)
|
||||
{
|
||||
char *str;
|
||||
@ -432,6 +448,8 @@ void irc_servers_init(void)
|
||||
signal_add_last("server connect failed", (SIGNAL_FUNC) sig_connect_failed);
|
||||
signal_add("event 001", (SIGNAL_FUNC) event_connected);
|
||||
signal_add("event 004", (SIGNAL_FUNC) event_server_info);
|
||||
signal_add("event 465", (SIGNAL_FUNC) event_server_banned);
|
||||
signal_add("event error", (SIGNAL_FUNC) event_error);
|
||||
signal_add("event ping", (SIGNAL_FUNC) event_ping);
|
||||
signal_add("event empty", (SIGNAL_FUNC) event_empty);
|
||||
|
||||
@ -455,6 +473,8 @@ void irc_servers_deinit(void)
|
||||
signal_remove("server connect failed", (SIGNAL_FUNC) sig_connect_failed);
|
||||
signal_remove("event 001", (SIGNAL_FUNC) event_connected);
|
||||
signal_remove("event 004", (SIGNAL_FUNC) event_server_info);
|
||||
signal_remove("event 465", (SIGNAL_FUNC) event_server_banned);
|
||||
signal_remove("event error", (SIGNAL_FUNC) event_error);
|
||||
signal_remove("event ping", (SIGNAL_FUNC) event_ping);
|
||||
signal_remove("event empty", (SIGNAL_FUNC) event_empty);
|
||||
|
||||
|
@ -85,6 +85,7 @@ typedef struct {
|
||||
char *away_reason;
|
||||
int usermode_away:1;
|
||||
int server_operator:1;
|
||||
int banned:1; /* not allowed to connect to this server */
|
||||
|
||||
int whois_coming:1; /* Mostly just to display away message right.. */
|
||||
int whois_found:1; /* Did WHOIS return any entries? */
|
||||
|
@ -128,6 +128,10 @@ static void server_connect_copy_skeleton(IRC_SERVER_CONNECT_REC *dest, IRC_SERVE
|
||||
dest->max_msgs = src->max_msgs;
|
||||
}
|
||||
|
||||
#define server_should_reconnect(server) \
|
||||
(irc_server_check(server) && (server)->connection_lost && \
|
||||
((server)->connrec->ircnet != NULL || !(server)->banned))
|
||||
|
||||
static void sig_reconnect(IRC_SERVER_REC *server)
|
||||
{
|
||||
IRC_SERVER_CONNECT_REC *conn;
|
||||
@ -138,7 +142,7 @@ static void sig_reconnect(IRC_SERVER_REC *server)
|
||||
|
||||
g_return_if_fail(server != NULL);
|
||||
|
||||
if (reconnect_time == -1 || !server->connection_lost || !irc_server_check(server))
|
||||
if (reconnect_time == -1 || !server_should_reconnect(server))
|
||||
return;
|
||||
|
||||
conn = g_new0(IRC_SERVER_CONNECT_REC, 1);
|
||||
@ -168,6 +172,7 @@ static void sig_reconnect(IRC_SERVER_REC *server)
|
||||
sserver->last_connect = server->connect_time == 0 ?
|
||||
time(NULL) : server->connect_time;
|
||||
sserver->last_failed = !server->connected;
|
||||
if (server->banned) sserver->banned = TRUE;
|
||||
}
|
||||
|
||||
if (sserver == NULL || conn->ircnet == NULL) {
|
||||
@ -198,10 +203,9 @@ static void sig_reconnect(IRC_SERVER_REC *server)
|
||||
for (tmp = setupservers; tmp != NULL; tmp = tmp->next) {
|
||||
SETUP_SERVER_REC *rec = tmp->data;
|
||||
|
||||
if (rec->ircnet == NULL || g_strcasecmp(conn->ircnet, rec->ircnet) != 0)
|
||||
continue;
|
||||
|
||||
if (!rec->last_connect || !rec->last_failed || rec->last_connect < now-FAILED_RECONNECT_WAIT) {
|
||||
if (rec->ircnet != NULL && g_strcasecmp(conn->ircnet, rec->ircnet) == 0 &&
|
||||
!rec->banned && (!rec->last_connect || !rec->last_failed ||
|
||||
rec->last_connect < now-FAILED_RECONNECT_WAIT)) {
|
||||
sserver_connect(rec, conn);
|
||||
return;
|
||||
}
|
||||
@ -215,7 +219,8 @@ static void sig_reconnect(IRC_SERVER_REC *server)
|
||||
if (!found && g_strcasecmp(rec->address, server->connrec->address) == 0 &&
|
||||
server->connrec->port == rec->port)
|
||||
found = TRUE;
|
||||
else if (found && rec->ircnet != NULL && g_strcasecmp(conn->ircnet, rec->ircnet) == 0) {
|
||||
else if (found && !rec->banned && rec->ircnet != NULL &&
|
||||
g_strcasecmp(conn->ircnet, rec->ircnet) == 0) {
|
||||
sserver_connect(rec, conn);
|
||||
break;
|
||||
}
|
||||
@ -228,6 +233,7 @@ static void sig_reconnect(IRC_SERVER_REC *server)
|
||||
if (through) {
|
||||
/* shouldn't happen unless there's no servers in
|
||||
this ircnet in setup.. */
|
||||
irc_server_connect_free(conn);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,8 @@ typedef struct {
|
||||
IPADDR *own_ip; /* resolved own_address if not NULL */
|
||||
|
||||
time_t last_connect; /* to avoid reconnecting too fast.. */
|
||||
int last_failed; /* if last connection attempt failed */
|
||||
int last_failed:1; /* if last connection attempt failed */
|
||||
int banned:1; /* if we're banned from this server */
|
||||
} SETUP_SERVER_REC;
|
||||
|
||||
extern GSList *setupservers; /* list of irc servers */
|
||||
|
Loading…
Reference in New Issue
Block a user