mirror of
git://git.psyced.org/git/psyced
synced 2024-08-15 03:25:10 +00:00
net/spyc is not looking good :-(
This commit is contained in:
parent
40e7a625ee
commit
a4e16cd2c4
6 changed files with 70 additions and 84 deletions
|
@ -5,7 +5,12 @@
|
|||
#include <net.h>
|
||||
#include <services.h>
|
||||
|
||||
#ifdef SPYC
|
||||
inherit SPYC_PATH "circuit";
|
||||
#else
|
||||
inherit PSYC_PATH "circuit";
|
||||
#endif
|
||||
|
||||
inherit NET_PATH "circuit";
|
||||
|
||||
volatile object super;
|
||||
|
@ -37,7 +42,11 @@ int logon(int failure) {
|
|||
if (port && port != PSYC_SERVICE) peeraddr += ":"+port;
|
||||
// circuit::logon now also implies a full greeting
|
||||
// therefore it needs peeraddr, and the emit is redundant
|
||||
# ifdef SPYC
|
||||
SPYC_PATH "circuit"::logon(failure);
|
||||
# else
|
||||
PSYC_PATH "circuit"::logon(failure);
|
||||
# endif
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1127,7 +1127,7 @@ vamixed startParse(string a) {
|
|||
restart();
|
||||
if (isServer()) greet();
|
||||
}
|
||||
# ifdef SPYC_PATH
|
||||
# if defined(SPYC_PATH) && defined(USE_SPYC)
|
||||
else if (a == "|") { // new S_GLYPH_PACKET_DELIMITER
|
||||
object o = clone_object(SPYC_PATH "server");
|
||||
unless (o && exec(o, ME) && o->logon(0)) {
|
||||
|
|
|
@ -25,7 +25,7 @@ volatile string netloc;
|
|||
|
||||
// this is completely anti-psyc. it should take mcs as arguments
|
||||
// and look up the actual message from textdb.. FIXME
|
||||
#define CIRCUITERROR(reason) { debug_message("PSYC CIRCUIT ERROR: " reason); \
|
||||
#define CIRCUITERROR(reason) { debug_message("SPYC CIRCUIT: " reason "\n"); \
|
||||
croak("_error_circuit", "circuit error: " \
|
||||
reason); \
|
||||
return 0; \
|
||||
|
@ -61,6 +61,25 @@ varargs mixed croak(string mc, string data, vamapping vars, vamixed source) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef USE_VERIFICATION
|
||||
// request sender authentication and/or target acknowledgement
|
||||
// from the remote side
|
||||
void sender_verification(array(string) sourcehosts, array(string) targethosts)
|
||||
{
|
||||
// FIXME: wrong variables here
|
||||
mapping vars = ([ "_list_sources_hosts" : sourcehosts,
|
||||
"_list_targets_hosts" : targethosts,
|
||||
"_tag" : RANDHEXSTRING ]);
|
||||
// assumption: we have already resolved all targethosts and
|
||||
// they point to the remote ip
|
||||
foreach(string ho : targethosts) {
|
||||
sAuthenticated(ho);
|
||||
}
|
||||
|
||||
msg(0, "_request_verification", 0, vars);
|
||||
}
|
||||
#endif
|
||||
|
||||
// gets called during socket logon
|
||||
int logon(int failure) {
|
||||
sAuthHosts(([ ])); // reset authhosts
|
||||
|
@ -134,7 +153,20 @@ int logon(int failure) {
|
|||
// FIXME
|
||||
unless(isServer()) {
|
||||
emit("|\n"); // initial greeting
|
||||
#ifdef USE_FEATURES
|
||||
// we have no features to request or offer
|
||||
msg(0, "_request_features", 0);
|
||||
#else
|
||||
# ifdef USE_VERIFICATION
|
||||
// start hostname verification
|
||||
// rather: look at Q and look for the hostnames we need
|
||||
sender_verification(({ SERVER_HOST }), ({ peerhost }));
|
||||
# else
|
||||
if (function_exists("runQ")) {
|
||||
runQ();
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -192,23 +224,6 @@ mapping process_header(mixed varops) {
|
|||
#define PSYC_TCP
|
||||
#include "dispatch.i"
|
||||
|
||||
// request sender authentication and/or target acknowledgement
|
||||
// from the remote side
|
||||
void sender_verification(array(string) sourcehosts, array(string) targethosts)
|
||||
{
|
||||
// FIXME: wrong variables here
|
||||
mapping vars = ([ "_list_sources_hosts" : sourcehosts,
|
||||
"_list_targets_hosts" : targethosts,
|
||||
"_tag" : RANDHEXSTRING ]);
|
||||
// assumption: we have already resolved all targethosts and
|
||||
// they point to the remote ip
|
||||
foreach(string ho : targethosts) {
|
||||
sAuthenticated(ho);
|
||||
}
|
||||
|
||||
msg(0, "_request_verification", 0, vars);
|
||||
}
|
||||
|
||||
// receives a msg from the remote side
|
||||
// note: this is circuit-messaging
|
||||
void circuit_msg(string mc, mapping vars, string data) {
|
||||
|
@ -245,13 +260,13 @@ void circuit_msg(string mc, mapping vars, string data) {
|
|||
} else {
|
||||
// FIXME!!!!
|
||||
CIRCUITERROR("sorry, no more than one element in _list_sources_hosts currently");
|
||||
P0(("more than one element in _list_sources_hosts: %O\n", vars["_list_sources_hosts"]))
|
||||
}
|
||||
// keep tag if present!!!
|
||||
// resolve all of _list_sources_hosts
|
||||
// look at _list_targets_hosts and determine localhostiness
|
||||
} else {
|
||||
CIRCUITERROR("_request_verification is not allowed on TLS circuits.");
|
||||
// _request_verification is not allowed on tls circuits
|
||||
}
|
||||
break;
|
||||
case "_notice_features":
|
||||
|
@ -262,15 +277,19 @@ void circuit_msg(string mc, mapping vars, string data) {
|
|||
flags -= TCP_PENDING_TIMEOUT;
|
||||
}
|
||||
sTextPath();
|
||||
#ifdef USE_FEATURES
|
||||
if (tls_query_connection_state(ME) == 0) {
|
||||
# ifdef USE_VERIFICATION
|
||||
// start hostname verification
|
||||
// rather: look at Q and look for the hostnames we need
|
||||
sender_verification(({ SERVER_HOST }), ({ peerhost }));
|
||||
# endif
|
||||
} else {
|
||||
if (function_exists("runQ")) {
|
||||
runQ();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case "_notice_verification":
|
||||
P0(("_notice verification with %O\n", vars))
|
||||
|
|
|
@ -29,14 +29,16 @@ void dispatch(mixed header_vars, mixed varops, mixed method, mixed body) {
|
|||
if ((t = vars["_context"] || vars["_source"])) {
|
||||
array(mixed) u;
|
||||
unless (u = parse_uniform(t)) {
|
||||
DISPATCHERROR("logical source is not an uniform\n")
|
||||
DISPATCHERROR("logical source is not a uniform\n")
|
||||
}
|
||||
#ifdef PSYC_TCP
|
||||
#ifdef USE_VERIFICATION
|
||||
# ifdef PSYC_TCP
|
||||
unless (qAuthenticated(NAMEPREP(u[UHost]))) {
|
||||
DISPATCHERROR("non-authenticated host\n")
|
||||
}
|
||||
#else
|
||||
# else
|
||||
// TODO?
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
// check that _target is hosted by us
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue