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 v2 0/3] Initial work for DNS lookup implementation
Date: Fri, 1 Aug 2025 08:54:21 +0700 [thread overview]
Message-ID: <20250801015427.439511-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
On Thu, 31 Jul 2025 21:01:02 +0700, Ammar Faizi wrote:
>> On Thu, Jul 31, 2025 at 10:07:44AM +0700, Ahmad Gani wrote:
>> +int init_addr(const char *addr, struct gwp_sockaddr *addr_st, uint16_t port)
> This is a no-no. We don't need it.
Sorry, I didn't know the existence of convert_str_to_ssaddr, the init_addr
is now replaced with convert_str_to_ssaddr.
> In gwproxy.c, there is convert_str_to_ssaddr(). It's also better than
> your version because with it you can have:
>
> ./gwproxy --target google.com:80 --bind localhost:1111
> Not restricted to IP address format, but domain name is also ok.
Looking at the example, I guess I need to add logic to handle Special-use
domain name [1] and an ability to detect local name server in the system
to fully replace glibc's getaddrinfo, but since it's mentioned somewhere
in the mail threads [2] that we can use glibc's getaddrinfo for just
bootstrapping purpose I guess I don't need to fully replace it then.
I also bring back __cold attribute on convert_ssaddr_to_str function to
inform the compiler that function is unlikely to be executed and thus
change optiomization priority for size first rather than speed.
## Changelog
v1 -> v2:
- use existing convert_str_to_ssaddr instead of init_addr
- fix memory leak when init_addr (now it's replaced) failed
- modify convert_str_to_ssaddr to support default port
- bring back __cold attribute on convert_ssaddr_to_str
- don't fill a dangling pointer as Sir Alviro said [3]
- for now it's blocking, attempt_retry label is not needed
[1]:
- https://en.wikipedia.org/wiki/Special-use_domain_name
[2]:
- https://lore.gnuweeb.org/gwml/aIu7m+NE8Iny+YQN@linux.gnuweeb.org
[3]:
- https://lore.gnuweeb.org/gwml/CAOG64qMPmFL-+7OrVv4psmyOt8G-3OZJGa=bQ1a_wuV06WTyng@mail.gmail.com/
Signed-off-by: Ahmad Gani <reyuki@gnuweeb.org>
---
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 | 289 ++++++++++++++++++++++++++++++++
src/gwproxy/dnslookup.h | 118 +++++++++++++
src/gwproxy/dnsparser.c | 357 ++++++++++++++++++++++++++++++++++++++++
src/gwproxy/dnsparser.h | 191 +++++++++++++++++++++
src/gwproxy/gwproxy.c | 93 +----------
src/gwproxy/net.c | 103 ++++++++++++
src/gwproxy/net.h | 35 ++++
10 files changed, 1099 insertions(+), 102 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
next reply other threads:[~2025-08-01 1:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-01 1:54 Ahmad Gani [this message]
2025-08-01 1:54 ` [PATCH gwproxy v2 1/3] dnslookup: split common functionality and struct into net.c Ahmad Gani
2025-08-01 23:43 ` Alviro Iskandar Setiawan
2025-08-01 23:45 ` Alviro Iskandar Setiawan
2025-08-02 1:08 ` reyuki
2025-08-02 1:34 ` Alviro Iskandar Setiawan
2025-08-01 1:54 ` [PATCH gwproxy v2 2/3] dnslookup: Allow only port string number Ahmad Gani
2025-08-01 1:54 ` [PATCH gwproxy v2 3/3] dnslookup: Initial work for implementation of C-ares-like getaddrinfo function Ahmad Gani
2025-08-02 1:37 ` Alviro Iskandar Setiawan
2025-08-02 2:06 ` 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=20250801015427.439511-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