Compress all instructions (closes #19 github issue)
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2012-02-26 Keith Winstein <mosh-devel@mit.edu>
|
||||||
|
|
||||||
|
* Version 0.96 released.
|
||||||
|
|
||||||
|
* Compress all instructions with zlib
|
||||||
|
|
||||||
2012-02-25 Keith Winstein <mosh-devel@mit.edu>
|
2012-02-25 Keith Winstein <mosh-devel@mit.edu>
|
||||||
|
|
||||||
* Version 0.95 released.
|
* Version 0.95 released.
|
||||||
|
|||||||
+2
-1
@@ -2,7 +2,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ([2.65])
|
AC_PREREQ([2.65])
|
||||||
AC_INIT([mosh], [0.95], [mosh-devel@mit.edu])
|
AC_INIT([mosh], [0.96], [mosh-devel@mit.edu])
|
||||||
AM_INIT_AUTOMAKE([-Wall -Werror])
|
AM_INIT_AUTOMAKE([-Wall -Werror])
|
||||||
AC_CONFIG_SRCDIR([src/frontend/mosh-client.cc])
|
AC_CONFIG_SRCDIR([src/frontend/mosh-client.cc])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
@@ -41,6 +41,7 @@ AC_CHECK_FUNCS([clock_gettime gettimeofday inet_ntoa iswprint memchr memset nl_l
|
|||||||
|
|
||||||
# Checks for protobuf
|
# Checks for protobuf
|
||||||
PKG_CHECK_MODULES([protobuf], [protobuf])
|
PKG_CHECK_MODULES([protobuf], [protobuf])
|
||||||
|
PKG_CHECK_MODULES([zlib], [zlib])
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile src/Makefile src/crypto/Makefile src/frontend/Makefile src/network/Makefile src/protobufs/Makefile src/statesync/Makefile src/terminal/Makefile src/util/Makefile scripts/Makefile src/examples/Makefile man/Makefile])
|
AC_CONFIG_FILES([Makefile src/Makefile src/crypto/Makefile src/frontend/Makefile src/network/Makefile src/protobufs/Makefile src/statesync/Makefile src/terminal/Makefile src/util/Makefile scripts/Makefile src/examples/Makefile man/Makefile])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
Vendored
+8
@@ -1,3 +1,11 @@
|
|||||||
|
mosh (0.96-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* Version 0.96 released.
|
||||||
|
|
||||||
|
* Compress all instructions with zlib
|
||||||
|
|
||||||
|
-- Keith Winstein <keithw@mit.edu> Sun, 26 Feb 2012 04:40:46 -0500
|
||||||
|
|
||||||
mosh (0.95-1) unstable; urgency=low
|
mosh (0.95-1) unstable; urgency=low
|
||||||
|
|
||||||
* Version 0.95 released.
|
* Version 0.95 released.
|
||||||
|
|||||||
@@ -3,4 +3,4 @@ AM_CXXFLAGS = -pedantic -Wno-long-long -Werror -Wall -Wextra -Weffc++ -fno-defau
|
|||||||
|
|
||||||
noinst_LIBRARIES = libmoshnetwork.a
|
noinst_LIBRARIES = libmoshnetwork.a
|
||||||
|
|
||||||
libmoshnetwork_a_SOURCES = network.cc network.h networktransport.cc networktransport.h transportfragment.cc transportfragment.h transportsender.cc transportsender.h transportstate.h
|
libmoshnetwork_a_SOURCES = network.cc network.h networktransport.cc networktransport.h transportfragment.cc transportfragment.h transportsender.cc transportsender.h transportstate.h compressor.cc compressor.h
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#include <zlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "compressor.h"
|
||||||
|
|
||||||
|
using namespace Network;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
string Compressor::compress_str( const string input )
|
||||||
|
{
|
||||||
|
size_t len = BUFFER_SIZE;
|
||||||
|
assert( Z_OK == compress( buffer, &len,
|
||||||
|
reinterpret_cast<const unsigned char *>( input.data() ),
|
||||||
|
input.size() ) );
|
||||||
|
return string( reinterpret_cast<char *>( buffer ), len );
|
||||||
|
}
|
||||||
|
|
||||||
|
string Compressor::uncompress_str( const string input )
|
||||||
|
{
|
||||||
|
size_t len = BUFFER_SIZE;
|
||||||
|
assert( Z_OK == uncompress( buffer, &len,
|
||||||
|
reinterpret_cast<const unsigned char *>( input.data() ),
|
||||||
|
input.size() ) );
|
||||||
|
return string( reinterpret_cast<char *>( buffer ), len );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* construct on first use */
|
||||||
|
Compressor & Network::get_compressor( void )
|
||||||
|
{
|
||||||
|
static Compressor the_compressor;
|
||||||
|
return the_compressor;
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef COMPRESSOR_H
|
||||||
|
#define COMPRESSOR_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Network {
|
||||||
|
class Compressor {
|
||||||
|
private:
|
||||||
|
static const int BUFFER_SIZE = 2048 * 2048; /* effective limit on terminal size */
|
||||||
|
|
||||||
|
unsigned char *buffer;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Compressor() : buffer( NULL ) { buffer = new unsigned char[ BUFFER_SIZE ]; }
|
||||||
|
~Compressor() { if ( buffer ) { delete[] buffer; } }
|
||||||
|
|
||||||
|
std::string compress_str( const std::string input );
|
||||||
|
std::string uncompress_str( const std::string input );
|
||||||
|
|
||||||
|
/* unused */
|
||||||
|
Compressor( const Compressor & );
|
||||||
|
Compressor & operator=( const Compressor & );
|
||||||
|
};
|
||||||
|
|
||||||
|
Compressor & get_compressor( void );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "transportfragment.h"
|
#include "transportfragment.h"
|
||||||
#include "transportinstruction.pb.h"
|
#include "transportinstruction.pb.h"
|
||||||
|
#include "compressor.h"
|
||||||
|
|
||||||
using namespace Network;
|
using namespace Network;
|
||||||
using namespace TransportBuffers;
|
using namespace TransportBuffers;
|
||||||
@@ -121,7 +122,7 @@ Instruction FragmentAssembly::get_assembly( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
Instruction ret;
|
Instruction ret;
|
||||||
assert( ret.ParseFromString( encoded ) );
|
assert( ret.ParseFromString( get_compressor().uncompress_str( encoded ) ) );
|
||||||
|
|
||||||
fragments.clear();
|
fragments.clear();
|
||||||
fragments_arrived = 0;
|
fragments_arrived = 0;
|
||||||
@@ -155,7 +156,7 @@ vector<Fragment> Fragmenter::make_fragments( const Instruction &inst, int MTU )
|
|||||||
last_instruction = inst;
|
last_instruction = inst;
|
||||||
last_MTU = MTU;
|
last_MTU = MTU;
|
||||||
|
|
||||||
string payload = inst.SerializeAsString();
|
string payload = get_compressor().compress_str( inst.SerializeAsString() );
|
||||||
uint16_t fragment_num = 0;
|
uint16_t fragment_num = 0;
|
||||||
vector<Fragment> ret;
|
vector<Fragment> ret;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user