diff options
| author | forsyth <forsyth@vitanuova.com> | 2011-01-17 11:10:35 +0000 |
|---|---|---|
| committer | forsyth <forsyth@vitanuova.com> | 2011-01-17 11:10:35 +0000 |
| commit | d6b4eae8eb0a5ca3119414005e483fedd63a62d6 (patch) | |
| tree | 4959b04b1ae02ce5ccb4b3c0a8c459ff46587eb7 /appl/cmd/listen.b | |
| parent | 9e6910dc0c747c8f30b87f6482f4eadb48ad6654 (diff) | |
20110117-1110
Diffstat (limited to 'appl/cmd/listen.b')
| -rw-r--r-- | appl/cmd/listen.b | 33 |
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); |
