diff --git a/configure.ac b/configure.ac index 96b6dfee..c7ed2ebd 100644 --- a/configure.ac +++ b/configure.ac @@ -342,26 +342,6 @@ AS_IF([test "$hyperscan" = no], [ AM_CONDITIONAL([HAVE_HYPERSCAN], [test "$hyperscan" = "yes"]) -AC_ARG_WITH(zlib-path, -AC_HELP_STRING([--with-zlib-path=DIR],[Path to libz.so for ziplinks support.]), -[LIBS="$LIBS -L$withval"],) - -AC_ARG_ENABLE(zlib, -AC_HELP_STRING([--disable-zlib],[Disable ziplinks support]), -[zlib=$enableval],[zlib=yes]) - -if test "$zlib" = yes; then - -AC_CHECK_HEADER(zlib.h, [ - AC_CHECK_LIB(z, zlibVersion, - [ - AC_SUBST(ZLIB_LD, -lz) - AC_DEFINE(HAVE_LIBZ, 1, [Define to 1 if zlib (-lz) is available.]) - ], zlib=no) -], zlib=no) - -fi - AC_ARG_WITH(sctp-path, AC_HELP_STRING([--with-sctp-path=DIR],[Path to libsctp.so for SCTP support.]), [LIBS="$LIBS -L$withval"],) @@ -713,7 +693,6 @@ echo " Configuration of ${BRANDING_NAME}-${BRANDING_VERSION}: Install directory : $prefix - Ziplinks : $zlib OpenSSL : $openssl SCTP : $sctp diff --git a/doc/ircd.conf.example b/doc/ircd.conf.example index 834ef8b0..2c04a0a5 100644 --- a/doc/ircd.conf.example +++ b/doc/ircd.conf.example @@ -312,7 +312,7 @@ connect "irc.uplink.com" { accept_password = "anotherpassword"; port = 6666; class = "server"; - flags = compressed, topicburst; + flags = topicburst; #fingerprint = "c77106576abf7f9f90cca0f63874a60f2e40a64b"; }; diff --git a/doc/reference.conf b/doc/reference.conf index 702e4325..ac826308 100644 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -581,12 +581,11 @@ connect "irc.uplink.com" { /* flags: controls special options for this server * encrypted - marks the accept_password as being crypt()'d * autoconn - automatically connect to this server - * compressed - compress traffic via ziplinks * topicburst - burst topics between servers * ssl - ssl/tls encrypted server connections * no-export - marks the link as a no-export link (not exported to other links) */ - flags = compressed, topicburst; + flags = topicburst; }; connect "ipv6.lame.server" { @@ -604,9 +603,6 @@ connect "ipv6.lame.server" { }; connect "ssl.uplink.com" { - /* Example of ssl server-to-server connection, ssl flag doesn't need - * compressed flag, 'cause it uses own compression - */ host = "203.0.113.129"; send_password = "password"; accept_password = "anotherpassword"; @@ -1311,14 +1307,6 @@ general { * provided they have umode +s set */ oper_snomask = "+s"; - /* compression level: level of compression for compressed links between - * servers. - * - * values are between: 1 (least compression, fastest) - * and: 9 (most compression, slowest). - */ - #compression_level = 6; - /* burst_away: This enables bursting away messages to servers. * With this disabled, we will only propogate AWAY messages * as users send them, but never burst them. Be warned though diff --git a/help/opers/stats b/help/opers/stats index 8e87ddaa..d13b5814 100644 --- a/help/opers/stats +++ b/help/opers/stats @@ -40,5 +40,4 @@ X S - Shows ssld processes * X - Shows gecos bans (Old X: lines) ^ y - Shows connection classes (Old Y: lines) * z - Shows memory stats -* Z - Shows ziplinks stats ^ ? - Shows connected servers and sendq info about them diff --git a/include/client.h b/include/client.h index 9bc443f7..fa736bd3 100644 --- a/include/client.h +++ b/include/client.h @@ -93,16 +93,6 @@ struct Server struct scache_entry *nameinfo; }; -struct ZipStats -{ - unsigned long long in; - unsigned long long in_wire; - unsigned long long out; - unsigned long long out_wire; - double in_ratio; - double out_ratio; -}; - struct Client { rb_dlink_node node; @@ -277,7 +267,6 @@ struct LocalUser struct ws_ctl *ws_ctl; /* ctl for wsockd */ SSL_OPEN_CB *ssl_callback; /* ssl connection is now open */ uint32_t localflags; - struct ZipStats *zipstats; /* zipstats */ uint16_t cork_count; /* used for corking/uncorking connections */ struct ev_entry *event; /* used for associated events */ diff --git a/include/s_conf.h b/include/s_conf.h index 4d4b6b40..1bad8090 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -174,7 +174,6 @@ struct config_file_entry char *fname_operspylog; char *fname_ioerrorlog; - unsigned char compression_level; int disable_fake_channels; int dots_in_ident; int failed_oper_notice; diff --git a/include/s_serv.h b/include/s_serv.h index 1c15b014..b917aa6f 100644 --- a/include/s_serv.h +++ b/include/s_serv.h @@ -79,7 +79,6 @@ extern unsigned int CAP_EX; /* Can do channel +e exemptions */ extern unsigned int CAP_CHW; /* Can do channel wall @# */ extern unsigned int CAP_IE; /* Can do invite exceptions */ extern unsigned int CAP_KLN; /* Can do KLINE message */ -extern unsigned int CAP_ZIP; /* Can do ZIPlinks */ extern unsigned int CAP_KNOCK; /* supports KNOCK */ extern unsigned int CAP_TB; /* supports TBURST */ extern unsigned int CAP_UNKLN; /* supports remote unkline */ @@ -97,12 +96,6 @@ extern unsigned int CAP_MLOCK; /* supports MLOCK messages */ /* XXX: added for backwards compatibility. --nenolod */ #define CAP_MASK (capability_index_mask(serv_capindex) & ~(CAP_TS6 | CAP_CAP)) -#ifdef HAVE_LIBZ -#define CAP_ZIP_SUPPORTED CAP_ZIP -#else -#define CAP_ZIP_SUPPORTED 0 -#endif - /* * Capability macros. */ diff --git a/ircd/client.c b/ircd/client.c index 8430525c..8cf44bd2 100644 --- a/ircd/client.c +++ b/ircd/client.c @@ -307,11 +307,6 @@ free_local_client(struct Client *client_p) rb_free(client_p->localClient->cipher_string); - if (IsCapable(client_p, CAP_ZIP)) - ssld_decrement_clicount(client_p->localClient->z_ctl); - - rb_free(client_p->localClient->zipstats); - if (client_p->localClient->ws_ctl != NULL) wsockd_decrement_clicount(client_p->localClient->ws_ctl); diff --git a/ircd/ircd.c b/ircd/ircd.c index 6c6c45d6..e4654f9e 100644 --- a/ircd/ircd.c +++ b/ircd/ircd.c @@ -353,18 +353,6 @@ initialize_global_set_options(void) } -/* - * initialize_server_capabs - * - * inputs - none - * output - none - */ -static void -initialize_server_capabs(void) -{ - default_server_capabs &= ~CAP_ZIP; -} - #ifdef _WIN32 /* * relocate_paths @@ -786,7 +774,6 @@ solanum_main(int argc, char * const argv[]) rehash_bans(); - initialize_server_capabs(); /* Set up default_server_capabs */ initialize_global_set_options(); if(ServerInfo.name == NULL) diff --git a/ircd/newconf.c b/ircd/newconf.c index d6eef9f0..01fbcc0b 100644 --- a/ircd/newconf.c +++ b/ircd/newconf.c @@ -356,7 +356,7 @@ static struct mode_table auth_table[] = { static struct mode_table connect_table[] = { { "autoconn", SERVER_AUTOCONN }, - { "compressed", SERVER_COMPRESSED }, + { "compressed", 0 }, { "encrypted", SERVER_ENCRYPTED }, { "topicburst", SERVER_TB }, { "sctp", SERVER_SCTP }, @@ -1268,14 +1268,6 @@ conf_end_connect(struct TopConf *tc) return 0; } -#ifndef HAVE_LIBZ - if(ServerConfCompressed(yy_server)) - { - conf_report_error("Ignoring connect::flags::compressed -- zlib not available."); - yy_server->flags &= ~SERVER_COMPRESSED; - } -#endif - add_server_conf(yy_server); rb_dlinkAdd(yy_server, &yy_server->node, &server_conf_list); @@ -1398,9 +1390,6 @@ conf_set_connect_flags(void *data) { conf_parm_t *args = data; - /* note, we allow them to set compressed, then remove it later if - * they do and LIBZ isnt available - */ set_modes_from_table(&yy_server->flags, "flag", connect_table, args); } @@ -1580,24 +1569,6 @@ conf_set_general_stats_l_oper_only(void *data) conf_report_error("Invalid setting '%s' for general::stats_l_oper_only.", val); } -static void -conf_set_general_compression_level(void *data) -{ -#ifdef HAVE_LIBZ - ConfigFileEntry.compression_level = *(unsigned int *) data; - - if((ConfigFileEntry.compression_level < 1) || (ConfigFileEntry.compression_level > 9)) - { - conf_report_error - ("Invalid general::compression_level %d -- using default.", - ConfigFileEntry.compression_level); - ConfigFileEntry.compression_level = 0; - } -#else - conf_report_error("Ignoring general::compression_level -- zlib not available."); -#endif -} - static void conf_set_general_default_umodes(void *data) { @@ -2653,7 +2624,6 @@ static struct ConfEntry conf_general_table[] = { "oper_only_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_only_umodes, 0, NULL }, { "oper_umodes", CF_STRING | CF_FLIST, conf_set_general_oper_umodes, 0, NULL }, { "oper_snomask", CF_QSTRING, conf_set_general_oper_snomask, 0, NULL }, - { "compression_level", CF_INT, conf_set_general_compression_level, 0, NULL }, { "havent_read_conf", CF_YESNO, conf_set_general_havent_read_conf, 0, NULL }, { "hide_error_messages",CF_STRING, conf_set_general_hide_error_messages,0, NULL }, { "stats_i_oper_only", CF_STRING, conf_set_general_stats_i_oper_only, 0, NULL }, diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 6e8cb5d5..b6924300 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -779,10 +779,6 @@ set_default_conf(void) ConfigFileEntry.tls_ciphers_oper_only = false; ConfigFileEntry.oper_secure_only = false; -#ifdef HAVE_LIBZ - ConfigFileEntry.compression_level = 4; -#endif - ConfigFileEntry.oper_umodes = UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_OPERWALL | UMODE_WALLOP; ConfigFileEntry.oper_only_umodes = UMODE_SERVNOTICE; diff --git a/ircd/s_serv.c b/ircd/s_serv.c index 23720889..98caf93a 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -73,7 +73,6 @@ unsigned int CAP_EX; unsigned int CAP_CHW; unsigned int CAP_IE; unsigned int CAP_KLN; -unsigned int CAP_ZIP; unsigned int CAP_KNOCK; unsigned int CAP_TB; unsigned int CAP_UNKLN; @@ -116,7 +115,6 @@ init_builtin_capabs(void) CAP_IE = capability_put(serv_capindex, "IE", NULL); CAP_KLN = capability_put(serv_capindex, "KLN", NULL); CAP_KNOCK = capability_put(serv_capindex, "KNOCK", NULL); - CAP_ZIP = capability_put(serv_capindex, "ZIP", NULL); CAP_TB = capability_put(serv_capindex, "TB", NULL); CAP_UNKLN = capability_put(serv_capindex, "UNKLN", NULL); CAP_CLUSTER = capability_put(serv_capindex, "CLUSTER", NULL); @@ -443,12 +441,7 @@ check_server(const char *name, struct Client *client_p) } attach_server_conf(client_p, server_p); - /* clear ZIP/TB if they support but we dont want them */ -#ifdef HAVE_LIBZ - if(!ServerConfCompressed(server_p)) -#endif - ClearCap(client_p, CAP_ZIP); - + /* clear TB if they support but we dont want it */ if(!ServerConfTb(server_p)) ClearCap(client_p, CAP_TB); @@ -797,7 +790,6 @@ server_estab(struct Client *client_p) /* pass info to new server */ send_capabilities(client_p, default_server_capabs | CAP_MASK - | (ServerConfCompressed(server_p) ? CAP_ZIP_SUPPORTED : 0) | (ServerConfTb(server_p) ? CAP_TB : 0)); sendto_one(client_p, "SERVER %s 1 :%s%s", @@ -809,12 +801,6 @@ server_estab(struct Client *client_p) if(!rb_set_buffers(client_p->localClient->F, READBUF_SIZE)) ilog_error("rb_set_buffers failed for server"); - /* Enable compression now */ - if(IsCapable(client_p, CAP_ZIP)) - { - start_zlib_session(client_p); - } - client_p->servptr = &me; if(IsAnyDead(client_p)) @@ -1316,7 +1302,6 @@ serv_connect_callback(rb_fde_t *F, int status, void *data) /* pass my info to the new server */ send_capabilities(client_p, default_server_capabs | CAP_MASK - | (ServerConfCompressed(server_p) ? CAP_ZIP_SUPPORTED : 0) | (ServerConfTb(server_p) ? CAP_TB : 0)); sendto_one(client_p, "SERVER %s 1 :%s%s", diff --git a/ircd/sslproc.c b/ircd/sslproc.c index 42338de5..cb73b0e4 100644 --- a/ircd/sslproc.c +++ b/ircd/sslproc.c @@ -35,9 +35,6 @@ #include "packet.h" #include "certfp.h" -#define ZIPSTATS_TIME 60 - -static void collect_zipstats(void *unused); static void ssl_read_ctl(rb_fde_t * F, void *data); static int ssld_count; @@ -349,41 +346,6 @@ start_ssldaemon(int count) return started; } -static void -ssl_process_zipstats(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf) -{ - struct Client *server; - struct ZipStats *zips; - char *parv[6]; - int parc = rb_string_to_array(ctl_buf->buf, parv, sizeof(parv)); - - if (parc < sizeof(parv)) - return; - - server = find_server(NULL, parv[1]); - if(server == NULL || server->localClient == NULL || !IsCapable(server, CAP_ZIP)) - return; - if(server->localClient->zipstats == NULL) - server->localClient->zipstats = rb_malloc(sizeof(struct ZipStats)); - - zips = server->localClient->zipstats; - - zips->in += strtoull(parv[2], NULL, 10); - zips->in_wire += strtoull(parv[3], NULL, 10); - zips->out += strtoull(parv[4], NULL, 10); - zips->out_wire += strtoull(parv[5], NULL, 10); - - if(zips->in > 0) - zips->in_ratio = ((double) (zips->in - zips->in_wire) / (double) zips->in) * 100.00; - else - zips->in_ratio = 0; - - if(zips->out > 0) - zips->out_ratio = ((double) (zips->out - zips->out_wire) / (double) zips->out) * 100.00; - else - zips->out_ratio = 0; -} - static void ssl_process_open_fd(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf) { @@ -566,9 +528,6 @@ ssl_process_cmd_recv(ssl_ctl_t * ctl) case 'F': ssl_process_certfp(ctl, ctl_buf); break; - case 'S': - ssl_process_zipstats(ctl, ctl_buf); - break; case 'I': ircd_ssl_ok = false; ilog(L_MAIN, "%s", cannot_setup_ssl); @@ -852,126 +811,6 @@ ssld_decrement_clicount(ssl_ctl_t * ctl) } } -/* - * what we end up sending to the ssld process for ziplinks is the following - * Z[ourfd][level][RECVQ] - * Z = ziplinks command = buf[0] - * ourfd = Our end of the socketpair = buf[1..4] - * level = zip level buf[5] - * recvqlen = our recvq len = buf[6-7] - * recvq = any data we read prior to starting ziplinks - */ -void -start_zlib_session(void *data) -{ - struct Client *server = (struct Client *) data; - uint16_t recvqlen; - uint8_t level; - void *xbuf; - - rb_fde_t *F[2]; - rb_fde_t *xF1, *xF2; - char *buf; - void *recvq_start; - - size_t hdr = (sizeof(uint8_t) * 2) + sizeof(uint32_t); - size_t len; - int cpylen, left; - - server->localClient->event = NULL; - - recvqlen = rb_linebuf_len(&server->localClient->buf_recvq); - - len = recvqlen + hdr; - - if(len > READBUF_SIZE) - { - sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, - "ssld - attempted to pass message of %zd len, max len %d, giving up", - len, READBUF_SIZE); - ilog(L_MAIN, "ssld - attempted to pass message of %zd len, max len %d, giving up", len, READBUF_SIZE); - exit_client(server, server, server, "ssld readbuf exceeded"); - return; - } - - buf = rb_malloc(len); - level = ConfigFileEntry.compression_level; - - uint32_to_buf(&buf[1], rb_get_fd(server->localClient->F)); - buf[5] = (char) level; - - recvq_start = &buf[6]; - server->localClient->zipstats = rb_malloc(sizeof(struct ZipStats)); - - xbuf = recvq_start; - left = recvqlen; - - do - { - cpylen = rb_linebuf_get(&server->localClient->buf_recvq, xbuf, left, LINEBUF_PARTIAL, LINEBUF_RAW); - left -= cpylen; - xbuf = (void *) (((uintptr_t) xbuf) + cpylen); - } - while(cpylen > 0); - - /* Pass the socket to ssld. */ - *buf = 'Z'; - if(rb_socketpair(AF_UNIX, SOCK_STREAM, 0, &xF1, &xF2, "Initial zlib socketpairs") == -1) - { - sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Error creating zlib socketpair - %s", strerror(errno)); - ilog(L_MAIN, "Error creating zlib socketpairs - %s", strerror(errno)); - exit_client(server, server, server, "Error creating zlib socketpair"); - rb_free(buf); - return; - } - - F[0] = server->localClient->F; - F[1] = xF1; - server->localClient->F = xF2; - /* need to redo as what we did before isn't valid now */ - uint32_to_buf(&buf[1], connid_get(server)); - - server->localClient->z_ctl = which_ssld(); - if(!server->localClient->z_ctl) - { - exit_client(server, server, server, "Error finding available ssld"); - rb_free(buf); - return; - } - server->localClient->z_ctl->cli_count++; - ssl_cmd_write_queue(server->localClient->z_ctl, F, 2, buf, len); - rb_free(buf); -} - -static void -collect_zipstats(void *unused) -{ - rb_dlink_node *ptr; - struct Client *target_p; - char buf[sizeof(uint8_t) + sizeof(uint32_t) + HOSTLEN]; - void *odata; - size_t len; - uint32_t id; - - buf[0] = 'S'; - odata = buf + sizeof(uint8_t) + sizeof(uint32_t); - - RB_DLINK_FOREACH(ptr, serv_list.head) - { - target_p = ptr->data; - if(IsCapable(target_p, CAP_ZIP)) - { - len = sizeof(uint8_t) + sizeof(uint32_t); - - id = rb_get_fd(target_p->localClient->F); - uint32_to_buf(&buf[1], id); - rb_strlcpy(odata, target_p->name, (sizeof(buf) - len)); - len += strlen(odata) + 1; /* Get the \0 as well */ - ssl_cmd_write_queue(target_p->localClient->z_ctl, NULL, 0, buf, len); - } - } -} - static void cleanup_dead_ssl(void *unused) { @@ -1011,6 +850,5 @@ ssld_foreach_info(void (*func)(void *data, pid_t pid, int cli_count, enum ssld_s void init_ssld(void) { - rb_event_addish("collect_zipstats", collect_zipstats, NULL, ZIPSTATS_TIME); rb_event_addish("cleanup_dead_ssld", cleanup_dead_ssl, NULL, 60); } diff --git a/modules/m_stats.c b/modules/m_stats.c index d77791e5..0e974e26 100644 --- a/modules/m_stats.c +++ b/modules/m_stats.c @@ -127,7 +127,6 @@ static void stats_class(struct Client *); static void stats_memory(struct Client *); static void stats_servlinks(struct Client *); static void stats_ltrace(struct Client *, int, const char **); -static void stats_ziplinks(struct Client *); static void stats_comm(struct Client *); static void stats_capability(struct Client *); @@ -187,7 +186,6 @@ static struct stats_cmd stats_cmd_table[256] = { ['y'] = HANDLER_NORM(stats_class, false, NULL), ['Y'] = HANDLER_NORM(stats_class, false, NULL), ['z'] = HANDLER_NORM(stats_memory, false, "oper:general"), - ['Z'] = HANDLER_NORM(stats_ziplinks, false, "oper:general"), ['?'] = HANDLER_NORM(stats_servlinks, false, NULL), }; @@ -1396,38 +1394,6 @@ stats_memory (struct Client *source_p) (long)remote_client_memory_used); } -static void -stats_ziplinks (struct Client *source_p) -{ - rb_dlink_node *ptr; - struct Client *target_p; - struct ZipStats *zipstats; - int sent_data = 0; - char buf[128], buf1[128]; - RB_DLINK_FOREACH (ptr, serv_list.head) - { - target_p = ptr->data; - if(IsCapable (target_p, CAP_ZIP)) - { - zipstats = target_p->localClient->zipstats; - sprintf(buf, "%.2f%%", zipstats->out_ratio); - sprintf(buf1, "%.2f%%", zipstats->in_ratio); - sendto_one_numeric(source_p, RPL_STATSDEBUG, - "Z :ZipLinks stats for %s send[%s compression " - "(%llu kB data/%llu kB wire)] recv[%s compression " - "(%llu kB data/%llu kB wire)]", - target_p->name, - buf, zipstats->out >> 10, - zipstats->out_wire >> 10, buf1, - zipstats->in >> 10, zipstats->in_wire >> 10); - sent_data++; - } - } - - sendto_one_numeric(source_p, RPL_STATSDEBUG, - "Z :%u ziplink(s)", sent_data); -} - static void stats_servlinks (struct Client *source_p) { diff --git a/ssld/Makefile.am b/ssld/Makefile.am index 72837a2c..c5dad1d7 100644 --- a/ssld/Makefile.am +++ b/ssld/Makefile.am @@ -4,4 +4,4 @@ AM_CPPFLAGS = -I../include -I../librb/include ssld_SOURCES = ssld.c -ssld_LDADD = ../librb/src/librb.la @ZLIB_LD@ +ssld_LDADD = ../librb/src/librb.la diff --git a/ssld/ssld.c b/ssld/ssld.c index 1939260f..5c37a730 100644 --- a/ssld/ssld.c +++ b/ssld/ssld.c @@ -22,10 +22,6 @@ #include "stdinc.h" -#ifdef HAVE_LIBZ -#include -#endif - #define MAXPASSFD 4 #ifndef READBUF_SIZE #define READBUF_SIZE 16384 @@ -70,15 +66,6 @@ typedef struct _mod_ctl static mod_ctl_t *mod_ctl; - -#ifdef HAVE_LIBZ -typedef struct _zlib_stream -{ - z_stream instream; - z_stream outstream; -} zlib_stream_t; -#endif - typedef struct _conn { rb_dlink_node node; @@ -148,27 +135,9 @@ static void mod_cmd_write_queue(mod_ctl_t * ctl, const void *data, size_t len); static const char *remote_closed = "Remote host closed the connection"; static bool ssld_ssl_ok; static int certfp_method = RB_SSL_CERTFP_METH_CERT_SHA1; -#ifdef HAVE_LIBZ -static bool zlib_ok = true; -#else static bool zlib_ok = false; -#endif -#ifdef HAVE_LIBZ -static void * -ssld_alloc(void *unused, size_t count, size_t size) -{ - return rb_malloc(count * size); -} - -static void -ssld_free(void *unused, void *ptr) -{ - rb_free(ptr); -} -#endif - static conn_t * conn_find_by_id(uint32_t id) { @@ -196,15 +165,6 @@ free_conn(conn_t * conn) { rb_free_rawbuffer(conn->modbuf_out); rb_free_rawbuffer(conn->plainbuf_out); -#ifdef HAVE_LIBZ - if(IsZip(conn)) - { - zlib_stream_t *stream = conn->stream; - inflateEnd(&stream->instream); - deflateEnd(&stream->outstream); - rb_free(stream); - } -#endif rb_free(conn); } @@ -379,81 +339,6 @@ mod_cmd_write_queue(mod_ctl_t * ctl, const void *data, size_t len) mod_write_ctl(ctl->F, ctl); } -#ifdef HAVE_LIBZ -static void -common_zlib_deflate(conn_t * conn, void *buf, size_t len) -{ - char outbuf[READBUF_SIZE]; - int ret, have; - z_stream *outstream = &((zlib_stream_t *) conn->stream)->outstream; - outstream->next_in = buf; - outstream->avail_in = len; - outstream->next_out = (Bytef *) outbuf; - outstream->avail_out = sizeof(outbuf); - - ret = deflate(outstream, Z_SYNC_FLUSH); - if(ret != Z_OK) - { - /* deflate error */ - close_conn(conn, WAIT_PLAIN, "Deflate failed: %s", zError(ret)); - return; - } - if(outstream->avail_out == 0) - { - /* avail_out empty */ - close_conn(conn, WAIT_PLAIN, "error compressing data, avail_out == 0"); - return; - } - if(outstream->avail_in != 0) - { - /* avail_in isn't empty... */ - close_conn(conn, WAIT_PLAIN, "error compressing data, avail_in != 0"); - return; - } - have = sizeof(outbuf) - outstream->avail_out; - conn_mod_write(conn, outbuf, have); -} - -static void -common_zlib_inflate(conn_t * conn, void *buf, size_t len) -{ - char outbuf[READBUF_SIZE]; - int ret, have = 0; - ((zlib_stream_t *) conn->stream)->instream.next_in = buf; - ((zlib_stream_t *) conn->stream)->instream.avail_in = len; - ((zlib_stream_t *) conn->stream)->instream.next_out = (Bytef *) outbuf; - ((zlib_stream_t *) conn->stream)->instream.avail_out = sizeof(outbuf); - - while(((zlib_stream_t *) conn->stream)->instream.avail_in) - { - ret = inflate(&((zlib_stream_t *) conn->stream)->instream, Z_NO_FLUSH); - if(ret != Z_OK) - { - if(!strncmp("ERROR ", buf, 6)) - { - close_conn(conn, WAIT_PLAIN, "Received uncompressed ERROR"); - return; - } - close_conn(conn, WAIT_PLAIN, "Inflate failed: %s", zError(ret)); - return; - } - have = sizeof(outbuf) - ((zlib_stream_t *) conn->stream)->instream.avail_out; - - if(((zlib_stream_t *) conn->stream)->instream.avail_in) - { - conn_plain_write(conn, outbuf, have); - have = 0; - ((zlib_stream_t *) conn->stream)->instream.next_out = (Bytef *) outbuf; - ((zlib_stream_t *) conn->stream)->instream.avail_out = sizeof(outbuf); - } - } - if(have == 0) - return; - - conn_plain_write(conn, outbuf, have); -} -#endif - static bool plain_check_cork(conn_t * conn) { @@ -507,12 +392,7 @@ conn_plain_read_cb(rb_fde_t *fd, void *data) } conn->plain_in += length; -#ifdef HAVE_LIBZ - if(IsZip(conn)) - common_zlib_deflate(conn, inbuf, length); - else -#endif - conn_mod_write(conn, inbuf, length); + conn_mod_write(conn, inbuf, length); if(IsDead(conn)) return; if(plain_check_cork(conn)) @@ -605,12 +485,7 @@ conn_mod_read_cb(rb_fde_t *fd, void *data) return; } conn->mod_in += length; -#ifdef HAVE_LIBZ - if(IsZip(conn)) - common_zlib_inflate(conn, inbuf, length); - else -#endif - conn_plain_write(conn, inbuf, length); + conn_plain_write(conn, inbuf, length); } } @@ -832,65 +707,6 @@ process_stats(mod_ctl_t * ctl, mod_ctl_buf_t * ctlb) mod_cmd_write_queue(ctl, outstat, strlen(outstat) + 1); /* +1 is so we send the \0 as well */ } -#ifdef HAVE_LIBZ -static void -zlib_process(mod_ctl_t * ctl, mod_ctl_buf_t * ctlb) -{ - uint8_t level; - size_t recvqlen; - size_t hdr = (sizeof(uint8_t) * 2) + sizeof(uint32_t); - void *recvq_start; - z_stream *instream, *outstream; - conn_t *conn; - uint32_t id; - - conn = make_conn(ctl, ctlb->F[0], ctlb->F[1]); - if(rb_get_type(conn->mod_fd) == RB_FD_UNKNOWN) - rb_set_type(conn->mod_fd, RB_FD_SOCKET); - - if(rb_get_type(conn->plain_fd) == RB_FD_UNKNOWN) - rb_set_type(conn->plain_fd, RB_FD_SOCKET); - - id = buf_to_uint32(&ctlb->buf[1]); - conn_add_id_hash(conn, id); - - level = (uint8_t)ctlb->buf[5]; - - recvqlen = ctlb->buflen - hdr; - recvq_start = &ctlb->buf[6]; - - SetZip(conn); - conn->stream = rb_malloc(sizeof(zlib_stream_t)); - instream = &((zlib_stream_t *) conn->stream)->instream; - outstream = &((zlib_stream_t *) conn->stream)->outstream; - - instream->total_in = 0; - instream->total_out = 0; - instream->zalloc = (alloc_func) ssld_alloc; - instream->zfree = (free_func) ssld_free; - instream->data_type = Z_ASCII; - inflateInit(&((zlib_stream_t *) conn->stream)->instream); - - outstream->total_in = 0; - outstream->total_out = 0; - outstream->zalloc = (alloc_func) ssld_alloc; - outstream->zfree = (free_func) ssld_free; - outstream->data_type = Z_ASCII; - - if(level > 9) - level = (uint8_t) Z_DEFAULT_COMPRESSION; - - deflateInit(&((zlib_stream_t *) conn->stream)->outstream, level); - if(recvqlen > 0) - common_zlib_inflate(conn, recvq_start, recvqlen); - - conn_mod_read_cb(conn->mod_fd, conn); - conn_plain_read_cb(conn->plain_fd, conn); - return; - -} -#endif - static void ssl_new_keys(mod_ctl_t * ctl, mod_ctl_buf_t * ctl_buf) { @@ -1038,26 +854,10 @@ mod_process_cmd_recv(mod_ctl_t * ctl) break; } -#ifdef HAVE_LIBZ - case 'Z': - { - if (ctl_buf->nfds != 2 || ctl_buf->buflen < 6) - { - cleanup_bad_message(ctl, ctl_buf); - break; - } - - /* just zlib only */ - zlib_process(ctl, ctl_buf); - break; - } -#else - case 'Z': send_nozlib_support(ctl, ctl_buf); break; -#endif default: break; /* Log unknown commands */