Skip to content

Commit c9ebba7

Browse files
committed
add default value
1 parent 50d5ead commit c9ebba7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

docs/content/programs/tcp-proxy.org

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#+TITLE: tcp-proxy
22
#+DATE: 2024-09-01T00:02:43+0800
3-
#+LASTMOD: 2024-09-01T21:05:27+0800
3+
#+LASTMOD: 2024-09-02T22:06:56+0800
44
#+TYPE: docs
55
#+DESCRIPTION: Forward TCP requests hitting a specified port on the localhost to a different port on another host
66

@@ -16,11 +16,11 @@ Both IPv4 and IPv6 are supported. On Linux [[https://man7.org/linux/man-pages/ma
1616
./zig-out/bin/tcp-proxy [OPTIONS]
1717

1818
OPTIONS:
19-
-b, --bind_host STRING Local bind host(required)
20-
-p, --local_port INTEGER Local bind port(required)
19+
-b, --bind_host STRING Local bind host(default: 0.0.0.0)
20+
-p, --local_port INTEGER Local bind port(default: 8081)
2121
-H, --remote_host STRING Remote host(required)
2222
-P, --remote_port INTEGER Remote port(required)
23-
--buf_size INTEGER Buffer size for tcp read/write(default: 1024)
23+
--buf_size INTEGER Buffer size for tcp read/write(default: 16384)
2424
--server_threads INTEGER Server worker threads num(default: 24)
2525
-h, --help
2626
-v, --version
@@ -33,7 +33,7 @@ tcp-proxy -b 0.0.0.0 -p 8082 -H 192.168.0.2 -P 8082
3333
This will forward tcp requests from =localhost:8082= to =192.168.0.2:8082=
3434

3535
* Benchmark
36-
[[https://iperf.fr/][iPerf3]] is used to benchmark proxy between zigcli and [[https://github.com/kklis/proxy][proxy]], which written in C.
36+
[[https://iperf.fr/][iPerf3]] is used to benchmark performance between zigcli and [[https://github.com/kklis/proxy][this]], a proxy written in C.
3737
** All in one
3838
- server/client/proxy :: =192.168.31.142=, debian 12
3939
| | sender | receiver |

src/bin/tcp-proxy.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ pub fn main() !void {
1616
const allocator = std.heap.page_allocator;
1717

1818
const opt = try simargs.parse(allocator, struct {
19-
bind_host: []const u8,
20-
local_port: u16,
19+
bind_host: []const u8 = "0.0.0.0",
20+
local_port: u16 = 8081,
2121
remote_host: []const u8,
2222
remote_port: u16,
2323
buf_size: usize = 1024 * 16,

0 commit comments

Comments
 (0)