{"id":17826884,"url":"https://github.com/bmarwell/nameserviceagent","last_synced_at":"2025-07-08T00:09:04.329Z","repository":{"id":151108043,"uuid":"296616302","full_name":"bmarwell/nameserviceagent","owner":"bmarwell","description":"A simple name service hook -- modifies Java’s DNS resolution behaviour","archived":false,"fork":false,"pushed_at":"2020-09-23T21:04:19.000Z","size":75,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-09T11:53:54.318Z","etag":null,"topics":["agent","dns","dns-over-https","dnsresolver","java","javaagent","name-service","round-robin"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmarwell.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-18T12:34:28.000Z","updated_at":"2023-07-16T20:25:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"98044aba-c480-4505-ac8e-b781535dfeb8","html_url":"https://github.com/bmarwell/nameserviceagent","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwell%2Fnameserviceagent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwell%2Fnameserviceagent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwell%2Fnameserviceagent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwell%2Fnameserviceagent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmarwell","download_url":"https://codeload.github.com/bmarwell/nameserviceagent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229780093,"owners_count":18122919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","dns","dns-over-https","dnsresolver","java","javaagent","name-service","round-robin"],"created_at":"2024-10-27T18:55:24.925Z","updated_at":"2024-12-15T03:49:22.863Z","avatar_url":"https://github.com/bmarwell.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Name Resolver Replacement Agent for Java\n\nimage:https://www.travis-ci.com/bmhm/nameserviceagent.svg?branch=main[\"Build Status\",link=\"https://www.travis-ci.com/bmhm/nameserviceagent\"]\nimage:https://img.shields.io/badge/License-Apache%202.0-blue.svg[\"Apache License v2.0\",link=\"https://opensource.org/licenses/Apache-2.0\"\"]\nimage:https://codecov.io/gh/bmhm/nameserviceagent/branch/main/graph/badge.svg[\"Code Coverage\",link=\"https://codecov.io/gh/bmhm/nameserviceagent\"]\n\n== Use case / what is this agent for?\n\nIf you want to modify DNS resolving, you are out of luck with java.\nThe SPI NameServiceDefinition was silently removed in Java 9+.\nEven with this definition, it was impossible to just extend the default `NameService` implementation.\n\nIf you want to modify the behaviour of the existing `InetAddress::NameService` implementation, this agent will let you do this via ugly reflection and will break in later java versions as well.\n\nOracle has not provided a solution to this problem.\nfootnote:jdk8134577[See: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8134577[JDK-8134577 : Eliminate or standardize a replacement for sun.net.spi.nameservice.NameServiceDescriptor].]\nfootnote:jdk8201428[See: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8201428[JDK-8201428 : Provide a standard API for name resolution].]\nfootnote:jdk8192780[See: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8192780[JDK-8192780 : Consider restoring DNS SPI].]\n\n== Requirements\n\n* This agent requires Java 8+.\n* About 20 kiB of disk and heap space.\n\n== Usage\n\nTo use this agent, there are three steps to this:\n\n1. Compilation or Download\n2. Mount the agent with default configuration\n3. Configure or extend the agent\n\n=== Compilation or download\n\nYou can compile this agent using `./mvnw package`.\nAll you need is java11+ for compilation.\nYou can use the file `./agent/target/nameserviceagent-agent-1.0.0-SNAPSHOT.jar`.\n\nAlternative:\nDownload the nameserviceagent-agent.jar from the releases.\n\n=== Mounting the agent\n\nYou can mount the agent using `java -javaagent:nameserviceagent-agent.jar \u003cyourtool\u003e`.\n\n=== Configuration\n\nCurrently these options are available:\n\n|===\n|key |type |default value |description\n\n|`nameserviceagent.implementation`\n|System Property (`-D`)\n|`DefaultSequentialReachableNameService`\n|Switch the implementation of the replaced/injected naming service.\n\n|`nameserviceagent.reachable.timeoutMs`\n|System Property (`-D`)\n|`100` (ms)\n|Timeout for the DefaultSequentialReachableNameService when a remote host is considered unavailable.\n|===\n\n==== Default configuration\n\n:fn-hostfile: footnote:[By default, java will use your system’s DNS resolver. If you specify `-Djdk.net.hosts.file=hosts.txt`, DNS resolution will be replaced by this host file mechanism.]\nThe default configuration will use the default nameService (e.g. system dns or host file‎{fn-hostfile}).\nHowever, while the default implementation will just use the 1st IP returned, this implementation will in fact check all the IP addresses.\n\n=== Always resolve loopback\n\nThis DNS NameResolver implementation will always resolve to loopback (either `127.0.0.1` or `::1`).\n\nThis configuration can be activated like this:\n\n[source,sh]\n....\njava\n    -javaagent:${localRepositoryPath}/io/github/bmhm/nameserviceagent/nameserviceagent-agent/@project.version@/nameserviceagent-agent-@project.version@.jar\n    -Dnameserviceagent.implementation=io.github.bmhm.nameserviceagent.agent.nameservice.AlwaysLocalhostLoopbackNameService\n....\n\n==== Other configurations\n\nFeel free to create PRs for other Configs -- eg DNSoHTTPS, DNSfromDB, etc.\n\n== Extension\n\nIf you want to write your own DNS Name Resolver, just extend `AbstractProxyNameService`\nand make sure you also have the public constructor with the NameService interface.\n\nProvide the full class name via the system property `nameserviceagent.implementation`.\n\n== Production use\n\nThis agent is not intended for production code.\nIt will probably fail for more recent java releases which do not allow acces via reflection.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmarwell%2Fnameserviceagent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmarwell%2Fnameserviceagent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmarwell%2Fnameserviceagent/lists"}