mirror of
https://github.com/ChronosX88/psyced.git
synced 2024-12-04 08:02:19 +00:00
removed interesting but unrecoverable FORK code
This commit is contained in:
parent
c3a47f7e0a
commit
adafed5817
@ -84,9 +84,6 @@ perl:
|
||||
[+] non-blocking writes using buffers
|
||||
[-] tkperl client
|
||||
|
||||
all:
|
||||
[+] start development of negotiations (see FORK)
|
||||
|
||||
|
||||
VERSION 2.0
|
||||
===========
|
||||
|
27
CHANGESTODO
27
CHANGESTODO
@ -1635,30 +1635,6 @@ http://www.holoweb.net/~liam/irc++/ http://achurch.org/irc3/ gale.org
|
||||
http://freshmeat.net/projects/boo/
|
||||
http://www.oreillynet.com/pub/t/78
|
||||
|
||||
== FORK ================================================================
|
||||
- _INTERNAL_trust einbauen
|
||||
- unique counters für contexte, ergo global packet ids unterstützen
|
||||
see also http://about.psyc.eu/Routing 2.2
|
||||
|
||||
- einmaliges rendern von psyc paketen ohne psycd realisieren,
|
||||
idealerweise auch im sendmsg() statt in group/route, und zwar so:
|
||||
// <lynX> new idea: for future use, psyc packets need to be cached
|
||||
// according to their packet id anyway, so whenever the _count is
|
||||
// the same as the one before, sendmsg() can optimize by using
|
||||
// the last cached outgoing packet of this context. this way the
|
||||
// render-only-once optimization can move down into sendmsg()
|
||||
|
||||
* das problem der dangling delivers bei destructeten psyc servern.
|
||||
- die drittbeste lösung ist im begriff abgeschafft zu werden:
|
||||
psycd ist allerdings noch nicht vollständig ausgemerzt
|
||||
: die zweitbeste lösung macht FORK derzeit mit psyc_deliver() in der lib
|
||||
+ die beste lösung wäre psyc/server und active.c wieder in ein
|
||||
gemeinsames circuit.c zusammenzuführen. der versuch mal schnell active.c
|
||||
zum neuen server zu machen ist gescheitert, da active.c schon eine weile
|
||||
lang server.c gar nicht inheritet. letztlich ist diese operation nicht
|
||||
überstürzenswert, lieber vorsichtig planen - etwa in dem wir für das neue
|
||||
mixgerät aus active, server und circuit erstmal ein temporäres newct.c machen
|
||||
|
||||
________________________________________________________________________
|
||||
== UNDER CONSTRUCTION: (offene baustellen im LPC code) =================
|
||||
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
@ -3956,3 +3932,6 @@ net/circuit
|
||||
or postpones it to become a bigger problem later ;)
|
||||
net/person
|
||||
- tg fixes the ~0 bug!
|
||||
=== 201101 ============================================================
|
||||
* removed interesting but unrecoverable FORK code
|
||||
|
||||
|
@ -221,11 +221,7 @@ runQ() {
|
||||
// 0:source, 1:method, 2:data, 3:vars, 4:target
|
||||
// revert to string source if the object has destructed
|
||||
source = t[0] || t[3]["_source"];
|
||||
#ifdef FORK
|
||||
msg(source, t[1], t[2], t[3], 0, t[4], t[5]);
|
||||
#else
|
||||
msg(source, t[1], t[2], t[3], 0, t[4]);
|
||||
#endif
|
||||
#if 1
|
||||
// <lynX> i need to know if this could ever happen, and if so
|
||||
// if it is harmless anyhow. see below.
|
||||
|
@ -1,700 +0,0 @@
|
||||
// vim:foldmethod=marker:syntax=lpc:noexpandtab
|
||||
|
||||
// this whole file is a mistake... and not in use...
|
||||
|
||||
#ifdef FORK // {{{
|
||||
|
||||
#include <net.h>
|
||||
#include <uniform.h>
|
||||
#include <services.h>
|
||||
|
||||
inherit NET_PATH "state";
|
||||
inherit NET_PATH "queue2";
|
||||
|
||||
#include "../psyc/edit.i"
|
||||
|
||||
string psycName() { return ""; }
|
||||
|
||||
varargs mixed find_psyc_object(string t, object connection, array(mixed) u) {
|
||||
string r, svc, user;
|
||||
object o;
|
||||
|
||||
PT((">> t: %O\n", t))
|
||||
|
||||
unless (strlen(t) && u = (u || parse_uniform(t))) return 0;
|
||||
|
||||
//unless (u[UScheme] && u[UScheme] == "psyc") {
|
||||
unless (u[UScheme] && strlen(u[UScheme])) {
|
||||
if (connection)
|
||||
connection -> w("_failure_unsupported_target_relative",
|
||||
"No support for relative targets yet.");
|
||||
return 0;
|
||||
//QUIT
|
||||
}
|
||||
unless (u[UHost] && strlen(u[UHost])) {
|
||||
if (connection)
|
||||
connection -> w("_failure_unsupported_notation_location",
|
||||
"No support for fancy UNLs yet.");
|
||||
return 0;
|
||||
//QUIT
|
||||
}
|
||||
// TODO: croak if host:port isnt us?
|
||||
// or implement proxy service?
|
||||
// do any checking for gateway schemes?
|
||||
user = u[UUser];
|
||||
r = u[UResource];
|
||||
if (r && strlen(r)) {
|
||||
#if __EFUN_DEFINED__(trim)
|
||||
# include <sys/strings.h>
|
||||
r = trim(r, TRIM_RIGHT, '/');
|
||||
#else
|
||||
while (r[<1] == '/') r = r[..<2];
|
||||
#endif
|
||||
if (strlen(r)) switch(r[0]) {
|
||||
case '^':
|
||||
case '~':
|
||||
if (user) {
|
||||
if (connection)
|
||||
connection -> w("_error_invalid_uniform_user_duplicate",
|
||||
"Two users in uniform not allowed here.");
|
||||
// QUIT
|
||||
return 0;
|
||||
}
|
||||
user = r[1..];
|
||||
break;
|
||||
case '$':
|
||||
// target wird auf serv/args gesetzt
|
||||
// weiss noch nicht ob das gut ist
|
||||
t = r[1..];
|
||||
unless (sscanf(t, "%s/%s", svc, r))
|
||||
svc = t;
|
||||
//P3(("find_service: %O for %O(%O)\n", o, svc, r))
|
||||
if (o = find_service(lower_case(svc)))
|
||||
break;
|
||||
unless (user) {
|
||||
if (connection)
|
||||
connection -> w("_failure_unavailable_service",
|
||||
"No service '[_service]' available here.", ([ "_service" : svc ]) );
|
||||
return 0;
|
||||
}
|
||||
case '@':
|
||||
// t[0..0] = PLACE_PATH;
|
||||
r = PLACE_PATH + lower_case(r[1..]);
|
||||
if (o = find_object(r)) break;
|
||||
// should check for legal name instead
|
||||
// of catch. TODO
|
||||
catch(o = r -> load());
|
||||
// fall thru
|
||||
default:
|
||||
o = find_object(r);
|
||||
D2( if(!o)
|
||||
D("OBJECT NOT FOUND: "+ r +"\n"); )
|
||||
}
|
||||
else unless (user) return 0;
|
||||
if (user && !objectp(o)) {
|
||||
o = summon_person(user);
|
||||
// o = find_person(user);
|
||||
// unless(o) o = createUser(user);
|
||||
}
|
||||
}
|
||||
return o;
|
||||
}
|
||||
// new psyc-parser to fit the needs ot the new api. operates on _one_ string
|
||||
// containing _one_ paket (everything after the mc is considered the data)
|
||||
//
|
||||
// returns the mc, psyc-data remains in the buffer.
|
||||
#define ERROR(x) { monitor_report("_error_broken_syntax", x+((connection) ? sprintf(" from %O.", connection) : ".")); return 0; }
|
||||
//#define ERROR(x) { monitor_report("_error_broken_syntax", x); return 0; }
|
||||
|
||||
static string spsyc_parse(string buf, mapping vars, int iscontext, string source,
|
||||
object connection, object o) {
|
||||
string mod, var, val, mc, line, lastmod, lastvar;
|
||||
mixed lastval;
|
||||
int a = 0, b;
|
||||
|
||||
while (a < strlen(buf) && !mc && ((b = strstr(buf, "\n", a)) != -1
|
||||
|| b = strlen(buf))) {
|
||||
|
||||
val = "";
|
||||
line = buf[a..b-1];
|
||||
switch(buf[a]) {
|
||||
case ':':
|
||||
case '=':
|
||||
case '+':
|
||||
case '-':
|
||||
unless (sscanf(line, "%1.1s%s%t%s", mod, var, val)
|
||||
|| sscanf(line, "%1.1s%s", mod, var)) {
|
||||
if (connection)
|
||||
connection -> w("_error_broken_syntax",
|
||||
"You are in league with Ratzinger,\
|
||||
the evil lord or broken psyc.");
|
||||
// <lynX> runtime error erzeugen!?? wie kommt ihr darauf
|
||||
// das sei eine gute idee? damit man nen grund hat große
|
||||
// teure catches zu machen? ich will in meinen logs nur
|
||||
// runtime fehler von bugs - ist schon schlimm genug das
|
||||
// schrottige http-zugriffe sowas auslösen, aber logs
|
||||
// voller fehler von buggy psyc implementationen, nein!
|
||||
// man sagt der gegenseite dass was faul ist, killt evtl
|
||||
// die verbindung falls der fehler nicht recoverbar ist,
|
||||
// reported oder loggt das problem, aber dann is gut!
|
||||
ERROR(S("PSYC parsing failed in '%s'", line))
|
||||
}
|
||||
unless (sizeof(var)) {
|
||||
if (mod == "-") {
|
||||
if (connection)
|
||||
connection -> w("_error_broken_syntax",
|
||||
"Diminishing of lists is not supported.");
|
||||
ERROR("PSYC parsing failed (Invalid list diminish)")
|
||||
} else unless (lastvar) {
|
||||
if (connection)
|
||||
connection -> w("_error_broken_syntax",
|
||||
"Wrong list continuation.");
|
||||
ERROR("PSYC parsing failed (Invalid list continuation)")
|
||||
} else unless (lastmod == mod) {
|
||||
if (connection)
|
||||
connection -> w("_error_broken_syntax",
|
||||
"Inconsistent list continuation. Do not mix modifiers.");
|
||||
ERROR("PSYC parsing failed (Invalid list continuation)")
|
||||
}
|
||||
|
||||
if (pointerp(lastval)) {
|
||||
lastval += ({ val });
|
||||
} else {
|
||||
lastval = ({ lastval, val });
|
||||
}
|
||||
a = b+1;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
case '\t':
|
||||
unless (lastvar) {
|
||||
if (connection)
|
||||
connection -> w("_error_broken_syntax",
|
||||
"Continuation without variable.");
|
||||
ERROR("PSYC parsing failed (Invalid variable continuation)")
|
||||
}
|
||||
if (pointerp(lastval))
|
||||
lastval[<1] += "\n"+line[1..];
|
||||
else lastval += "\n"+line[1..];
|
||||
a = b+1;
|
||||
continue;
|
||||
case '_':
|
||||
int i;
|
||||
for (i = b - a - 1; i>=0; i--) {
|
||||
unless (line[i] == '_' ||
|
||||
(line[i] >= 'a' && line[i] <= 'z') ||
|
||||
(line[i] >= '0' && line[i] <= '9') ||
|
||||
(line[i] >= 'A' && line[i] <= 'Z')) {
|
||||
if (connection)
|
||||
connection -> w("_error_illegal_method",
|
||||
"[_method] is not a valid method name.",
|
||||
([ "_method" : line ]));
|
||||
ERROR("PSYC parsing failed (Invalid method '"
|
||||
+ line +"')\n")
|
||||
}
|
||||
}
|
||||
mc = line;
|
||||
switch(mc) {
|
||||
case "_conversation": // we will soon have to decide its
|
||||
case "_converse": // final name...
|
||||
case "_talk":
|
||||
mc = "_message";
|
||||
break;
|
||||
default:
|
||||
if (abbrev("_conversation", mc)) {
|
||||
mc[..12] = "_message";
|
||||
} else if (abbrev("_converse", mc)) {
|
||||
mc[..8] = "_message";
|
||||
} else if (abbrev("_talk", mc)) {
|
||||
mc[..4] = "_message";
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (connection)
|
||||
connection -> w("_error_broken_syntax",
|
||||
"Unsupported modifier '[_modifier]'",
|
||||
([ "_modifier" : line[0] ]));
|
||||
ERROR("PSYC parsing failed (Unknown modifier '"
|
||||
+ line[0] + "')")
|
||||
}
|
||||
if (lastmod) switch(lastmod[0]) {
|
||||
case '=':
|
||||
if (o)
|
||||
o -> Assign(source, lastvar, lastval, iscontext);
|
||||
case ':':
|
||||
vars[lastvar] = lastval;
|
||||
break;
|
||||
case '+':
|
||||
if (o)
|
||||
o -> Augment(source, lastvar, lastval, iscontext);
|
||||
break;
|
||||
case '-':
|
||||
if (o)
|
||||
o -> Diminish(source, lastvar, lastval, iscontext);
|
||||
break;
|
||||
}
|
||||
|
||||
lastmod = mod;
|
||||
lastvar = var;
|
||||
lastval = val;
|
||||
a = b+1;
|
||||
}
|
||||
unless (mc) {
|
||||
// malformed psyc-packet in buf. get on it!
|
||||
if (connection)
|
||||
connection -> w("_error_broken_syntax",
|
||||
"Received packet without method.");
|
||||
ERROR("PSYC parsing failed (Method missing)")
|
||||
}
|
||||
|
||||
if (strlen(buf) == b) { // no data. packet ends with mc
|
||||
buf = "";
|
||||
} else {
|
||||
// still data in buf. buf[b] is the last \n before the psyc-data
|
||||
buf = buf[b+1..];
|
||||
}
|
||||
|
||||
return mc;
|
||||
}
|
||||
|
||||
// not exactly beautiful to have it here, but still more efficient than
|
||||
// having hordes of if (psycd) checks..
|
||||
int deliver(mixed ip, string peerip, object connection, string peeraddr,
|
||||
string host, string data, mapping mvars) {
|
||||
string psycaddr;
|
||||
PT(("deliver(%O, %O, %O, %O)\n", ip, host, data, mvars))
|
||||
mixed o, target = mvars["_target"];
|
||||
int trustworthy = (member(mvars, "_INTERNAL_trust"))
|
||||
? to_int(mvars["_INTERNAL_trust"])
|
||||
: 0;
|
||||
|
||||
|
||||
|
||||
if (ip == -1) {
|
||||
monitor_report("_error_something_because_somebody_was_once_again_too_lazy_to_look_up_a_method_which_most_likely_already_exists_in_library_dns_c", S("%O could not resolve %O.",
|
||||
ME, host));
|
||||
|
||||
if (objectp(connection))
|
||||
connection->w("_error_invalid_host", "Could not resolve [_host].",
|
||||
([ "_host": host ]));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ip && ip != peerip) {
|
||||
monitor_report("_warning_rejected_relay_incoming",
|
||||
"Dropped a packet from "+ peerip +
|
||||
" trying to relay for "+ host);
|
||||
P0(("Dropped a packet from "+ peerip +
|
||||
" trying to relay for "+ host +"\n"+
|
||||
" in parse:deliver(%O, %O, %O, %O)\n",
|
||||
ip, host, data, mvars))
|
||||
if (connection)
|
||||
connection->w("_error_rejected_relay_incoming",
|
||||
"You are not allowed to relay for [_host].",
|
||||
([ "_host": host ]));
|
||||
return 1;
|
||||
} else if (psycaddr = mvars["_context"] || mvars["_source"]) {
|
||||
// schmorp??
|
||||
if (connection)
|
||||
// is psycaddr already lc?
|
||||
register_target(lower_case(psycaddr), connection);
|
||||
} else psycaddr = "psyc://"+peeraddr;
|
||||
|
||||
if (member(mvars, "_source_identification")) {
|
||||
mixed t = lookup_identification(psycaddr,
|
||||
mvars["_source_identification"]);
|
||||
unless (t) {
|
||||
// the i: is a safety measure in case of a supergau
|
||||
// that mvars["_source_identification"] could somehow resemble
|
||||
// some other queue in the system.. not convinced..
|
||||
// see also two more occurences in this file.
|
||||
//
|
||||
string n = "i:"+mvars["_source_identification"]+psycaddr;
|
||||
unless (qExists(n)) qInit(n, 100, 5);
|
||||
enqueue(n, ({ ip, peerip, connection, peeraddr, host, data,
|
||||
mvars }));
|
||||
return 0;
|
||||
} else if (t == mvars["_source_identification"]) {
|
||||
// TODO: increase trustworthy ness
|
||||
mvars["_source_technical"] = psycaddr;
|
||||
mvars["_source"] = mvars["_source_identification"];
|
||||
m_delete(mvars, "_source_identification");
|
||||
} else {
|
||||
PT(("someone (%O) claims an identification (%O) though he is "
|
||||
"already"
|
||||
" registered as someone else. Will we allow multiple"
|
||||
" identifications per unl? Should - in theory - be possible"
|
||||
" and okay. dropping this message.\n",
|
||||
psycaddr, mvars["_source_identification"]))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
string state, err, mc;
|
||||
mixed source, t;
|
||||
mixed *u;
|
||||
int iscontext = 0; // if we are in context-state
|
||||
mapping psycvars = ([ "_INTERNAL_origin" : connection ]);
|
||||
|
||||
// this is our new context-routing without target.
|
||||
// 1 _source
|
||||
// 2 _target
|
||||
// 4 _context
|
||||
switch(
|
||||
(member(mvars, "_source") ? 1 : 0) |
|
||||
(member(mvars, "_target") ? 2 : 0) |
|
||||
(member(mvars, "_context") ? 4 : 0)
|
||||
) {
|
||||
case 5:
|
||||
# if DEBUG > 0
|
||||
PT(("Received both context(%s) and source(%s) from %O\n",
|
||||
mvars["_context"], mvars["_source"], psycaddr))
|
||||
# endif
|
||||
case 4:
|
||||
t = mvars["_context"];
|
||||
state = t;
|
||||
iscontext = 1;
|
||||
o = find_context(t);
|
||||
unless (o) {
|
||||
// no one is interested / online
|
||||
// is this an abuse or a feature?
|
||||
// fippo: feature, context may be 0
|
||||
// if no one who is normally listening is online
|
||||
PT(("Dropped messages from %s because there was no\
|
||||
context slave for %s.\n",
|
||||
psycaddr, mvars["_context"]))
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case 6: // this is unicast from context to target in the context's
|
||||
// state
|
||||
state = mvars["_context"];
|
||||
iscontext = 1;
|
||||
case 3:
|
||||
// "Link to [_source] established.. uses this
|
||||
// and place/slave too (although improperly)
|
||||
//m_delete(mvars, "_source");
|
||||
unless (iscontext) {
|
||||
source = lower_case(mvars["_source"]);
|
||||
state = source;
|
||||
}
|
||||
case 2:
|
||||
t = mvars["_target"];
|
||||
// this is a message from the rootobj but since its target is
|
||||
// not our rootmsg we need to offer some kind of source.
|
||||
// TODO: Why not use ME here ??
|
||||
unless (source)
|
||||
source = psycaddr;
|
||||
if (trustworthy > 7) {
|
||||
P2(("%O relaying permitted for %O to %O via %O\n",
|
||||
ME, source, t, o))
|
||||
// We should do mmp-routing here.. but find out before if
|
||||
// there is any connections registered for that target/host
|
||||
}
|
||||
u = parse_uniform(t);
|
||||
if (u && (u[UResource] == "" || !u[UResource])) {
|
||||
// rootMSG. that parse_uniform makes me quite unhappy.
|
||||
// we may check the string t only for the existance of a
|
||||
// resource since we allready know that it is a valid url.
|
||||
// TODO
|
||||
} else unless (o = psyc_object(t) || find_psyc_object(t)) {
|
||||
PT(("Found no recipent for %O. Dropping message.\n", t))
|
||||
return 1;
|
||||
}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
// this is a message to our rootmsg from someone
|
||||
source = lower_case(mvars["_source"]);
|
||||
break;
|
||||
case 0:
|
||||
// going to our rootmsg from hell
|
||||
source = psycaddr;
|
||||
break;
|
||||
default:
|
||||
PT(("Unimplemented routing-scheme (_source, _target and _context are all present)\n"))
|
||||
return 1;
|
||||
}
|
||||
// can this safely move into one of the ifs above? TODO
|
||||
if (t = mvars["_source_relay"]) {
|
||||
if (t = psyc_object(t)) {
|
||||
P2(("local _source_relay %O from %O, cont %O\n",
|
||||
t, source, mvars["_context"]))
|
||||
mvars["_source_relay"] = t;
|
||||
}
|
||||
}
|
||||
|
||||
unless (mc = spsyc_parse(&data, psycvars, iscontext, state,
|
||||
connection, o)) {
|
||||
if (connection)
|
||||
destruct(connection);
|
||||
return 1;
|
||||
}
|
||||
|
||||
# ifdef PSYC_TCP
|
||||
P2(("TCP[%s] => %O: %s\n", peeraddr, o || t, mc))
|
||||
# else
|
||||
PT(("UDP[%s] => %O: %s\n", peeraddr, o || t, mc))
|
||||
# endif
|
||||
|
||||
# ifndef GOOD_IDEA
|
||||
// why do we parse for auth mcs here if we already do it
|
||||
// in common::rootMsg? if this should be here instead,
|
||||
// you can make these checks a bit more efficient if
|
||||
// you first ensure that the target of this message is
|
||||
// the server root. it's also nicer to the users that
|
||||
// you're not looking at their messages here.. ;)
|
||||
//
|
||||
if (mc == "_error_invalid_authentication") {
|
||||
string n;
|
||||
unless (member(mvars, "_source") &&
|
||||
member(psycvars, "_location")) {
|
||||
PT(("got _error_invalid_authentication without proper"
|
||||
"vars.\n"))
|
||||
return 0;
|
||||
|
||||
}
|
||||
n = "i:"+mvars["_source"]+psycvars["_location"];
|
||||
unless (qExists(n)) {
|
||||
PT(("got _error_invalid_authentication for something we "
|
||||
"never requested.\n"))
|
||||
return 0;
|
||||
}
|
||||
sendmsg(psycvars["_location"], "_error_invalid_source_identification",
|
||||
"Your identification [_location] seems to be bogus. "
|
||||
"Du kommst hier ned rein!\n",
|
||||
([ "_location" : mvars["_source"]]));
|
||||
qDel(n);
|
||||
return 1;
|
||||
} else if (mc == "_notice_authentication") {
|
||||
string n;
|
||||
unless (member(mvars, "_source") &&
|
||||
member(psycvars, "_location")) {
|
||||
PT(("got _notice_authentication without proper"
|
||||
"vars.\n"))
|
||||
return 0;
|
||||
}
|
||||
n = "i:"+mvars["_source"]+psycvars["_location"];
|
||||
unless (qExists(n)) {
|
||||
PT(("got _notice_authentication for something we "
|
||||
"never requested.\n"))
|
||||
return 0;
|
||||
}
|
||||
register_location(psycvars["_location"], mvars["_source"]);
|
||||
while (qSize(n))
|
||||
apply(#'deliver, shift(n));
|
||||
return 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
// we could put these mmp-vars into cvars only to avoid this loop
|
||||
foreach (string key : mvars) {
|
||||
if (mergeRoutingVar(key))
|
||||
psycvars[key] = mvars[key];
|
||||
}
|
||||
PT(("deliver ending with target: %O and mc: %O\n", o, mc))
|
||||
|
||||
if (objectp(o))
|
||||
o -> msg(source, mc, (data == "" ? 0 : data), psycvars, 0,
|
||||
source);
|
||||
else if (connection) {
|
||||
// per-connection "server root" which actually handles
|
||||
// connection feature negotiation
|
||||
connection -> rootMsg(source, mc, data == "" ? 0 : data,
|
||||
psycvars, source);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* wrong order of arguments.. elsaga: how did this ever work!?
|
||||
int msg(mixed target, string mc, mixed data, mapping vars,
|
||||
mixed source, mixed target2) {
|
||||
*/
|
||||
int msg(mixed source, string mc, mixed data, mapping vars,
|
||||
mixed showingLog, mixed target) {
|
||||
string sname;
|
||||
int port;
|
||||
string user, host, obj;
|
||||
string buf, room;
|
||||
object o;
|
||||
mixed t;
|
||||
array(mixed) u = parse_uniform(target);
|
||||
|
||||
unless (u[UHost]) {
|
||||
sendmsg(source, "_failure_unsupported_notation_location",
|
||||
"PSYC server-independent uniform network "
|
||||
"identificators not implemented yet.", 0, 0);
|
||||
return 0;
|
||||
}
|
||||
#if DEBUG > 0
|
||||
unless (stringp(mc)) {
|
||||
P0(("psyc_sendmsg got mc == %O from %O.\n"
|
||||
"probably a mistake when converting a walk_mapping.\n",
|
||||
mc, previous_object()))
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
sname = psyc_name(source);
|
||||
// host = lower_case(u[UHostPort]);
|
||||
// unless (u[URoot]) u[URoot] = "psyc://"+host;
|
||||
|
||||
// TODO: no need for vars
|
||||
unless (mappingp(vars)) vars = ([ ]);
|
||||
P3(("looking for %O(%O) in %O..\n", target, u[UHostPort], targets))
|
||||
// if (member(targets, t2 = u[URoot])) {
|
||||
// t = targets[t2];
|
||||
// if (t) {
|
||||
unless (port = u[UPort]) port = PSYC_SERVICE;
|
||||
else if (port < 0) {
|
||||
sendmsg(vars["_context"] || source,
|
||||
"_failure_network_connect_invalid_port",
|
||||
"No connectable port known for [_source_relay].",
|
||||
([ "_source_relay" : target || u[UHost] ]), ME);
|
||||
// ME shouldn't be necessary! TODO
|
||||
return 0;
|
||||
}
|
||||
host = lower_case(u[UHost]);
|
||||
user = u[UUser];
|
||||
obj = u[UResource];
|
||||
// was: obj = u[UResource];
|
||||
// but probably caused the erratic rootMsg() events
|
||||
//obj = u[UUser] ? "~" + u[UUser] : u[UResource];
|
||||
//
|
||||
// if (host == SERVER_HOST) host = "127.0.0.1";
|
||||
#if 1
|
||||
//
|
||||
// at this point i should be able to recognize targets which are my own!
|
||||
// net/gateway/aim would use that.. TODO
|
||||
//
|
||||
// see also legal_domain and legal_host
|
||||
if (query_udp_port() == port && (host == "127.0.0.1"
|
||||
|| host == "127.1"
|
||||
#ifdef __HOST_IP_NUMBER__
|
||||
|| host == __HOST_IP_NUMBER__
|
||||
#else
|
||||
|| host == myIP
|
||||
#endif
|
||||
// || host == SERVER_HOST
|
||||
// || lower_case(host) == myLowerCaseHost
|
||||
|| host == my_lower_case_host() || host == "localhost")) {
|
||||
if (stringp(obj)) {
|
||||
if (obj[<1] == '/') obj = obj[..<2];
|
||||
if (strlen(obj)) switch(obj[0]) {
|
||||
case '^':
|
||||
case '~':
|
||||
unless(user) user = obj[1..];
|
||||
break;
|
||||
case '$':
|
||||
// no services available yet
|
||||
// but here's the support for them
|
||||
obj[0..0] = "/service/";
|
||||
break;
|
||||
case '@':
|
||||
// t[0..0] = PLACE_PATH;
|
||||
obj = PLACE_PATH + lower_case(obj[1..]);
|
||||
if (o = find_object(obj)) break;
|
||||
// should check for legal name instead
|
||||
// of catch. TODO
|
||||
catch(obj -> load());
|
||||
// fall thru
|
||||
default:
|
||||
o = find_object(obj);
|
||||
D2( if(!o) D(S("OBJECT NOT FOUND: %O\n", t)); )
|
||||
} else unless(user) {
|
||||
// rootMsg(source, mc,
|
||||
// buffer == "" ? 0 : buffer, cvars);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// user@ is ignored if /@ or /~ is given..
|
||||
if (user && !objectp(o)) {
|
||||
o = summon_person(user); //, PSYC_PATH "user");
|
||||
//o = find_person(user);
|
||||
//unless(o) o = createUser(user);
|
||||
}
|
||||
// cache the resulting object for the url
|
||||
register_target(lower_case(target), o);
|
||||
return sendmsg(o, mc, data, vars, source);
|
||||
// or deliver directly?
|
||||
}
|
||||
#endif
|
||||
// okay so we have no existing connection..
|
||||
// current rule of thumb to decide whether to open up a tcp
|
||||
// also all localhost traffic should be handled by udp TODO
|
||||
#ifdef _flag_enable_routing_UDP
|
||||
unless (u[UTransport] == "d" || abbrev("_notice", mc)) {
|
||||
#endif
|
||||
dns_resolve(host, (:
|
||||
object o;
|
||||
string addr = $1;
|
||||
string hopo = $2;
|
||||
string psycaddr = "psyc://"+ addr;
|
||||
|
||||
// if ($3 && $3 != PSYC_SERVICE) {
|
||||
if ($9) {
|
||||
hopo += ":"+$9;
|
||||
addr += ":"+$9;
|
||||
}
|
||||
unless (o = find_target_handler(psycaddr)) {
|
||||
o = ("psyc:"+hopo) -> circuit($2, $3, 0, "psyc", 0,
|
||||
system_queue());
|
||||
}
|
||||
register_target($4, o);
|
||||
register_target("psyc://"+hopo, o);
|
||||
register_target(psycaddr, o);
|
||||
P2(("delivering %O(%O) over %O\n", hopo, $1, o))
|
||||
// psyc/circuit.c will register psyc://IP:PORT at logon()
|
||||
// the last thing missing is a way to register all CNAMEs
|
||||
return o->msg($5, $6, $7, $8, 0, $4);
|
||||
// ip=1 2 3 4 5 6 7 8 9
|
||||
:),
|
||||
host, port, target, sname, mc, data, vars, u[UPort]
|
||||
);
|
||||
return 1;
|
||||
#ifdef _flag_enable_routing_UDP
|
||||
}
|
||||
// fall thru to UDP
|
||||
# if DEBUG > 1
|
||||
if (port) {
|
||||
D(S("UDP[%s:%d] <= %O: %s\n", host, port, source, mc));
|
||||
} else {
|
||||
D(S("UDP[%s] <= %O: %s\n", host, source, mc));
|
||||
}
|
||||
# endif
|
||||
if (objectp(source)) buf = make_psyc(mc, data, vars, source);
|
||||
else buf = make_psyc(mc, data, vars);
|
||||
buf = make_mmp(buf, vars);
|
||||
|
||||
if (host == "localhost") return send_udp(host, port, buf);
|
||||
P3(("send_udp %O:%O packet:\n%O", host,port,buf))
|
||||
dns_resolve(host, (: if ($2 < 0) {
|
||||
send_udp($1, $2, $3);
|
||||
}
|
||||
return; :), port, buf);
|
||||
return 1;
|
||||
#endif /* _flag_enable_routing_UDP */
|
||||
}
|
||||
|
||||
object load() {
|
||||
return ME;
|
||||
}
|
||||
|
||||
int outstate() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
mapping state() {
|
||||
return ([]);
|
||||
}
|
||||
|
||||
void create() {
|
||||
qCreate();
|
||||
}
|
||||
|
||||
#endif // }}}
|
@ -154,19 +154,6 @@ sendmsg(target, mc, data, vars, source, showingLog, callback) {
|
||||
#endif
|
||||
target = t;
|
||||
}
|
||||
#endif //}}}
|
||||
#ifdef FORK //{{{
|
||||
# if 0
|
||||
if (vars) { // shouldn't _count be set for msgs with empty vars, too?
|
||||
// these are overwritten by source, target. maybe we should stop
|
||||
// objects from reusing vars since that could easily be abused
|
||||
// to broatcast junk.
|
||||
m_delete(vars, "_source");
|
||||
m_delete(vars, "_target");
|
||||
// <lynX> why are you manually deleting some vars here which are also
|
||||
// defined in isRouting and do not delete _context or _counter?
|
||||
} else vars = ([ ]);
|
||||
# endif
|
||||
#endif //}}}
|
||||
if (mappingp(vars)) {
|
||||
// uhm. better rename simul-efun-sendmsg and let sendmsg be defined in
|
||||
|
@ -93,13 +93,6 @@ castmsg(source, mc, data, vars) {
|
||||
mixed route;
|
||||
mixed noa; // Nickname of local user Or Amount of people on route
|
||||
// in TIDILY mode should be Mapping of people on route
|
||||
#ifdef FORK // {{{
|
||||
string buf;
|
||||
|
||||
// as ldmud isn't a threading enviroment there shouldn't be a chance of
|
||||
// psycd getting destructed while we're residing in this function.
|
||||
// so we're ensuring its existence only once.
|
||||
#endif // }}}
|
||||
|
||||
P2(("%O castmsg(%O,%O,%O..) for %O\n", ME, source,mc,data, _routes))
|
||||
D4(P2(("%O vars = %O\n", ME, vars)))
|
||||
@ -204,9 +197,6 @@ remove_member(source, origin) {
|
||||
stringp(t = origin) ||
|
||||
#endif
|
||||
t = origin->qOrigin())
|
||||
#ifdef FORK
|
||||
&& t += "/$cslave"
|
||||
#endif
|
||||
&& member(_routes, t)) {
|
||||
RM(source, t);
|
||||
} else if (member(_routes, source)) {
|
||||
@ -267,9 +257,6 @@ insert_member(source, origin) {
|
||||
#endif
|
||||
P2(("%O insert_member(%O, %O)\n", ME, source, origin))
|
||||
if (objectp(origin) && (t = origin->qOrigin())) {
|
||||
#ifdef FORK
|
||||
t = t + "/$cslave";
|
||||
#endif
|
||||
#if defined(TIDILY) && defined(MEMBERS_BY_SOURCE)
|
||||
unless (member(_routes, t)) _routes[t] = m_allocate(1, 0);
|
||||
m_add(_routes[t], source);
|
||||
@ -277,9 +264,6 @@ insert_member(source, origin) {
|
||||
_routes[t]++;
|
||||
#endif
|
||||
} else if (stringp(origin)) {
|
||||
#ifdef FORK
|
||||
origin = origin + "/$cslave";
|
||||
#endif
|
||||
#if defined(TIDILY) && defined(MEMBERS_BY_SOURCE)
|
||||
unless (member(_routes, origin)) _routes[origin] = m_allocate(1, 0);
|
||||
m_add(_routes[origin], source);
|
||||
|
@ -124,11 +124,7 @@ void remove_member(mixed member, mixed origin) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef FORK
|
||||
msg(source, method, data, mapping vars) {
|
||||
#else
|
||||
castmsg(source, method, data, mapping vars) {
|
||||
#endif
|
||||
/*
|
||||
* implement group manager logic
|
||||
* and fan out everything else?
|
||||
|
@ -702,7 +702,6 @@ int xmpp_sendmsg(mixed target, string mc, mixed data, mapping vars,
|
||||
showingLog,otarget);
|
||||
}
|
||||
|
||||
#ifndef FORK
|
||||
// PSYC-enabled message delivery function
|
||||
varargs mixed sendmsg(mixed target, string mc, mixed data, vamapping vars,
|
||||
vamixed source, vaint showingLog, vaclosure callback,
|
||||
@ -972,196 +971,6 @@ varargs mixed sendmsg(mixed target, string mc, mixed data, vamapping vars,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else // FORK {{{
|
||||
|
||||
volatile object _psyced;
|
||||
|
||||
#define PSYCED (_psyced || _psyced = DAEMON_PATH "psyc" -> load(), _psyced)
|
||||
|
||||
object cookie_factory(string uni) { // uni must be lowercase
|
||||
mixed *u;
|
||||
string tmp;
|
||||
object o;
|
||||
|
||||
if (o = targets[uni]) return o;
|
||||
|
||||
u = parse_uniform(uni);
|
||||
unless (u) return 0;
|
||||
|
||||
switch(u[UScheme]) {
|
||||
#ifdef PSYC_PATH
|
||||
case "psyc":
|
||||
if (o = targets[u[URoot]]) {
|
||||
P2(("%O to be delivered on %O's circuit\n",
|
||||
uni, query_ip_name(o) || o ))
|
||||
register_target(uni, o);
|
||||
// was delivermsg(
|
||||
return o;
|
||||
// no more cleansing of targets mapping.. see also net/library.i
|
||||
// } else {
|
||||
// P1(("PSYC/TCP target %O gone!\n", t2))
|
||||
// m_delete( targets, t2 );
|
||||
// }
|
||||
}
|
||||
return PSYCED;;; // three semicolons because of extra importance
|
||||
//return psyc_sendmsg(target,mc,data,vars,showingLog,source,u);
|
||||
#endif
|
||||
#ifdef JABBER_PATH
|
||||
case "xmpp":
|
||||
// actually jabber does not allow other ports
|
||||
// in the url.. but anyway, here
|
||||
// comes a jabber implementation which does.
|
||||
// so you can only use it to debug jabber
|
||||
// code of other psyceds ;)
|
||||
//
|
||||
//tmp = u[UCircuit] || "xmpp:"+ u[UHostPort];
|
||||
tmp = "xmpp:"+ u[UHostPort];
|
||||
if (o = targets[tmp]) {
|
||||
P2(("%O to be delivered on %O\n", uni, o ))
|
||||
} else {
|
||||
// we use C:xmpp:host(:port) as an object name
|
||||
// we can change that if it is confusing
|
||||
#ifdef QUEUE_WITH_SCHEME
|
||||
o = ("C:"+tmp)-> circuit(u[UHost], u[UPort]
|
||||
|| JABBER_S2S_SERVICE, 0, "xmpp-server",
|
||||
tmp, systemQ);
|
||||
#else
|
||||
o = ("C:"+tmp)-> circuit(u[UHost], u[UPort]
|
||||
|| JABBER_S2S_SERVICE, 0, "xmpp-server",
|
||||
u[UHostPort], systemQ);
|
||||
#endif
|
||||
register_target(tmp, o);
|
||||
// jabber scheme makes it impossible to
|
||||
// cohost several servers on one ip#
|
||||
if (u[UPort])
|
||||
register_target("xmpp:"+ u[UHost], o);
|
||||
}
|
||||
register_target(uni, o);
|
||||
return o;
|
||||
//return o->msg(source,mc,data,vars, showingLog,otarget);
|
||||
#else
|
||||
/*
|
||||
case "xmpp":
|
||||
return source -> w("_error_unavailable_scheme",
|
||||
"Scheme '[_scheme]' is not available",
|
||||
([ "_scheme" : "xmpp" ]));
|
||||
*/
|
||||
#endif
|
||||
#ifdef SMTP_PATH
|
||||
case "mailto":
|
||||
unless (tmp = legal_mailto(u[UUserAtHost])) {
|
||||
#if 0
|
||||
source ->w(
|
||||
"_error_invalid_mailto",
|
||||
"Sorry, that doesn't look like a valid email address to me.");
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
}
|
||||
o = summon_person(tmp, SMTP_PATH "user");
|
||||
unless (o) return 0;
|
||||
register_target(uni, o);
|
||||
return o;
|
||||
//o -> msg(source, mc, data, vars);
|
||||
#endif
|
||||
}
|
||||
if (schemes[u[UScheme]])
|
||||
return schemes[u[UScheme]];
|
||||
//return schemes[u[UScheme]]->msg(source, mc, data, vars, showingLog, target);
|
||||
// ifdeffing out isnt the smartest of options, but for now..
|
||||
#ifndef BRAIN
|
||||
if (u[UScheme]
|
||||
# if __EFUN_DEFINED__(regmatch)
|
||||
&&! regmatch(u[UScheme], "[^a-z0-9]")
|
||||
# else
|
||||
&&! sizeof(regexp( ({ u[UScheme] }), "[^a-z0-9]"))
|
||||
# endif
|
||||
) {
|
||||
// current gateway discovery strategy
|
||||
u = parse_uniform("psyc://"+ u[UScheme] +
|
||||
".scheme.psyced.org/$"+ u[UScheme] +
|
||||
"/"+ u[UBody]);
|
||||
return PSYCED;
|
||||
//return psyc_sendmsg(target,mc,data,vars,showingLog,source,u);
|
||||
}
|
||||
#endif
|
||||
// TODO
|
||||
#if 0
|
||||
source ->pr("_error_unknown_scheme",
|
||||
"%O is not a supported protocol scheme.\n",
|
||||
u[UScheme]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
varargs int sendmsg(mixed target, string mc, mixed data, mapping vars,
|
||||
mixed source, int showingLog) { // proto.h!
|
||||
mixed tmp, *u;
|
||||
object o;
|
||||
|
||||
P3(("sendmsg(%O,%O,%O,..,%O,%O)\n",
|
||||
target, mc, data, source, showingLog))
|
||||
|
||||
#ifdef SANDBOX
|
||||
// we can't avoid having this check in here, so we better avoid
|
||||
// having two parallel security systems for the sandbox and thus
|
||||
// disallow sending psyc messages without using sendmsg()..
|
||||
// this keeps the sandbox tidy and intelligible :)
|
||||
//
|
||||
if (extern_call() && (!geteuid(previous_object())
|
||||
|| stringp(geteuid(previous_object()))
|
||||
&& geteuid(previous_object())[0] != '/')) {
|
||||
unless (source == previous_object()
|
||||
|| source == vars["_context"]) {
|
||||
raise_error(sprintf("INVALID SENDMSG by %O(%O) (pretended "
|
||||
"to be target/context %O/%O\n",
|
||||
previous_object(),
|
||||
geteuid(previous_object()),
|
||||
target,
|
||||
vars["_context"]));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
unless (source) source = previous_object();
|
||||
// target = lower_case(target) ist fuer xmpp nicht
|
||||
// gut, weil der resource-teil dort case-sensitive
|
||||
// ist... der node@domain-Part aber nicht
|
||||
if (stringp(target)) {
|
||||
int i;
|
||||
string otarget;
|
||||
|
||||
// ist das nicht ein alter hack fuer net/irc?
|
||||
// wieso issn der in der lib?
|
||||
if ((i = index(target, '%')) != -1) {
|
||||
target[i] = '@';
|
||||
}
|
||||
|
||||
otarget = target;
|
||||
target = lower_case(target);
|
||||
//D("sendmsg for "+target+"\n");
|
||||
tmp = cookie_factory(target);
|
||||
if (tmp) { // && interactive(tmp)) {
|
||||
PT(("delivery agent %O for %O (%s)\n", tmp, target,
|
||||
mc || "0"))
|
||||
return tmp->msg(source, mc, data, vars, showingLog, otarget);
|
||||
}
|
||||
// TODO ERROR
|
||||
}
|
||||
if (objectp(target)) {
|
||||
// returnwert sagt aus, ob msg dargestellt werden will
|
||||
// nicht aber, dass sie erfolgreich angekommen ist, denn das ist ja eh
|
||||
target -> msg(source, mc, data, vars, showingLog);
|
||||
// deshalb machen wir das lieber selber klar
|
||||
return 2;
|
||||
}
|
||||
D2(else D(S("sendmsg encountered %O as target for (%O,%s,%O,%O)\n",
|
||||
target, source, mc, data, vars));)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // FORK }}}
|
||||
|
||||
#ifndef __PIKE__
|
||||
|
||||
#ifdef PSYC_PATH
|
||||
|
@ -299,11 +299,7 @@ nomask mixed call_other(mixed obj, string func, varargs mixed * b) {
|
||||
int i;
|
||||
|
||||
if ((i = index(s, '#')) == -1) i = strlen(s) - 1;
|
||||
unless (func == "qName"
|
||||
#ifdef FORK
|
||||
|| func == "qOrigin"
|
||||
#endif
|
||||
) switch (s[..i]) {
|
||||
unless (func == "qName") switch (s[..i]) {
|
||||
case "net/person#":
|
||||
case "net/user#":
|
||||
//if (func == "qName" || func == "msg") break;
|
||||
|
@ -1362,10 +1362,6 @@ msg(source, mc, data, mapping vars) {
|
||||
}
|
||||
P1(("no. he's local.\n"))
|
||||
#endif
|
||||
#ifdef FORK // {{{
|
||||
if (member(vars, "_INTERNAL_origin")
|
||||
&& !vars["_INTERNAL_origin"]) return;
|
||||
#endif // }}}
|
||||
if (neu) // mayEnter hook
|
||||
unless (enter(source, mc, data, vars)) return;
|
||||
insert_member(source, mc, data, vars, ni, neu, again);
|
||||
|
@ -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…
Reference in New Issue
Block a user