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

replace the local server nickspace by autoalias!

This commit is contained in:
psyc://psyced.org/~lynX 2009-03-04 00:40:26 +01:00
parent a4e16cd2c4
commit 8e4e990261
46 changed files with 246 additions and 101 deletions

View file

@ -5,7 +5,7 @@
#ifdef FORK // {{{
#include <net.h>
#include <url.h>
#include <uniform.h>
#include <services.h>
inherit NET_PATH "state";

View file

@ -20,7 +20,7 @@
#include <net.h>
#include <storage.h>
#include <url.h>
#include <uniform.h>
#ifdef ENTITY_STATE //{{{
# define HEADER_ONLY

View file

@ -12,7 +12,7 @@
// necessity to recover.
//
#include <net.h>
#include <url.h>
#include <uniform.h>
//#include <text.h>
inherit NET_PATH "gateway/generic";

View file

@ -19,7 +19,7 @@
// gateway in python (see aim.c)
//
#include <net.h>
#include <url.h>
#include <uniform.h>
//#include <text.h>
#include <xml.h>

View file

@ -28,7 +28,7 @@
#include <net.h>
#include <person.h>
#include <status.h>
#include <url.h>
#include <uniform.h>
#ifdef CONTEXT_STATE // {{{
# define HEADER_ONLY

View file

@ -18,7 +18,7 @@
#ifdef PERSISTENT_SLAVES
# define PARANOID_PERSISTENT_SLAVES
# include <url.h>
# include <uniform.h>
inherit NET_PATH "storage";
private volatile string _file;

View file

@ -4,7 +4,7 @@
#include <net.h>
#include <text.h>
#include <person.h>
#include <url.h>
#include <uniform.h>
#define NO_INHERIT
#include <user.h>

View file

@ -6,7 +6,7 @@
//
#include <ht/http.h>
#include <net.h>
#include <url.h>
#include <uniform.h>
#include <services.h>
virtual inherit NET_PATH "output"; // virtual: in case we get inherited..

View file

@ -17,7 +17,7 @@
# define HTTP_PORT 44444 // should return null instead?
#endif
// not worthy of summoning url.h for this one..
// not worthy of summoning uniform.h for this one..
string htuniform(object server, string prot, mapping headers) {
// it is really totally crazy to trust what the browser says
string host = headers["host"];

View file

@ -8,7 +8,7 @@
//
#include <ht/http.h>
#include <net.h>
#include <url.h>
#include <uniform.h>
#include <xml.h>
#include <lpctypes.h>

View file

@ -11,13 +11,11 @@
#define RANDHEXSTRING sprintf("%x", random(__INT_MAX__))
// maybe we should expect psyc usage peak around 2030?
// or will psyc reform its protocol by then anyway?
// ok.. let's go for 2009 so we can renovate time formats
// around 2020.. by the way, 2009-02-14 is a saturday, so
// we'll be having a hot friday night party for psyc epoch!
//
#define PSYC_EPOCH 1234567890 // 2009-02-14 00:31:30 CET
// maybe we should expect psyc usage peak around 2030
//efine PSYC_EPOCH 1234567890 // 2009-02-14 00:31:30 CET
#define PSYC_EPOCH 1440444041 // 2015-08-24 21:20:41 CET (Monday)
// 2000000000 is 2033-05-18 05:33:20 CET (Wednesday)
// 2002002002 is 2033-06-10 09:40:02 CET (Friday)
// TODO: new driver will be able to combine \n, too
// new expat parser will also be able to combine >
@ -230,6 +228,7 @@
#endif
#ifdef EXPERIMENTAL
# define USE_AUTOALIAS
// fippo's brilliant single-user channel emulation for jabber MUCs
// unfortunately it provides no advantages over the old method, yet.
// would be cool to cache a member list at least! TODO
@ -243,6 +242,7 @@
//# ifndef __PIKE__
//# define USE_LIVING
//# endif
# define USE_THE_NICK
#endif
#ifdef __NO_SRV__ // since psyclpc 4.0.4

View file

@ -16,7 +16,7 @@
#include <net.h>
#include <storage.h>
#include <status.h>
#include <url.h>
#include <uniform.h>
#ifdef BRAIN

View file

@ -19,9 +19,10 @@
#define UHostPort 12 // just host:port (and transport)
#define URoot 13 // root UNI of peer/server
#define USlashes 14 // the // if the protocol has them
//efine UCircuit 15 // scheme:host:port
#define UNick 15 // whatever works as a nickname
//efine UCircuit 16 // scheme:host:port
// (not provided by parse_uniform)
#define USize 15
#define USize 16
#define UName(uniform) (uniform[UUser] || uniform[UResource][1 ..])
#endif

View file

@ -37,7 +37,7 @@
#include <status.h>
#include <services.h>
#include <text.h>
#include <url.h>
#include <uniform.h>
#include "error.h" // gets numeric codes
#include "reply.h" // gets numeric codes
@ -219,7 +219,7 @@ advertise(source) {
//static send(source, text) {
render(mc, data, vars, source) {
//# include <url.h>
//# include <uniform.h>
// mixed *u = parse_uniform(psyc_name(source));
// unless (mappingp(u) && u[UHost]) {
// P1(("failed\n"))

View file

@ -14,7 +14,7 @@ inherit IRC_PATH "decode";
#include "reply.h"
#include "person.h"
#include "psyc.h"
#include "url.h"
#include "uniform.h"
#include "hack.i"

View file

@ -4,7 +4,7 @@
#define NO_INHERIT
#include "jabber.h"
#undef NO_INHERIT
#include <url.h>
#include <uniform.h>
#ifdef ERQ_WITHOUT_SRV
# define hostname host // hostname contains the name before SRV resolution

View file

@ -6,7 +6,7 @@
#include <net.h>
#include <text.h>
//virtual inherit NET_PATH "output";
#include <url.h>
#include <uniform.h>
#ifdef __psyclpc__
# if __VERSION_MICRO__ > 4

View file

@ -4,7 +4,7 @@
#define NO_INHERIT
#include "jabber.h"
#undef NO_INHERIT
#include <url.h>
#include <uniform.h>
inherit NET_PATH "xml/common";

View file

@ -7,7 +7,7 @@
#define NO_INHERIT
#include "jabber.h" // inherits net/jabber/common
#undef NO_INHERIT
#include "url.h"
#include "uniform.h"
#include "services.h"
#define NO_INHERIT

View file

@ -1,6 +1,6 @@
#include "jabber.h"
#include <net.h> // vim:set syntax=lpc
#include <url.h>
#include <uniform.h>
#include "presence.h"
#include <time.h>

View file

@ -1,6 +1,6 @@
#include "jabber.h"
#include <net.h>
#include <url.h>
#include <uniform.h>
// just renderMembers
#include NET_PATH "members.i"

View file

@ -3,7 +3,7 @@
#include "server.h" // inherits net/server
#include "person.h" // find_person
#include "url.h"
#include "uniform.h"
#include <sys/tls.h>
volatile string authtag;

View file

@ -2,7 +2,7 @@
#include "jabber.h"
#include "user.h"
#include "person.h"
#include <url.h>
#include <uniform.h>
#include <peers.h>
// important to #include user.h first
@ -33,7 +33,7 @@ qHasCurrentPlace() { return 0; }
void create() {
jabber2avail = shared_memory("jabber2avail");
return ::create();
::create();
}
/* it should be posible to do some things in a way that can be shared between

View file

@ -4,7 +4,7 @@
#include <net.h>
#include <services.h>
#include <person.h>
#include <url.h>
#include <uniform.h>
#ifdef _uniform_node
# define myUNL _uniform_node

View file

@ -9,7 +9,13 @@
// linked to the driver. see also CHANGESTODO for thoughts on how to do a
// generic template replacement C function in a way that it does psyctext()
// effectively, but can also be used for other syntaxes.
//
// local debug messages - turn them on by using psyclpc -DDpsyctext=<level>
#ifdef Dpsyctext
# undef DEBUG
# define DEBUG Dpsyctext
#endif
#include <net.h>
#include <proto.h>
@ -17,7 +23,11 @@ varargs string psyctext(string s, mapping m, vastring data,
vamixed source, vastring nick) {
string r, p, q, v;
P3(("psyctext(%O)\n", s))
#if DEBUG > 2
P3(("psyctext(%O, .., %O, %O, %O) %O\n", s, data, source, nick, m))
#else
P2(("psyctext(%O, .., %O, %O, %O)\n", s, data, source, nick))
#endif
unless(s) return "";
if (s == "") {
if (data) s = data;
@ -31,12 +41,70 @@ varargs string psyctext(string s, mapping m, vastring data,
unless (mappingp(m)) return s;
#endif
r="";
while (sscanf(s, "%s[%s]%s", p, v, s) && v) {
if (v == "_nick") r += p + (nick || m["_nick"]);
else if (v == "_data") r += p + (data || "");
else unless (member(m, v)) {
if (v == "_source") r += p + UNIFORM(source);
else {
while (sscanf(s, "%s[%s]%s", p, v, s) && v) switch(v) {
case "_data":
r += p + (data || "");
break;
case "_nick":
#ifdef USE_THE_NICK
r += p + (nick || m["_nick"] || "?");
#else
// _nick can mean _source_relay instead of physical source
// and in some dirty cases we do not even provide _source_relay
q = m["_source_relay"] || m["_source"];
unless (q) {
// so we are forced to use the _nick from the message
q = m["_nick"] || nick;
if (q) {
r += p + q;
break;
}
// no _nick? okay, then it has to be this one
q = UNIFORM(source) || "?";
}
if (previous_object()) q = previous_object()->uni2nick(q) || q;
r += p + q;
#endif
break;
case "_source":
// should this support _source_relay? var inheritance!
#ifdef USE_THE_NICK
r += p + (nick || m["_nick"] || m["_source"] || UNIFORM(source) || "?");
#else
q = m["_source"] || UNIFORM(source) || "?";
if (previous_object()) q = previous_object()->uni2nick(q) || q;
r += p + q;
#endif
break;
case "_source_relay":
#ifdef USE_THE_NICK
r += p + (nick || m["_nick"] || m["_source_relay"] || "?");
#else
q = m["_source_relay"] || "?";
if (previous_object()) q = previous_object()->uni2nick(q) || q;
r += p + q;
#endif
break;
case "_target":
#ifdef USE_THE_NICK
r += p + (m["_nick_target"] || m["_target"] || "?");
#else
q = m["_target"] || "?";
if (previous_object()) q = previous_object()->uni2nick(q) || q;
r += p + q;
#endif
break;
case "_context":
#ifdef USE_THE_NICK
r += p + (m["_nick_place"] || m["_context"] || "?");
#else
q = m["_context"] || "?";
if (previous_object()) q = previous_object()->uni2nick(q) || q;
r += p + q;
#endif
break;
default:
unless (member(m, v)) {
#ifdef _flag_debug_unresolved_psyctext
raise_error(v +" unresolved in psyctext format\n");
#else
@ -44,7 +112,6 @@ varargs string psyctext(string s, mapping m, vastring data,
data, previous_object()))
#endif
r += p + "["+v+"]"; // pretend we havent seen it
}
}
else if (stringp(m[v])) r += p + m[v];
else if (pointerp(m[v])) { // used by showMembers
@ -54,7 +121,7 @@ varargs string psyctext(string s, mapping m, vastring data,
else if (intp(m[v])) { // used by /lu and /edit
if (v == "_time_idle")
r += p + timedelta(m[v]);
else if (abbrev("_time", v))
else if (abbrev("_time", v)) // should be _date
r += p + time_or_date(m[v]);
else
r += p + to_string(m[v]);
@ -76,6 +143,7 @@ varargs string psyctext(string s, mapping m, vastring data,
}
}
if (s != "") r += s;
P4(("\t-> %s\n", r))
return r;
}
@ -89,7 +157,6 @@ varargs string psyctext(string s, mapping m, vastring data,
// evil!! -lynX
//
varargs void w(string mc, string data, mixed vars) {
// oh my god seit wann gibt's denn das!?
raise_error(sprintf("%O ended up in library/text:w(%s) for %O\n",
previous_object(), mc, this_interactive()));
}

View file

@ -1,4 +1,4 @@
// $Id: url.c,v 1.43 2008/03/29 20:36:43 lynx Exp $ // vim:syntax=lpc
// $Id: uniform.c,v 1.43 2008/03/29 20:36:43 lynx Exp $ // vim:syntax=lpc
//
// URLs.. URIs.. UNLs.. UNIs.. maybe even URNs..
// the fact they wear a uniform is the only thing these items have in common
@ -7,10 +7,10 @@
// common format.. the uniform :)
//
// TODO: first move everything called _uniform or url somewhere into here
// then rename everything into uniform, also url.c and url.h..
// then rename everything into uniform, also uniform.c and uniform.h..
#include <net.h>
#include <url.h>
#include <uniform.h>
string legal_url(string url, string scheme) {
if (scheme &&! abbrev(scheme+":", url)) return 0;
@ -21,7 +21,7 @@ string legal_url(string url, string scheme) {
}
/** pass it a URL string and it will find out if that string
** is a uniform, and if so return an array as defined in url.h
** is a uniform, and if so return an array as defined in uniform.h
**
** <fippo> what about using
** http://www.gbiv.com/protocols/uri/rfc/rfc3986.html#regexp ?
@ -90,6 +90,9 @@ varargs array(mixed) parse_uniform(string url, vaint tolerant) {
}
u[UHost] = t;
P4(("parse_uniform %s = %O (tolerant: %O)\n", url, u, tolerant))
u[UNick] = u[UUser]
|| (strlen(u[UResource]) && u[UResource][1 ..])
|| u[UBody];
return u;
}

View file

@ -41,7 +41,7 @@
#include <person.h>
#include <psyc.h>
#include <storage.h>
#include <url.h>
#include <uniform.h>
#if __EFUN_DEFINED__(tls_query_connection_info)
# include <sys/tls.h>

View file

@ -125,7 +125,7 @@
#include <net.h>
#include <person.h>
#include <status.h>
#include <url.h>
#include <uniform.h>
#include <driver.h>
#ifdef BETA

View file

@ -13,7 +13,7 @@
#include <status.h>
#include <driver.h>
#ifdef WE_PROBABLY_DONT_NEED_THIS
# include <url.h>
# include <uniform.h>
#endif
virtual inherit NET_PATH "place/storic";

View file

@ -16,7 +16,7 @@
#include <services.h>
#include <person.h>
#include <driver.h>
#include <url.h>
#include <uniform.h>
#include <text.h>
#include <psyc.h>

View file

@ -5,7 +5,7 @@
#include "common.h"
#include <net.h>
#include <url.h>
#include <uniform.h>
#include <psyc.h>
#ifdef __MCCP__

View file

@ -73,7 +73,12 @@ static int build_header(string key, mixed val, mapping vars) {
#endif
}
} else if (intp(val)) {
#ifdef SPYC
klopp = abbrev("_date", key) ? to_string(val - PSYC_EPOCH)
: to_string(val);
#else
klopp = to_string(val);
#endif
} else {
mixed k,d, sep;

View file

@ -322,6 +322,8 @@ vamixed parse(string a) {
// intermediate hack in lack of real type support
// which needs to be done in net/spyc
if (abbrev("_time", vname)) vvalue = to_int(vvalue);
// unused as yet: else if (abbrev("_date", vname))
// vvalue = PSYC_EPOCH + to_int(vvalue);
#endif
cvars[lastvar = vname] = vvalue;
#ifdef SYSTEM_SECRET

View file

@ -7,7 +7,7 @@
// einen generischen relay für allerlei zwecke.
#include <net.h>
#include <url.h>
#include <uniform.h>
//#include <text.h>
//inherit NET_PATH "gateway/generic";

View file

@ -5,7 +5,7 @@
#include <net.h>
#include <person.h>
#include <services.h>
#include <url.h>
#include <uniform.h>
#include <psyc.h>
// SECURITY CONCERN:

View file

@ -4,7 +4,7 @@
* this is currently broken and I dont have the time to fix it
*/
#include <net.h>
#include <url.h>
#include <uniform.h>
#include <person.h>
#include <dns.h>
@ -30,7 +30,7 @@
*
*/
#include <net.h>
#include <url.h>
#include <uniform.h>
#include <person.h>
#include "sip.h"

View file

@ -3,7 +3,7 @@
#include "psyc.h"
#include <net.h>
#include <url.h>
#include <uniform.h>
#include <tls.h>
#include <text.h>

View file

@ -81,6 +81,9 @@ void dispatch(mixed header_vars, mixed varops, mixed method, mixed body) {
vop[2] = 0;
}
break;
case "_date":
vop[2] = to_int(vop[2]) + PSYC_EPOCH;
break;
case "_time":
case "_amount":
vop[2] = to_int(vop[2]);

View file

@ -3,7 +3,7 @@
#include "psyc.h"
#include <net.h>
#include <url.h>
#include <uniform.h>
#include <text.h>
inherit NET_PATH "spyc/parse";

View file

@ -11,7 +11,7 @@
#include <net.h>
#include <person.h>
#include <psyc.h>
#include <url.h>
#include <uniform.h>
inherit NET_PATH "person";
inherit NET_PATH "common";
@ -29,6 +29,48 @@ volatile mapping tags;
volatile int showEcho;
volatile mixed beQuiet;
// my nickspace. used by psyctext(). could be passed as closure, but then
// it wouldn't be available for *any* psyctext call in user objects.
uni2nick(n) {
PT(("uni2nick(%O) in %O\n", n, ME))
#ifdef USE_AUTOALIAS
string ln = lower_case(n);
string al = raliases[ln];
if (al) return al;
if (member(raliases, ln)) return n; // marked dead
mixed u = parse_uniform(n);
al = lower_case(u[UNick]);
if (aliases[al]) {
raliases[ln] = 0; // mark dead
PT(("uni2nick: already belongs to %O\n", aliases[al]))
w("_failure_unavailable_alias",
"No alias for [_uniform_new]: [_nick_old] already belongs to [_uniform_old].",
([ "_uniform_new": n,
"_uniform_old": aliases[al],
"_nick_old": al ]) );
return n;
}
aliases[al] = n;
raliases[ln] = al = u[UNick];
PT(("uni2nick: autoaliased %O to %O\n", n, al))
w("_notice_add_alias_automatic",
"[_uniform_entity] is known as [_nick_entity].",
([ "_uniform_entity": n,
"_nick_entity": al ]) );
return al;
#else
// this enables local nickspace, but it fails on local uniforms,
// it fails when local nick collides with alias, so either you make
// it super complicated here, or you keep it super stupid.
//if (objectp(n)) return n->qName();
# ifdef ALIASES
return raliases[lower_case(n)] || n;
# else
return n;
# endif
#endif
}
// jabber needs no private echo but plenty of public echo..
// net/jabber takes care of that, we just give it echo here.
// in psyc echoes are essential, so they are on.
@ -371,12 +413,10 @@ msg(source, mc, data, mapping vars, showingLog) {
) {
if (data && index(data, '\n') != -1)
data = replace(data, "\n", " ");
// this used to trigger a systemwide _request_authentication
//t = lookup_identification(source, vars["_source_identification"]);
// now uni::msg does these kind of things
#ifdef USE_THE_NICK
if (t != source) {
if (objectp(source)) {
#ifdef ALIASES
# ifdef ALIASES
string t2;
if (t2 = raliases[nick = source->qNameLower()]) {
@ -384,22 +424,22 @@ msg(source, mc, data, mapping vars, showingLog) {
} else if (aliases[lower_case(nick)]) {
nick = t;
}
#else
# else
nick = source->qName();
#endif
# endif
} else {
#ifdef ALIASES
# ifdef ALIASES
nick = raliases[source] || source;
#else
# else
nick = source;
#endif
# endif
}
#ifndef TRUST_PSYC_HACK
# ifdef ALIASES
# ifndef TRUST_PSYC_HACK
# ifdef ALIASES
} else if (raliases[source]) {
nick = raliases[source];
# endif
# endif
} else {
// short term solution (nick manager to follow)
//if (nick) nick = "("+ source + ") "+ nick;
@ -428,7 +468,7 @@ msg(source, mc, data, mapping vars, showingLog) {
"_nick":vars["_nick_verbatim"] ]));
}
else nick = stringp(source) ? source : to_string(source);
# if 0 //DEBUG > 1
# if 0 //DEBUG > 1
// checking for validity of messages should
// happen at psyc-parsing level.. maybe? YEEEES!!
// and.. vars["_context"] is zero when showing log!
@ -440,17 +480,19 @@ msg(source, mc, data, mapping vars, showingLog) {
}
// this just wont work.. it even breaks
// remote _message_echo_private's
# endif
# endif
#endif
}
nick2 = nick;
#endif // USE_THE_NICK
// belongs into person.c?
if (mc == "_message") mc = vars["_context"] ?
"_message_public" : "_message_private";
P3(("%O got msg(%O,%O,%O,%O)\n", ME,source,mc,data,vars))
}
#ifdef USE_THE_NICK
else if (nick && nick != MYNICK) {
#ifdef ALIASES
# ifdef ALIASES
string tn;
// ein kleines bisschen hilflosigkeit (&&! showingLog)
//
@ -464,10 +506,11 @@ msg(source, mc, data, mapping vars, showingLog) {
} else if (aliases[tn] &&! showingLog) {
nick2 = nick = UNIFORM(source);
} else
#endif
# endif
nick2 = vars["_nick_stylish"] || vars["_nick_local"] || nick;
} else nick2 = nick = MYNICK;
P3(("q/n/n2: %O,%O,%O\n", MYNICK,nick,nick2))
#endif // USE_THE_NICK
t = vars && vars["_context"] || source;
#ifdef SANDBOX

View file

@ -40,7 +40,7 @@
#include <closures.h>
#include <driver.h>
#include <misc.h>
#include <url.h>
#include <uniform.h>
#include <services.h>
#include <status.h>
@ -2422,8 +2422,7 @@ friend(rm, entity, ni, trustee) {
// nick, not the one the user typed in.
t = ([ "_nick": MYNICK ]);
if (trustee) t["_trustee"] = trustee;
sendmsg(entity, "_request_friendship",
"[_nick] kindly asks for your friendship.", t);
sendmsg(entity, "_request_friendship", 0, t);
return 1;
}
# endif // _flag_disable_module_friendship