summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/ops/net.rs25
-rw-r--r--cli/tests/echo_server.ts3
2 files changed, 17 insertions, 11 deletions
diff --git a/cli/ops/net.rs b/cli/ops/net.rs
index 11bf410d1..507eff504 100644
--- a/cli/ops/net.rs
+++ b/cli/ops/net.rs
@@ -49,8 +49,9 @@ pub fn op_accept(
#[derive(Deserialize)]
struct DialArgs {
- network: String,
- address: String,
+ transport: String,
+ hostname: String,
+ port: u16,
}
pub fn op_dial(
@@ -59,9 +60,11 @@ pub fn op_dial(
_zero_copy: Option<PinnedBuf>,
) -> Result<JsonOp, ErrBox> {
let args: DialArgs = serde_json::from_value(args)?;
- let network = args.network;
- assert_eq!(network, "tcp"); // TODO Support others.
- let address = args.address;
+ assert_eq!(args.transport, "tcp"); // TODO Support others.
+
+ // TODO(ry) Using format! is suboptimal here. Better would be if
+ // state.check_net and resolve_addr() took hostname and port directly.
+ let address = format!("{}:{}", args.hostname, args.port);
state.check_net(&address)?;
@@ -117,8 +120,9 @@ pub fn op_shutdown(
#[derive(Deserialize)]
struct ListenArgs {
- network: String,
- address: String,
+ transport: String,
+ hostname: String,
+ port: u16,
}
pub fn op_listen(
@@ -127,10 +131,11 @@ pub fn op_listen(
_zero_copy: Option<PinnedBuf>,
) -> Result<JsonOp, ErrBox> {
let args: ListenArgs = serde_json::from_value(args)?;
+ assert_eq!(args.transport, "tcp");
- let network = args.network;
- assert_eq!(network, "tcp");
- let address = args.address;
+ // TODO(ry) Using format! is suboptimal here. Better would be if
+ // state.check_net and resolve_addr() took hostname and port directly.
+ let address = format!("{}:{}", args.hostname, args.port);
state.check_net(&address)?;
diff --git a/cli/tests/echo_server.ts b/cli/tests/echo_server.ts
index 73995eab5..82ee1fdab 100644
--- a/cli/tests/echo_server.ts
+++ b/cli/tests/echo_server.ts
@@ -1,6 +1,7 @@
const { args, listen, copy } = Deno;
const addr = args[1] || "127.0.0.1:4544";
-const listener = listen("tcp", addr);
+const [hostname, port] = addr.split(":");
+const listener = listen({ hostname, port: Number(port) });
console.log("listening on", addr);
listener.accept().then(
async (conn): Promise<void> => {