Skip to content

Commit 1dfe45f

Browse files
committed
docs: add usage for java 17; fix urls
1 parent b513254 commit 1dfe45f

File tree

5 files changed

+65
-45
lines changed

5 files changed

+65
-45
lines changed

README.md

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ Java Dns Cache Manipulator(`DCM`) contains 2 subprojects:
4242
- [Clear JVM DNS cache](#clear-jvm-dns-cache)
4343
- [Set/View the default DNS cache time of JVM](#setview-the-default-dns-cache-time-of-jvm)
4444
- [Precautions for use](#precautions-for-use)
45+
- [JVM settings for Java 17](#jvm-settings-for-java-17)
46+
- [Domain name case](#domain-name-case)
47+
- [Domain resolvation cache](#domain-resolvation-cache)
4548
- [More detailed functions](#more-detailed-functions)
4649
- [🔌 Java API Docs](#-java-api-docs)
4750
- [🍪 Dependency](#-dependency)
@@ -51,10 +54,11 @@ Java Dns Cache Manipulator(`DCM`) contains 2 subprojects:
5154
- [🔧 Features](#-features-1)
5255
- [👥 User Guide](#-user-guide-1)
5356
- [Download](#download)
54-
- [Set/reset DNS](#setreset-dns)
55-
- [View DNS Cache content](#view-dns-cache-content)
56-
- [Delete/Empty DNS Cache](#deleteempty-dns-cache)
57-
- [Set/View JVM's default DNS cache time](#setview-jvms-default-dns-cache-time)
57+
- [Set/reset a DNS cache entry](#setreset-a-dns-cache-entry)
58+
- [View DNS cache entry content](#view-dns-cache-entry-content)
59+
- [Delete a DNS Cache](#delete-a-dns-cache)
60+
- [Clear DNS Cache](#clear-dns-cache)
61+
- [Set/View DNS cache time of `JVM`](#setview-dns-cache-time-of-jvm)
5862
- [📚 Related information](#-related-information)
5963

6064
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -93,7 +97,7 @@ Java Dns Cache Manipulator(`DCM`) contains 2 subprojects:
9397

9498
## 👥 User Guide
9599

96-
Set/View DNS through the class [`DnsCacheManipulator`](src/main/java/com/alibaba/dcm/DnsCacheManipulator.java).
100+
Set/View DNS through the class [`DnsCacheManipulator`](library/src/main/java/com/alibaba/dcm/DnsCacheManipulator.java).
97101

98102
### Set directly
99103

@@ -214,29 +218,45 @@ DnsCacheManipulator.setDnsNegativeCachePolicy(0);
214218

215219
### Precautions for use
216220

217-
- The domain name is not case-sensitive, and the domain name will be converted to lower case uniformly before entering the DNS Cache.
218-
One of the causes is that the case of the domain name in the DNS query result will be different from the case of the entered domain name, if the entered domain name has uppercase letters.
219-
- For the logic that has been resolved and saved the IP, setting the JVM DNS cache will not take effect! The connection can be re-created or the Client can be resolved.
220-
For HttpClient:
221-
222-
```java
223-
HttpClient client = new HttpClient();
224-
GetMethod m1 = new GetMethod("https://bing.com");
225-
client.executeMethod(m1);
226-
String content = m1.getResponseBodyAsString();
227-
228-
// Set up DNS and bind to your own machine
229-
DnsCacheManipulator.setDnsCache("bing.com", "192.168.1.1");
230-
231-
// Re-execute m1, still the old result
232-
client.executeMethod(m1);
233-
String content = m1.getResponseBodyAsString();
234-
235-
// Re-create GetMethod to get the results on your own machine
236-
GetMethod m2 = new GetMethod("https://bing.com");
237-
client.executeMethod(m2);
238-
content = m2.getResponseBodyAsString();
239-
```
221+
#### JVM settings for Java 17
222+
223+
If use DCM under Java 17, add below Java options:
224+
225+
```java
226+
--add-opens java.base/java.net=ALL-UNNAMED
227+
--add-opens java.base/sun.net=ALL-UNNAMED
228+
```
229+
230+
#### Domain name case
231+
232+
The domain name is not case-sensitive, and the domain name may be converted to lower case uniformly before entering the DNS Cache.
233+
234+
One of the causes is that the case of the domain name in the DNS query result will be different from the case of the entered domain name, if the entered domain name has uppercase letters.
235+
236+
#### Domain resolvation cache
237+
238+
- For the logic that has been resolved and saved the IP, setting the JVM DNS cache will not take effect! The connection can be re-created or the Client can be resolved.
239+
240+
For `HttpClient`:
241+
242+
```java
243+
HttpClient client = new HttpClient();
244+
GetMethod m1 = new GetMethod("https://bing.com");
245+
client.executeMethod(m1);
246+
String content = m1.getResponseBodyAsString();
247+
248+
// Set up DNS and bind to your own machine
249+
DnsCacheManipulator.setDnsCache("bing.com", "192.168.1.1");
250+
251+
// Re-execute m1, still the old result
252+
client.executeMethod(m1);
253+
String content = m1.getResponseBodyAsString();
254+
255+
// Re-create GetMethod to get the results on your own machine
256+
GetMethod m2 = new GetMethod("https://bing.com");
257+
client.executeMethod(m2);
258+
content = m2.getResponseBodyAsString();
259+
```
240260

241261
### More detailed functions
242262

docs/developer-guide.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<a href="https://ci.appveyor.com/project/oldratlee/java-dns-cache-manipulator"><img src="https://img.shields.io/appveyor/ci/oldratlee/java-dns-cache-manipulator/master?logo=appveyor&amp;logoColor=white" alt="Build Status"></a>
55
<a href="https://coveralls.io/github/alibaba/java-dns-cache-manipulator?branch=master"><img src="https://img.shields.io/coveralls/github/alibaba/java-dns-cache-manipulator/master?logo=coveralls&amp;logoColor=white" alt="Coveralls branch"></a>
66
<a href="https://codeclimate.com/github/alibaba/java-dns-cache-manipulator/maintainability"><img src="https://api.codeclimate.com/v1/badges/80e64dc9160cf6f62080/maintainability" alt="Maintainability"></a>
7-
<a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/JDK-6+-green?logo=java&amp;logoColor=white" alt="JDK support"></a>
7+
<a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/Java-6+-green?logo=java&amp;logoColor=white" alt="JDK support"></a>
88
<a href="https://www.apache.org/licenses/LICENSE-2.0.html"><img src="https://img.shields.io/github/license/alibaba/java-dns-cache-manipulator?color=4D7A97" alt="License"></a>
99
<a href="https://alibaba.github.io/java-dns-cache-manipulator/apidocs/"><img src="https://img.shields.io/github/release/alibaba/java-dns-cache-manipulator?label=javadoc&amp;color=3d7c47&amp;logo=microsoft-academic&amp;logoColor=white" alt="Javadocs"></a>
1010
<a href="https://search.maven.org/artifact/com.alibaba/dns-cache-manipulator"><img src="https://img.shields.io/maven-central/v/com.alibaba/dns-cache-manipulator?color=2d545e&amp;logo=apache-maven&amp;logoColor=white" alt="Maven Central"></a>
@@ -24,9 +24,9 @@
2424
The DNS Cache of the JVM is maintained in the private field of the InetAddress class and is set by reflection. For specific implementation, see
2525

2626

27-
- [`InetAddressCacheUtilCommons.java`](library/src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilCommons.java)
28-
- [`InetAddressCacheUtilForJdk8Minus.java`](library/src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilForJdk8Minus.java)
29-
- [`InetAddressCacheUtilForJdk9Plus.java`](library/src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilForJdk9Plus.java)
27+
- [`InetAddressCacheUtilCommons.java`](../library/src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilCommons.java)
28+
- [`InetAddressCacheUtilForJava8Minus.java`](../library/src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilForJava8Minus.java)
29+
- [`InetAddressCacheUtilForJava9Plus.java`](../library/src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilForJava9Plus.java)
3030

3131
Pay attention to the thread safety of setting the DNS Cache of JVM
3232
The DNS Cache of the JVM is obviously shared globally, so the setting is guaranteed to be thread-safe and there is no concurrency problem.
@@ -54,7 +54,7 @@ private static void cacheAddresses(String hostname,
5454
}
5555
```
5656

57-
In the [`InetAddressCacheUtilForJdk8Minus`](library/src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilForJdk8Minus.java) class, the read and write to the DNS Cache also consistently adds a synchronized block with addressCache as the lock to ensure thread safety.
57+
In the [`InetAddressCacheUtilForJava8Minus`](../library/src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilForJava8Minus.java) class, the read and write to the DNS Cache also consistently adds a synchronized block with addressCache as the lock to ensure thread safety.
5858

5959
## Need to test different versions of JDK
6060

@@ -66,11 +66,11 @@ The current tested LTS `JDK` versions 6/8/11/17, other `JDK` versions should wor
6666
## 📚 Related Resources
6767

6868
- The source code of the class `InetAddress`:
69-
- `JDK 6`[`InetAddress`](https://hg.openjdk.java.net/jdk6/jdk6/jdk/file/8deef18bb749/src/share/classes/java/net/InetAddress.java#l739)
70-
- `JDK 7`[`InetAddress`](https://hg.openjdk.java.net/jdk7u/jdk7u/jdk/file/4dd5e486620d/src/share/classes/java/net/InetAddress.java#l742)
71-
- `JDK 8`[`InetAddress`](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/45e4e636b757/src/share/classes/java/net/InetAddress.java#l748)
72-
- `JDK 9`[`InetAddress`](https://hg.openjdk.java.net/jdk9/jdk9/jdk/file/65464a307408/src/java.base/share/classes/java/net/InetAddress.java#l783)
73-
- `JDK 11`[`InetAddress`](https://hg.openjdk.java.net/jdk/jdk11/file/1ddf9a99e4ad/src/java.base/share/classes/java/net/InetAddress.java#l787)
69+
- `JDK 6` [`InetAddress`](https://hg.openjdk.java.net/jdk6/jdk6/jdk/file/8deef18bb749/src/share/classes/java/net/InetAddress.java#l739)
70+
- `JDK 7` [`InetAddress`](https://hg.openjdk.java.net/jdk7u/jdk7u/jdk/file/4dd5e486620d/src/share/classes/java/net/InetAddress.java#l742)
71+
- `JDK 8` [`InetAddress`](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/45e4e636b757/src/share/classes/java/net/InetAddress.java#l748)
72+
- `JDK 9` [`InetAddress`](https://hg.openjdk.java.net/jdk9/jdk9/jdk/file/65464a307408/src/java.base/share/classes/java/net/InetAddress.java#l783)
73+
- `JDK 11` [`InetAddress`](https://hg.openjdk.java.net/jdk/jdk11/file/1ddf9a99e4ad/src/java.base/share/classes/java/net/InetAddress.java#l787)
7474
- [`JVM Networking Properties` - `java docs`](http://docs.oracle.com/javase/8/docs/technotes/guides/net/properties.html)
7575
- [Domain Name System - wikipedia](http://en.wikipedia.org/wiki/Domain_Name_System)
7676
- `Java DNS` FAQ

docs/zh-CN/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<a href="https://ci.appveyor.com/project/oldratlee/java-dns-cache-manipulator"><img src="https://img.shields.io/appveyor/ci/oldratlee/java-dns-cache-manipulator/master?logo=appveyor&amp;logoColor=white" alt="Build Status"></a>
55
<a href="https://coveralls.io/github/alibaba/java-dns-cache-manipulator?branch=master"><img src="https://img.shields.io/coveralls/github/alibaba/java-dns-cache-manipulator/master?logo=coveralls&amp;logoColor=white" alt="Coveralls branch"></a>
66
<a href="https://codeclimate.com/github/alibaba/java-dns-cache-manipulator/maintainability"><img src="https://api.codeclimate.com/v1/badges/80e64dc9160cf6f62080/maintainability" alt="Maintainability"></a>
7-
<a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/JDK-6+-green?logo=java&amp;logoColor=white" alt="JDK support"></a>
7+
<a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/Java-6+-green?logo=java&amp;logoColor=white" alt="JDK support"></a>
88
<a href="https://www.apache.org/licenses/LICENSE-2.0.html"><img src="https://img.shields.io/github/license/alibaba/java-dns-cache-manipulator?color=4D7A97" alt="License"></a>
99
<a href="https://alibaba.github.io/java-dns-cache-manipulator/apidocs/"><img src="https://img.shields.io/github/release/alibaba/java-dns-cache-manipulator?label=javadoc&amp;color=3d7c47&amp;logo=microsoft-academic&amp;logoColor=white" alt="Javadocs"></a>
1010
<a href="https://search.maven.org/artifact/com.alibaba/dns-cache-manipulator"><img src="https://img.shields.io/maven-central/v/com.alibaba/dns-cache-manipulator?color=2d545e&amp;logo=apache-maven&amp;logoColor=white" alt="Maven Central"></a>

docs/zh-CN/library.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Java Dns Cache Manipulator(DCM) Library
55
<a href="https://ci.appveyor.com/project/oldratlee/java-dns-cache-manipulator"><img src="https://img.shields.io/appveyor/ci/oldratlee/java-dns-cache-manipulator/master?logo=appveyor&amp;logoColor=white" alt="Build Status"></a>
66
<a href="https://coveralls.io/github/alibaba/java-dns-cache-manipulator?branch=master"><img src="https://img.shields.io/coveralls/github/alibaba/java-dns-cache-manipulator/master?logo=coveralls&amp;logoColor=white" alt="Coveralls branch"></a>
77
<a href="https://codeclimate.com/github/alibaba/java-dns-cache-manipulator/maintainability"><img src="https://api.codeclimate.com/v1/badges/80e64dc9160cf6f62080/maintainability" alt="Maintainability"></a>
8-
<a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/JDK-6+-green?logo=java&amp;logoColor=white" alt="JDK support"></a>
8+
<a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/Java-6+-green?logo=java&amp;logoColor=white" alt="JDK support"></a>
99
<a href="https://www.apache.org/licenses/LICENSE-2.0.html"><img src="https://img.shields.io/github/license/alibaba/java-dns-cache-manipulator?color=4D7A97" alt="License"></a>
1010
<a href="https://alibaba.github.io/java-dns-cache-manipulator/apidocs/"><img src="https://img.shields.io/github/release/alibaba/java-dns-cache-manipulator?label=javadoc&amp;color=3d7c47&amp;logo=microsoft-academic&amp;logoColor=white" alt="Javadocs"></a>
1111
<a href="https://search.maven.org/artifact/com.alibaba/dns-cache-manipulator"><img src="https://img.shields.io/maven-central/v/com.alibaba/dns-cache-manipulator?color=2d545e&amp;logo=apache-maven&amp;logoColor=white" alt="Maven Central"></a>
@@ -81,7 +81,7 @@ Java Dns Cache Manipulator(DCM) Library
8181
:busts_in_silhouette: User Guide
8282
=====================================
8383

84-
通过类[`DnsCacheManipulator`](src/main/java/com/alibaba/dcm/DnsCacheManipulator.java)设置`DNS`
84+
通过类[`DnsCacheManipulator`](../../library/src/main/java/com/alibaba/dcm/DnsCacheManipulator.java)设置`DNS`
8585

8686
直接设置
8787
----------------------------------
@@ -270,9 +270,9 @@ PS:
270270

271271
`JVM``DNS Cache`维护在类`InetAddress`的私有字段中,通过反射来设置,具体实现参见
272272

273-
- [`InetAddressCacheUtilCommons.java`](src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilCommons.java)
274-
- [`InetAddressCacheUtilForJdk8Minus.java`](src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilForJdk8Minus.java)
275-
- [`InetAddressCacheUtilForJdk9Plus.java`](src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilForJdk9Plus.java)
273+
- [`InetAddressCacheUtilCommons.java`](../../library/src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilCommons.java)
274+
- [`InetAddressCacheUtilForJava9Plus.java`](../../library/src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilForJava8Minus.java)
275+
- [`InetAddressCacheUtilForJava9Plus.java`](../../library/src/main/java/com/alibaba/dcm/internal/InetAddressCacheUtilForJava9Plus.java)
276276

277277
注意设置`JVM``DNS Cache`的线程安全问题
278278
----------------------------------

docs/zh-CN/tool.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Java Dns Cache Manipulator Tool
55
<a href="https://ci.appveyor.com/project/oldratlee/java-dns-cache-manipulator"><img src="https://img.shields.io/appveyor/ci/oldratlee/java-dns-cache-manipulator/master?logo=appveyor&amp;logoColor=white" alt="Build Status"></a>
66
<a href="https://coveralls.io/github/alibaba/java-dns-cache-manipulator?branch=master"><img src="https://img.shields.io/coveralls/github/alibaba/java-dns-cache-manipulator/master?logo=coveralls&amp;logoColor=white" alt="Coveralls branch"></a>
77
<a href="https://codeclimate.com/github/alibaba/java-dns-cache-manipulator/maintainability"><img src="https://api.codeclimate.com/v1/badges/80e64dc9160cf6f62080/maintainability" alt="Maintainability"></a>
8-
<a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/JDK-6+-green?logo=java&amp;logoColor=white" alt="JDK support"></a>
8+
<a href="https://openjdk.java.net/"><img src="https://img.shields.io/badge/Java-6+-green?logo=java&amp;logoColor=white" alt="JDK support"></a>
99
<a href="https://www.apache.org/licenses/LICENSE-2.0.html"><img src="https://img.shields.io/github/license/alibaba/java-dns-cache-manipulator?color=4D7A97" alt="License"></a>
1010
<a href="https://alibaba.github.io/java-dns-cache-manipulator/apidocs/"><img src="https://img.shields.io/github/release/alibaba/java-dns-cache-manipulator?label=javadoc&amp;color=3d7c47&amp;logo=microsoft-academic&amp;logoColor=white" alt="Javadocs"></a>
1111
<a href="https://search.maven.org/artifact/com.alibaba/dns-cache-manipulator"><img src="https://img.shields.io/maven-central/v/com.alibaba/dns-cache-manipulator?color=2d545e&amp;logo=apache-maven&amp;logoColor=white" alt="Maven Central"></a>

0 commit comments

Comments
 (0)