feat(net): support domain names in peer configuration#6727
Open
317787106 wants to merge 12 commits intotronprotocol:developfrom
Open
feat(net): support domain names in peer configuration#6727317787106 wants to merge 12 commits intotronprotocol:developfrom
317787106 wants to merge 12 commits intotronprotocol:developfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allows
node.seed.ip.list,node.active,node.passive,node.fastForward, andnode.backup.membersconfiguration 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:
InetUtilCentral DNS resolution utility used by both startup parsing and runtime refresh:
resolveInetSocketAddressList(List<String>)— converts a list ofipOrDomain:portstrings toInetSocketAddressobjects. IP literals are used as-is; domain entries are resolved viaLookUpTxt.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) toInetAddress; IP literals take the fast path without a DNS lookup.BackupManager(framework)init(), each configured backup member is resolved viaInetUtil.resolveInetAddress. The resolved IP is stored inmembers; entries with a domain host are additionally tracked in adomainIpCache.dnsExecutorServicescheduler runsrefreshMemberIps()every 60 seconds whendomainIpCacheis non-empty. If DNS returns a new IP, the old IP is removed frommembersand the new IP is added;localIpis never added.dnsExecutorServiceis shut down alongsideexecutorServiceinstop().Args(framework)getInetSockerAddress(config, path)helper that callsInetUtil.resolveInetSocketAddressList, used by bothgetInetSocketAddress(seed/active/passive nodes) andgetInetAddress. Unresolvable domain entries in seed lists are silently dropped; unresolvable backup member entries throwTronError(PARAMETER_INIT)at startup via the newcheckBackupMembers()validator.Dependency
libp2pfromio.github.tronprotocol:libp2p:2.2.7toio.github.tronprotocol:libp2p:2.2.8, which exposes theLookUpTxt.lookUpIpAPI used for DNS resolution.Behaviour Summary
node.backup.membersTronErrorthrown at startupTest
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 throwsTronError(PARAMETER_INIT), resolvable domain passes.