From 723775f1f93cf6b753b03a192dcb47899944c878 Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Tue, 24 May 2011 18:55:33 +0200 Subject: [PATCH] provide autodetect when libpsyc is available --- src/comm.c | 17 +++++++++++------ src/comm.h | 2 +- src/pkg-tls.c | 6 ++++-- src/version.sh | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/comm.c b/src/comm.c index 4d03387..4fe277b 100644 --- a/src/comm.c +++ b/src/comm.c @@ -3187,8 +3187,9 @@ get_message (char *buff, size_t *len) inet_volume_in += l; #endif - // If we're receiving the first bytes call a peek function - // which could enable_binary depending on the content of the buffer +#ifdef HAS_PSYC + // If we're receiving the first bytes call a peek function which + // could enable_binary depending on the content of the buffer // We only need this until we give up the old PSYC syntax. if (!ip->connected) { put_c_n_string(++inter_sp, ip->text, l); @@ -3197,7 +3198,7 @@ get_message (char *buff, size_t *len) sapply(new_tabled("connection_peek"), ip->ob, 1); ip->connected = MY_TRUE; } - +#endif /* Experimental support for * binary data streams, by fippo 2008 */ @@ -4012,8 +4013,12 @@ new_player ( object_t *ob, SOCKET_T new_socket new_interactive->tls_status = TLS_INACTIVE; new_interactive->tls_session = NULL; new_interactive->tls_cb = NULL; -# ifdef USE_EXPERIMENTAL - new_interactive->tls_autodetect = ob == NULL? 9 : 0; /* give tls 9 seconds to start */ +# ifdef HAS_PSYC + /* give TLS 4 seconds to start. in fact even 1 second should + * be enough as the TLS init packet is sent immediately with + * the TCP 3-way handshake completion. + */ + new_interactive->tls_autodetect = ob == NULL? 4 : 0; # endif new_interactive->tls_want_peer_cert = MY_FALSE; #endif @@ -4543,7 +4548,7 @@ call_function_interactive (interactive_t *i, char *str, size_t len) /* Call the input_to() function with the newly input string */ -#ifdef USE_EXPERIMENTAL +#ifdef HAS_PSYC // enable_binary i suppose if (len == 0) { push_c_string(inter_sp, str); } else { diff --git a/src/comm.h b/src/comm.h index 3623c8e..6dcbf69 100644 --- a/src/comm.h +++ b/src/comm.h @@ -290,7 +290,7 @@ struct interactive_s { # define TLS_ACTIVE 2 /* Session is secure */ # define TLS_BROKEN 3 /* Error has occurred */ CBool tls_want_peer_cert; -# ifdef USE_EXPERIMENTAL +# ifdef HAS_PSYC int tls_autodetect; # endif callback_t *tls_cb; diff --git a/src/pkg-tls.c b/src/pkg-tls.c index 94a3761..41a74b5 100644 --- a/src/pkg-tls.c +++ b/src/pkg-tls.c @@ -12,6 +12,8 @@ #ifdef USE_TLS +/* #define DEBUG **/ + #include #if defined(HAS_OPENSSL) @@ -802,7 +804,7 @@ tls_continue_handshake (interactive_t *ip) return 1; #endif #ifdef HAS_OPENSSL -# ifdef USE_EXPERIMENTAL +# ifdef HAS_PSYC /* detect non-tls data on a tls connection * heuristic taken from jabberds jadc2s */ @@ -1445,7 +1447,7 @@ f_tls_error(svalue_t *sp) const char *text; int err = sp->u.number; -#ifdef USE_EXPERIMENTAL +#ifdef HAS_PSYC if (err == ERR_TLS_NOT_DETECTED) text = "Unencrypted connection detected"; else #endif diff --git a/src/version.sh b/src/version.sh index af13df4..d76d070 100644 --- a/src/version.sh +++ b/src/version.sh @@ -17,7 +17,7 @@ version_longtype="stable" # A timestamp, to be used by bumpversion and other scripts. # It can be used, for example, to 'touch' this file on every build, thus # forcing revision control systems to add it on every checkin automatically. -version_stamp="Tue May 24 16:27:09 CEST 2011" +version_stamp="Tue May 24 18:47:17 CEST 2011" # Okay, LDMUD is using 3.x.x so to avoid conflicts let's just use 4.x.x version_major=4