summaryrefslogtreecommitdiff
path: root/appl/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'appl/cmd')
-rw-r--r--appl/cmd/auxi/mangaload.b26
-rw-r--r--appl/cmd/cddb.b25
-rw-r--r--appl/cmd/import.b23
-rw-r--r--appl/cmd/ip/ping.b25
-rw-r--r--appl/cmd/ip/rip.b11
-rw-r--r--appl/cmd/lockfs.b93
-rw-r--r--appl/cmd/ndb/dns.b14
-rw-r--r--appl/cmd/styxchat.b37
-rw-r--r--appl/cmd/telnet.b37
-rw-r--r--appl/cmd/webgrab.b11
10 files changed, 119 insertions, 183 deletions
diff --git a/appl/cmd/auxi/mangaload.b b/appl/cmd/auxi/mangaload.b
index 380dd22e..d91c07c5 100644
--- a/appl/cmd/auxi/mangaload.b
+++ b/appl/cmd/auxi/mangaload.b
@@ -16,6 +16,9 @@ include "timers.m";
timers: Timers;
Timer: import timers;
+include "dial.m";
+ dial: Dial;
+
include "arg.m";
Mangaload: module
@@ -88,6 +91,7 @@ init(nil: ref Draw->Context, args: list of string)
{
sys = load Sys Sys->PATH;
timers = load Timers Timers->PATH;
+ dial = load Dial Dial->PATH;
ip = load IP IP->PATH;
ip->init();
@@ -137,9 +141,9 @@ init(nil: ref Draw->Context, args: list of string)
filesize := int d.length;
port := sys->sprint("%d", 16r8695);
- addr := netmkaddr(hd args, "icmp", port);
- (rok, c) := sys->dial(addr, port);
- if(rok < 0){
+ addr := dial->netmkaddr(hd args, "icmp", port);
+ c := dial->dial(addr, port);
+ if(c == nil){
sys->fprint(sys->fildes(2), "mangaload: can't dial %s: %r\n", addr);
raise "fail:dial";
}
@@ -182,7 +186,6 @@ init(nil: ref Draw->Context, args: list of string)
last := 0;
while((n := sys->read(fd, buf, len buf)) >= 0 && !last){
last = n != len buf;
- nretry := 0;
Retry:
for(;;){
if(++nsent%10 == 0){ # probe
@@ -345,18 +348,3 @@ Icmp.unpack(b: array of byte): ref Icmp
ic.data = b[Odata:];
return ic;
}
-
-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);
-}
diff --git a/appl/cmd/cddb.b b/appl/cmd/cddb.b
index 5d88725b..35df120d 100644
--- a/appl/cmd/cddb.b
+++ b/appl/cmd/cddb.b
@@ -14,6 +14,9 @@ include "bufio.m";
include "string.m";
str: String;
+include "dial.m";
+ dial: Dial;
+
include "arg.m";
Cddb: module
@@ -66,8 +69,8 @@ dumpcddb(t: ref Toc)
cddbfilltoc(t: ref Toc): int
{
- (ok, conn) := sys->dial(netmkaddr(server, "tcp", "888"), nil);
- if(ok < 0) {
+ conn := dial->dial(dial->netmkaddr(server, "tcp", "888"), nil);
+ if(conn == nil){
sys->fprint(sys->fildes(2), "cddb: cannot dial %s: %r\n", server);
return -1;
}
@@ -149,7 +152,7 @@ cddbfilltoc(t: ref Toc): int
DPRINT(2, sys->sprint("cddb %s\n", p));
if(len p >= 7 && p[0:7] == "DTITLE=")
t.title += p[7:];
- else if(len p >= 6 && p[0:6] == "TTITLE"&& isdigit(p[6])) {
+ else if(len p >= 7 && p[0:6] == "TTITLE"&& isdigit(p[6])) {
i = atoi(p[6:]);
if(i < t.ntrack) {
p = p[6:];
@@ -200,6 +203,7 @@ init(nil: ref Draw->Context, args: list of string)
sys = load Sys Sys->PATH;
bufio = load Bufio Bufio->PATH;
str = load String String->PATH;
+ dial = load Dial Dial->PATH;
arg := load Arg Arg->PATH;
arg->init(args);
@@ -237,21 +241,6 @@ init(nil: ref Draw->Context, args: list of string)
dumpcddb(toc);
}
-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);
-}
-
atoi(s: string): int
{
return int s;
diff --git a/appl/cmd/import.b b/appl/cmd/import.b
index fb69d0ab..b82495f9 100644
--- a/appl/cmd/import.b
+++ b/appl/cmd/import.b
@@ -4,6 +4,7 @@ include "sys.m";
sys: Sys;
include "draw.m";
+include "dial.m";
include "keyring.m";
include "security.m";
include "factotum.m";
@@ -35,6 +36,7 @@ init(nil: ref Draw->Context, args: list of string)
if(factotum == nil)
nomod(Factotum->PATH);
factotum->init();
+ dial := load Dial Dial->PATH;
arg := load Arg Arg->PATH;
if(arg == nil)
@@ -80,9 +82,9 @@ init(nil: ref Draw->Context, args: list of string)
if(facfd == nil)
fail("factotum", sys->sprint("can't open %s: %r", factotumfile));
- dest := netmkaddr(addr, "net", "exportfs");
- (ok, c) := sys->dial(dest, nil);
- if(ok < 0)
+ dest := dial->netmkaddr(addr, "net", "exportfs");
+ c := dial->dial(dest, nil);
+ if(c == nil)
fail("dial failed", sys->sprint("can't dial %s: %r", dest));
ai := factotum->proxy(c.dfd, facfd, "proto=p9any role=client "+keyspec);
if(ai == nil)
@@ -161,18 +163,3 @@ pushssl(fd: ref Sys->FD, secretin, secretout: array of byte, alg: string): (ref
return (c.dfd, nil);
}
-
-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);
-}
diff --git a/appl/cmd/ip/ping.b b/appl/cmd/ip/ping.b
index a148c1e6..d0547390 100644
--- a/appl/cmd/ip/ping.b
+++ b/appl/cmd/ip/ping.b
@@ -16,6 +16,9 @@ include "timers.m";
include "rand.m";
rand: Rand;
+include "dial.m";
+ dial: Dial;
+
include "arg.m";
Ping: module
@@ -74,6 +77,7 @@ init(nil: ref Draw->Context, args: list of string)
sys = load Sys Sys->PATH;
rand = load Rand Rand->PATH;
timers = load Timers Timers->PATH;
+ dial = load Dial Dial->PATH;
ip = load IP IP->PATH;
ip->init();
@@ -117,9 +121,9 @@ init(nil: ref Draw->Context, args: list of string)
opentime();
rand->init(int(nsec()/big 1000));
- addr := netmkaddr(hd args, "icmp", "1");
- (ok, c) := sys->dial(addr, nil);
- if(ok < 0){
+ addr := dial->netmkaddr(hd args, "icmp", "1");
+ c := dial->dial(addr, nil);
+ if(c == nil){
sys->fprint(sys->fildes(2), "ip/ping: can't dial %s: %r\n", addr);
raise "fail:dial";
}
@@ -333,21 +337,6 @@ Icmp.unpack(b: array of byte): ref Icmp
return ic;
}
-netmkaddr(addr, net, svc: string): string
-{
- if(net == nil)
- net = "net";
- (n, l) := 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);
-}
-
timefd: ref Sys->FD;
opentime()
diff --git a/appl/cmd/ip/rip.b b/appl/cmd/ip/rip.b
index 90c1b6ce..81dfca58 100644
--- a/appl/cmd/ip/rip.b
+++ b/appl/cmd/ip/rip.b
@@ -15,6 +15,10 @@ include "bufio.m";
include "daytime.m";
daytime: Daytime;
+include "dial.m";
+ dial: Dial;
+
+
include "ip.m";
ip: IP;
IPaddr, Ifcaddr, Udphdr: import ip;
@@ -105,6 +109,7 @@ init(nil: ref Draw->Context, args: list of string)
sys = load Sys Sys->PATH;
bufio = load Bufio Bufio->PATH;
daytime = load Daytime Daytime->PATH;
+ dial = load Dial Dial->PATH;
ip = load IP IP->PATH;
ip->init();
@@ -420,7 +425,7 @@ sendroutes(ifc: ref Ifcaddr, dst: IPaddr, op: int, changes: int)
buf[o+2] = byte 0;
buf[o+3] = byte 0;
o += Riphdrlen;
- rips := buf[IP->Udphdrlen+Riphdrlen:];
+# rips := buf[IP->Udphdrlen+Riphdrlen:];
if(op == OpRequest){
buf[o:] = zeroentry;
ip->put4(buf, o+Ometric, HopLimit);
@@ -602,8 +607,8 @@ Gateway.contains(g: self ref Gateway, a: IPaddr): int
riplisten(): ref Sys->FD
{
addr := sys->sprint("%s/udp!*!rip", netdir);
- (ok, c) := sys->announce(addr);
- if(ok < 0)
+ c := dial->announce(addr);
+ if(c == nil)
fatal(sys->sprint("can't announce %s: %r", addr));
if(sys->fprint(c.cfd, "headers") < 0)
fatal(sys->sprint("can't set udp headers: %r"));
diff --git a/appl/cmd/lockfs.b b/appl/cmd/lockfs.b
index 1b958de2..e15c897c 100644
--- a/appl/cmd/lockfs.b
+++ b/appl/cmd/lockfs.b
@@ -16,6 +16,8 @@ include "keyring.m";
keyring: Keyring;
include "security.m";
auth: Auth;
+include "dial.m";
+ dial: Dial;
Lockfs: module {
init: fn(nil: ref Draw->Context, argv: list of string);
@@ -71,19 +73,12 @@ Uproc: type chan of (ref Ureq, chan of (ref Sys->FD, string));
maxqidpath := big 1;
locks: list of ref Lockfile;
lockdir: string;
-authinfo: ref Keyring->Authinfo;
timefd: ref Sys->FD;
MAXCONN: con 20;
verbose := 0;
-usage()
-{
- sys->fprint(stderr, "usage: lockfs [-A] [-a alg]... [-p addr] dir [mountpoint]\n");
- raise "fail:usage";
-}
-
badmodule(p: string)
{
sys->fprint(stderr, "lockfs: cannot load %s: %r\n", p);
@@ -105,6 +100,9 @@ init(nil: ref Draw->Context, argv: list of string)
devgen = load Dirgenmod "$self";
if (devgen == nil)
badmodule("self as Dirgenmod");
+ dial = load Dial Dial->PATH;
+ if(dial == nil)
+ badmodule(Dial->PATH);
timefd = sys->open("/dev/time", sys->OREAD);
if (timefd == nil) {
sys->fprint(stderr, "lockfs: cannot open /dev/time: %r\n");
@@ -114,55 +112,52 @@ init(nil: ref Draw->Context, argv: list of string)
if (arg == nil)
badmodule(Arg->PATH);
arg->init(argv);
+ arg->setusage("lockfs [-A] [-e 'crypt hash'] ... [-k keyspec] [-p addr] dir [mountpoint]");
addr := "";
doauth := 1;
algs: list of string;
+ keyspec: string;
while ((opt := arg->opt()) != 0) {
case opt {
'p' =>
- addr = arg->arg();
- 'a' =>
- alg := arg->arg();
- if (alg == nil)
- usage();
- algs = alg :: algs;
+ addr = arg->earg();
+ 'k' =>
+ addr = arg->earg();
+ 'a' or 'e' =>
+ algs = arg->earg() :: algs;
'A' =>
doauth = 0;
'v' =>
verbose = 1;
* =>
- usage();
+ arg->usage();
}
}
argv = arg->argv();
if (argv == nil || (addr != nil && tl argv != nil))
- usage();
+ arg->usage();
if (addr == nil)
doauth = 0; # no authentication necessary for local mount
if (doauth) {
auth = load Auth Auth->PATH;
if (auth == nil)
badmodule(Auth->PATH);
- if ((e := auth->init()) != nil) {
- sys->fprint(stderr, "lockfs: cannot init auth: %s\n", e);
- raise "fail:errors";
- }
- keyring = load Keyring Keyring->PATH;
- if (keyring == nil)
- badmodule(Keyring->PATH);
- authinfo = keyring->readauthinfo("/usr/" + user() + "/keyring/default");
+ auth->init();
}
mountpoint := lockdir = hd argv;
if (tl argv != nil)
mountpoint = hd tl argv;
if (addr != nil) {
- if (doauth && algs == nil)
- algs = "none" :: nil; # XXX is this default a bad idea?
+ if (doauth){
+ if(algs == nil)
+ algs = "none" :: nil; # XXX is this default a bad idea?
+ keyspec += " :alg='"+flatten(algs, ' ')+"'";
+ }
srvrq := chan of (ref Sys->FD, string, Uproc);
srvsync := chan of (int, string);
- spawn listener(addr, srvrq, srvsync, algs);
+ spawn listener(addr, keyspec, srvrq, srvsync, algs);
(srvpid, err) := <-srvsync;
srvsync = nil;
if (srvpid == -1) {
@@ -633,28 +628,28 @@ revrqlist(ls: list of ref Openreq) : list of ref Openreq
}
# addr should be, e.g. tcp!*!2345
-listener(addr: string, ch: chan of (ref Sys->FD, string, Uproc),
+listener(addr: string, keyspec: string, ch: chan of (ref Sys->FD, string, Uproc),
sync: chan of (int, string), algs: list of string)
{
- addr = netmkaddr(addr, "tcp", "33234");
- (ok, c) := sys->announce(addr);;
- if (ok == -1) {
+ addr = dial->netmkaddr(addr, "tcp", "33234");
+ c := dial->announce(addr);
+ if(c == nil) {
sync <-= (-1, sys->sprint("cannot anounce on %s: %r", addr));
return;
}
sync <-= (sys->pctl(0, nil), nil);
for (;;) {
- (n, nc) := sys->listen(c);
- if (n == -1) {
+ nc := dial->listen(c);
+ if (nc == nil) {
ch <-= (nil, sys->sprint("listen failed: %r"), nil);
return;
}
- dfd := sys->open(nc.dir + "/data", Sys->ORDWR);
+ dfd := dial->accept(nc);
if (dfd != nil) {
if (algs == nil)
ch <-= (dfd, nil, nil);
else
- spawn authenticator(dfd, ch, algs);
+ spawn authenticator(dfd, keyspec, ch);
}
}
}
@@ -662,9 +657,9 @@ listener(addr: string, ch: chan of (ref Sys->FD, string, Uproc),
# authenticate a connection, setting the user id appropriately,
# and then act as a server, performing file operations
# on behalf of the central process.
-authenticator(dfd: ref Sys->FD, ch: chan of (ref Sys->FD, string, Uproc), algs: list of string)
+authenticator(dfd: ref Sys->FD, keyspec: string, ch: chan of (ref Sys->FD, string, Uproc))
{
- (fd, err) := auth->server(algs, authinfo, dfd, 1);
+ (fd, err) := auth->auth(keyspec, dfd, 1);
if (fd == nil) {
if (verbose)
sys->fprint(stderr, "lockfs: authentication failed: %s\n", err);
@@ -730,21 +725,6 @@ doreq(greq: ref Ureq): (ref Sys->FD, string)
return (fd, err);
}
-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);
-}
-
user(): string
{
fd := sys->open("/dev/user", sys->OREAD);
@@ -771,3 +751,14 @@ now(): int
return 0;
return int (big string buf[0:n] / big 1000000);
}
+
+flatten(l: list of string, sep: int): string
+{
+ s := "";
+ for(; l != nil; l = tl l){
+ if(s != "")
+ s[len s] = sep;
+ s += hd l;
+ }
+ return s;
+}
diff --git a/appl/cmd/ndb/dns.b b/appl/cmd/ndb/dns.b
index 7c116c99..0cd7957c 100644
--- a/appl/cmd/ndb/dns.b
+++ b/appl/cmd/ndb/dns.b
@@ -46,6 +46,9 @@ include "keyring.m";
include "security.m";
random: Random;
+include "dial.m";
+ dial: Dial;
+
DNS: module
{
init: fn(nil: ref Draw->Context, nil: list of string);
@@ -85,6 +88,9 @@ init(nil: ref Draw->Context, args: list of string)
arg := load Arg Arg->PATH;
if(arg == nil)
cantload(Arg->PATH);
+ dial = load Dial Dial->PATH;
+ if(dial == nil)
+ cantload(Dial->PATH);
arg->init(args);
arg->setusage("dns [-Drh] [-f dnsfile] [-x mntpt]");
svcname := "#sdns";
@@ -1778,8 +1784,8 @@ kill(pid: int)
udpport(): ref Sys->FD
{
- (ok, conn) := sys->announce(mntpt+"/udp!*!0");
- if(ok < 0)
+ conn := dial->announce(mntpt+"/udp!*!0");
+ if(conn == nil)
return nil;
if(sys->fprint(conn.cfd, "headers") < 0){
sys->fprint(stderr, "dns: can't set headers mode: %r\n");
@@ -1802,8 +1808,8 @@ tcpquery(query: array of byte): (ref DNSmsg, string)
ipa := query[Udpraddr+IPv4off:];
addr := sys->sprint("tcp!%d.%d.%d.%d!%d", int ipa[0], int ipa[1], int ipa[2], int ipa[3], DNSport);
- (ok, conn) := sys->dial(addr, nil);
- if(ok < 0)
+ conn := dial->dial(addr, nil);
+ if(conn == nil)
return (nil, sys->sprint("can't dial %s: %r", addr));
query = query[Udphdrsize-2:];
put2(query, 0, len query-2); # replace UDP header by message length
diff --git a/appl/cmd/styxchat.b b/appl/cmd/styxchat.b
index f66b49fe..20d0d968 100644
--- a/appl/cmd/styxchat.b
+++ b/appl/cmd/styxchat.b
@@ -20,6 +20,9 @@ include "bufio.m";
bufio: Bufio;
Iobuf: import bufio;
+include "dial.m";
+ dial: Dial;
+
include "arg.m";
Styxchat: module
@@ -39,6 +42,7 @@ init(nil: ref Draw->Context, args: list of string)
styx = load Styx Styx->PATH;
str = load String String->PATH;
bufio = load Bufio Bufio->PATH;
+ dial = load Dial Dial->PATH;
styx->init();
client := 1;
@@ -74,21 +78,21 @@ init(nil: ref Draw->Context, args: list of string)
stdin = sys->fildes(0);
dest := hd args;
if(addr){
- dest = netmkaddr(dest, "net", "styx");
+ dest = dial->netmkaddr(dest, "net", "styx");
if (client){
- (rc, c) := sys->dial(dest, nil);
- if(rc < 0)
+ c := dial->dial(dest, nil);
+ if(c == nil)
err(sys->sprint("can't dial %s: %r", dest));
fd = c.dfd;
}else{
- (rlc, lc) := sys->announce(dest);
- if (rlc < 0)
+ lc := dial->announce(dest);
+ if(lc == nil)
err(sys->sprint("can't announce %s: %r", dest));
- (rc, c) := sys->listen(lc);
- if (rc < 0)
+ c := dial->listen(lc);
+ if(c == nil)
err(sys->sprint("can't listen on %s: %r", dest));
- fd = sys->open(c.dir + "/data", Sys->ORDWR);
- if (fd == nil)
+ fd = dial->accept(c);
+ if(fd == nil)
err(sys->sprint("can't open %s/data: %r", c.dir));
}
}else{
@@ -107,21 +111,6 @@ init(nil: ref Draw->Context, args: list of string)
}
}
-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);
-}
-
quit(e: int)
{
fd := sys->open("/prog/"+string sys->pctl(0, nil)+"/ctl", Sys->OWRITE);
diff --git a/appl/cmd/telnet.b b/appl/cmd/telnet.b
index ff5a59e0..014811c9 100644
--- a/appl/cmd/telnet.b
+++ b/appl/cmd/telnet.b
@@ -2,11 +2,12 @@ implement Telnet;
include "sys.m";
sys: Sys;
- Connection: import sys;
include "draw.m";
- draw: Draw;
- Context: import draw;
+
+include "dial.m";
+ dial: Dial;
+ Connection: import dial;
Telnet: module
{
@@ -34,7 +35,7 @@ BSL: con 21; # ^u backspace line
EOT: con 4; # ^d end of file
ESC: con 27; # hold mode
-net: Connection;
+net: ref Connection;
stdin, stdout, stderr: ref Sys->FD;
# control characters
@@ -99,12 +100,13 @@ usage()
raise "fail:usage";
}
-init(nil: ref Context, argv: list of string)
+init(nil: ref Draw->Context, argv: list of string)
{
sys = load Sys Sys->PATH;
stderr = sys->fildes(2);
stdout = sys->fildes(1);
stdin = sys->fildes(0);
+ dial = load Dial Dial->PATH;
if (len argv < 2)
usage();
@@ -120,11 +122,11 @@ init(nil: ref Context, argv: list of string)
ccfd: ref Sys->FD;
connect(addr: string, port: string)
{
- ok: int;
- (ok, net) = sys->dial(netmkaddr(addr, "tcp", port), nil);
- if(ok < 0) {
- sys->fprint(stderr, "telnet: %r\n");
- return;
+ dest := dial->netmkaddr(addr, "tcp", port);
+ net = dial->dial(dest, nil);
+ if(net == nil) {
+ sys->fprint(stderr, "telnet: can't dial %s: %r\n", dest);
+ raise "fail:dial";
}
sys->fprint(stderr, "telnet: connected to %s\n", addr);
@@ -465,18 +467,3 @@ raw(on: int)
else
sys->fprint(ccfd, "rawoff");
}
-
-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);
-}
diff --git a/appl/cmd/webgrab.b b/appl/cmd/webgrab.b
index 4e8fd6ce..062c342b 100644
--- a/appl/cmd/webgrab.b
+++ b/appl/cmd/webgrab.b
@@ -31,6 +31,9 @@ include "daytime.m";
include "bufio.m";
B: Bufio;
+include "dial.m";
+ D: Dial;
+
include "arg.m";
Webgrab: module
@@ -52,6 +55,7 @@ init(nil: ref Draw->Context, args: list of string)
S = load String String->PATH;
U = load Url Url->PATH;
DT = load Daytime Daytime->PATH;
+ D = load Dial Dial->PATH;
B = load Bufio Bufio->PATH;
arg := load Arg Arg->PATH;
if(S == nil || U == nil || DT == nil || B == nil || arg == nil)
@@ -381,9 +385,10 @@ httpget(u: ref ParsedUrl) : (string, array of byte, ref Sys->FD, ref ParsedUrl)
dialhost = u.host;
port = u.port;
}
- (ok, net) := sys->dial("tcp!" + dialhost + "!" + port, nil);
- if(ok < 0)
- return (sys->sprint("can't dial %s: %r", dialhost), nil, nil, nil);
+ dest := D->netmkaddr(dialhost, "tcp", port);
+ net := D->dial(dest, nil);
+ if(net == nil)
+ return (sys->sprint("can't dial %s: %r", dest), nil, nil, nil);
# prepare request
if(u.query != ""){