From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server-vie001.gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_DBL_BLOCKED_OPENDNS, URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=new2025; t=1755147192; bh=OjMYkPuFisevOyHxMIe5SOWD/t6G+vIdMLy8+icEWRU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:Message-ID:Date:From:Reply-To:Subject:To: Cc:In-Reply-To:References:Resent-Date:Resent-From:Resent-To: Resent-Cc:User-Agent:Content-Type:Content-Transfer-Encoding; b=nVzPrKQrXpOAkbFTrYh26C64LARGjTiWO6eUGvZd6nCNFkn8VPsvFSGO5JlLvf1nN s/iWUPsKZpJb5wwxrrucubhfcqtlue0xpLhJla3/tMVHCCPdo86VSPSf8st/jqMZ+V HbELBmL1B6wUSV2yyjq+X/UR3MWWKPBARNnChnfxcdNY2DDjHbt2Ww2t7mp0pDQVJZ j6fqLo4taMIWZTA1Xg+EAaG2utjH0zGts+xEVZL2YVm+glBE0b+0wtNA7WEzZfaSx+ jEiVdD0XVarO0b2WrkEZ9SrTW28AbCPf8AdWnC7bJz9DRIe7J6kegURWd82hywZwrc YEXmlDNzcWDUg== Received: from zero (unknown [36.68.224.235]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id 82EF13127F9A; Thu, 14 Aug 2025 04:53:11 +0000 (UTC) From: Ahmad Gani To: Ammar Faizi Cc: Ahmad Gani , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH gwproxy v5 0/2] Initial work on integration of DNS parser lib in gwproxy Date: Thu, 14 Aug 2025 11:46:53 +0700 Message-ID: <20250814044658.252579-1-reyuki@gnuweeb.org> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Hi Chief, This is revision v5 of initial work on integration of DNS parser lib in gwproxy. This is an RFC draft, the patches itself aren't final. With current model, the caller is responsible to do the socket part, this imply unlike conventional glibc's getaddrinfo that handle both socket and crafting payload inside its abstraction, thus allow AF_UNSPEC, the build query only craft packet for particular family at a time [1], either AF_INET or AF_INET6, not both, I see this not as a limitation, but rather an advantage, most of the time we don't need to request for both IPv6 and IPv4, but there's still a case where both family is desired, it's often happened for fallback mechanism. I'll spend some time thinking about how to integrate these functions into gwproxy. # 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 - for now it's blocking, attempt_retry label is not needed v2 -> v3: - remove TODO(reyuki): hints->ai_family is used to filter results - make gw_ares_getaddrinfo asynchronous by change UDP socket to non-blocking - move socket creation to library initialization - make UDP socket unconnected - restructure internal struct and program execution flow to support async - update unit test of dns parser - transaction id creation is delegated to caller - fix logic bug in serialize_answ that can lead to memory error: invalid read - rename parameter prt and split commit message - move variable declaration in for loop according to the Sir Alviro coding-style v3 -> v4: - add else block in the convert_str_to_ssaddr function - use format specifier %hu for uint16_t in printf - update base commit to branch master from upstream remote repository v4 -> v5: - squash commits to eliminate changes unrelated to the commit subject - change commit subject: use imperative form for the subject - update base commit to branch master from upstream remote repository - changing the email subject to depict a turnaround of design changes - drop the c-ares style thing - restructure dnsparser.c and dnsparser.h [1]: - https://lore.gnuweeb.org/gwml/20250806035727.216702-1-reyuki@gnuweeb.org/ - www.ietf.org/rfc/rfc9619.pdf - https://stackoverflow.com/questions/4082081/requesting-a-and-aaaa-records-in-single-dns-query/4083071 Signed-off-by: Ahmad Gani --- Ahmad Gani (2): dns: Allow only port string number dnsparser: Add dns parser code man/gwp_dns_queue.3 | 2 +- src/gwproxy/dns.h | 3 +- src/gwproxy/dnsparser.c | 568 ++++++++++++++++++++++++++++++++++++++++ src/gwproxy/dnsparser.h | 210 +++++++++++++++ 4 files changed, 780 insertions(+), 3 deletions(-) create mode 100644 src/gwproxy/dnsparser.c create mode 100644 src/gwproxy/dnsparser.h base-commit: cff091cf6441845c1a8fc56b9e1216bf6cf48dca -- Ahmad Gani