public inbox for gwml@vger.gnuweeb.org
 help / color / mirror / Atom feed
From: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
To: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Cc: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>,
	GNU/Weeb Mailing List <gwml@vger.gnuweeb.org>
Subject: [PATCH gwproxy v1 1/2] io_uring: Add auth-file hot reload support
Date: Thu, 31 Jul 2025 07:27:23 +0700	[thread overview]
Message-ID: <20250731002724.294967-2-alviro.iskandar@gnuweeb.org> (raw)
In-Reply-To: <20250731002724.294967-1-alviro.iskandar@gnuweeb.org>

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


  reply	other threads:[~2025-07-31  0:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250731002724.294967-2-alviro.iskandar@gnuweeb.org \
    --to=alviro.iskandar@gnuweeb.org \
    --cc=ammarfaizi2@gnuweeb.org \
    --cc=gwml@vger.gnuweeb.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox