mirror of
https://github.com/ChronosX88/psyced.git
synced 2024-11-09 12:01:00 +00:00
let is_localhost() do its lower_case itself.. thx fip
This commit is contained in:
parent
15dd8c0ada
commit
a0cc248e00
@ -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
|
||||
|
@ -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("<db:verify from='%s' to='%s' id='%s' type='error'>"
|
||||
"<error type='cancel'>"
|
||||
"<item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>"
|
||||
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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]);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -2544,7 +2544,7 @@ logon(host) {
|
||||
&& mode[PPL_NOTIFY] >= PPL_NOTIFY_FRIEND) continue;
|
||||
if (u = parse_uniform(ni)) {
|
||||
// <lynX> 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 {
|
||||
|
@ -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();
|
||||
|
@ -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))
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user