1
0
Fork 0
mirror of git://git.psyced.org/git/psyced synced 2024-08-15 03:25:10 +00:00

things that happened in 2008

This commit is contained in:
psyc://psyced.org/~lynX 2009-01-26 21:12:53 +01:00
parent 8f98522570
commit 94530cc322
136 changed files with 3222 additions and 2873 deletions

View file

@ -1,4 +1,4 @@
// $Id: interface.h,v 1.51 2008/04/09 16:49:23 lynx Exp $ // vim:syntax=lpc:ts=8
// $Id: interface.h,v 1.54 2008/08/26 13:42:24 lynx Exp $ // vim:syntax=lpc:ts=8
#define _INCLUDE_INTERFACE_H
// let's stay compatible for a while
@ -8,10 +8,12 @@
# define SAVE_FORMAT 0
//#endif
#ifdef __psyclpc__
# define DRIVER_VERSION "psyclpc/" __VERSION__
#else
#ifndef __psyclpc__
# define DRIVER_VERSION "ldmud/" __VERSION__
#else
# define DRIVER_VERSION "psyclpc/" __VERSION__
# define hex2int(HEX) to_int("0x"+ HEX)
#endif
// driver abstraction kit -- abstraction layer from driver details
@ -114,6 +116,14 @@
#define vamixed mixed
#define vaint int
// extracts hh:mm:ss format from ctime output
#define hhmmss(CTIME) CTIME[11..18]
// extracts hh:mm format from ctime output (for idle times)
#define hhmm(CTIME) CTIME[11..15]
// typical timestamp string: hhmm or iso-date if older than 24 hours
#define time_or_date(TS) \
(time() - TS > 24*60*60 ? isotime(TS, 0) : hhmm(ctime( TS )))
#if __EFUN_DEFINED__(convert_charset)
# ifdef TRANSLIT // TRANSLIT has no effect whatsoever. grrr!
# define iconv(s, FROM, TO) (s = convert_charset(s, FROM, TO +"//TRANSLIT"))
@ -140,3 +150,9 @@
# define DEBUG_TRACE "(DEBUG_TRACE disabled: DEBUG level below 1)"
# endif
#endif
// some ldmud versions previous to 610 have a problem with digest-md5
#if __VERSION_MAJOR__ < 4 && __VERSION_MICRO__ < 611
# echo Warning: Your driver is so old, it cannot do DIGEST-MD5
# define _flag_disable_authentication_digest_MD5
#endif

View file

