* [PATCH gwproxy v1 0/2] Auth-file hot reload and show help message for invalid parameters
@ 2025-07-31 0:27 Alviro Iskandar Setiawan
2025-07-31 0:27 ` [PATCH gwproxy v1 1/2] io_uring: Add auth-file hot reload support Alviro Iskandar Setiawan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-31 0:27 UTC (permalink / raw)
To: Ammar Faizi; +Cc: Alviro Iskandar Setiawan, GNU/Weeb Mailing List
Hi Chief,
Two patches for gwproxy this morning. My first time sending patches
for gwproxy today. This patch series adds support for hot reloading
the auth-file in io_uring and also adds a help message for invalid
parameters in gwproxy.
When gwproxy is run with a zero argument (or argc=1), it doesn't show a
helpful message, just like this:
Error: --target is required unless --as-socks5 is specified.
Show the help when the argument is invalid to let new users get better
experience.
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
Alviro Iskandar Setiawan (2):
io_uring: Add auth-file hot reload support
gwproxy: Show help on invalid parameter
src/gwproxy/ev/io_uring.c | 28 ++++++++++++++++++++++++++++
src/gwproxy/gwproxy.c | 13 +++++++++----
2 files changed, 37 insertions(+), 4 deletions(-)
base-commit: ab8b6ee9729481c0e73c3a84cf1684ff4d24803e
--
Alviro Iskandar Setiawan
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH gwproxy v1 1/2] io_uring: Add auth-file hot reload support
2025-07-31 0:27 [PATCH gwproxy v1 0/2] Auth-file hot reload and show help message for invalid parameters Alviro Iskandar Setiawan
@ 2025-07-31 0:27 ` Alviro Iskandar Setiawan
2025-07-31 0:27 ` [PATCH gwproxy v1 2/2] gwproxy: Show help on invalid parameter Alviro Iskandar Setiawan
2025-07-31 0:29 ` [PATCH gwproxy v1 0/2] Auth-file hot reload and show help message for invalid parameters Ammar Faizi
2 siblings, 0 replies; 4+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-31 0:27 UTC (permalink / raw)
To: Ammar Faizi; +Cc: Alviro Iskandar Setiawan, GNU/Weeb Mailing List
Handle auth-file hot reload from io_uring as well.
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
src/gwproxy/ev/io_uring.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/gwproxy/ev/io_uring.c b/src/gwproxy/ev/io_uring.c
index d6e9b9a..e0e3be2 100644
--- a/src/gwproxy/ev/io_uring.c
+++ b/src/gwproxy/ev/io_uring.c
@@ -746,6 +746,28 @@ static int handle_ev_dns_query(struct gwp_wrk *w, void *udata)
return handle_socks5_connect_target(w, gcp);
}
+static void prep_socks5_auth_reload(struct gwp_wrk *w)
+{
+ static const size_t l = sizeof(struct inotify_event) + NAME_MAX + 1;
+ struct gwp_ctx *ctx = w->ctx;
+ struct io_uring_sqe *s;
+
+ assert(ctx->socks5);
+ s = get_sqe_nofail(w);
+ io_uring_prep_read(s, ctx->ino_fd, ctx->ino_buf, l, 0);
+ s->user_data = EV_BIT_SOCKS5_AUTH_FILE;
+}
+
+static int handle_ev_socks5_auth_file(struct gwp_wrk *w)
+{
+ struct gwp_ctx *ctx = w->ctx;
+
+ prep_socks5_auth_reload(w);
+ gwp_socks5_auth_reload(ctx->socks5);
+ pr_info(&ctx->lh, "Reloaded SOCKS5 authentication file");
+ return 0;
+}
+
static int handle_event(struct gwp_wrk *w, struct io_uring_cqe *cqe)
{
void *udata = (void *)CLEAR_EV_BIT(cqe->user_data);
@@ -795,6 +817,9 @@ static int handle_event(struct gwp_wrk *w, struct io_uring_cqe *cqe)
pr_dbg(&ctx->lh, "Handling client send no callback event: %d", cqe->res);
r = (cqe->res < 0) ? cqe->res : 0;
break;
+ case EV_BIT_SOCKS5_AUTH_FILE:
+ pr_dbg(&ctx->lh, "Handling SOCKS5 auth file reload event: %d", cqe->res);
+ return handle_ev_socks5_auth_file(w);
case EV_BIT_TARGET_CANCEL:
gcp = udata;
pr_dbg(&ctx->lh, "Handling target cancel event: %d", cqe->res);
@@ -890,6 +915,9 @@ int gwp_ctx_thread_entry_io_uring(struct gwp_wrk *w)
pr_info(&ctx->lh, "Worker %u started (io_uring)", w->idx);
+ if (w->idx == 0 && ctx->cfg.as_socks5 && ctx->ino_fd >= 0)
+ prep_socks5_auth_reload(w);
+
io_uring_set_iowait(&w->iou->ring, false);
arm_accept(w);
while (!ctx->stop) {
--
Alviro Iskandar Setiawan
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH gwproxy v1 2/2] gwproxy: Show help on invalid parameter
2025-07-31 0:27 [PATCH gwproxy v1 0/2] Auth-file hot reload and show help message for invalid parameters Alviro Iskandar Setiawan
2025-07-31 0:27 ` [PATCH gwproxy v1 1/2] io_uring: Add auth-file hot reload support Alviro Iskandar Setiawan
@ 2025-07-31 0:27 ` Alviro Iskandar Setiawan
2025-07-31 0:29 ` [PATCH gwproxy v1 0/2] Auth-file hot reload and show help message for invalid parameters Ammar Faizi
2 siblings, 0 replies; 4+ messages in thread
From: Alviro Iskandar Setiawan @ 2025-07-31 0:27 UTC (permalink / raw)
To: Ammar Faizi; +Cc: Alviro Iskandar Setiawan, GNU/Weeb Mailing List
When gwproxy is run with a zero argument (or argc=1), it doesn't show a
helpful message, just like this:
Error: --target is required unless --as-socks5 is specified.
Show the help when the argument is invalid to let new users get better
experience.
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
src/gwproxy/gwproxy.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/gwproxy/gwproxy.c b/src/gwproxy/gwproxy.c
index c5283a9..dac9903 100644
--- a/src/gwproxy/gwproxy.c
+++ b/src/gwproxy/gwproxy.c
@@ -230,25 +230,30 @@ static int parse_options(int argc, char *argv[], struct gwp_cfg *cfg)
if (!cfg->as_socks5 && !cfg->target) {
fprintf(stderr, "Error: --target is required unless --as-socks5 is specified.\n");
- return -EINVAL;
+ goto einval;
}
if (cfg->nr_workers <= 0) {
fprintf(stderr, "Error: --nr-workers must be at least 1.\n");
- return -EINVAL;
+ goto einval;
}
if (cfg->target_buf_size <= 1) {
fprintf(stderr, "Error: --target-buf-size must be greater than 1.\n");
- return -EINVAL;
+ goto einval;
}
if (cfg->client_buf_size <= 1) {
fprintf(stderr, "Error: --client-buf-size must be greater than 1.\n");
- return -EINVAL;
+ goto einval;
}
return 0;
+
+einval:
+ fprintf(stderr, "\n");
+ show_help(argv[0]);
+ return -EINVAL;
}
#define FULL_ADDRSTRLEN (INET6_ADDRSTRLEN + sizeof(":65535[]") - 1)
--
Alviro Iskandar Setiawan
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH gwproxy v1 0/2] Auth-file hot reload and show help message for invalid parameters
2025-07-31 0:27 [PATCH gwproxy v1 0/2] Auth-file hot reload and show help message for invalid parameters Alviro Iskandar Setiawan
2025-07-31 0:27 ` [PATCH gwproxy v1 1/2] io_uring: Add auth-file hot reload support Alviro Iskandar Setiawan
2025-07-31 0:27 ` [PATCH gwproxy v1 2/2] gwproxy: Show help on invalid parameter Alviro Iskandar Setiawan
@ 2025-07-31 0:29 ` Ammar Faizi
2 siblings, 0 replies; 4+ messages in thread
From: Ammar Faizi @ 2025-07-31 0:29 UTC (permalink / raw)
To: Alviro Iskandar Setiawan; +Cc: Ammar Faizi, GNU/Weeb Mailing List
On Thu, 31 Jul 2025 07:27:22 +0700, Alviro Iskandar Setiawan wrote:
> Two patches for gwproxy this morning. My first time sending patches
> for gwproxy today. This patch series adds support for hot reloading
> the auth-file in io_uring and also adds a help message for invalid
> parameters in gwproxy.
>
> [...]
Applied, thanks!
[1/2] io_uring: Add auth-file hot reload support
commit: 1d1310a45f0279690a26bda37b15e28346d1fa00
[2/2] gwproxy: Show help on invalid parameter
commit: f20ce1f68ba77662df2297c36c0affd256c6d704
Best regards,
--
Ammar Faizi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-31 0:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-31 0:27 [PATCH gwproxy v1 0/2] Auth-file hot reload and show help message for invalid parameters Alviro Iskandar Setiawan
2025-07-31 0:27 ` [PATCH gwproxy v1 1/2] io_uring: Add auth-file hot reload support Alviro Iskandar Setiawan
2025-07-31 0:27 ` [PATCH gwproxy v1 2/2] gwproxy: Show help on invalid parameter Alviro Iskandar Setiawan
2025-07-31 0:29 ` [PATCH gwproxy v1 0/2] Auth-file hot reload and show help message for invalid parameters Ammar Faizi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox