From cb075b220765f4451ec6eac4e4ea9b2c7606798b Mon Sep 17 00:00:00 2001 From: Vivian Tam Date: Fri, 30 Sep 2022 10:42:12 +1300 Subject: [PATCH] added a traceRouteWithPort option --- pom.xml | 4 +-- .../mulesoft/tool/network/NetworkUtils.java | 4 +++ src/main/mule/net-tools.xml | 33 ++++++++++++------- src/main/resources/api/net-tools.raml | 26 +++++++++++++++ src/main/resources/web/index.html | 12 +++++-- 5 files changed, 62 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index 664d13d..0ecd851 100644 --- a/pom.xml +++ b/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - com.mycompany + com.mulesoft.tool net-tools-api - 2.4.0 + 2.4.0-issue23-SNAPSHOT mule-application net-tools-api diff --git a/src/main/java/com/mulesoft/tool/network/NetworkUtils.java b/src/main/java/com/mulesoft/tool/network/NetworkUtils.java index 31d399c..73496ea 100644 --- a/src/main/java/com/mulesoft/tool/network/NetworkUtils.java +++ b/src/main/java/com/mulesoft/tool/network/NetworkUtils.java @@ -89,6 +89,10 @@ public static String traceRoute(String host) throws Exception { return execute(new ProcessBuilder("traceroute", "-w", "3", "-q", "1", "-m", "18", "-n", host)); } + public static String traceRouteWithPort(String host, String port) throws Exception { + return execute(new ProcessBuilder("traceroute", "-w", "3", "-q", "1", "-m", "18", "-p", port, "-n", host)); + } + public static String certest(String host, String port) throws Exception { return execute(new ProcessBuilder("openssl", "s_client", "-showcerts", "-servername", host, "-connect", host+":"+port)); } diff --git a/src/main/mule/net-tools.xml b/src/main/mule/net-tools.xml index b00e5e7..5a9f5f8 100644 --- a/src/main/mule/net-tools.xml +++ b/src/main/mule/net-tools.xml @@ -54,7 +54,7 @@ splitBy(attributes.requestPath, ".")[-1] default ""]]> - + - + - + - + - + - + - + - + - + - + + + + + + + + diff --git a/src/main/resources/api/net-tools.raml b/src/main/resources/api/net-tools.raml index e2f9ef3..69ef71f 100644 --- a/src/main/resources/api/net-tools.raml +++ b/src/main/resources/api/net-tools.raml @@ -67,6 +67,32 @@ securitySchemes: 9 216.239.50.189 1.963 ms 216.239.54.205 2.139 ms 216.239.49.9 1.962 ms 10 216.239.58.213 2.424 ms 64.233.174.43 2.246 ms 216.239.58.215 1.577 ms 11 8.8.8.8 1.824 ms 1.383 ms 1.339 ms +/traceroutePort: + get: + description: Runs a traceroute test from the Mule host to the specified endpoint + queryParameters: + host: + description: The domain or ip of the host to traceroute + type: string + port: + description: The port number of host to traceroute + type: number + responses: + 200: + body: + text/plain: + example: | + 1 216.182.237.132 1.203 ms 216.182.237.128 1.185 ms 216.182.237.132 1.681 ms + 2 100.64.1.13 1.671 ms 100.64.1.235 1.337 ms 100.64.1.205 1.649 ms + 3 100.64.0.184 469.084 ms 100.64.0.210 992.624 ms 100.64.0.216 1012.502 ms + 4 100.64.16.43 0.777 ms 100.64.16.47 0.940 ms 100.64.16.91 0.904 ms + 5 72.21.222.221 1.588 ms 72.21.222.223 1.561 ms 72.21.222.221 1.581 ms + 6 54.240.242.42 12.569 ms 54.240.243.142 3.572 ms 54.240.242.102 18.003 ms + 7 54.240.243.93 1.225 ms 54.240.242.13 1.249 ms 1.244 ms + 8 52.95.216.113 1.092 ms 0.878 ms 0.972 ms + 9 216.239.50.189 1.963 ms 216.239.54.205 2.139 ms 216.239.49.9 1.962 ms + 10 216.239.58.213 2.424 ms 64.233.174.43 2.246 ms 216.239.58.215 1.577 ms + 11 8.8.8.8 1.824 ms 1.383 ms 1.339 ms /dns: get: description: Resolves the specified endpoint's IP using the hosts DNS servers diff --git a/src/main/resources/web/index.html b/src/main/resources/web/index.html index a1ac060..c6cf20d 100644 --- a/src/main/resources/web/index.html +++ b/src/main/resources/web/index.html @@ -140,6 +140,7 @@