@ -1,4 +1,4 @@
// $Id: master.c,v 1.61 2008/03/11 16:15:15 lynx Exp $ // vim:syntax=lpc:ts=8
// $Id: master.c,v 1.66 2008/07/20 21:26:04 lynx Exp $ // vim:syntax=lpc:ts=8
//
#ifdef INIT_FILE
#undef INIT_FILE
@ -11,6 +11,12 @@ mixed valid_write(string path, string eff_user, string call, object caller);
// bei amylaar und ldmud braucht master.c den absoluten pfad..
#include "/local/config.h"
#ifdef Dmaster
# undef DEBUG
# define DEBUG Dmaster
#endif
#include NET_PATH "include/net.h"
#include DRIVER_PATH "sys/driver_hook.h"
#include DRIVER_PATH "sys/debug_message.h"
@ -19,7 +25,7 @@ mixed valid_write(string path, string eff_user, string call, object caller);
#ifdef PRO_PATH
inherit PRO_PATH "master";
#else
# include DRIVER_PATH "master/psycmuve.i"
inherit DRIVER_PATH "master/accept";
#endif
#include DRIVER_PATH "master/classic.i"
@ -177,23 +183,26 @@ void disconnect(object ob, string remaining) {
string host = query_ip_name(ob);
string name = object_name(ob);
PT(("disconnected: %O from %O%s\n", ob, host,
// happens when first clone fails:
unless (ob && objectp(ob) && ob != ME) return;
// this disconnect was expected behaviour:
if (ob->disconnected(remaining)) return;
// unexpected disconnection.
//
// disconnected() must return true when the
// socket disconnection was expected and is no
// cause for concern. if we got here, it is.
//
// 'remaining' is empty in most cases, still
// we don't output 'remaining' on console
// as it occasionally triggers a utf8 conversion error
// instead we drop this into a logfile
SIMUL_EFUN_FILE -> log_file("DISC", "%O %O %O\n",
name, host, remaining);
P2(("Unexpected disconnect in %s from %O%s\n", name, host,
remaining && strlen(remaining) ?
" with "+ strlen(remaining) +" bytes remaining" : ""))
// happens when first clone fails
unless (ob && objectp(ob) && ob != ME) return;
unless (ob->disconnected(remaining)) {
// disconnected() must return true when the
// socket disconnection was expected and is no
// cause for concern. if we got here, it is.
//
// 'remaining' is empty in most cases, still
// we don't output 'remaining' on console
// as it occasionally triggers a utf8 conversion error
// instead we drop this into a logfile
SIMUL_EFUN_FILE -> log_file("DISC", "%O %O %O\n",
name, host, remaining);
}
}
// even though the name of the function is weird, this is the
@ -217,7 +226,7 @@ void receive_udp(string host, string msg, int port) {
case '|':
unless (spycd) {
spycd = SPYC_PATH "udp" -> load();
PT(("SPYC UDP daemon created.\n"))
P1(("SPYC UDP daemon created.\n"))
unless (spycd) return;
}
spycd -> parseUDP(host, port, msg);
@ -226,7 +235,7 @@ void receive_udp(string host, string msg, int port) {
case '.':
unless (psycd) {
psycd = PSYC_PATH "udp" -> load();
PT(("PSYC UDP daemon created.\n"))
P1(("PSYC UDP daemon created.\n"))
unless (psycd) return;
}
psycd -> parseUDP (host,port,msg);

View file

@ -1,398 +0,0 @@
// $Id: psycmuve.i,v 1.113 2008/01/30 17:22:41 lynx Exp $ // vim:syntax=lpc:ts=8
//
// this file contains the glue between LDMUD and psyced to
// connect the socket ports to appropriately named objects.
//
#include NET_PATH "include/services.h"
#include DRIVER_PATH "include/driver.h"
#include CONFIG_PATH "config.h"
volatile int shutdown_in_progress = 0;
// not part of the master/driver API.. this is called from the library
void notify_shutdown_first(int progress) {
P3(("%O notify_shutdown_first(%O)\n", ME, progress))
shutdown_in_progress = progress;
}
#ifndef UID2NICK
# ifdef _userid_nick_mapping
# define UID2NICK(uid) ([ _userid_nick_mapping ])[uid]
# endif
#endif
/*
* This function is called every time a TCP connection is established.
* It dispatches the ports to the protocol implementations.
* input_to() can't be called from here.
*
* uid is only passed if USE_AUTHLOCAL is built into the driver.
*/
object connect(int uid) {
int peerport;
mixed arg, t;
D2(if (uid) D("connected on port "+query_mud_port()+" by uid "+uid+"\n");)
#ifndef H_DEFAULT_PROMPT
set_prompt("");
#endif
if (shutdown_in_progress) {
PT(("shutdown_in_progress(%O): putting connection from %O on hold\n",
shutdown_in_progress, query_ip_name(ME)))
// put the connection on hold to avoid further reconnects
return clone_object(NET_PATH "utility/onhold");
}
// we dont want the telnet machine most of the time
// but disabling and re-enabling it for telnet doesn't work
switch(query_mud_port()) {
#if HAS_PORT(PSYCS_PORT, PSYC_PATH)
case PSYCS_PORT: // inofficial & temporary
t = tls_init_connection(this_object());
if (t < 0) PP(( "TLS on %O: %O\n",
query_mud_port(), tls_error(t) ));
#endif // fall thru
#if HAS_PORT(PSYC_PORT, PSYC_PATH)
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;
query_ip_number(&arg);
// this assumes network byte order provided by driver
peerport = pointerp(arg) ? (arg[2]*256 + arg[3]) : 0;
if (peerport < 0) peerport = 65536 + peerport;
// no support for non-AF_INET nets yet
if (peerport == PSYC_SERVICE) peerport = 0;
# else
// as long as the object names don't collide, this is okay too
peerport = 65536 + random(9999999);
# endif
# ifdef DRIVER_HAS_RENAMED_CLONES
t = "S:psyc:"+query_ip_number();
// tcp peerports cannot be connected to, so we use minus
if (peerport) t += ":-"+peerport;
# else
t = clone_object(PSYC_PATH "server");
# endif
// the psyc backend distinguishes listen ports from peers using minus
D3(D(S("%O -> load(%O, %O)\n", t, query_ip_number(), -peerport));)
return t -> load(query_ip_number(), -peerport);
#endif
#if HAS_PORT(SPYCS_PORT, SPYC_PATH)
case SPYCS_PORT: // inofficial & temporary
t = tls_init_connection(this_object());
if (t < 0) PP(( "TLS on %O: %O\n",
query_mud_port(), tls_error(t) ));
#endif // fall thru
#if HAS_PORT(SPYC_PORT, SPYC_PATH)
case SPYC_PORT:
#endif
#if HAS_PORT(SPYC_PORT, SPYC_PATH) || HAS_PORT(SPYCS_PORT, SPYC_PATH)
# ifdef DRIVER_HAS_CALL_BY_REFERENCE
arg = ME;
query_ip_number(&arg);
// this assumes network byte order provided by driver
peerport = pointerp(arg) ? (arg[2]*256 + arg[3]) : 0;
if (peerport < 0) peerport = 65536 + peerport;
// no support for non-AF_INET nets yet
if (peerport == SPYC_SERVICE) peerport = 0;
# else
// as long as the object names don't collide, this is okay too
peerport = 65536 + random(9999999);
# endif
# ifdef DRIVER_HAS_RENAMED_CLONES
t = "S:psyc:"+query_ip_number();
// tcp peerports cannot be connected to, so we use minus
if (peerport) t += ":-"+peerport;
# else
t = clone_object(SPYC_PATH "server");
# endif
// the psyc backend distinguishes listen ports from peers using minus
D3(D(S("%O -> load(%O, %O)\n", t, query_ip_number(), -peerport));)
return t -> load(query_ip_number(), -peerport);
#endif
#if HAS_PORT(POP3S_PORT, POP3_PATH)
case POP3S_PORT:
t = tls_init_connection(this_object());
if (t < 0) PP(( "TLS on %O: %O\n",
query_mud_port(), tls_error(t) ));
return clone_object(POP3_PATH "server");
#endif
#if HAS_PORT(POP3_PORT, POP3_PATH)
case POP3_PORT:
return clone_object(POP3_PATH "server");
#endif
#if HAS_PORT(SMTPS_PORT, NNTP_PATH)
case SMTPS_PORT:
t = tls_init_connection(this_object());
if (t < 0) PP(( "TLS on %O: %O\n",
query_mud_port(), tls_error(t) ));
return clone_object(SMTP_PATH "server");
#endif
#if HAS_PORT(SMTP_PORT, SMTP_PATH)
case SMTP_PORT:
return clone_object(SMTP_PATH "server");
#endif
// heldensagas little http app
#if HAS_PORT(SHT_PORT, SHT_PATH)
case SHT_PORT:
return clone_object(SHT_PATH "server");
#endif
#if HAS_PORT(NNTPS_PORT, NNTP_PATH)
case NNTPS_PORT:
t = tls_init_connection(this_object());
if (t < 0) PP(( "TLS on %O: %O\n",
query_mud_port(), tls_error(t) ));
return clone_object(NNTP_PATH "server");
#endif
#if HAS_PORT(NNTP_PORT, NNTP_PATH)
case NNTP_PORT:
return clone_object(NNTP_PATH "server");
#endif
#if HAS_PORT(JABBERS_PORT, JABBER_PATH)
case JABBERS_PORT:
t = tls_init_connection(this_object());
if (t < 0) PP(( "TLS on %O: %O\n",
query_mud_port(), tls_error(t) ));
return clone_object(JABBER_PATH "server");
#endif
#if HAS_PORT(JABBER_PORT, JABBER_PATH)
case JABBER_PORT:
# if __EFUN_DEFINED__(enable_telnet)
enable_telnet(0); // are you sure!???
# endif
return clone_object(JABBER_PATH "server");
#endif
#if HAS_PORT(JABBER_S2S_PORT, JABBER_PATH)
case JABBER_S2S_PORT:
# ifdef DRIVER_HAS_CALL_BY_REFERENCE
arg = ME;
query_ip_number(&arg);
// this assumes network byte order provided by driver
peerport = pointerp(arg) ? (arg[2]*256 + arg[3]) : 0;
if (peerport < 0) peerport = 65536 + peerport;
if (peerport == JABBER_S2S_SERVICE) peerport = 0;
# else
// as long as the object names don't collide, this is okay too
peerport = 65536 + random(9999999);
# endif
# if __EFUN_DEFINED__(enable_telnet)
enable_telnet(0);
# endif
t = "S:xmpp:"+query_ip_number();
// it's just an object name, but let's be consequent minus peerport
if (peerport) t += ":-"+peerport;
# ifdef _flag_log_sockets_XMPP
SIMUL_EFUN_FILE -> log_file("RAW_XMPP", "\n\n%O: %O -> load(%O, %O)",
ME, t,
# ifdef _flag_log_hosts
query_ip_number(),
# else
"?",
# endif
-peerport);
# endif
P3(("%O -> load(%O, %O)\n", t, query_ip_number(), -peerport))
return t -> load(query_ip_number(), -peerport);
#endif
#if 0 //__EFUN_DEFINED__(enable_binary)
// work in progress
case 8888:
enable_binary();
enable_telnet(0);
return clone_object(NET_PATH "socks/protocol");
case 1935:
enable_binary();
enable_telnet(0);
return clone_object(NET_PATH "rtmp/protocol");
#endif
#if HAS_PORT(IRCS_PORT, IRC_PATH)
case IRCS_PORT:
t = tls_init_connection(this_object());
if (t < 0) PP(( "TLS on %O: %O\n",
query_mud_port(), tls_error(t) ));
return clone_object(IRC_PATH "server");
#endif
#if HAS_PORT(IRC_PORT, IRC_PATH)
case IRC_PORT:
# if 0 // __EFUN_DEFINED__(enable_telnet)
enable_telnet(0); // shouldn't harm.. but it does!!!
# endif
return clone_object(IRC_PATH "server");
#endif
#if HAS_PORT(APPLET_PORT, APPLET_PATH)
case APPLET_PORT:
# if __EFUN_DEFINED__(enable_telnet)
// enable_telnet(0);
# endif
return clone_object(APPLET_PATH "server");
#endif
#if HAS_PORT(TELNETS_PORT, TELNET_PATH)
case TELNETS_PORT:
return clone_object(TELNET_PATH "sslserver");
#endif
#if HAS_PORT(TELNET_PORT, TELNET_PATH)
case TELNET_PORT:
// set_prompt("> ");
t = clone_object(TELNET_PATH "server");
# ifdef UID2NICK
if (uid && (arg = UID2NICK(uid))) {
t -> sName(arg);
}
# endif
return t;
#endif
#if HAS_PORT(HTTPS_PORT, HTTP_PATH)
case HTTPS_PORT:
t = tls_init_connection(this_object());
// should it return 0 in a tls_error case?
D1( if (t < 0) PP(( "TLS(%O) on %O: %O\n", t, query_mud_port(), tls_error(t) )); )
D2( else if (t > 0) PP(( "Setting up TLS connection in the background.\n" )); )
D2( else PP(( "Oh yeah, I'm initializing an https session!\n" )); )
return clone_object(HTTP_PATH "server");
#endif
#if HAS_PORT(HTTP_PORT, HTTP_PATH)
case HTTP_PORT:
return clone_object(HTTP_PATH "server");
#endif
#if HAS_PORT(MUDS_PORT, MUD_PATH)
case MUDS_PORT:
t = tls_init_connection(this_object());
if (t < 0) PP(( "TLS on %O: %O\n",
query_mud_port(), tls_error(t) ));
return clone_object(MUD_PATH "login");
#endif
#if HAS_PORT(MUD_PORT, MUD_PATH)
default:
// if you want to multiplex psyced with an LPMUD game
// set_prompt("> ");
return clone_object(MUD_PATH "login");
#endif
}
PP(("Received connection on port %O which isn't configured.\n",
query_mud_port()));
return (object)0;
}
#ifdef DRIVER_HAS_RENAMED_CLONES
// named clones -lynx
object compile_object(string file) {
string path, name;
object rob;
# ifdef PSYC_PATH
if (abbrev("S:psyc:", file)) {
rob = clone_object(PSYC_PATH "server");
D2(if (rob) PP(("NAMED CLONE: %O => %s\n", rob, file));)
return rob;
}
if (abbrev("psyc:", file)) {
rob = clone_object(PSYC_PATH "active");
D2(if (rob) PP(("NAMED CLONE: %O => %s\n", rob, file));)
return rob;
}
# endif
# ifdef SPYC_PATH
if (abbrev("S:psyc:", file)) {
rob = clone_object(SPYC_PATH "server");
D2(if (rob) PP(("NAMED CLONE: %O => %s\n", rob, file));)
return rob;
}
if (abbrev("psyc:", file)) {
rob = clone_object(SPYC_PATH "active");
D2(if (rob) PP(("NAMED CLONE: %O => %s\n", rob, file));)
return rob;
}
# endif
# ifdef HTTP_PATH
// match both http:/ and https:/ objects ;D
if (abbrev("http", file)) {
rob = clone_object(HTTP_PATH "fetch");
if (rob) rob->fetch(file[..<3]);
return rob;
}
if (abbrev("xmlrpc:", file)) {
rob = clone_object(HTTP_PATH "xmlrpc");
if (rob) rob->fetch("http://" + file[7..<3]);
return rob;
}
# endif
if (sscanf(file, "%s#%s.c", path, name) && name != "") {
// my function in simul_efun
unless (name = SIMUL_EFUN_FILE->legal_name(name)) return (object)0;
rob = clone_object(path);
rob -> sName(name);
D2(if (rob) PP(("NAMED CLONE: %O becomes %s of %s\n",
rob, name, path));)
return rob;
}
if (sscanf(file, "place/%s.c", name) && name != "") {
#ifdef SANDBOX
string t;
#endif
// my function in simul_efun
unless (name = SIMUL_EFUN_FILE->legal_name(name)) return (object)0;
#ifdef SANDBOX
if (file_size(t = USER_PATH + name + ".c") != -1) {
rob = t -> sName(name);
D2(if (rob) PP(("USER PLACE loaded: %O becomes %O\n", rob, file));)
} else {
#endif
#ifdef _flag_disable_places_arbitrary
P2(("WARN: cloned places disabled by #define %O\n", file))
return (object)0;
#else
#ifdef _path_archetype_place_default
rob = clone_object(_path_archetype_place_default);
#else
rob = clone_object(NET_PATH "place/default");
#endif
rob -> sName(name);
D2(if (rob) PP(("PLACE CLONED: %O becomes %O\n", rob, file));)
#endif
#ifdef SANDBOX
}
#endif
return rob;
}
if (sscanf(file, "%s/text.c", path) && path != "") {
rob = clone_object(NET_PATH "text");
rob -> sPath(path);
D2(if (rob) PP(("DB CLONED: %O becomes %s/text\n", rob, path));)
return rob;
}
# ifdef JABBER_PATH
if (abbrev("S:xmpp:", file)) {
rob = clone_object(JABBER_PATH "gateway");
D2(if (rob) PP(("NAMED CLONE: %O => %s\n", rob, file));)
return rob;
}
if (abbrev("C:xmpp:", file)) {
rob = clone_object(JABBER_PATH "active");
D2(if (rob) PP(("NAMED CLONE: %O => %s\n", rob, file));)
return rob;
}
# endif
P0(("WARN: could not create %O\n", file))
return (object)0;
}
#endif

View file

@ -84,4 +84,7 @@
#define TLS_HASH_MD5 (6)
#define TLS_HASH_RIPEMD160 (7)
/* autodetect feature: when no TLS is found on socket, this code is returned */
#define ERR_TLS_NOT_DETECTED -31337
#endif /* LPC_TLS_H */