Author Topic: patch for fluffos 2.21  (Read 1735 times)

Offline yeik

  • Acquaintance
  • *
  • Posts: 18
    • View Profile
patch for fluffos 2.21
« on: February 10, 2011, 12:26:30 am »
I have created a patch for fluffos 2.21-ds01 that will properly turn off compression if the compression is on and the client sends DONT TELOPT_COMPRESS/TELOPT_COMPRESS2
I have tested it in cmud 3.32 enabling and disabling the compression. optionally you could remove the  telnet_compress_send_request_v2 or add  telnet_compress_send_request_v1 to be sent if the telopt_compress is received (ie if there is a bug in the compression and want to try restarting it on the client, giving them the option)

this is the first time i have done a patch, so any feedback would be great.

Thanks and enjoy


Code: [Select]
*** ../comm.c 2011-02-09 22:15:06.086291001 -0700
--- comm.c 2011-02-09 22:13:40.878291000 -0700
***************
*** 139,144 ****
--- 139,145 ----
  static void end_compression (interactive_t *);
  static void start_compression (interactive_t *);
  static int send_compressed (interactive_t *ip, unsigned char* data, int length);
+ static int flush_compressed_output (interactive_t *ip);
 
 
  #ifdef NO_SNOOP
***************
*** 1114,1122 ****
  #ifdef HAVE_ZLIB
                      case TELOPT_COMPRESS2:
                          // If we are told not to use v2, then try v1.
                          add_binary_message(ip->ob, telnet_compress_send_request_v1,
                                      sizeof(telnet_compress_send_request_v1));
!                         break;
  #endif
                  }
                  ip->state = TS_DATA;
--- 1115,1136 ----
  #ifdef HAVE_ZLIB
                      case TELOPT_COMPRESS2:
                          // If we are told not to use v2, then try v1.
+          if (ip->compressed_stream)
+ {
+ end_compression(ip);
+ add_binary_message(ip->ob, telnet_compress_send_request_v2,
+ sizeof(telnet_compress_send_request_v2));
+ break;
+ }
                          add_binary_message(ip->ob, telnet_compress_send_request_v1,
                                      sizeof(telnet_compress_send_request_v1));
!                          break;
!     case TELOPT_COMPRESS:
! if(ip->compressed_stream)
! {
! end_compression(ip);
! }
! break;
  #endif
                  }
                  ip->state = TS_DATA;
***************
*** 3166,3172 ****
 
      if (deflate(ip->compressed_stream, Z_FINISH) != Z_STREAM_END) {
      }
!
      deflateEnd(ip->compressed_stream);
      FREE(ip->compressed_stream);
      ip->compressed_stream = NULL;
--- 3180,3186 ----
 
      if (deflate(ip->compressed_stream, Z_FINISH) != Z_STREAM_END) {
      }
!     flush_compressed_output(ip);
      deflateEnd(ip->compressed_stream);
      FREE(ip->compressed_stream);
      ip->compressed_stream = NULL;

« Last Edit: February 10, 2011, 12:28:34 am by yeik »