#! /bin/sh /usr/share/dpatch/dpatch-run ## s2s_compression.dpatch by Norman Rasmussen ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Add support for s2s compression @DPATCH@ diff -urNad jabberd2-2.2.7~/etc/s2s.xml.dist.in jabberd2-2.2.7/etc/s2s.xml.dist.in --- jabberd2-2.2.7~/etc/s2s.xml.dist.in 2009-02-28 23:42:59.000000000 +0200 +++ jabberd2-2.2.7/etc/s2s.xml.dist.in 2009-02-28 23:43:00.000000000 +0200 @@ -160,6 +160,11 @@ 65535 + + + diff -urNad jabberd2-2.2.7~/s2s/in.c jabberd2-2.2.7/s2s/in.c --- jabberd2-2.2.7~/s2s/in.c 2009-02-17 11:29:05.000000000 +0200 +++ jabberd2-2.2.7/s2s/in.c 2009-02-28 23:45:40.000000000 +0200 @@ -64,7 +64,7 @@ conn_t in = (conn_t) arg; s2s_t s2s = (s2s_t) arg; struct sockaddr_storage sa; - int namelen = sizeof(sa), port, nbytes; + int namelen = sizeof(sa), port, nbytes, flags = 0; char ipport[INET6_ADDRSTRLEN + 17]; switch(a) { @@ -138,11 +138,16 @@ snprintf(ipport, INET6_ADDRSTRLEN + 16, "%s/%d", in->ip, in->port); xhash_put(s2s->in_accept, pstrdup(xhash_pool(s2s->in_accept),ipport), (void *) in); + flags = S2S_DB_HEADER; #ifdef HAVE_SSL - sx_server_init(in->s, S2S_DB_HEADER | ((s2s->sx_ssl != NULL) ? SX_SSL_STARTTLS_OFFER : 0) ); -#else - sx_server_init(in->s, S2S_DB_HEADER); + if(s2s->sx_ssl != NULL) + flags |= SX_SSL_STARTTLS_OFFER; +#endif +#ifdef HAVE_LIBZ + if(s2s->compression) + flags |= SX_COMPRESS_OFFER; #endif + sx_server_init(in->s, flags); break; } diff -urNad jabberd2-2.2.7~/s2s/main.c jabberd2-2.2.7/s2s/main.c --- jabberd2-2.2.7~/s2s/main.c 2009-02-28 23:42:20.000000000 +0200 +++ jabberd2-2.2.7/s2s/main.c 2009-02-28 23:43:00.000000000 +0200 @@ -150,6 +150,8 @@ s2s->io_max_fds = j_atoi(config_get_one(s2s->config, "io.max_fds", 0), 1024); + s2s->compression = (config_get(s2s->config, "io.compression") != NULL); + s2s->stanza_size_limit = j_atoi(config_get_one(s2s->config, "io.limits.stanzasize", 0), 0); s2s->check_interval = j_atoi(config_get_one(s2s->config, "check.interval", 0), 60); @@ -711,6 +713,12 @@ } #endif +#ifdef HAVE_LIBZ + /* get compression up and running */ + if(s2s->compression) + sx_env_plugin(s2s->sx_env, sx_compress_init); +#endif + /* get sasl online */ s2s->sx_sasl = sx_env_plugin(s2s->sx_env, sx_sasl_init, "xmpp", NULL, NULL); if(s2s->sx_sasl == NULL) { diff -urNad jabberd2-2.2.7~/s2s/out.c jabberd2-2.2.7/s2s/out.c --- jabberd2-2.2.7~/s2s/out.c 2009-02-28 23:42:20.000000000 +0200 +++ jabberd2-2.2.7/s2s/out.c 2009-02-28 23:43:00.000000000 +0200 @@ -1536,7 +1536,7 @@ /* key is valid */ if(nad_find_attr(nad, 0, -1, "type", "valid") >= 0) { - log_write(out->s2s->log, LOG_NOTICE, "[%d] [%s, port=%d] outgoing route '%s' is now valid%s", out->fd->fd, out->ip, out->port, rkey, (out->s->flags & SX_SSL_WRAPPER) ? ", TLS negotiated" : ""); + log_write(out->s2s->log, LOG_NOTICE, "[%d] [%s, port=%d] outgoing route '%s' is now valid%s%s", out->fd->fd, out->ip, out->port, rkey, (out->s->flags & SX_SSL_WRAPPER) ? ", TLS negotiated" : "", out->s->compressed ? ", ZLIB compression enabled" : ""); xhash_put(out->states, pstrdup(xhash_pool(out->states), rkey), (void *) conn_VALID); /* !!! small leak here */ @@ -1625,7 +1625,7 @@ attr = nad_find_attr(nad, 0, -1, "type", "valid"); if(attr >= 0) { xhash_put(in->states, pstrdup(xhash_pool(in->states), rkey), (void *) conn_VALID); - log_write(in->s2s->log, LOG_NOTICE, "[%d] [%s, port=%d] incoming route '%s' is now valid%s", in->fd->fd, in->ip, in->port, rkey, (in->s->flags & SX_SSL_WRAPPER) ? ", TLS negotiated" : ""); + log_write(in->s2s->log, LOG_NOTICE, "[%d] [%s, port=%d] incoming route '%s' is now valid%s%s", in->fd->fd, in->ip, in->port, rkey, (in->s->flags & SX_SSL_WRAPPER) ? ", TLS negotiated" : "", in->s->compressed ? ", ZLIB compression enabled" : ""); valid = 1; } else { log_write(in->s2s->log, LOG_NOTICE, "[%d] [%s, port=%d] incoming route '%s' is now invalid", in->fd->fd, in->ip, in->port, rkey); diff -urNad jabberd2-2.2.7~/s2s/s2s.h jabberd2-2.2.7/s2s/s2s.h --- jabberd2-2.2.7~/s2s/s2s.h 2009-02-28 23:42:20.000000000 +0200 +++ jabberd2-2.2.7/s2s/s2s.h 2009-02-28 23:43:00.000000000 +0200 @@ -131,6 +131,9 @@ /** max file descriptors */ int io_max_fds; + /** enable Stream Compression */ + int compression; + /** maximum stanza size */ int stanza_size_limit;