expect TLS autodetect only when libpsyc is compiled in (fixes alice' dot bug)

This commit is contained in:
psyc://psyced.org/~lynX 2011-05-24 18:54:56 +02:00
parent 47232884b9
commit 069a3b66ae
6 changed files with 39 additions and 38 deletions

View File

@ -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!

View File

@ -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

View File

@ -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) {

View File

@ -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))

View File

@ -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
}
#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)) {

View File

@ -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]);
}