mirror of
git://git.psyced.org/git/psyced
synced 2024-08-15 03:25:10 +00:00
removed interesting but unrecoverable FORK code
This commit is contained in:
parent
c3a47f7e0a
commit
adafed5817
18 changed files with 13 additions and 1532 deletions
|
@ -58,18 +58,7 @@ int msg(string source, string method, string data,
|
|||
P3(("active.c:msg(%O, %O, %O) in %O%s\n", source, method, data, ME,
|
||||
(interactive()) ? "(connected)" : "(not connected)"))
|
||||
|
||||
unless (interactive())
|
||||
#ifdef FORK // {{{
|
||||
{
|
||||
if (!member(vars, "_source"))
|
||||
vars["_source"] = UNIFORM(source);
|
||||
unless (super)
|
||||
return enqueue(source, method, data, vars, showingLog, target);
|
||||
return super->msg(source, method, data, vars, showingLog, target);
|
||||
}
|
||||
return ::msg(source, method, data, vars, showingLog, target);
|
||||
#else // }}}
|
||||
{
|
||||
unless (interactive()) {
|
||||
P2(("%O is not interactive (no network connection)\n", ME))
|
||||
if (!member(vars, "_source"))
|
||||
vars["_source"] = UNIFORM(source);
|
||||
|
@ -85,7 +74,6 @@ int msg(string source, string method, string data,
|
|||
// return super->msg(source, method, data, vars, showingLog, target);
|
||||
}
|
||||
return ::msg(source, method, data, vars, showingLog, target);
|
||||
#endif // !FORK
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -40,13 +40,6 @@ inherit PSYC_PATH "common";
|
|||
|
||||
//volatile mapping namecache = ([]);
|
||||
|
||||
#ifdef FORK
|
||||
volatile mapping _o, memory;
|
||||
// why do we need to do this, el?
|
||||
//psycName() { return ""; }
|
||||
#else
|
||||
//# define MMP_STATE
|
||||
#endif
|
||||
#ifdef MMP_STATE
|
||||
// first steps at making use of TCPs persistence
|
||||
volatile string lastSource;
|
||||
|
@ -60,11 +53,7 @@ volatile int flags = 0;
|
|||
|
||||
#define PSYC_TCP
|
||||
// contains PSYC parser
|
||||
#ifdef FORK
|
||||
# include "routerparse.i"
|
||||
#else
|
||||
# include "parse.i"
|
||||
#endif
|
||||
#include "parse.i"
|
||||
|
||||
int greet() {
|
||||
string usingmods;
|
||||
|
@ -112,7 +101,7 @@ int greet() {
|
|||
#define UNDERMODS "_context"
|
||||
usingmods = UNDERMODS;
|
||||
|
||||
#if defined(__MCCP__) && !defined(FORK)
|
||||
#if defined(__MCCP__)
|
||||
# define ZIPMOD ";_compress"
|
||||
if (query_mccp(ME)) usingmods += ZIPMOD;
|
||||
#else
|
||||
|
@ -133,25 +122,6 @@ int greet() {
|
|||
// servers will just skip them..
|
||||
//
|
||||
// und eigentlich ist das alles nur eitelkeit, die vielen vars. sagt el. ;)
|
||||
#ifdef FORK // {{{
|
||||
emit(S_GLYPH_PACKET_DELIMITER "\n");
|
||||
emit("\
|
||||
=_source "+ SERVER_UNIFORM +"\n\
|
||||
=_target_peer psyc://"+ peeraddr +"/\n\
|
||||
=_available_characters UTF-8\n\
|
||||
=_available_protocols " PROTS "\n\
|
||||
" SCHEMES "\
|
||||
=_understand_modules " UNDERMODS TLSMOD "\n\
|
||||
=_using_characters " SYSTEM_CHARSET "\n\
|
||||
=_using_protocols " USINGPROTS "\n\
|
||||
=_using_modules "+ usingmods +"\n\
|
||||
\n\
|
||||
:_implementation " SERVER_VERSION " " DRIVER_VERSION " " OSTYPE " " MACHTYPE "\n\
|
||||
:_page_description http://www.psyc.eu/\n\
|
||||
_notice_circuit_established\n\
|
||||
Circuit to [_source] running [_implementation] established.\n\
|
||||
Available protocols: [_available_protocols].\n" S_GLYPH_PACKET_DELIMITER "\n");
|
||||
#else // }}}
|
||||
// should we rename _target into _target_raw here? maybe, then again
|
||||
// all subsequent traffic still goes to this target unless the
|
||||
// other side tells us her name
|
||||
|
@ -187,7 +157,6 @@ Circuit to [_source] running [_implementation] established.\n" S_GLYPH_PACKET_DE
|
|||
_status_circuit\n\
|
||||
" TSCHEMES "\
|
||||
Available protocols: [_available_protocols].\n" S_GLYPH_PACKET_DELIMITER "\n");
|
||||
#endif // !FORK
|
||||
#ifdef _flag_log_sockets_PSYC
|
||||
log_file("RAW_PSYC", "« %O greeted.\n", ME);
|
||||
#endif
|
||||
|
@ -296,7 +265,7 @@ int logon(int neverfails) {
|
|||
cvars = ([]);
|
||||
pvars = ([ "_INTERNAL_origin" : ME ]);
|
||||
|
||||
#if defined(MMP_STATE) && !defined(FORK)
|
||||
#if defined(MMP_STATE)
|
||||
lastSource = lastTarget = lastContext = 0;
|
||||
#endif
|
||||
next_input_to(#'startParse);
|
||||
|
@ -309,19 +278,6 @@ int logon(int neverfails) {
|
|||
// peerport value is positive for real listen() ports
|
||||
if (peerport) peeraddr += ":"+peerport;
|
||||
// }
|
||||
#ifdef FORK // {{{
|
||||
// init the out-state. these will be sent by greet()
|
||||
_o = ([
|
||||
"_source" : SERVER_UNIFORM,
|
||||
"_target" : "psyc:"+ peeraddr +"/",
|
||||
]);
|
||||
memory = copy(_o);
|
||||
#if 0
|
||||
memory = ([ "_source" : SERVER_UNIFORM; 4,
|
||||
"_target" : "psyc:" + peeraddr +"/"; 4,
|
||||
]);
|
||||
#endif
|
||||
#endif // }}}
|
||||
if (cur = find_target_handler( "psyc://"+ peeraddr +"/" )) {
|
||||
unless (cur->isServer()) {
|
||||
cur->takeover();
|
||||
|
@ -338,7 +294,6 @@ int logon(int neverfails) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifndef FORK // edit.i is included into the library. should be enough
|
||||
#include "edit.i"
|
||||
|
||||
// called from sendmsg() either by registered target or psyc: scheme
|
||||
|
@ -480,59 +435,6 @@ varargs int msg(string source, string mc, string data,
|
|||
//PT(("» %O\t%s\n", ME, buf))
|
||||
return emit(buf);
|
||||
}
|
||||
#else /* FORK {{{ */
|
||||
|
||||
varargs int msg(string source, string mc, string data,
|
||||
mapping vars, int showingLog, mixed target) {
|
||||
string buf;
|
||||
mapping mvars = copy(vars);
|
||||
|
||||
P2(("TCP[%s] <= %s: %s\n", peeraddr || "error",
|
||||
to_string(source), mc || "-"))
|
||||
// to_string(vars["_source_relay"] || source)
|
||||
|
||||
// <lynX> yet another place where sources are rendered..
|
||||
// but it is no longer compliant to the specs. don't use this.
|
||||
vars["_source"] = UNIFORM(source);
|
||||
unless (member(vars, "_context"))
|
||||
vars["_target"] = UNIFORM(target);
|
||||
|
||||
// do state only if source is an object.
|
||||
if (objectp(source)) buf = make_psyc(mc, data, vars, source);
|
||||
else buf = make_psyc(mc, data, vars);
|
||||
|
||||
#ifdef _flag_log_sockets_PSYC
|
||||
log_file("RAW_PSYC", "« %O\n%s\n", ME, buf);
|
||||
#endif
|
||||
return emit(make_mmp(buf, vars, ME));
|
||||
}
|
||||
|
||||
int send(string data, mapping vars) {
|
||||
#ifdef _flag_log_sockets_PSYC
|
||||
log_file("RAW_PSYC", "« %O send(%O)\n", ME, data);
|
||||
#endif
|
||||
return emit(make_mmp(data, vars, ME));
|
||||
}
|
||||
|
||||
int outstate(string key, string value) {
|
||||
if (member(_o, key)) {
|
||||
m_delete(memory, key);
|
||||
if (_o[key] == value) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
mapping state() {
|
||||
mapping t = ([]);
|
||||
string key;
|
||||
|
||||
foreach (key : memory)
|
||||
t[key] = "";
|
||||
|
||||
memory = copy(_o);
|
||||
return t;
|
||||
}
|
||||
#endif // FORK }}}
|
||||
|
||||
void reboot(string reason, int restart, int pass) {
|
||||
P3(("reboot(%O, %O, %O) in %O\n", pass, restart, reason, ME))
|
||||
|
|
|
@ -13,11 +13,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef __PIKE__
|
||||
#ifdef FORK
|
||||
virtual inherit NET_PATH "state";
|
||||
#endif
|
||||
virtual inherit NET_PATH "trust";
|
||||
#endif
|
||||
|
||||
// protos.
|
||||
varargs mixed croak(string mc, string data, vamapping vars, vamixed source);
|
||||
|
@ -267,61 +263,3 @@ void internalError() {
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef FORK // {{{
|
||||
void Assign(mixed source, string key, mixed value) {
|
||||
}
|
||||
void negotiate(mixed modules) {
|
||||
#ifdef __TLS__
|
||||
unless (pointerp(modules))
|
||||
modules = ({ modules });
|
||||
foreach (string key : modules) {
|
||||
if ("_encrypt" == key) {
|
||||
if (tls_query_connection_state(ME) == 0) {
|
||||
|
||||
croak("", "", "", ([ "+_using_modules" : "_encrypt", "_target" : "" ]));
|
||||
|
||||
tls_init_connection(ME);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#ifdef __MCCP__
|
||||
if ("_compress" == key) {
|
||||
P0(("%O is getting compressed from the other side."
|
||||
"ouch! Closing Connection!\n", ME))
|
||||
croak("_error_compress_unavailable",
|
||||
"I don't want to receive compressed data.");
|
||||
destruct(ME);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void gotiate(mixed modules) {
|
||||
unless (pointerp(modules))
|
||||
modules = ({ modules });
|
||||
foreach (string key : modules) {
|
||||
#ifdef __MCCP__
|
||||
if ("_compress" == key) {
|
||||
if(query_mccp(ME)
|
||||
#ifdef __TLS__
|
||||
|| tls_query_connection_state(ME) > 0
|
||||
#endif
|
||||
) break;
|
||||
croak("", "", "", ([ "+_using_modules" : "_compress" ]));
|
||||
enable_telnet(0);
|
||||
start_mccp_compress(TELOPT_COMPRESS2);
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void Diminish(mixed source, string key, mixed value) {
|
||||
}
|
||||
void Reset() {
|
||||
|
||||
}
|
||||
|
||||
#endif // FORK }}}
|
||||
|
|
|
@ -5,12 +5,6 @@
|
|||
|
||||
volatile mapping isRouting = shared_memory("routing");
|
||||
|
||||
#ifdef FORK
|
||||
// these macros support state modifiers in varnames.. we'll need that later
|
||||
#define isRoutingVar(x) (stringp(x) && strlen(x) > 1 && member(isRouting, (x[0] == '_') ? x : x[1..]))
|
||||
#define mergeRoutingVar(x) (stringp(x) && strlen(x) > 1 && (isRouting[(x[0] == '_') ? x : x[1..]] & PSYC_ROUTING_MERGE)
|
||||
#endif
|
||||
|
||||
volatile string rbuf, ebuf; // pike has no pass-by-reference
|
||||
|
||||
static int build_header(string key, mixed val, mapping vars) {
|
||||
|
@ -27,17 +21,11 @@ static int build_header(string key, mixed val, mapping vars) {
|
|||
monitor_report("_failure_invalid_variable_name", s);
|
||||
return -9;
|
||||
}
|
||||
#ifndef FORK
|
||||
routeMe = isRouting[key];
|
||||
# if 1 //def EXPERIMENTAL
|
||||
P3(("isRouting[%O] = %O, render? %O\n",
|
||||
key, routeMe, routeMe & PSYC_ROUTING_RENDER))
|
||||
if ((routeMe &&! (routeMe & PSYC_ROUTING_RENDER))
|
||||
|| abbrev("_INTERNAL", key)) return -1;
|
||||
# else
|
||||
if (routeMe || abbrev("_INTERNAL", key)) return -1;
|
||||
# endif
|
||||
#endif /* ! FORK */
|
||||
P2(("build_header(%O, %O) into %s vars\n", key, val,
|
||||
routeMe ? "routing" : "entity"))
|
||||
if (key[0] == '_') key = ":"+key;
|
||||
|
@ -289,31 +277,8 @@ static varargs string psyc_render(mixed source, string mc, mixed data,
|
|||
ebuf += "\n:_count\t" + vars["_count"];
|
||||
#endif
|
||||
#if __EFUN_DEFINED__(walk_mapping)
|
||||
#ifndef FORK // NO STATE
|
||||
// walk_mapping could be rewritten into foreach, but thats work
|
||||
walk_mapping(vars, #'build_header, vars);
|
||||
#else /* FORK {{{ */
|
||||
# if 0 //ndef EXPERIMENTAL
|
||||
// At least the psyced needs _count first to handle that properly
|
||||
m_delete(vars, "_count");
|
||||
# endif
|
||||
foreach (string key, mixed value : vars) {
|
||||
// why does FORK weed out _INTERNAL in two places? ah nevermind
|
||||
if (abbrev("_INTERNAL_", key)) {
|
||||
// equal on a line by itself to mean "clear all state"
|
||||
if (key == "_INTERNAL_state_clear")
|
||||
ebuf = "\n="+ ebuf;
|
||||
continue;
|
||||
}
|
||||
|
||||
// CONTEXT_STATE and ENTITY_STATE here
|
||||
if (!isRoutingVar(key) && (!objectp(obj)
|
||||
|| obj->outstate(target, key, value, hascontext)))
|
||||
build_header(key, value);
|
||||
}
|
||||
if (objectp(obj))
|
||||
walk_mapping(obj->state(target, hascontext), #'build_header);
|
||||
#endif /* FORK }}} */
|
||||
#else // PIKE, MudOS...
|
||||
mixed key, val;
|
||||
|
||||
|
@ -341,48 +306,6 @@ static varargs string psyc_render(mixed source, string mc, mixed data,
|
|||
return ebuf +"\n" S_GLYPH_PACKET_DELIMITER "\n";
|
||||
}
|
||||
|
||||
#ifdef FORK // {{{
|
||||
|
||||
static varargs string mmp_make_header(mapping vars, object o) {
|
||||
buf = "";
|
||||
foreach (string key, mixed value : vars) {
|
||||
if (abbrev("_INTERNAL_", key)) continue;
|
||||
if (isRoutingVar(key) && (!objectp(o) || o->outstate(key, value)))
|
||||
build_header(key, value);
|
||||
}
|
||||
if (objectp(o))
|
||||
walk_mapping(o->state(), #'build_header);
|
||||
return buf;
|
||||
}
|
||||
|
||||
varargs string make_mmp(string data, mapping vars, object o) {
|
||||
// we could regreplace here and do some funny nntp-like encoding of
|
||||
// leading dots.. but we should simply implement _length instead. one day.
|
||||
if (data == "." || data[0..1] == ".\n" || strstr(data, "\n.\n") != -1) {
|
||||
# if 0 // one day we shall be able to parse that, too
|
||||
vars["_length"] = strlen(data);
|
||||
# else
|
||||
P1(("%O: %O tried to send %O via psyc. censored.\n",
|
||||
previous_object() || ME, vars["_nick"] || vars, data))
|
||||
// this message makes some people feel like they missed out
|
||||
// on something..
|
||||
//data = "*** censored message ***";
|
||||
data = "";
|
||||
# endif
|
||||
}
|
||||
return mmp_make_header(vars, o)
|
||||
+ ((data && "" != data) ? "\n"+data+"\n.\n" : "\n.\n");
|
||||
}
|
||||
|
||||
varargs string make_psyc(string mc, string data, mapping vars, object o) {
|
||||
unless (stringp(data))
|
||||
data = "";
|
||||
return psyc_make_header(vars, o, vars["_target"], member(vars, "_context"))
|
||||
+ ((mc) ? mc +"\n"+data : "");
|
||||
}
|
||||
|
||||
#endif /* FORK }}} */
|
||||
|
||||
// notice for completeness: the PSYC renderer does not convert_charset
|
||||
// from SYSTEM_CHARSET to UTF-8, so to produce correct PSYC you must not
|
||||
// switch to a different SYSTEM_CHARSET, or you have to fix that...
|
||||
|
|
|
@ -117,7 +117,6 @@ object psyc_object(string uniform) {
|
|||
return unl2obj[uniform];
|
||||
}
|
||||
|
||||
#ifndef FORK
|
||||
object find_psyc_object(array(mixed) u) {
|
||||
P3((">> find_psyc_object(%O)\n", u))
|
||||
string t, r, svc, user;
|
||||
|
@ -227,7 +226,7 @@ int psyc_sendmsg(mixed target, string mc, mixed data, mapping vars,
|
|||
|
||||
// TODO: vars should be enforced system-wide
|
||||
unless (mappingp(vars)) vars = ([ ]);
|
||||
#ifndef FORK
|
||||
|
||||
// seid ihr euch wirklich sicher, dass ihr diese zeile entfernen wollt?
|
||||
vars["_target"] = target;
|
||||
// <lynX> this could help protect against sources who destruct while
|
||||
|
@ -239,7 +238,7 @@ int psyc_sendmsg(mixed target, string mc, mixed data, mapping vars,
|
|||
// rather adapt the other spots where it's used rather than here..
|
||||
// after all it's mostly speed improvements.. no big thing.. TODO
|
||||
vars["_source"] = sname;
|
||||
#endif
|
||||
|
||||
unless (port = u[UPort]) port = u[UTransport] == "s" ?
|
||||
PSYCS_SERVICE : PSYC_SERVICE;
|
||||
else {
|
||||
|
@ -334,7 +333,7 @@ int psyc_sendmsg(mixed target, string mc, mixed data, mapping vars,
|
|||
// this makes it look for host:port as its queue
|
||||
o = ("psyc:"+hopo) -> circuit($2, $3, u[UTransport],
|
||||
usesrv && "psyc", hopo, systemQ, psychopo);
|
||||
#endif
|
||||
#endif //__PIKE__
|
||||
// SRV tag "psyc" is actively being checked, but
|
||||
// don't rely on it.. just use it as a fallback if
|
||||
// nothing else is possible, but some clients may
|
||||
|
@ -350,11 +349,7 @@ int psyc_sendmsg(mixed target, string mc, mixed data, mapping vars,
|
|||
return o->msg($5, $6, $7, $8, 0, $4);
|
||||
// ip=1 2 3 4 5 6 7 8 9
|
||||
:),
|
||||
#ifdef FORK
|
||||
host, port, target, source, mc, data, vars, u[UPort]
|
||||
#else
|
||||
host, port, target, sname, mc, data, vars, u[UPort]
|
||||
#endif
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
@ -434,7 +429,6 @@ int psyc_sendmsg(mixed target, string mc, mixed data, mapping vars,
|
|||
#endif /* _flag_enable_routing_UDP */
|
||||
#endif // PIKE
|
||||
}
|
||||
#endif
|
||||
|
||||
/* this breaks /connect ...
|
||||
object createUser(string nick) {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// vim:foldmethod=marker:syntax=lpc:noexpandtab
|
||||
// $Id: parse.i,v 1.358 2008/12/27 00:42:04 lynx Exp $
|
||||
//
|
||||
#ifndef FORK
|
||||
|
||||
#ifndef __PIKE__
|
||||
# include <tls.h>
|
||||
#endif
|
||||
|
@ -1180,5 +1178,3 @@ vamixed startParse(string a) {
|
|||
string qOrigin() { return origin_unl; }
|
||||
|
||||
void sOrigin(string origin) { unless (origin_unl) origin_unl = origin; }
|
||||
|
||||
#endif /* !FORK */
|
||||
|
|
|
@ -1,287 +0,0 @@
|
|||
// vim:foldmethod=marker:syntax=lpc:noexpandtab
|
||||
// $Id: routerparse.i,v 1.15 2008/02/06 12:16:16 lynx Exp $
|
||||
//
|
||||
// THIS FILE IS FORK ONLY, thus currently not in use.
|
||||
//
|
||||
// TODO: both parsers need to croak on incoming _INTERNAL vars!!
|
||||
|
||||
#ifdef FORK // {{{
|
||||
// MMP PARSER - parses the routing header of PSYC, also known as MMP.
|
||||
//
|
||||
// THIS IS THE INNOVATIVE RID'N'SAGE PARSER REWRITE
|
||||
// they wanted to have it completely seperate from the original parse.i
|
||||
// so *keep* it seperate in its own file, routerparse.i!
|
||||
//
|
||||
// unfortunately it handles context counters in a non-universal way.. TODO
|
||||
// also it misses support for _trust
|
||||
|
||||
// this flag should enable forward-checks of dns resolutions..
|
||||
// currently we don't have that, so this flag actually disables
|
||||
// use of unprooven resolved hostnames and reduces everything to
|
||||
// ip numbers.
|
||||
//#define HOST_CHECKS
|
||||
|
||||
#ifndef PSYC_LIST_SIZE_LIMIT
|
||||
# define PSYC_LIST_SIZE_LIMIT 404
|
||||
#endif
|
||||
|
||||
// just the plain ip number of the remote host
|
||||
// ^^ glatte lüge!
|
||||
volatile string peerhost;
|
||||
#if 0 //defined(PSYC_TCP) && __EFUN_DEFINED__(strrstr)
|
||||
volatile string peerdomain;
|
||||
#endif
|
||||
// remote port number
|
||||
volatile int peerport;
|
||||
// unresolved-ip or ip:port
|
||||
volatile string peeraddr;
|
||||
// holds last ip we were connected to
|
||||
volatile string peerip;
|
||||
// how much can we trust the content of this packet?
|
||||
volatile int ctrust;
|
||||
|
||||
volatile closure _deliver;
|
||||
volatile object _psyced;
|
||||
#define PSYCED (_psyced ? _deliver : (_psyced = DAEMON_PATH "psyc" -> load(), _deliver = symbol_function("deliver", _psyced)))
|
||||
|
||||
|
||||
// current variables (":"), permanent variables ("=", "+", "-")
|
||||
//
|
||||
volatile mapping cvars = 0, pvars = ([ "_INTERNAL_origin" : ME ]), nvars = 0;
|
||||
|
||||
//
|
||||
// a distinction between mmp and psyc-vars should be made
|
||||
|
||||
// current method and incoming buffer
|
||||
volatile string buffer;
|
||||
|
||||
// cache of patched remote uniforms
|
||||
volatile mapping patches = ([]);
|
||||
|
||||
// parsing helpers..
|
||||
// MMP
|
||||
volatile string lastvar, lastmod, checkpack, origin_unl;
|
||||
volatile mixed lastvalue;
|
||||
// list parsing helpers..
|
||||
volatile array(mixed) list;
|
||||
volatile mapping hash;
|
||||
volatile int l = 0;
|
||||
//volatile int pongtime; // TODO: FORK is missing the PONG
|
||||
|
||||
# ifndef PSYC_TCP
|
||||
// resolved UNL of remote server (psyc://hostname or psyc://hostname:port)
|
||||
volatile string netloc;
|
||||
# define QUIT return 0;
|
||||
# endif
|
||||
|
||||
// prototype definition for #'getdata
|
||||
getdata(string a);
|
||||
restart();
|
||||
|
||||
#ifdef __LDMUD__
|
||||
# define SCANFIT (sscanf(a, "%1.1s%s%t%s", mod, vname, vvalue) || sscanf(a, "%1.1s%s", mod, vname))
|
||||
#else
|
||||
# define SCANFIT (sscanf(a, "%1s%s%*[ \t]%s", mod, vname, vvalue) || sscanf(a, "%1s%s", mod, vname))
|
||||
#endif
|
||||
|
||||
#define SPLITVAL(val) \
|
||||
unless (sscanf(val, "%s %s", val, vdata)) vdata = 0
|
||||
// sollte es wirklich ein space sein? hmmm.. %t ist sowieso zu grob..
|
||||
|
||||
# ifndef PSYC_TCP
|
||||
# define UDPRETURN(x) return x;
|
||||
# define ERROR(m) UDPRETURN(0)
|
||||
# else
|
||||
# define UDPRETURN(x)
|
||||
# define ERROR(m) { croak("_error_syntax_broken", "Failed in parsing " \
|
||||
"[_modifier], closing connection.", \
|
||||
([ "_modifier" : intp(m) \
|
||||
? to_string(({m})) \
|
||||
: to_string(m) ])); \
|
||||
monitor_report("_error_syntax_broken", \
|
||||
sprintf("MMP parsing failed. closing connection: %O", ME)); \
|
||||
destruct(ME); \
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef PSYC_TCP
|
||||
void
|
||||
# else
|
||||
mixed
|
||||
# endif
|
||||
mmp_parse(string a) {
|
||||
string mod, vname, vvalue;
|
||||
|
||||
P3(("MMP>> %O\n", a))
|
||||
|
||||
if (sizeof(a)) switch(a[0]) {
|
||||
case '=':
|
||||
case '+':
|
||||
case '-':
|
||||
# ifndef PSYC_TCP
|
||||
// hier könnten wir jedenfalls nen error ausgeben
|
||||
// udp und state ist keine gute kombination
|
||||
# endif
|
||||
case ':':
|
||||
unless (2 <= sscanf(a, "%1.1s%s%t%s", mod, vname, vvalue)
|
||||
|| 2 == sscanf(a, "%1.1s%s", mod, vname)) {
|
||||
ERROR(a[0]);
|
||||
}
|
||||
if (vvalue == "") vvalue = 0;
|
||||
P3(("G: %O %O %O\n", mod, vname, vvalue))
|
||||
unless (vname) {
|
||||
unless (lastvar && a[0] != '-' && lastmod
|
||||
&& lastmod[0] == a[0]) ERROR(a[0]);
|
||||
if (pointerp(lastvalue)) {
|
||||
lastvalue += ({ vvalue });
|
||||
} else {
|
||||
lastvalue = ({ lastvalue, vvalue });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
case '\t':
|
||||
unless (lastvar) {
|
||||
ERROR(a[0]);
|
||||
}
|
||||
if (pointerp(lastvalue))
|
||||
lastvalue[<1] += "\n"+a[1..];
|
||||
lastvalue += "\n"+a[1..];
|
||||
return;
|
||||
default:
|
||||
ERROR(a[0]);
|
||||
}
|
||||
|
||||
if (lastmod) switch(lastmod[0]) {
|
||||
# ifdef PSYC_TCP
|
||||
case '=':
|
||||
unless (lastvalue) {
|
||||
m_delete(pvars, lastvar);
|
||||
break;
|
||||
}
|
||||
if (lastvar == "_understand_modules") {
|
||||
gotiate(lastvalue);
|
||||
} else if (lastvar == "_use_modules") {
|
||||
negotiate(lastvalue);
|
||||
}
|
||||
pvars[lastvar] = lastvalue;
|
||||
# endif
|
||||
case ':':
|
||||
if (lastvalue)
|
||||
cvars[lastvar] = lastvalue;
|
||||
else
|
||||
m_add(nvars, lastvar);
|
||||
break;
|
||||
# ifdef PSYC_TCP
|
||||
case '+':
|
||||
_augment(pvars, lastvar, lastvalue);
|
||||
if (lastvar == "_understand_modules") {
|
||||
gotiate(lastvalue);
|
||||
} else if (lastvar == "_use_modules") {
|
||||
negotiate(lastvalue);
|
||||
}
|
||||
break;
|
||||
case '-':
|
||||
_diminish(pvars, lastvar, lastvalue);
|
||||
break;
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
unless (sizeof(a)) {
|
||||
# ifdef PSYC_TCP
|
||||
next_input_to(#'getdata);
|
||||
# endif
|
||||
// TODO init cvars = copy(pvars)
|
||||
cvars = (pvars + cvars) - nvars;
|
||||
UDPRETURN(2)
|
||||
} else if (a[0] == '.') {
|
||||
# ifdef PSYC_TCP
|
||||
next_input_to(#'mmp_parse);
|
||||
# endif
|
||||
restart();
|
||||
UDPRETURN(1)
|
||||
} else {
|
||||
lastmod = mod;
|
||||
lastvar = vname;
|
||||
lastvalue = vvalue;
|
||||
# ifdef PSYC_TCP
|
||||
next_input_to(#'mmp_parse);
|
||||
# endif
|
||||
UDPRETURN(1)
|
||||
}
|
||||
# ifdef PSYC_TCP
|
||||
if (timeoutPending) remove_call_out(#'quit);
|
||||
# endif
|
||||
}
|
||||
|
||||
getdata(string a) {
|
||||
P4(("GETDATA: %O\n", a));
|
||||
if (a != ".") {
|
||||
if (buffer == "")
|
||||
buffer = a;
|
||||
else
|
||||
buffer += "\n"+a;
|
||||
# ifdef PSYC_TCP
|
||||
next_input_to(#'getdata);
|
||||
# endif
|
||||
} else {
|
||||
array(mixed) u;
|
||||
string t = cvars["_context"] || cvars["_source"];
|
||||
|
||||
# ifdef PSYC_TCP
|
||||
// let's do this before we deliver in case we run into
|
||||
// a runtime error (but it's still better to fix it!)
|
||||
next_input_to(#'mmp_parse);
|
||||
# endif
|
||||
if (!t || trustworthy > 5) {
|
||||
funcall(PSYCED, 0, 0, ME, peeraddr, peerhost,
|
||||
buffer, cvars);
|
||||
} else unless (u = parse_uniform(t)) {
|
||||
P1((">> parse_uniform %O %O\n", t, u))
|
||||
croak("_error_invalid_uniform",
|
||||
"Looks like a malformed URL to me.");
|
||||
QUIT
|
||||
} else dns_resolve(u[UHost], PSYCED, peerip, ME, peeraddr,
|
||||
u[UHost], buffer, cvars);
|
||||
restart();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
restart() {
|
||||
// delete temporary variables for next msg
|
||||
cvars = ([ "_INTERNAL_trust" : trustworthy ]);
|
||||
nvars = m_allocate(0, 1);
|
||||
lastvalue = lastvar = lastmod = 0;
|
||||
// delete other stuff too
|
||||
buffer = "";
|
||||
ctrust = trustworthy;
|
||||
return 1;
|
||||
}
|
||||
|
||||
# ifdef PSYC_TCP
|
||||
startParse(string a) {
|
||||
if (a == ".") restart();
|
||||
else {
|
||||
croak("_error_syntax_initialization",
|
||||
"The protocol begins with a dot on a line by itself.");
|
||||
QUIT
|
||||
}
|
||||
next_input_to(#'mmp_parse);
|
||||
}
|
||||
# endif
|
||||
|
||||
// also overrides createUser in net/server.c
|
||||
createUser(string nick) {
|
||||
D2(D("creating " PSYC_PATH "user for "+ nick +"\n");)
|
||||
return named_clone(PSYC_PATH "user", nick);
|
||||
}
|
||||
|
||||
qOrigin() { return origin_unl; }
|
||||
|
||||
sOrigin(origin) { P3(("sOrigin(%O) (%O) in %O\n", origin, origin_unl, ME))
|
||||
unless (origin_unl) origin_unl = origin; }
|
||||
|
||||
#endif /* FORK }}} */
|
|
@ -28,21 +28,13 @@ volatile mapping namecache = ([]);
|
|||
|
||||
// TODO? should keep caches of host:port per remote target somewhat like tcp
|
||||
|
||||
#ifdef FORK
|
||||
# include "routerparse.i"
|
||||
#else
|
||||
# include "parse.i"
|
||||
#endif
|
||||
#include "parse.i"
|
||||
|
||||
object load() { return ME; } // avoid a find_object call in obj/master
|
||||
|
||||
parseUDP2(host, ip, port, msg) {
|
||||
string *m;
|
||||
int i, l
|
||||
#ifdef FORK
|
||||
, parsed
|
||||
#endif
|
||||
;
|
||||
int i, l;
|
||||
|
||||
unless (stringp(host)) host = ip;
|
||||
|
||||
|
@ -82,13 +74,8 @@ parseUDP2(host, ip, port, msg) {
|
|||
// i'd like to know why no-mc has to be an empty string
|
||||
// rather than NULL from now on.
|
||||
// should you find out, pls tell me.. -lynX
|
||||
#ifdef FORK
|
||||
if (parsed == 2) getdata(m[l]);
|
||||
else unless (parsed = mmp_parse(m[l])) {
|
||||
#else
|
||||
if (sizeof(mc)) getdata(m[l]);
|
||||
else unless (parse(m[l])) {
|
||||
#endif
|
||||
log_file("PSYCHACK", "Can't parseUDP(%s): %O in %O\n",
|
||||
peeraddr,m[l],msg );
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue