Date: Wed, 21 Feb 2018 02:42:50 -0500 From: Charles Sprickman <spork@bway.net> To: apache@FreeBSD.org Subject: FreeBSD Port: www/mod_cband Message-ID: <760D90A5-E9AB-41D4-9E63-E32052DAAAB7@bway.net>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hi,
I’m testing out one of the patches floating around to make mod_cband work on apache 2.4.x, is there any interest in including this small patch (and one Makefile change) so that mod_cband can be used with a current apache? After lots of looking, I’m not seeing anything else that really compares to mod_cband, especially for web hosting where one needs to enforce a quota on bytes transferred over a period of time (week, month).
Makefile change is just "USE_APACHE= 22” to "USE_APACHE= 22+”.
The other changes are pretty small and are attached - dump them in the port’s “files” directory and it should build. The compiler warnings are the same as those generated by the current port (strncmp suggestions, unsigned int comparison warning).
I’m running this now on a 10.4 server with apache 2.4.29. I’d like to let it cook for a few days, but at first glance this seems to be working fine.
Thanks,
Charles
--
Charles Sprickman
NetEng/SysAdmin
Bway.net - New York's Best Internet www.bway.net
spork@bway.net - 212.982.9800
[-- Attachment #2 --]
--- ./src/mod_cband.c.orig 2006-11-14 16:23:36.000000000 -0500
+++ ./src/mod_cband.c 2018-02-21 01:36:57.392077194 -0500
@@ -1330,7 +1330,7 @@
p.bitlen = 32;
p.ref_count = 0;
p.family = AF_INET;
- p.add.sin.s_addr = inet_addr(r->connection->remote_ip);
+ p.add.sin.s_addr = inet_addr(r->connection->client_ip);
node = patricia_search_best(config->tree, &p);
@@ -1339,7 +1339,7 @@
if (leaf) {
#ifdef DEBUG
- fprintf(stderr,"%s leaf %s\n",r->connection->remote_ip,leaf);
+ fprintf(stderr,"%s leaf %s\n",r->connection->client_ip,leaf);
fflush(stderr);
#endif
return atoi(leaf);
@@ -1359,10 +1359,10 @@
if (entry == NULL)
return -1;
- if (c->remote_ip != NULL)
- addr = inet_addr(c->remote_ip);
+ if (c->client_ip != NULL)
+ addr = inet_addr(c->client_ip);
else
- addr = c->remote_addr->sa.sin.sin_addr.s_addr;
+ addr = c->client_addr->sa.sin.sin_addr.s_addr;
time_now = apr_time_now();
hosts = config->remote_hosts.hosts;
@@ -1375,7 +1375,7 @@
for (i = 0; i < MAX_REMOTE_HOSTS; i++) {
time_delta = (time_now - hosts[i].remote_last_time) / 1e6;
if (hosts[i].used && ((time_delta <= MAX_REMOTE_HOST_LIFE) || (hosts[i].remote_conn > 0)) &&
- (hosts[i].remote_addr == addr) && (hosts[i].virtual_name == entry->virtual_name)) {
+ (hosts[i].client_addr == addr) && (hosts[i].virtual_name == entry->virtual_name)) {
mod_cband_sem_up(config->remote_hosts.sem_id);
/* END CRITICAL SECTION */
return i;
@@ -1388,7 +1388,7 @@
if ((hosts[i].used == 0) || ((time_delta > MAX_REMOTE_HOST_LIFE) && (hosts[i].remote_conn <= 0))) {
memset(&hosts[i], 0, sizeof(mod_cband_remote_host));
hosts[i].used = 1;
- hosts[i].remote_addr = addr;
+ hosts[i].client_addr = addr;
hosts[i].remote_last_time = time_now;
hosts[i].remote_last_refresh = time_now;
hosts[i].virtual_name = entry->virtual_name;
@@ -2528,7 +2528,7 @@
unsigned long total_connections = 0;
float bps, current_speed_bps = 0;
float rps, current_speed_rps = 0;
- struct in_addr remote_addr;
+ struct in_addr client_addr;
unsigned long time_now, time_delta;
int odd = 0, ok = 0;
const char *odd_str;
@@ -2804,9 +2804,9 @@
odd = 0;
}
- remote_addr.s_addr = config->remote_hosts.hosts[i].remote_addr;
+ client_addr.s_addr = config->remote_hosts.hosts[i].client_addr;
ap_rputs("<tr>", r);
- ap_rprintf(r, "<td class=remote_%s>%s</td>", odd_str, inet_ntoa((struct in_addr)remote_addr));
+ ap_rprintf(r, "<td class=remote_%s>%s</td>", odd_str, inet_ntoa((struct in_addr)client_addr));
ap_rprintf(r, "<td class=remote_%s>%s</td>", odd_str, config->remote_hosts.hosts[i].virtual_name);
mod_cband_status_print_connections(r, config->remote_hosts.hosts[i].remote_max_conn, config->remote_hosts.hosts[i].remote_conn);
[-- Attachment #3 --]
--- src/mod_cband.h.orig 2018-02-21 02:31:56.897849087 -0500
+++ src/mod_cband.h 2018-02-21 01:52:30.289010989 -0500
@@ -159,7 +159,7 @@
typedef struct mod_cband_remote_host {
int used;
- unsigned long remote_addr;
+ unsigned long client_addr;
unsigned long remote_conn;
unsigned long remote_kbps, remote_max_conn;
unsigned long remote_last_time;
[-- Attachment #4 --]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?760D90A5-E9AB-41D4-9E63-E32052DAAAB7>
