Line 0
Link Here
|
|
|
1 |
From 284c7a8020b664ecc6cb1f326af55325a46f7d3a Mon Sep 17 00:00:00 2001 |
2 |
From: Nathan Phillip Brink <binki@gentoo.org> |
3 |
Date: Mon, 12 Sep 2011 23:25:09 +0000 |
4 |
Subject: [PATCH] Throttle almost everything (except PING, PONG, and certain QUIT messages) sent to the IRCd. |
5 |
|
6 |
Fixes being killed for Excess Flooding on freenode by using the existing |
7 |
fakelag mechanism. The existing fakelag works great but was just not hooked |
8 |
into earlier. |
9 |
--- |
10 |
src/connection.c | 14 +++++++++++--- |
11 |
1 files changed, 11 insertions(+), 3 deletions(-) |
12 |
|
13 |
diff --git a/src/connection.c b/src/connection.c |
14 |
index c793e18..e226f92 100644 |
15 |
--- a/src/connection.c |
16 |
+++ b/src/connection.c |
17 |
@@ -23,6 +23,7 @@ static SSL_CTX *sslctx = NULL; |
18 |
static int ssl_cx_idx; |
19 |
static BIO *errbio = NULL; |
20 |
extern char *conf_ssl_certfile; |
21 |
+static int cn_want_write(connection_t *cn); |
22 |
static int SSLize(connection_t *cn, int *nc); |
23 |
static SSL_CTX *SSL_init_context(void); |
24 |
/* SSH like trust management */ |
25 |
@@ -326,6 +327,11 @@ static int real_write_all(connection_t *cn) |
26 |
return 0; |
27 |
} |
28 |
|
29 |
+/* |
30 |
+ * May only be used when writing to the client or when sending |
31 |
+ * timing-sensitive data to the server (PONG, PING for lagtest, QUIT) |
32 |
+ * because fakelag is not enforced. |
33 |
+ */ |
34 |
void write_line_fast(connection_t *cn, char *line) |
35 |
{ |
36 |
int r; |
37 |
@@ -353,13 +359,15 @@ void write_line_fast(connection_t *cn, char *line) |
38 |
void write_lines(connection_t *cn, list_t *lines) |
39 |
{ |
40 |
list_append(cn->outgoing, lines); |
41 |
- real_write_all(cn); |
42 |
+ if (cn_want_write(cn)) |
43 |
+ real_write_all(cn); |
44 |
} |
45 |
|
46 |
void write_line(connection_t *cn, char *line) |
47 |
{ |
48 |
list_add_last(cn->outgoing, bip_strdup(line)); |
49 |
- real_write_all(cn); |
50 |
+ if (cn_want_write(cn)) |
51 |
+ real_write_all(cn); |
52 |
} |
53 |
|
54 |
list_t *read_lines(connection_t *cn, int *error) |
55 |
@@ -718,7 +726,7 @@ static int check_event_write(fd_set *fds, connection_t *cn, int *nc) |
56 |
/* token generation interval: 1200ms */ |
57 |
#define TOKEN_INTERVAL 1200 |
58 |
|
59 |
-int cn_want_write(connection_t *cn) |
60 |
+static int cn_want_write(connection_t *cn) |
61 |
{ |
62 |
if (cn->anti_flood) { |
63 |
struct timeval tv; |
64 |
-- |
65 |
1.7.3.4 |
66 |
|