Skip to content

feat(net): support domain names in peer configuration#6727

Open
317787106 wants to merge 12 commits intotronprotocol:developfrom
317787106:feature/support_domain
Open

feat(net): support domain names in peer configuration#6727
317787106 wants to merge 12 commits intotronprotocol:developfrom
317787106:feature/support_domain

Conversation

@317787106
Copy link
Copy Markdown
Collaborator

Summary

Allows node.seed.ip.list, node.active, node.passive, node.fastForward, and node.backup.members configuration entries to specify domain names in addition to IP literals. Domains are resolved to IPs at startup; backup member IPs are refreshed automatically every 60 seconds when DNS returns a different address.
Closes #6634

Problem

All network peer configuration fields previously required numeric IP addresses. Operators running nodes behind dynamic DNS or cloud load-balancers had to manually update config files whenever IPs changed. Backup members in particular need continuous accuracy because they participate in keep-alive health checks.

Changes

New: InetUtil

Central DNS resolution utility used by both startup parsing and runtime refresh:

  • resolveInetSocketAddressList(List<String>) — converts a list of ipOrDomain:port strings to InetSocketAddress objects. IP literals are used as-is; domain entries are resolved via LookUpTxt.lookUpIp (IPv4 first, IPv6 fallback). When there are multiple domain entries, resolution is parallelised using a bounded thread pool (up to 10 threads). Unresolvable entries are silently skipped.
  • resolveInetAddress(String) — resolves a bare host (no port) to InetAddress; IP literals take the fast path without a DNS lookup.

BackupManager (framework)

  • At init(), each configured backup member is resolved via InetUtil.resolveInetAddress. The resolved IP is stored in members; entries with a domain host are additionally tracked in a domainIpCache.
  • A new dnsExecutorService scheduler runs refreshMemberIps() every 60 seconds when domainIpCache is non-empty. If DNS returns a new IP, the old IP is removed from members and the new IP is added; localIp is never added.
  • dnsExecutorService is shut down alongside executorService in stop().

Args (framework)

  • Extracted a shared getInetSockerAddress(config, path) helper that calls InetUtil.resolveInetSocketAddressList, used by both getInetSocketAddress (seed/active/passive nodes) and getInetAddress. Unresolvable domain entries in seed lists are silently dropped; unresolvable backup member entries throw TronError(PARAMETER_INIT) at startup via the new checkBackupMembers() validator.

Dependency

  • Switched libp2p from io.github.tronprotocol:libp2p:2.2.7 to io.github.tronprotocol:libp2p:2.2.8, which exposes the LookUpTxt.lookUpIp API used for DNS resolution.

Behaviour Summary

Config field Unresolvable domain Domain IP change
Seed / active / passive / fastForward Entry skipped silently Re-read at next startup
node.backup.members TronError thrown at startup Auto-refreshed every 60 s

Test

  • InetUtilTest (18 tests): resolveInetSocketAddressList — IPv4/IPv6 literals, domain resolution, IPv6 fallback, input order preserved, unresolvable entries dropped. resolveInetAddress — same coverage for the no-port variant.
  • BackupManagerTest (6 new tests): init() domain-to-IP mapping and local-IP exclusion; refreshMemberIps() — IP changed, IP unchanged, DNS failure retains old IP.
  • ArgsTest (3 new tests): checkBackupMembers() — IP members pass, unresolvable domain throws TronError(PARAMETER_INIT), resolvable domain passes.

@github-actions github-actions Bot requested a review from xxo1shine April 28, 2026 14:01
@halibobo1205 halibobo1205 added the topic:net p2p net work, synchronization label Apr 29, 2026
@halibobo1205 halibobo1205 added this to the GreatVoyage-v4.8.2 milestone Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:net p2p net work, synchronization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Support domain names in node.backup.members and seed.node.ip.list

2 participants