summaryrefslogtreecommitdiff
path: root/appl/cmd/styxlisten.b
diff options
context:
space:
mode:
authorforsyth <forsyth@vitanuova.com>2011-01-17 10:45:22 +0000
committerforsyth <forsyth@vitanuova.com>2011-01-17 10:45:22 +0000
commit9e6910dc0c747c8f30b87f6482f4eadb48ad6654 (patch)
tree4f835b35913acfb115b15ea4f1c6af40fd77ab54 /appl/cmd/styxlisten.b
parent16501eaf1cb642b80d7fa0236407a27aecb35b02 (diff)
emu/Nt/ipif.c
Diffstat (limited to 'appl/cmd/styxlisten.b')
-rw-r--r--appl/cmd/styxlisten.b34
1 files changed, 12 insertions, 22 deletions
diff --git a/appl/cmd/styxlisten.b b/appl/cmd/styxlisten.b
index df136e47..4c8bcc94 100644
--- a/appl/cmd/styxlisten.b
+++ b/appl/cmd/styxlisten.b
@@ -1,6 +1,8 @@
implement Styxlisten;
include "sys.m";
sys: Sys;
+include "dial.m";
+ dial: Dial;
include "draw.m";
include "keyring.m";
keyring: Keyring;
@@ -28,6 +30,9 @@ init(ctxt: ref Draw->Context, argv: list of string)
auth = load Auth Auth->PATH;
if (auth == nil)
badmodule(Auth->PATH);
+ dial = load Dial Dial->PATH;
+ if (dial == nil)
+ badmodule(Dial->PATH);
if ((e := auth->init()) != nil)
error("auth init failed: " + e);
keyring = load Keyring Keyring->PATH;
@@ -76,7 +81,7 @@ init(ctxt: ref Draw->Context, argv: list of string)
arg = nil;
if (doauth && algs == nil)
algs = getalgs();
- addr := netmkaddr(hd argv, "tcp", "styx");
+ addr := dial->netmkaddr(hd argv, "tcp", "styx");
cmd := tl argv;
authinfo: ref Keyring->Authinfo;
@@ -88,8 +93,8 @@ init(ctxt: ref Draw->Context, argv: list of string)
error(sys->sprint("cannot read %s: %r", keyfile));
}
- (ok, c) := sys->announce(addr);
- if (ok == -1)
+ c := dial->announce(addr);
+ if (c == nil)
error(sys->sprint("cannot announce on %s: %r", addr));
if(!trusted){
sys->unmount(nil, "/mnt/keys"); # should do for now
@@ -103,17 +108,17 @@ init(ctxt: ref Draw->Context, argv: list of string)
spawn listener(c, popen(ctxt, cmd, lsync), authinfo, algs, lsync);
}
-listener(c: Sys->Connection, mfd: ref Sys->FD, authinfo: ref Keyring->Authinfo, algs: list of string, lsync: chan of int)
+listener(c: ref Dial->Connection, mfd: ref Sys->FD, authinfo: ref Keyring->Authinfo, algs: list of string, lsync: chan of int)
{
lsync <-= sys->pctl(0, nil);
for (;;) {
- (n, nc) := sys->listen(c);
- if (n == -1)
+ nc := dial->listen(c);
+ if (nc == nil)
error(sys->sprint("listen failed: %r"));
if (verbose)
sys->fprint(stderr(), "styxlisten: got connection from %s",
readfile(nc.dir + "/remote"));
- dfd := sys->open(nc.dir + "/data", Sys->ORDWR);
+ dfd := dial->accept(nc);
if (dfd != nil) {
if(nc.cfd != nil)
sys->fprint(nc.cfd, "keepalive");
@@ -245,18 +250,3 @@ stderr(): ref Sys->FD
{
return sys->fildes(2);
}
-
-netmkaddr(addr, net, svc: string): string
-{
- if(net == nil)
- net = "net";
- (n, nil) := sys->tokenize(addr, "!");
- if(n <= 1){
- if(svc== nil)
- return sys->sprint("%s!%s", net, addr);
- return sys->sprint("%s!%s!%s", net, addr, svc);
- }
- if(svc == nil || n > 2)
- return addr;
- return sys->sprint("%s!%s", addr, svc);
-}