summaryrefslogtreecommitdiff
path: root/appl/cmd/listen.b
diff options
context:
space:
mode:
Diffstat (limited to 'appl/cmd/listen.b')
-rw-r--r--appl/cmd/listen.b33
1 files changed, 14 insertions, 19 deletions
diff --git a/appl/cmd/listen.b b/appl/cmd/listen.b
index 5a06892d..25869223 100644
--- a/appl/cmd/listen.b
+++ b/appl/cmd/listen.b
@@ -7,8 +7,6 @@ include "keyring.m";
keyring: Keyring;
include "security.m";
auth: Auth;
-include "dial.m";
- dial: Dial;
include "sh.m";
sh: Sh;
Context: import sh;
@@ -33,9 +31,6 @@ init(drawctxt: 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);
sh = load Sh Sh->PATH;
if (sh == nil)
badmodule(Sh->PATH);
@@ -125,8 +120,8 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string,
sys->pctl(Sys->FORKFD, nil);
ctxt := Context.new(drawctxt);
- acon := dial->announce(addr);
- if (acon == nil) {
+ (ok, acon) := sys->announce(addr);
+ if (ok == -1) {
sys->fprint(stderr(), "listen: failed to announce on '%s': %r\n", addr);
sync <-= "cannot announce";
exit;
@@ -151,15 +146,15 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string,
}
sync <-= nil;
- listench := chan of ref Dial->Connection;
- authch := chan of (string, ref Dial->Connection);
+ listench := chan of (int, Sys->Connection);
+ authch := chan of (string, Sys->Connection);
spawn listener(listench, acon, addr);
for (;;) {
user := "";
- ccon: ref Dial->Connection;
+ ccon: Sys->Connection;
alt {
- c := <-listench =>
- if (c == nil){
+ (lok, c) := <-listench =>
+ if (lok == -1){
sync <-= "listen";
exit;
}
@@ -187,13 +182,13 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string,
}
}
-listener(listench: chan of ref Dial->Connection, c: ref Dial->Connection, addr: string)
+listener(listench: chan of (int, Sys->Connection), c: Sys->Connection, addr: string)
{
for (;;) {
- nc := dial->listen(c);
- if (nc == nil) {
+ (ok, nc) := sys->listen(c);
+ if (ok == -1) {
sys->fprint(stderr(), "listen: listen error on '%s': %r\n", addr);
- listench <-= nc;
+ listench <-= (-1, nc);
exit;
}
if (verbose)
@@ -205,13 +200,13 @@ listener(listench: chan of ref Dial->Connection, c: ref Dial->Connection, addr:
else{
if(nc.cfd != nil)
sys->fprint(nc.cfd, "keepalive");
- listench <-= nc;
+ listench <-= (ok, nc);
}
}
}
-authenticator(authch: chan of (string, ref Dial->Connection),
- c: ref Dial->Connection, algs: list of string, addr: string)
+authenticator(authch: chan of (string, Sys->Connection),
+ c: Sys->Connection, algs: list of string, addr: string)
{
err: string;
(c.dfd, err) = auth->server(algs, serverkey, c.dfd, 0);