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:
parent
8f98522570
commit
94530cc322
136 changed files with 3222 additions and 2873 deletions
|
@ -1,5 +1,5 @@
|
|||
// vim:foldmethod=marker:syntax=lpc:noexpandtab
|
||||
// $Id: circuit.c,v 1.33 2008/03/29 16:00:02 fippo Exp $
|
||||
// $Id: circuit.c,v 1.38 2008/10/14 19:02:29 lynx Exp $
|
||||
|
||||
#include "psyc.h"
|
||||
#include <net.h>
|
||||
|
@ -62,7 +62,7 @@ varargs mixed croak(string mc, string data, vamapping vars, vamixed source) {
|
|||
}
|
||||
|
||||
// gets called during socket logon
|
||||
int logon(int success) {
|
||||
int logon(int failure) {
|
||||
sAuthHosts(([ ])); // reset authhosts
|
||||
legal_senders = ([ ]);
|
||||
instate = ([ "_INTERNAL_origin" : ME]);
|
||||
|
@ -119,7 +119,11 @@ int logon(int success) {
|
|||
|
||||
peerip = query_ip_number(ME) || "127.0.0.1";
|
||||
|
||||
#if __EFUN_DEFINED__(enable_binary)
|
||||
enable_binary(ME);
|
||||
#else
|
||||
# echo Driver compiled without enable_binary() - PSYC functionality warning!
|
||||
#endif
|
||||
input_to(#'feed, INPUT_IGNORE_BANG);
|
||||
|
||||
call_out(#'quit, 90);
|
||||
|
@ -185,206 +189,8 @@ mapping process_header(mixed varops) {
|
|||
return vars;
|
||||
}
|
||||
|
||||
// handling of packets received
|
||||
void done(mixed header_vars, mixed varops, mixed method, mixed body) {
|
||||
string vname;
|
||||
mixed vop; // value operation
|
||||
mapping vars;
|
||||
string t;
|
||||
|
||||
// check that method is a valid keyword
|
||||
if (method && !legal_keyword(method)) {
|
||||
CIRCUITERROR("non legal method");
|
||||
}
|
||||
// copy() + occasional double modifier ops should be more
|
||||
// efficient than merge at every packet --lynX
|
||||
// no one cares about "efficiency" here. please proof your
|
||||
// bold statements with benchmarks anyway
|
||||
vars = header_vars + instate;
|
||||
|
||||
// FIXME: this can happen earlier, e.g. in parse.c after
|
||||
// process_header
|
||||
// check _source/_context
|
||||
// this check can be skipped if _source and _context are empty
|
||||
if ((t = vars["_context"] || vars["_source"])) {
|
||||
array(mixed) u;
|
||||
unless (u = parse_uniform(t)) {
|
||||
CIRCUITERROR("logical source is not an uniform\n")
|
||||
}
|
||||
unless (qAuthenticated(NAMEPREP(u[UHost]))) {
|
||||
CIRCUITERROR("non-authenticated host\n")
|
||||
}
|
||||
}
|
||||
// check that _target is hosted by us
|
||||
// this check can be skipped if _target is not set
|
||||
if ((t = vars["_target"])) {
|
||||
array(mixed) u;
|
||||
unless (u = parse_uniform(t)) {
|
||||
CIRCUITERROR("target is not an uniform\n")
|
||||
}
|
||||
// FIXME relaying support here?
|
||||
if (!(is_localhost(u[UHost])) || u[UHost] == "localhost") {
|
||||
CIRCUITERROR("target is not configured on this server\n")
|
||||
}
|
||||
}
|
||||
// FIXME: i dont like this block... maybe we decode each variable
|
||||
// when setting it?
|
||||
// that would also fit with 0 as varname deletion
|
||||
// below
|
||||
foreach(vop : varops) {
|
||||
vname = vop[0];
|
||||
// TODO unpack _amount
|
||||
// TODO unpack _time
|
||||
if (abbrev("_list", vname)) {
|
||||
mixed plist = list_parse(vop[2]);
|
||||
if (plist == -1) {
|
||||
CIRCUITERROR("could not parse list");
|
||||
}
|
||||
vop[2] = plist;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME deliver packet
|
||||
// this should be a separate function
|
||||
PT(("vars is %O\n", vars))
|
||||
PT(("method %O\nbody %O\n", method, body))
|
||||
PT(("packet done\n"))
|
||||
// delivery rules as usual, but
|
||||
if (vars["_context"]) {
|
||||
mixed context;
|
||||
mixed context_state;
|
||||
mixed source, target;
|
||||
|
||||
if (vars["_source"]) {
|
||||
P0(("invalid _context %O with _source %O\n",
|
||||
context, vars["_source"]))
|
||||
CIRCUITERROR("invalid usage of context with _source");
|
||||
}
|
||||
|
||||
context = find_context(vars["_context"]);
|
||||
if (!objectp(context)) {
|
||||
P0(("context %O not found?!\n", vars["_context"]))
|
||||
return;
|
||||
}
|
||||
context_state = context->get_state();
|
||||
|
||||
// apply varops to context state
|
||||
foreach(vop : varops) {
|
||||
vname = vop[0];
|
||||
if (!legal_keyword(vname) || abbrev("_INTERNAL", vname)) {
|
||||
CIRCUITERROR("illegal varname in psyc")
|
||||
}
|
||||
|
||||
switch(vop[1]) { // the glyph
|
||||
case C_GLYPH_MODIFIER_SET:
|
||||
vars[vname] = vop[2];
|
||||
break;
|
||||
case C_GLYPH_MODIFIER_ASSIGN:
|
||||
vars[vname] = context_state[vname] = vop[2];
|
||||
break;
|
||||
case C_GLYPH_MODIFIER_AUGMENT:
|
||||
if (!abbrev("_list", vname)) {
|
||||
CIRCUITERROR("psyc modifier + with non-list arg")
|
||||
}
|
||||
// FIXME: duplicates?
|
||||
context_state[vname] += vop[2];
|
||||
PT(("current state is %O, augment %O\n", context_state[vname], vop[2]))
|
||||
break;
|
||||
case C_GLYPH_MODIFIER_DIMINISH:
|
||||
if (!abbrev("_list", vname)) {
|
||||
CIRCUITERROR("psyc modifier + with non-list arg")
|
||||
}
|
||||
PT(("current state is %O, diminish %O\n", context_state[vname], vop[2]))
|
||||
foreach(mixed item : vop[2])
|
||||
context_state[vname] -= ({ item });
|
||||
PT(("after dim: %O\n", context_state[vname]))
|
||||
break;
|
||||
case C_GLYPH_MODIFIER_QUERY:
|
||||
CIRCUITERROR("psyc modifier ? not implemented")
|
||||
break;
|
||||
}
|
||||
}
|
||||
vars = vars + context_state;
|
||||
// FIXME: is it legal to do this if this has _target?
|
||||
// there should be no mods then anyway
|
||||
context->commit_state(context_state);
|
||||
|
||||
|
||||
if (vars["_target"]) {
|
||||
// FIXME: delivery copycat from below
|
||||
// beware: source is set to 0 here as it may not be present
|
||||
target = find_psyc_object(parse_uniform(vars["_target"]));
|
||||
PT(("target is %O\n", target))
|
||||
// FIXME: net/entity can not yet deal with 0 method
|
||||
//
|
||||
if (objectp(context)) {
|
||||
context->msg(0, method || "", body, vars, 0, target);
|
||||
} else {
|
||||
// FIXME: proper croak back to sender here
|
||||
P0(("context %O for unicast to %O not found???\n", target))
|
||||
}
|
||||
} else {
|
||||
if (vars["_source_relay"]) {
|
||||
mixed localrelay;
|
||||
if ((localrelay = psyc_object(vars["_source_relay"]))) {
|
||||
P0(("local relay %O\n", localrelay))
|
||||
vars["_source_relay"] = localrelay;
|
||||
} else { // NORMALIZE UNIFORM
|
||||
vars["_source_relay"] = lower_case(vars["_source_relay"]);
|
||||
}
|
||||
}
|
||||
if (objectp(context)) {
|
||||
// do we need more local object detection here?
|
||||
context -> castmsg(source, method || "", body, vars);
|
||||
} else {
|
||||
// empty contexts are not bad currently
|
||||
// in the current implementation it only means that no one
|
||||
// interested in that context is online right now
|
||||
// FIXME: lines above are about the old stuff where we did
|
||||
// not have context state
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!vars["_target"] && !vars["_source"]) {
|
||||
circuit_msg(method, vars, body);
|
||||
} else {
|
||||
string source;
|
||||
mixed target;
|
||||
if (!vars["_source"]) {
|
||||
// FIXME: where to set netloc in active
|
||||
if (!netloc) { // set in sender after _request_features
|
||||
// FIXME: this is wrong
|
||||
CIRCUITERROR("Did you forget to request circuit features?");
|
||||
}
|
||||
source = netloc;
|
||||
} else {
|
||||
// FIXME: a macro NORMALIZE_UNIFORM that may do lower_case please
|
||||
// not a simple lower_case
|
||||
source = lower_case(vars["_source"]);
|
||||
}
|
||||
// source was checked either via x509 or dns before
|
||||
// so it is 'safe' to do this
|
||||
register_target(source);
|
||||
|
||||
|
||||
// deliver FIXME same code above
|
||||
if (!vars["_target"]) {
|
||||
target = find_object(NET_PATH "root");
|
||||
} else {
|
||||
target = find_psyc_object(parse_uniform(vars["_target"]));
|
||||
}
|
||||
PT(("target is %O\n", target))
|
||||
// FIXME: net/entity can not yet deal with 0 method
|
||||
if (objectp(target))
|
||||
target->msg(source, method || "", body, vars);
|
||||
else {
|
||||
// FIXME: proper croak back to sender here
|
||||
P0(("target %O not found???\n", target))
|
||||
}
|
||||
}
|
||||
}
|
||||
::done(header_vars, varops, method, body);
|
||||
}
|
||||
#define PSYC_TCP
|
||||
#include "dispatch.i"
|
||||
|
||||
// request sender authentication and/or target acknowledgement
|
||||
// from the remote side
|
||||
|
@ -486,8 +292,8 @@ varargs int msg(string source, string mc, string data,
|
|||
|
||||
unless(vars) vars = ([ ]);
|
||||
buf = psyc_render(source, mc, data, vars, showingLog, target);
|
||||
#ifdef _flag_log_sockets_PSYC
|
||||
log_file("RAW_PSYC", "» %O\n%s\n", ME, buf);
|
||||
#ifdef _flag_log_sockets_SPYC
|
||||
log_file("RAW_SPYC", "» %O\n%s\n", ME, buf);
|
||||
#endif
|
||||
return emit(buf);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// vim:foldmethod=marker:syntax=lpc:noexpandtab
|
||||
// $Id: parse.c,v 1.24 2008/03/29 16:00:02 fippo Exp $
|
||||
// $Id: parse.c,v 1.30 2008/12/18 18:16:14 lynx Exp $
|
||||
//
|
||||
#include "psyc.h"
|
||||
#include <net.h>
|
||||
|
@ -63,8 +63,8 @@ void resume_parse() {
|
|||
|
||||
// input data to the buffer
|
||||
void feed(string data) {
|
||||
# ifdef _flag_log_sockets_PSYC
|
||||
log_file("RAW_PSYC", "» %O\n%s\n", ME, data);
|
||||
# ifdef _flag_log_sockets_SPYC
|
||||
log_file("RAW_SPYC", "« %O\n%s\n", ME, data);
|
||||
# endif
|
||||
buffer += data;
|
||||
|
||||
|
@ -82,7 +82,7 @@ varargs mixed croak(string mc, string data, vamapping vars, vamixed source) {
|
|||
|
||||
|
||||
// called when a complete packet has arrived
|
||||
void done(mixed header_vars, mixed varops, mixed method, mixed body) {
|
||||
void dispatch(mixed header_vars, mixed varops, mixed method, mixed body) {
|
||||
parser_reset();
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ void parse_header() {
|
|||
buffer = buffer[2..];
|
||||
hvars = process_header(tvars);
|
||||
tvars = ({ });
|
||||
done(hvars, tvars, 0, 0);
|
||||
dispatch(hvars, tvars, 0, 0);
|
||||
} else {
|
||||
// this one is sth like |whatever
|
||||
// actually this should be noglyph i think
|
||||
|
@ -174,7 +174,7 @@ void parse_header() {
|
|||
break;
|
||||
case '\n': // deletion
|
||||
// this is currently implemented as "vvalue is 0" internally
|
||||
// and must handled in done() when merging
|
||||
// and must handled in dispatch() when merging
|
||||
buffer = buffer[1..];
|
||||
break;
|
||||
default:
|
||||
|
@ -273,6 +273,9 @@ void parse_content() {
|
|||
int fit;
|
||||
string method, body;
|
||||
|
||||
// at this point we should check for relaying, then potentially
|
||||
// route the data without parsing it.. TODO
|
||||
|
||||
parse_psyc();
|
||||
// ASSERT strlen(buffer)
|
||||
if (body_buffer[0] == C_LINEFEED) {
|
||||
|
@ -282,7 +285,7 @@ void parse_content() {
|
|||
// FIXME: i am not sure if this is correct...
|
||||
if (body_buffer == S_GLYPH_PACKET_DELIMITER) {
|
||||
P0(("encountered packet delimiter in packet body? how's that?\n"))
|
||||
done(hvars, tvars, 0, 0);
|
||||
dispatch(hvars, tvars, 0, 0);
|
||||
return;
|
||||
}
|
||||
fit = sscanf(body_buffer, "%.1s\n%.0s", method, body_buffer);
|
||||
|
@ -295,7 +298,7 @@ void parse_content() {
|
|||
// mhmm... why does body_buffer still contain the newline?
|
||||
// because the newline is by definition not part of the body!
|
||||
if (strlen(body_buffer)) body = body_buffer[..<2];
|
||||
done(hvars, tvars, method, body);
|
||||
dispatch(hvars, tvars, method, body);
|
||||
}
|
||||
|
||||
// buffer content until complete
|
||||
|
@ -304,19 +307,25 @@ void parse_content() {
|
|||
// the packet
|
||||
void buffer_content() {
|
||||
int t;
|
||||
if (body_len && strlen(buffer) >= body_len + 3) {
|
||||
// make sure that the packet is properly terminated
|
||||
if (buffer[body_len..body_len+2] != "\n" DELIM) {
|
||||
PARSEERROR("binary packet delimiter")
|
||||
if (body_len) {
|
||||
if (strlen(buffer) >= body_len + 3) {
|
||||
// make sure that the packet is properly terminated
|
||||
if (buffer[body_len..body_len+2] != "\n" DELIM) {
|
||||
PARSEERROR("packet delimiter after binary body not found")
|
||||
}
|
||||
body_buffer = buffer[..body_len];
|
||||
buffer = buffer[body_len+3..];
|
||||
parse_content();
|
||||
} else {
|
||||
P4(("buffer_content: waiting for more binary data\n"))
|
||||
}
|
||||
body_buffer = buffer[..body_len];
|
||||
buffer = buffer[body_len+3..];
|
||||
parse_content();
|
||||
} else if ((t = strstr(buffer, "\n" DELIM)) != -1) {
|
||||
body_buffer = buffer[..t];
|
||||
buffer = buffer[t+3..];
|
||||
parse_content();
|
||||
P4(("buffer_content: packet complete\n"))
|
||||
} else {
|
||||
P4(("buffer_content: waiting for more plain data. buffer %O vs %O\n", to_array(buffer), to_array("\n" DELIM)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,6 +336,7 @@ void first_response() {
|
|||
|
||||
// parser stepping function
|
||||
void step() {
|
||||
P3(("%O step: state %O, buffer %O\n", ME, state, buffer))
|
||||
if (!strlen(buffer))
|
||||
return;
|
||||
switch(state) {
|
||||
|
@ -345,7 +355,7 @@ void step() {
|
|||
return;
|
||||
if (buffer[0..1] == DELIM) {
|
||||
state = PSYCPARSE_STATE_HEADER;
|
||||
buffer = buffer[2..];
|
||||
buffer = buffer[2 ..];
|
||||
first_response();
|
||||
step();
|
||||
} else {
|
||||
|
|
|
@ -30,4 +30,11 @@
|
|||
#define PSYCPARSE_STATE_BLOCKED 2
|
||||
#define PSYCPARSE_STATE_GREET 3
|
||||
|
||||
#define DISPATCHERROR(reason) { \
|
||||
debug_message("SPYC DISPATCH ERROR: " reason); \
|
||||
croak("_error_dispatch", "dispatch error: " \
|
||||
reason); \
|
||||
return; \
|
||||
}
|
||||
|
||||
#include <psyc.h>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// vim:foldmethod=marker:syntax=lpc:noexpandtab
|
||||
// $Id: server.c,v 1.14 2008/03/11 13:42:27 lynx Exp $
|
||||
// $Id: server.c,v 1.18 2008/12/18 18:16:14 lynx Exp $
|
||||
//
|
||||
// the thing that answers on port 4404 of psyced.
|
||||
|
||||
|
@ -67,7 +67,7 @@ static void resolved(mixed host, mixed tag) {
|
|||
mixed uni, psycip;
|
||||
|
||||
unless (stringp(host)) {
|
||||
#if 1 //ndef BETA
|
||||
#if 1 //ndef SYMLYNX
|
||||
if (host == -2) {
|
||||
monitor_report("_warning_invalid_hostname",
|
||||
S("%O: %O has an invalid IN PTR", ME,
|
||||
|
@ -96,7 +96,7 @@ static void resolved(mixed host, mixed tag) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
// we sent them to beta, so let beta be easy on them
|
||||
// we sent them to the test server, so let it be easy on them
|
||||
host = peerip;
|
||||
#endif
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ static void resolved(mixed host, mixed tag) {
|
|||
if (peerport && peerport != PSYC_SERVICE) peeraddr += ":"+peerport;
|
||||
netloc = "psyc://"+peeraddr+"/";
|
||||
register_target( netloc );
|
||||
#if 1 // OPTIONAL
|
||||
#ifndef _flag_disable_module_authentication // OPTIONAL
|
||||
// should this server be connected to a psyc client, then the new
|
||||
// resolved name of the connection may have to be recognized as
|
||||
// location for the person. finally this code should be unnecessary
|
||||
|
@ -140,8 +140,8 @@ static void resolved(mixed host, mixed tag) {
|
|||
// cleanup? are you sure we will never need this again?
|
||||
register_location(psycip, 0); //cleanup
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // _flag_disable_module_authentication
|
||||
|
||||
// PIKE TPD: says psyc://127.0.0.1/ here .. should say
|
||||
// psyc://localhost:-23232/ instead
|
||||
P2(("%O resolves as %O (UNI %O)\n", ME, netloc, uni))
|
||||
|
@ -158,6 +158,26 @@ static void resolved(mixed host, mixed tag) {
|
|||
msg(0, "_notice_features", 0, tag ? ([ "_tag_reply" : tag ]) : 0);
|
||||
}
|
||||
|
||||
// this only gets called from net/psyc.. FIXME
|
||||
void greet() {
|
||||
// should be doing sTextPath(); here ?
|
||||
// should be sharing code with net/psyc and do a proper greeting
|
||||
// three separate packets follow (thus three emits)
|
||||
emit(S_GLYPH_PACKET_DELIMITER "\n");
|
||||
emit("\
|
||||
:_source\t"+ query_server_unl() +"\n\
|
||||
:_target_peer\tpsyc://"+ peeraddr +"/\n\
|
||||
\n\
|
||||
_notice_circuit_established\n" S_GLYPH_PACKET_DELIMITER "\n");
|
||||
emit("\
|
||||
:_source\t"+ query_server_unl() +"\n\
|
||||
\n\
|
||||
_status_circuit\n"); // S_GLYPH_PACKET_DELIMITER "\n");
|
||||
// last pipe is generated by fippo's code
|
||||
#ifdef _flag_log_sockets_SPYC
|
||||
log_file("RAW_SPYC", "» %O greeted.\n", ME);
|
||||
#endif
|
||||
}
|
||||
|
||||
void circuit_msg(string mc, mapping vars, string data) {
|
||||
switch(mc) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// vim:foldmethod=marker:syntax=lpc:noexpandtab
|
||||
// $Id: udp.c,v 1.3 2008/02/19 16:28:41 lynx Exp $
|
||||
// $Id: udp.c,v 1.7 2008/07/17 15:07:59 lynx Exp $
|
||||
|
||||
#include "psyc.h"
|
||||
#include <net.h>
|
||||
|
@ -8,22 +8,10 @@
|
|||
|
||||
inherit NET_PATH "spyc/parse";
|
||||
|
||||
#define CIRCUITERROR(reason) { debug_message("PSYC CIRCUIT ERROR: " reason); \
|
||||
croak("_error_circuit", "circuit error: " \
|
||||
reason); \
|
||||
return; \
|
||||
}
|
||||
|
||||
string netloc;
|
||||
|
||||
parseUDP2(host, ip, port, msg); // prototype
|
||||
|
||||
object load() { return ME; } // avoid a find_object call in obj/master
|
||||
|
||||
parseUDP(ip, port, msg) {
|
||||
dns_rresolve(ip, #'parseUDP2, ip, port, msg);
|
||||
}
|
||||
|
||||
// respond to the first packet - or don't do it
|
||||
first_response() { }
|
||||
|
||||
|
@ -39,155 +27,12 @@ parseUDP2(host, ip, port, msg) {
|
|||
feed(msg);
|
||||
}
|
||||
|
||||
void done(mixed varops, mixed method, mixed body) {
|
||||
string vname;
|
||||
mixed vop; // value operation
|
||||
mapping vars = ([ ]); // udp is stateless
|
||||
string t;
|
||||
|
||||
// FIXME: ideally, those unpacks would happen after the checks
|
||||
// that get a packet rejected
|
||||
// FIXME: this allows binary lists in mmp
|
||||
foreach(vname, vop : varops) {
|
||||
// TODO unpack _amount
|
||||
// TODO unpack _time
|
||||
if (abbrev("_list", vname)) {
|
||||
mixed plist = list_parse(vop[2]);
|
||||
if (plist == -1) {
|
||||
CIRCUITERROR("could not parse list");
|
||||
}
|
||||
vop[2] = plist;
|
||||
}
|
||||
}
|
||||
// apply mmp state
|
||||
foreach(vname, vop : varops) {
|
||||
if (vop[1] == 1) // vname was encountered in psyc part
|
||||
continue;
|
||||
switch(vop[0]) {
|
||||
case C_GLYPH_MODIFIER_SET:
|
||||
vars[vname] = vop[2];
|
||||
break;
|
||||
case C_GLYPH_MODIFIER_ASSIGN:
|
||||
case C_GLYPH_MODIFIER_AUGMENT:
|
||||
case C_GLYPH_MODIFIER_DIMINISH:
|
||||
case C_GLYPH_MODIFIER_QUERY:
|
||||
CIRCUITERROR("stateful operation in udp mode")
|
||||
break;
|
||||
}
|
||||
// FIXME: not every legal varname is a mmp varname
|
||||
// look at shared_memory("routing")
|
||||
if (!legal_keyword(vname) || abbrev("_INTERNAL", vname)) {
|
||||
CIRCUITERROR("illegal varname in header")
|
||||
}
|
||||
}
|
||||
|
||||
// check _source/_context
|
||||
// this check can be skipped if _source and _context are empty
|
||||
if ((t = vars["_context"] || vars["_source"])) {
|
||||
array(mixed) u;
|
||||
unless (u = parse_uniform(t)) {
|
||||
CIRCUITERROR("logical source is not an uniform\n")
|
||||
}
|
||||
}
|
||||
// check that _target is hosted by us
|
||||
// this check can be skipped if _target is empty
|
||||
if ((t = vars["_target"])) {
|
||||
array(mixed) u;
|
||||
unless (u = parse_uniform(t)) {
|
||||
CIRCUITERROR("target is not an uniform\n")
|
||||
}
|
||||
// FIXME relaying support here?
|
||||
unless (is_localhost(u[UHost])) {
|
||||
CIRCUITERROR("target is not configured on this server\n")
|
||||
}
|
||||
}
|
||||
foreach(vname, vop : varops) {
|
||||
if (vop[1] == 0) // vname was encountered in mmp header
|
||||
continue;
|
||||
|
||||
switch(vop[0]) { // the glyph
|
||||
case C_GLYPH_MODIFIER_SET:
|
||||
vars[vname] = vop[2];
|
||||
break;
|
||||
case C_GLYPH_MODIFIER_ASSIGN:
|
||||
case C_GLYPH_MODIFIER_AUGMENT:
|
||||
case C_GLYPH_MODIFIER_DIMINISH:
|
||||
case C_GLYPH_MODIFIER_QUERY:
|
||||
CIRCUITERROR("stateful operation in udp mode")
|
||||
break;
|
||||
}
|
||||
if (!legal_keyword(vname) || abbrev("_INTERNAL", vname)) {
|
||||
CIRCUITERROR("illegal varname in psyc")
|
||||
}
|
||||
}
|
||||
PT(("vars is %O\n", vars))
|
||||
PT(("method %O\nbody %O\n", method, body))
|
||||
PT(("packet done\n"))
|
||||
// delivery rules as usual, but
|
||||
if (vars["_context"]) {
|
||||
mixed context;
|
||||
mixed source, target;
|
||||
|
||||
if (vars["_source"] && vars["_target"]) {
|
||||
P0(("invalid _context %O with _source %O, _target %O\n",
|
||||
context, vars["_source"], vars["_target"]))
|
||||
CIRCUITERROR("invalid usage of context with _source and _target");
|
||||
} else if (vars["_source"]) {
|
||||
P0(("invalid _context %O with _source %O and empty _target\n",
|
||||
context, vars["_source"]))
|
||||
CIRCUITERROR("invalid usage of context with _source");
|
||||
} else if (vars["_target"]) {
|
||||
// as we don't have psyc e2e state yet...
|
||||
P0(("unicast from context %O to target %O not implemented yet\n",
|
||||
context, vars["_target"]))
|
||||
CIRCUITERROR("unicast from context to single member not implemented yet");
|
||||
} else {
|
||||
if (vars["_source_relay"]) {
|
||||
mixed localrelay;
|
||||
if ((localrelay = psyc_object(vars["_source_relay"]))) {
|
||||
P0(("local relay %O\n", localrelay))
|
||||
vars["_source_relay"] = localrelay;
|
||||
} else { // NORMALIZE UNIFORM
|
||||
vars["_source_relay"] = lower_case(vars["_source_relay"]);
|
||||
}
|
||||
}
|
||||
context = find_context(vars["_context"]);
|
||||
if (objectp(context)) {
|
||||
// FIXME: we need lots of local object detection here
|
||||
context -> castmsg(source, method || "", body, vars);
|
||||
} else {
|
||||
// empty contexts are not bad currently
|
||||
// in the current implementation it only means that no one
|
||||
// interested in that context is online right now
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!vars["_target"] && !vars["_source"]) {
|
||||
CIRCUITERROR("circuit_msg over udp?");
|
||||
} else {
|
||||
string source;
|
||||
mixed target;
|
||||
if (!vars["_source"]) {
|
||||
source = netloc;
|
||||
} else {
|
||||
// FIXME: a macro NORMALIZE_UNIFORM that may do lower_case please
|
||||
// not a simple lower_case
|
||||
source = lower_case(vars["_source"]);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
if (!vars["_target"])
|
||||
return;
|
||||
// deliver
|
||||
target = find_psyc_object(parse_uniform(vars["_target"]));
|
||||
PT(("target is %O\n", target))
|
||||
// FIXME: net/entity can not yet deal with 0 method
|
||||
if (objectp(target))
|
||||
target->msg(source, method || "", body, vars);
|
||||
else {
|
||||
P0(("target %O not found???\n", target))
|
||||
}
|
||||
}
|
||||
}
|
||||
::done(varops, method, body);
|
||||
parseUDP(ip, port, msg) {
|
||||
P0(("parseUDP from %s:%O %O\n", ip, port, msg))
|
||||
dns_rresolve(ip, #'parseUDP2, ip, port, msg);
|
||||
}
|
||||
|
||||
// dispatch for UDP isn't really working, but it is completely
|
||||
// ignoring the routing vars.. TODO FIXME
|
||||
#define PSYC_UDP
|
||||
#include "dispatch.i"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue