diff --git a/Changes b/Changes index 990fe43c4..42820a409 100644 --- a/Changes +++ b/Changes @@ -1910,3 +1910,4 @@ seen. gmtime warning still there - Updated docs, removed umode +I and cmode +H and added cmode +M - Removed some left over +I code - Added set::restrict-usermodes to /stats S (reported by AngryWolf) +- Zip links: Added link::compression-level so you can set the compression level per link. diff --git a/doc/unreal32docs.html b/doc/unreal32docs.html index aa53558b6..a36fe6c3f 100644 --- a/doc/unreal32docs.html +++ b/doc/unreal32docs.html @@ -1193,6 +1193,9 @@ loadmodule "src/modules/scan_http.so";

class
The class this server is put into, often a seperate server class is used for this.

+

compression-level (optional)
+ Specifies the compression level (1-9) for this link. Only used if link::options::zip is set. +

options block
One or more options used for connecting to the server. Sometimes not needed.
   ssl if you are connecting to a SSL port.
diff --git a/include/config.h b/include/config.h index 4a3e95183..e9767c896 100644 --- a/include/config.h +++ b/include/config.h @@ -522,11 +522,6 @@ */ #define FAST_BADWORD_REPLACE -/* If you use ziplinks, you can define the compression level here, - * higher=better compressed but more CPU time, can be 1-9, but 1-4 is suggested. - */ -#define ZIP_LEVEL 2 - /* ------------------------- END CONFIGURATION SECTION -------------------- */ #define MOTD MPATH #define RULES RPATH diff --git a/include/struct.h b/include/struct.h index 1a1f0b3d7..c41f14d8b 100644 --- a/include/struct.h +++ b/include/struct.h @@ -1019,6 +1019,9 @@ struct _configitem_link { #ifdef USE_SSL char *ciphers; #endif +#ifdef ZIP_LINKS + int compression_level; +#endif }; struct _configitem_except { @@ -1496,6 +1499,5 @@ int throttle_can_connect(struct IN_ADDR *in); #endif - #endif /* __struct_include__ */ diff --git a/include/zip.h b/include/zip.h index 25d6d7325..3de97b06d 100644 --- a/include/zip.h +++ b/include/zip.h @@ -46,10 +46,12 @@ struct Zdata { int first; /* First message? */ }; +#define ZIP_DEFAULT_LEVEL 2 + #endif /* ZIP_LINKS */ -extern int zip_init(struct Client *); +extern int zip_init(struct Client *, int); extern void zip_free(struct Client *); extern char *unzip_packet(struct Client *, char *, int *); extern char *zip_buffer(struct Client *, char *, int *, int); diff --git a/src/s_conf.c b/src/s_conf.c index 27eb7e8cd..bf9dca31a 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -4402,6 +4402,12 @@ int _conf_link(ConfigFile *conf, ConfigEntry *ce) { link->ciphers = strdup(cep->ce_vardata); } +#endif +#ifdef ZIP_LINKS + else if (!strcmp(cep->ce_varname, "compression-level")) + { + link->compression_level = atoi(cep->ce_vardata); + } #endif } AddListItem(link, conf_link); @@ -4425,7 +4431,7 @@ int _test_link(ConfigFile *conf, ConfigEntry *ce) "port", "password-receive", "password-connect", "class", "hub", "leaf", - "leafdepth", "ciphers", + "leafdepth", "ciphers", "compression-level", NULL }; if (!ce->ce_vardata) @@ -4476,6 +4482,25 @@ int _test_link(ConfigFile *conf, ConfigEntry *ce) errors++; } } +#ifdef ZIP_LINKS + if ((cep = config_find_entry(ce->ce_entries, "compression-level"))) + { + if (!cep->ce_vardata) + { + config_error("%s:%i: link::%s without contents", + cep->ce_fileptr->cf_filename, + cep->ce_varlinenum, cep->ce_varname); + errors++; + } else { + if ((atoi(cep->ce_vardata) < 1) || (atoi(cep->ce_vardata) > 9)) + { + config_error("%s:%i: compression-level should be in range 1..9", + cep->ce_fileptr->cf_filename, cep->ce_varlinenum); + errors++; + } + } + } +#endif if (errors > 0) return errors; for (cep = ce->ce_entries; cep; cep = cep->ce_next) diff --git a/src/s_serv.c b/src/s_serv.c index 5866e0f12..e820e9605 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -1070,7 +1070,7 @@ int m_server_synch(aClient *cptr, long numeric, ConfigItem_link *aconf) { if (cptr->proto & PROTO_ZIP) { - if (zip_init(cptr) == -1) + if (zip_init(cptr, aconf->compression_level ? aconf->compression_level : ZIP_DEFAULT_LEVEL) == -1) { zip_free(cptr); sendto_realops("Unable to setup compressed link for %s", get_client_name(cptr, TRUE)); @@ -2556,8 +2556,9 @@ CMD_FUNC(m_stats) if (acptr->zip->in->total_out && acptr->zip->out->total_in) { sendto_one(sptr, - ":%s NOTICE %s :Zipstats for link to %s: decompressed (in): %01lu/%01lu (%3.1f%%), compressed (out): %01lu/%01lu (%3.1f%%)", + ":%s NOTICE %s :Zipstats for link to %s (compresslevel %d): decompressed (in): %01lu/%01lu (%3.1f%%), compressed (out): %01lu/%01lu (%3.1f%%)", me.name, parv[0], get_client_name(acptr, TRUE), + acptr->serv->conf->compression_level ? acptr->serv->conf->compression_level : ZIP_DEFAULT_LEVEL, acptr->zip->in->total_in, acptr->zip->in->total_out, (100.0*(float)acptr->zip->in->total_in) /(float)acptr->zip->in->total_out, acptr->zip->out->total_in, acptr->zip->out->total_out, diff --git a/src/zip.c b/src/zip.c index 5c1febbe6..5e6b7e540 100644 --- a/src/zip.c +++ b/src/zip.c @@ -79,7 +79,7 @@ static char zipbuf[ZIP_BUFFER_SIZE]; ** Initialize compression structures for a server. ** If failed, zip_free() has to be called. */ -int zip_init(aClient *cptr) +int zip_init(aClient *cptr, int compressionlevel) { cptr->zip = (aZdata *) MyMalloc(sizeof(aZdata)); cptr->zip->incount = 0; @@ -105,7 +105,7 @@ int zip_init(aClient *cptr) cptr->zip->out->zalloc = NULL; cptr->zip->out->zfree = NULL; cptr->zip->out->data_type = Z_ASCII; - if (deflateInit(cptr->zip->out, ZIP_LEVEL) != Z_OK) + if (deflateInit(cptr->zip->out, compressionlevel) != Z_OK) return -1; return 0;