diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-09-20 18:32:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-20 18:32:18 -0400 |
commit | 97bb2bdb79cbd0a400c643e7be0029440cb15633 (patch) | |
tree | 92c883d38b7af413fcbfbac82f17775a7064dfec /tools | |
parent | 93b7acf99d6456e6e194c03f024b788ce5adf20e (diff) |
dial/listen API change (#3000)
Previously: dial("tcp", "deno.land:80")
Now: dial({ hostname: "deno.land", port: 80, transport: "tcp" })
Similarly with listen().
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/benchmark.py | 4 | ||||
-rw-r--r-- | tools/complex_permissions_test.ts | 6 | ||||
-rw-r--r-- | tools/deno_tcp.ts | 3 | ||||
-rw-r--r-- | tools/deno_tcp_proxy.ts | 10 | ||||
-rwxr-xr-x | tools/http_benchmark.py | 10 | ||||
-rw-r--r-- | tools/permission_prompt_test.ts | 6 |
6 files changed, 20 insertions, 19 deletions
diff --git a/tools/benchmark.py b/tools/benchmark.py index aaf708422..138135a98 100755 --- a/tools/benchmark.py +++ b/tools/benchmark.py @@ -211,8 +211,8 @@ def run_http(build_dir, new_data): def bundle_benchmark(deno_exe): bundles = { - "file_server": "https://deno.land/std/http/file_server.ts", - "gist": "https://deno.land/std/examples/gist.ts", + "file_server": "./js/deps/https/deno.land/std/http/file_server.ts", + "gist": "./js/deps/https/deno.land/std/examples/gist.ts", } sizes = {} diff --git a/tools/complex_permissions_test.ts b/tools/complex_permissions_test.ts index dd65a0e33..a2e0f7824 100644 --- a/tools/complex_permissions_test.ts +++ b/tools/complex_permissions_test.ts @@ -16,13 +16,15 @@ const test: (args: string[]) => void = { }, netListen(hosts: string[]): void { hosts.forEach(host => { - const listener = Deno.listen("tcp", host); + const [hostname, port] = host.split(":"); + const listener = Deno.listen({ hostname, port: Number(port) }); listener.close(); }); }, async netDial(hosts: string[]): Promise<void> { for (const host of hosts) { - const listener = await Deno.dial("tcp", host); + const [hostname, port] = host.split(":"); + const listener = await Deno.dial({ hostname, port: Number(port) }); listener.close(); } } diff --git a/tools/deno_tcp.ts b/tools/deno_tcp.ts index d744a09c1..2b259cd38 100644 --- a/tools/deno_tcp.ts +++ b/tools/deno_tcp.ts @@ -3,7 +3,8 @@ // https://github.com/denoland/deno/issues/726 is completed. // Note: this is a keep-alive server. const addr = Deno.args[1] || "127.0.0.1:4500"; -const listener = Deno.listen("tcp", addr); +const [hostname, port] = addr.split(":"); +const listener = Deno.listen({ hostname, port: Number(port) }); const response = new TextEncoder().encode( "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n" ); diff --git a/tools/deno_tcp_proxy.ts b/tools/deno_tcp_proxy.ts index 02f5ab944..23d219071 100644 --- a/tools/deno_tcp_proxy.ts +++ b/tools/deno_tcp_proxy.ts @@ -2,10 +2,16 @@ const addr = Deno.args[1] || "127.0.0.1:4500"; const originAddr = Deno.args[2] || "127.0.0.1:4501"; -const listener = Deno.listen("tcp", addr); +const [hostname, port] = addr.split(":"); +const [originHostname, originPort] = originAddr.split(":"); + +const listener = Deno.listen({ hostname, port: Number(port) }); async function handle(conn: Deno.Conn): Promise<void> { - const origin = await Deno.dial("tcp", originAddr); + const origin = await Deno.dial({ + hostname: originHostname, + port: Number(originPort) + }); try { await Promise.all([Deno.copy(conn, origin), Deno.copy(origin, conn)]); } catch (err) { diff --git a/tools/http_benchmark.py b/tools/http_benchmark.py index 5fac44e78..39bedae8c 100755 --- a/tools/http_benchmark.py +++ b/tools/http_benchmark.py @@ -49,13 +49,7 @@ def deno_http(deno_exe): "js/deps/https/deno.land/std/http/http_bench.ts", addr ] print "http_benchmark testing DENO using net/http." - return run( - deno_cmd, - addr, - merge_env={ - # Load from //js/deps/https/deno.land/net/ submodule. - "DENO_DIR": os.path.join(util.root_path, "js") - }) + return run(deno_cmd, addr) def deno_tcp_proxy(deno_exe, hyper_hello_exe): @@ -69,7 +63,6 @@ def deno_tcp_proxy(deno_exe, hyper_hello_exe): return run( deno_cmd, addr, - merge_env={"DENO_DIR": os.path.join(util.root_path, "js")}, origin_cmd=http_proxy_origin(hyper_hello_exe, origin_addr)) @@ -84,7 +77,6 @@ def deno_http_proxy(deno_exe, hyper_hello_exe): return run( deno_cmd, addr, - merge_env={"DENO_DIR": os.path.join(util.root_path, "js")}, origin_cmd=http_proxy_origin(hyper_hello_exe, origin_addr)) diff --git a/tools/permission_prompt_test.ts b/tools/permission_prompt_test.ts index 617f8b0fc..da0c986ed 100644 --- a/tools/permission_prompt_test.ts +++ b/tools/permission_prompt_test.ts @@ -1,5 +1,5 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -const { args, listen, env, exit, makeTempDirSync, readFileSync, run } = Deno; +const { args, env, exit, makeTempDirSync, readFileSync, run } = Deno; const firstCheckFailedMessage = "First check failed"; @@ -31,11 +31,11 @@ const test = { }, needsNet(): void { try { - listen("tcp", "127.0.0.1:4540"); + Deno.listen({ hostname: "127.0.0.1", port: 4540 }); } catch (e) { console.log(firstCheckFailedMessage); } - listen("tcp", "127.0.0.1:4541"); + Deno.listen({ hostname: "127.0.0.1", port: 4541 }); }, needsRun(): void { try { |