From 069a3b66ae55e812e05e0b15dea469c36f37db22 Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Tue, 24 May 2011 18:54:56 +0200 Subject: [PATCH] expect TLS autodetect only when libpsyc is compiled in (fixes alice' dot bug) --- CHANGESTODO | 12 +++++++----- world/drivers/ldmud/master/accept.c | 23 +++++++++++++---------- world/drivers/ldmud/master/master.c | 11 ++++------- world/net/group/slave.c | 6 +++--- world/net/psyc/parse.i | 19 ++++++------------- world/net/spyc/parse.c | 6 ++++++ 6 files changed, 39 insertions(+), 38 deletions(-) diff --git a/CHANGESTODO b/CHANGESTODO index 629bd2e..a53834b 100644 --- a/CHANGESTODO +++ b/CHANGESTODO @@ -118,10 +118,10 @@ ________________________________________________________________________ == psyced 1.0 ========================================================== ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ > SPYC -- net/spyc is buggy and incomplete - (implementation of http://about.psyc.eu/Specification) -_ to activate spyc support, defined USE_SPYC - it will attempt to use new syntax on outgoing links by default +- net/spyc depends on libpsyc being compiled into the driver + if it is available, it will be activated passively +- #define USE_SPYC if you want outgoing connections to require libpsyc + _ to debug verification, define USE_VERIFICATION _ to spend an extra round trip time negotiating, define USE_FEATURES @@ -3927,4 +3927,6 @@ net/person * removed interesting but unrecoverable FORK code * unlink detection rewrite and other fixes in client linking code edit.i now renamed into render.i because it renders psyc packets - +=== 201105 ============================================================ +net/spyc net/psyc + tg added support for libpsyc aka PSYC syntax according to spec! diff --git a/world/drivers/ldmud/master/accept.c b/world/drivers/ldmud/master/accept.c index 68bfbe0..11b96c1 100644 --- a/world/drivers/ldmud/master/accept.c +++ b/world/drivers/ldmud/master/accept.c @@ -17,10 +17,12 @@ #include DRIVER_PATH "sys/tls.h" -#ifndef ERR_TLS_NOT_DETECTED -# define ERR_TLS_NOT_DETECTED -31337 +#if __EFUN_DEFINED__(psyc_parse) +# define AUTODETECT 1 // use TLS autodetect if libpsyc is available +#else +# define AUTODETECT 0 # ifdef SPYC_PATH -# echo Warning: TLS autodetect is not enabled in driver. +# echo PSYC 1.0 will not work: libpsyc is not enabled in driver. # endif #endif @@ -70,7 +72,7 @@ object connect(int uid, int port, string service) { // we dont want the telnet machine most of the time // but disabling and re-enabling it for telnet doesn't work switch(port || query_mud_port()) { -#if HAS_PORT(PSYC_PORT, PSYC_PATH) +#if HAS_PORT(PSYC_PORT, PSYC_PATH) && AUTODETECT case PSYC_PORT: #endif #if HAS_PORT(PSYCS_PORT, PSYC_PATH) @@ -86,6 +88,9 @@ object connect(int uid, int port, string service) { } } #endif // fall thru +#if HAS_PORT(PSYC_PORT, PSYC_PATH) &&! AUTODETECT + case PSYC_PORT: +#endif #if HAS_PORT(PSYC_PORT, PSYC_PATH) || HAS_PORT(PSYCS_PORT, PSYC_PATH) # ifdef DRIVER_HAS_CALL_BY_REFERENCE arg = ME; @@ -112,6 +117,7 @@ object connect(int uid, int port, string service) { return t -> load(query_ip_number(), -peerport); #endif +// dedicated SPYC port.. should not be used, we have AUTODETECT #if HAS_PORT(SPYCS_PORT, SPYC_PATH) case SPYCS_PORT: // interim name for PSYC 1.0 according to SPEC # if __EFUN_DEFINED__(tls_want_peer_certificate) @@ -260,7 +266,7 @@ object connect(int uid, int port, string service) { return clone_object(IRC_PATH "server"); #endif #if HAS_PORT(IRC_PORT, IRC_PATH) - case IRC_PORT: + case IRC_PORT: // we could enable AUTODETECT for this.. # if 0 // __EFUN_DEFINED__(enable_telnet) enable_telnet(0); // shouldn't harm.. but it does!!! # endif @@ -285,11 +291,8 @@ object connect(int uid, int port, string service) { return clone_object(TELNET_PATH "server"); #endif #if HAS_PORT(TELNET_PORT, TELNET_PATH) - case TELNET_PORT: + case TELNET_PORT: // we could enable AUTODETECT for this.. (wait 4s) // set_prompt("> "); - // we can't do the usual autodetect here, as telnet users - // don't send first and rather expect the server to prompt - // the correct way to do this: implement telnet nego for tls. bah! t = clone_object(TELNET_PATH "server"); # ifdef UID2NICK if (uid && (arg = UID2NICK(uid))) { t -> sName(arg); } @@ -314,7 +317,7 @@ object connect(int uid, int port, string service) { #endif /* don't fall thru. allow for https: to be available without http: */ #if HAS_PORT(HTTP_PORT, HTTP_PATH) - case HTTP_PORT: + case HTTP_PORT: // AUTODETECT on the HTTP port? we could do that too return clone_object(HTTP_PATH "server"); #endif diff --git a/world/drivers/ldmud/master/master.c b/world/drivers/ldmud/master/master.c index 459140b..87c53e8 100644 --- a/world/drivers/ldmud/master/master.c +++ b/world/drivers/ldmud/master/master.c @@ -205,13 +205,6 @@ void disconnect(object ob, string remaining) { " with "+ strlen(remaining) +" bytes remaining" : "")) } -// even though the name of the function is weird, this is the -// place where UDP messages arrive -// -// how to multiplex InterMUD and PSYC on the same udp port: -// PSYC UDP packets always start with ".\n", just forward them to -// the PSYC UDP server daemon. -// volatile object psycd; #ifdef SPYC_PATH volatile object spycd; @@ -223,6 +216,9 @@ volatile object sipd; void receive_udp(string host, string msg, int port) { if (strlen(msg) > 1 && msg[1] == '\n') switch(msg[0]) { #ifdef SPYC_PATH +# if !__EFUN_DEFINED__(psyc_parse) +# echo New PSYC syntax will not work: Driver compiled without libpsyc! +# else case '|': unless (spycd) { spycd = SPYC_PATH "udp" -> load(); @@ -231,6 +227,7 @@ void receive_udp(string host, string msg, int port) { } spycd -> parseUDP(host, port, msg); return; +# endif #endif case '.': unless (psycd) { diff --git a/world/net/group/slave.c b/world/net/group/slave.c index 6d1c89e..3554f6d 100644 --- a/world/net/group/slave.c +++ b/world/net/group/slave.c @@ -35,7 +35,7 @@ private volatile mapping temp_state; inherit NET_PATH "state"; #endif -#ifdef USE_SPYC +#if __EFUN_DEFINED__(psyc_parse) mapping _state; // should probably merge with ifdef CONTEXT_STATE.. #endif @@ -47,7 +47,7 @@ void create() { unless(mappingp(cast_state)) cast_state = ([ ]); unless(mappingp(temp_state)) temp_state = ([ ]); #endif -#ifdef USE_SPYC +#if __EFUN_DEFINED__(psyc_parse) unless(mappingp(_state)) _state = ([ ]); #endif } @@ -273,7 +273,7 @@ void Diminish(mixed source, string key, mixed value) { #endif // }}} -#ifdef USE_SPYC +#if __EFUN_DEFINED__(psyc_parse) get_state() { PT(("cstate for %O picked up by %O: %O\n", ME, previous_object(), _state)) diff --git a/world/net/psyc/parse.i b/world/net/psyc/parse.i index 4a85c2b..9e7038e 100644 --- a/world/net/psyc/parse.i +++ b/world/net/psyc/parse.i @@ -1113,23 +1113,17 @@ protected int deliver(mixed ip, string host, string mc, string buffer, mapping c return 1; } +#if __EFUN_DEFINED__(psyc_parse) // temporary new "lfun" called from driver's comm.c to peek into new connection +// only exists if libpsyc is provided void connection_peek(string data) { P4((">> peek: %O\n", data)); -#ifdef USE_SPYC -# if !__EFUN_DEFINED__(psyc_parse) -# echo New PSYC syntax will not work: Driver compiled without libpsyc! -# endif + if (data[0] == C_GLYPH_NEW_PACKET_DELIMITER) { -# if __EFUN_DEFINED__(enable_binary) - enable_binary(ME); -# else -# echo New PSYC syntax will not work: Driver compiled without enable_binary! - raise_error("Driver compiled without enable_binary()"); -# endif + enable_binary(ME); } -#endif } +#endif #ifdef PSYC_TCP vamixed startParse(string a) { @@ -1137,8 +1131,7 @@ vamixed startParse(string a) { restart(); if (isServer()) greet(); } -// new syntax is so broken, we should not pretend to support it yet FIXME -# if defined(SPYC_PATH) && defined(USE_SPYC) +# if defined(SPYC_PATH) && __EFUN_DEFINED__(psyc_parse) else if (a[0] == C_GLYPH_NEW_PACKET_DELIMITER) { object o = clone_object(SPYC_PATH "server"); unless (o && exec(o, ME) && o->logon(0)) { diff --git a/world/net/spyc/parse.c b/world/net/spyc/parse.c index dc0eda7..b2fa658 100644 --- a/world/net/spyc/parse.c +++ b/world/net/spyc/parse.c @@ -86,6 +86,12 @@ void dispatch(mapping rvars, mapping evars, mixed method, mixed body) { } void psyc_dispatch(mixed p) { + if (p[PACKET_METHOD][0] != '_') { + log_file("SPYC", "%O SYNTAX %O\n", query_ip_name(), p); + croak("_error_invalid_method_compact", + "Compact methods undefined as yet."); + QUIT + } dispatch(p[PACKET_ROUTING], p[PACKET_ENTITY], p[PACKET_METHOD], p[PACKET_BODY]); }