public inbox for gwml@vger.gnuweeb.org
 help / color / mirror / Atom feed
From: Ahmad Gani <reyuki@gnuweeb.org>
To: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Cc: Ahmad Gani <reyuki@gnuweeb.org>,
	Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>,
	GNU/Weeb Mailing List <gwml@vger.gnuweeb.org>
Subject: [PATCH gwproxy v1 0/3] Initial work for DNS lookup implementation
Date: Thu, 31 Jul 2025 10:07:43 +0700	[thread overview]
Message-ID: <20250731030856.366368-1-reyuki@gnuweeb.org> (raw)

Hi Chief,

This is initial work of dns lookup feature, The patches aren't final, but
it's enough to get a grasp of what the interface looks like. I've 
provided a temporary entry point main function to test it.

There are 3 patches in this series:
- create net.h and net.c to store network related functionality.
- allow only port string number in service parameter of gwp_dns_queue
- initial work for implementation of C-ares-like getaddrinfo function

I propose to move the utility or helper function (that is commonly used 
in multiple places) to net.h and net.c, e.g., struct gwp_sockaddr is 
useful, and it possibly will be used in multiple places as the project 
expands.

I think it would be better to limit the service field to only contain the
port number, as SOCKS5 always uses a string port number.

in reply to Telegram chat [1]:
> (( It's the only reason we need a dedicated thread for resolving DNS ))

Is it preferred to use the current model (spawning dedicated DNS threads)
and make the behavior of the resolver the same as getaddrinfo (blocking)?
So far I've created the addrinfo interfaces with C-ares style and tested 
it; although, it's still blocking.

I would like to know the numbers for comparison between the thread model 
vs. the asynchronous model. Which approach is best for this scenario/case
(DNS resolution)?

I feel like multi-threading is much faster than single-threading, as it's
executed in true parallel (on a multi-core system) compared to 
concurrently doing things with an event notification mechanism.

My general understanding of parallel and concurrent is derived from this 
definition on the Stack Overflow answer [2]:
> Concurrency is when two or more tasks can start, run, and complete in 
> overlapping time periods. It doesn't necessarily mean they'll ever both
> be running at the same instant. For example, multitasking on
> a single-core machine. Parallelism is when tasks literally run at the 
> same time, e.g., on a multicore processor.

I also noticed that in the C-ares example [3], they recommend using the 
event thread example, and it is similar to the io_uring model in my 
perspective, where the operation is executed internally instead of 
letting the caller poll for readiness with ares_process_fd. Maybe we can 
mimic this aspect? I will remove the callback and make it blocking to 
make it compatible with the current thread model, but let's hear your 
opinion first.

I would like to request at least 40 revisions [4] to ensure I've learned 
something, so please treat me like I'm a dumb AI agent [5] (prompt me 
anything, I need more input!) and please review, thanks!

[1]:
- https://t.me/GNUWeeb/1192156

[2]:
- https://stackoverflow.com/a/1050257/22382954

[3]:
- https://c-ares.org/docs.html#examples

[4]:
- https://t.me/GNUWeeb/625966
- https://lore.kernel.org/lkml/20201104145430.300542-1-jarkko.sakkinen@linux.intel.com/T/

[5]:
- https://www.youtube.com/watch?v=P_O0ynyLOtI

Ahmad Gani (3):
  dnslookup: split common functionality and struct into net.c
  dnslookup: Allow only port string number
  dnslookup: Initial work for implementation of C-ares-like getaddrinfo
    function

 Makefile                |   1 +
 man/gwp_dns_queue.3     |   2 +-
 src/gwproxy/dns.h       |  12 +-
 src/gwproxy/dnslookup.c | 286 +++++++++++++++++++++++++++++++
 src/gwproxy/dnslookup.h | 110 ++++++++++++
 src/gwproxy/dnsparser.c | 362 ++++++++++++++++++++++++++++++++++++++++
 src/gwproxy/dnsparser.h | 188 +++++++++++++++++++++
 src/gwproxy/gwproxy.c   |  29 ----
 src/gwproxy/net.c       | 108 ++++++++++++
 src/gwproxy/net.h       |  27 +++
 10 files changed, 1085 insertions(+), 40 deletions(-)
 create mode 100644 src/gwproxy/dnslookup.c
 create mode 100644 src/gwproxy/dnslookup.h
 create mode 100644 src/gwproxy/dnsparser.c
 create mode 100644 src/gwproxy/dnsparser.h
 create mode 100644 src/gwproxy/net.c
 create mode 100644 src/gwproxy/net.h


base-commit: 0753f2d766e85fcbffc1f83dfd4e67d6206591cb
-- 
Ahmad Gani


             reply	other threads:[~2025-07-31  3:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-31  3:07 Ahmad Gani [this message]
2025-07-31  3:07 ` [PATCH gwproxy v1 1/3] dnslookup: split common functionality and struct into net.c Ahmad Gani
2025-07-31 14:01   ` Ammar Faizi
2025-07-31 18:28     ` Alviro Iskandar Setiawan
2025-07-31 18:36       ` Ammar Faizi
2025-07-31 18:42         ` Alviro Iskandar Setiawan
2025-07-31 18:53           ` Ammar Faizi
2025-07-31 19:03             ` Alviro Iskandar Setiawan
2025-07-31  3:07 ` [PATCH gwproxy v1 2/3] dnslookup: Allow only port string number Ahmad Gani
2025-07-31  3:07 ` [PATCH gwproxy v1 3/3] dnslookup: Initial work for implementation of C-ares-like getaddrinfo function Ahmad Gani
2025-07-31 18:19   ` Alviro Iskandar Setiawan
2025-07-31 19:14   ` Alviro Iskandar Setiawan
2025-08-01  1:51     ` reyuki
2025-08-01 23:32       ` Alviro Iskandar Setiawan
2025-07-31 13:39 ` [PATCH gwproxy v1 0/3] Initial work for DNS lookup implementation Ammar Faizi
2025-08-01  1:49   ` reyuki
2025-08-01  2:19     ` Ammar Faizi
2025-08-05  6:28       ` reyuki

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=20250731030856.366368-1-reyuki@gnuweeb.org \
    --to=reyuki@gnuweeb.org \
    --cc=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