From a0cc248e00b9616dc5e4ae66644979f4c7638c87 Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Sun, 24 Jul 2011 18:53:47 +0200 Subject: [PATCH] let is_localhost() do its lower_case itself.. thx fip --- world/net/entity.c | 2 +- world/net/jabber/gateway.c | 6 +++--- world/net/jabber/jabber.h | 4 ++-- world/net/jabber/mixin_parse.c | 2 +- world/net/jabber/server.c | 2 +- world/net/jabber/user.c | 8 ++++---- world/net/library.i | 2 +- world/net/library/dns.c | 4 ++-- world/net/person.c | 2 +- world/net/place/archetype.gen | 2 +- world/net/psyc/library.i | 4 ++-- world/net/psyc/parse.i | 4 ++-- world/net/sip/udp.c | 4 ++-- world/net/spyc/circuit.c | 2 +- world/net/spyc/dispatch.i | 2 +- 15 files changed, 25 insertions(+), 25 deletions(-) diff --git a/world/net/entity.c b/world/net/entity.c index 306c69f..8bba379 100644 --- a/world/net/entity.c +++ b/world/net/entity.c @@ -409,7 +409,7 @@ msg(source, mc, data, vars) { // and have it replaced by object.. but that's not the case // we _could_ however do that by using _uniform_trustee // and doing is_localhost on all _uniform's at parsing time - if (is_localhost(lower_case(u[UHost]))) trustee_nick = u[UNick]; + if (is_localhost(u[UHost])) trustee_nick = u[UNick]; } if (get_trust(trustee_nick, 0) < MINIMUM_TRUST) return 1; // entweder trustee ist ein local nick, dann kriegen wir den diff --git a/world/net/jabber/gateway.c b/world/net/jabber/gateway.c index c4387d1..1d62ef6 100644 --- a/world/net/jabber/gateway.c +++ b/world/net/jabber/gateway.c @@ -269,7 +269,7 @@ jabberMsg(XMLNode node) { // if we dont know the host, complain // put NAMEPREP(_host_XMPP) into the localhost mapping pleeeease //if (target != NAMEPREP(_host_XMPP)) { - unless (is_localhost(lower_case(target))) { + unless (is_localhost(target)) { monitor_report("_error_unknown_host", sprintf("%O sent us a dialback packet believing we would be %O", source, target)); @@ -349,7 +349,7 @@ jabberMsg(XMLNode node) { * then croak with a host-unknown and commit suicide */ // same as above... - unless (is_localhost(lower_case(target))) { + unless (is_localhost(target)) { emit(sprintf("" "" "" @@ -498,7 +498,7 @@ open_stream(XMLNode node) { if (node["@from"]) { packet += "to='" + node["@from"] + "' "; } - if (node["@to"] && !(is_localhost(lower_case(node["@to"])))) { + if (node["@to"] && !(is_localhost(node["@to"]))) { emit(packet + ">"); STREAM_ERROR("host-unknown", "") QUIT diff --git a/world/net/jabber/jabber.h b/world/net/jabber/jabber.h index ea3f9cb..6232722 100644 --- a/world/net/jabber/jabber.h +++ b/world/net/jabber/jabber.h @@ -84,8 +84,8 @@ virtual inherit JABBER_PATH "common"; # define _host_XMPP SERVER_HOST #endif -// this is not ready for is_localhost -#define is_localhost(a) (a) == _host_XMPP +// net/jabber is not ready for regular is_localhost +#define is_localhost(a) (lower_case(a)) == _host_XMPP #define JABSOURCE "_INTERNAL_source_jabber" diff --git a/world/net/jabber/mixin_parse.c b/world/net/jabber/mixin_parse.c index e15b126..bfe2d46 100644 --- a/world/net/jabber/mixin_parse.c +++ b/world/net/jabber/mixin_parse.c @@ -868,7 +868,7 @@ jabberMsg(XMLNode node, mixed origin, mixed *su, array(mixed) tu) { case "jabber:iq:last": switch(t) { case "get": - if (isplacemsg || is_localhost(lower_case(target))) + if (isplacemsg || is_localhost(target)) o = "/" + (tu[UResource] || ""); else o = summon_person(tu[UUser]); diff --git a/world/net/jabber/server.c b/world/net/jabber/server.c index cada632..038b7aa 100644 --- a/world/net/jabber/server.c +++ b/world/net/jabber/server.c @@ -338,7 +338,7 @@ jabberMsg(XMLNode node) { } // lets see if its one of our users sscanf(deco, "%s@%s", u, ho); - unless (is_localhost(lower_case(ho))) { + unless (is_localhost(ho)) { // wrong host SASL_ERROR("invalid-authzid") QUIT diff --git a/world/net/jabber/user.c b/world/net/jabber/user.c index 594e9da..48a401d 100644 --- a/world/net/jabber/user.c +++ b/world/net/jabber/user.c @@ -449,7 +449,7 @@ message(XMLNode node) { unless (u = parse_uniform(XMPP + node["@to"])) { D("impossible!\n"); } isplacemsg = ISPLACEMSG(node["@to"]); - if (is_localhost(lower_case(node["@to"]))) { + if (is_localhost(node["@to"])) { // it's too unusual to have commands without cmdchar // so let's use input() instead of cmd() here // IMHO this should check if input is a cmd @@ -828,7 +828,7 @@ iq(XMLNode node) { case "get": if (!node["@to"]) sendmsg(ME, "_request_list_feature", 0, vars); - else if (is_localhost(lower_case(node["@to"]))) + else if (is_localhost(node["@to"])) sendmsg("/", "_request_list_feature", 0, vars); /* else... TODO */ break; @@ -847,7 +847,7 @@ iq(XMLNode node) { if (!node["@to"]) // "my" places - let person.c handle this sendmsg(ME, "_request_list_item", 0, vars); - else if (is_localhost(lower_case(node["@to"]))) + else if (is_localhost(node["@to"])) // server's places - let root.c handle this sendmsg("/", "_request_list_item", 0, vars); /* else... TODO */ @@ -1114,7 +1114,7 @@ string jid2ppl(string jid) { // } sscanf(host, "%s/%s", host, resource); #if 1 // wieso 0??? sendmsg() hätte das hinkriegen sollen.. war der gedanke - if (is_localhost(lower_case(host))) { // local user + if (is_localhost(host)) { // local user P4(("is_localhost? %O, YES, then use %O\n", host, node)) // TODO: what about returning objects? if (strlen(node) && ISPLACEMSG(node)) return PREFIXFREE(node); diff --git a/world/net/library.i b/world/net/library.i index 9c4be2c..26d57c6 100644 --- a/world/net/library.i +++ b/world/net/library.i @@ -661,7 +661,7 @@ int xmpp_sendmsg(mixed target, string mc, mixed data, mapping vars, otarget, o )) // in XMPP this is sufficient since other servers on the same IP // need to have a different domain name - } else if (is_localhost(lower_case(u[UHost]))) { + } else if (is_localhost(u[UHost])) { unless (u[UUser]) { P0(("Intercepted %O to %O from %O\n", mc, target, source)) // 0 makes sendmsg try to relay via xmpp.scheme.psyced.org diff --git a/world/net/library/dns.c b/world/net/library/dns.c index 866b576..5337487 100644 --- a/world/net/library/dns.c +++ b/world/net/library/dns.c @@ -550,15 +550,15 @@ void dns_rresolve(string ip, closure callback, varargs array(mixed) extra) { // {{{ function: is_localhost #if 1 -// take care to always pass a lowercased (virtual) hostname int is_localhost(string host) { // async discovery of virtual hosts is not necessary // we should know all of our hostnames in advance for // security anyway - return member(localhosts, host); + return member(localhosts, lower_case(host)); } #else int is_localhost(string host, closure callback, varargs array(mixed) extra) { + host = lower_case(host); if (member(localhosts, host)) { funcall(callback, 1, extra); return; diff --git a/world/net/person.c b/world/net/person.c index e7ee345..0e2bb35 100644 --- a/world/net/person.c +++ b/world/net/person.c @@ -2544,7 +2544,7 @@ logon(host) { && mode[PPL_NOTIFY] >= PPL_NOTIFY_FRIEND) continue; if (u = parse_uniform(ni)) { // first we change the ppl, then we need this code -// if (is_localhost(lower_case(u[UHost]))) { +// if (is_localhost(u[UHost])) { // o = summon_person(u[UNick]); // insert_member(o); // } else { diff --git a/world/net/place/archetype.gen b/world/net/place/archetype.gen index 5ceec9e..f8a0f3a 100644 --- a/world/net/place/archetype.gen +++ b/world/net/place/archetype.gen @@ -2678,7 +2678,7 @@ sAide(whom) { #if 0 // change local uniform to nick ... isn't really correct like this array(mixed) u = parse_uniform(whom); - if (u && is_localhost(lower_case(u[UHost]))) whom = u[UResource]; + if (u && is_localhost(u[UHost])) whom = u[UResource]; #else object o = psyc_object(whom); if (o) whom = o->qName(); diff --git a/world/net/psyc/library.i b/world/net/psyc/library.i index 33a03bb..c7b8b4f 100644 --- a/world/net/psyc/library.i +++ b/world/net/psyc/library.i @@ -260,7 +260,7 @@ int psyc_sendmsg(mixed target, string mc, mixed data, mapping vars, return 0; } } - host = lower_case(u[UHost]); + host = lower_case(u[UHost]); // lower_case not necessary.. right? if (query_udp_port() == port && is_localhost(host)) { // this happens when a psyc client sends to a local // target that hasn't been incarnated yet... @@ -408,7 +408,7 @@ int psyc_sendmsg(mixed target, string mc, mixed data, mapping vars, unless (buf) return 0; #endif /* NEW_RENDER */ - // host seems to already be in lower_case + // we could store the result of the is_localhost above, right? if (is_localhost(host)) return send_udp(host, port, buf); PT(("dns_resolve + send_udp %O:%O packet:\n%s", host,port,buf)) dns_resolve(host, (: if (stringp($1)) diff --git a/world/net/psyc/parse.i b/world/net/psyc/parse.i index 9e7038e..29db96a 100644 --- a/world/net/psyc/parse.i +++ b/world/net/psyc/parse.i @@ -981,8 +981,8 @@ protected int deliver(mixed ip, string host, string mc, string buffer, mapping c cvars["_INTERNAL_nick_target"] = u[UNick]; #endif P3(("DEBUG: is_localhost is %O for %O of %O\n", - is_localhost(lower_case(u[UHost])), u[UHost], u)) - unless (is_localhost(lower_case(u[UHost]))) { + is_localhost(u[UHost])), u[UHost], u) + unless (is_localhost((u[UHost])) { if (trustworthy > 7) { P1(("RELAYING permitted for %O to %O (%O)\n", source, t, ME)) diff --git a/world/net/sip/udp.c b/world/net/sip/udp.c index 75c3384..d53d044 100644 --- a/world/net/sip/udp.c +++ b/world/net/sip/udp.c @@ -107,7 +107,7 @@ parseUDP(ip, port, msg) { send_udp(ip, port, reply); return; } - islocaltarget = is_localhost(lower_case(tu[UHost])); + islocaltarget = is_localhost(tu[UHost]); // TODO this may be either local or remote users if (islocaltarget && tu[UUser]) target = find_person(tu[UUser]); // TODO works only for online users @@ -156,7 +156,7 @@ parseUDP(ip, port, msg) { su = parse_uniform(source); source = 0; #if 0 - if (is_localhost(lower_case(su[UHost]))) { + if (is_localhost(su[UHost])) { object o; o = find_person(su[UUser]); // TODO: check that source is coming from diff --git a/world/net/spyc/circuit.c b/world/net/spyc/circuit.c index 21545da..e65f5d5 100644 --- a/world/net/spyc/circuit.c +++ b/world/net/spyc/circuit.c @@ -214,7 +214,7 @@ void circuit_msg(string mc, mapping vars, string data) { if (tls_query_connection_state(ME) == 0) { array(string) targethosts = ({ }); foreach(string ho : vars["_list_targets_hosts"]) { - if (is_localhost(lower_case(ho))) { + if (is_localhost(ho)) { targethosts += ({ ho }); } } diff --git a/world/net/spyc/dispatch.i b/world/net/spyc/dispatch.i index 7bf81e5..8a7026e 100644 --- a/world/net/spyc/dispatch.i +++ b/world/net/spyc/dispatch.i @@ -188,7 +188,7 @@ void dispatch(mapping rvars, mapping evars, mixed method, mixed body) { DISPATCHERROR("target is not a uniform\n") } // FIXME relaying support here? - if (!is_localhost(lower_case(u[UHost]))) { + if (!is_localhost(u[UHost])) { DISPATCHERROR("target is not configured on this server\n") } }