1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-10 06:23:13 +02:00

- Zip links: Added link::compression-level so you can set the compression level per link

This commit is contained in:
Bram Matthys
2003-02-15 21:13:37 +00:00
parent 4606d94e27
commit f2eb5f48b6
8 changed files with 41 additions and 12 deletions
+1
View File
@@ -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.
+3
View File
@@ -1193,6 +1193,9 @@ loadmodule "src/modules/scan_http.so";
<p><b>class</b><br>
The class this server is put into, often a seperate server class is used for this.
</p>
<p><b>compression-level</b> (optional)<br>
Specifies the compression level (1-9) for this link. Only used if link::options::zip is set.
</p>
<p><b>options block</b><br>
One or more options used for connecting to the server. Sometimes not needed.<br>
&nbsp;&nbsp;&nbsp;<b>ssl</b> if you are connecting to a SSL port.<br>
-5
View File
@@ -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
+3 -1
View File
@@ -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__ */
+3 -1
View File
@@ -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);
+26 -1
View File
@@ -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)
+3 -2
View File
@@ -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,
+2 -2
View File
@@ -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;