Skip to content
This repository was archived by the owner on May 4, 2024. It is now read-only.

Commit 4d80e93

Browse files
Updated to latest Spring and other dependency versions
- Updated to latest Spring and other dependency versions - Changes in HTTP Connector required changing the way we select HTTP or HTTPS as the protocol. Now we must have separate flows and listeners for each protocol. The existing listener flows are set to HTTPS. New HTTP flows are added that reference to the HTTPS flows. - The HTTP flows can be stopped via property - Added an ignoreFile list property for resource files a browser asks for that don't exist in the app, like "favicon.ico". Not required but now doesn't put a "resource not found" exception in the flow.
1 parent 96f1be0 commit 4d80e93

File tree

10 files changed

+152
-87
lines changed

10 files changed

+152
-87
lines changed

README.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Net Tools API
22

3-
The Net Tools API is a deployable Mule app that you can deploy to CloudHub. The app will then expose a very simple UI that will allow you to do basic networking commands. The idea is that most networking related issues with your CloudHub VPC and VPN are related to connectivity to your on-prem systems, and most of those issues end up being resolved on the customer end. If you have this tool available to you, you can work with your Networking team to test connectivity to various on-prem systems and verify that firewall and routing rules are working. It can also be used to generate some traffic that can help with diagnosing networking issues.
3+
The Net Tools API is a deployable Mule app that you can deploy to CloudHub or any worker cloud. The app will then expose a very simple UI that will allow you to do basic networking commands. The idea is that most networking related issues with your CloudHub VPC and VPN are related to connectivity to your on-prem systems, and most of those issues end up being resolved on the customer end. If you have this tool available to you, you can work with your Networking team to test connectivity to various on-prem systems and verify that firewall and routing rules are working. It can also be used to generate some traffic that can help with diagnosing networking issues.
44

55
This supports HTTP and HTTPS connections with a configurable port for each.
66

@@ -25,15 +25,26 @@ The UI can be accessed by using the base URL for the app. The options are liste
2525
- CloudHub Shared Load Balancer: `http://{app-name}.{region}.cloudhub.io` where the app-name and region are specific to the deployed app.
2626
- Dedicated Load Balancer: `custom url`. See *Configuration* section to update settings.
2727

28-
The API Console is available at the `/console` path.
29-
3028
The UI is protected by Basic Authentication, and the default credentials are listed in the *Configuration* section.
3129

3230
# Configuration
33-
The properties below can be set on the app to override the default settings. The proper port and protocol must be set to accommodate load balancer and VPC firewall rule settings. The default settings are for the CloudHub shared load balancer HTTP endpoint. See the [CloudHub Load Balancer documentation](https://docs.mulesoft.com/runtime-manager/lb-architecture) for which port and protocol to use for your configuration.
34-
35-
- `user`: User name for login; defaults to `vpc-tools`
36-
- `pass`: Password for login; defaults to `SomePass`
37-
- `protocol`: The protocol to use; defaults to `http`. Options: `http` or `https`
38-
- `httpPort`: Sets the listener port for http; defaults to `8081`
39-
- `httpsPort`: Sets the listener port for https; defaults to `8082`
31+
The properties below can be set on the app to override the default settings. The proper ports must be set to accommodate load balancer and VPC firewall rule settings. The default settings are for the CloudHub shared load balancer HTTP endpoint.
32+
33+
- `user`: User name for login. Defaults to `vpc-tools`
34+
- `pass`: Password for login. Defaults to `SomePass`
35+
- `httpPort`: Sets the listener port for HTTP. Defaults to `8081`
36+
- `httpsPort`: Sets the listener port for HTTPS. Defaults to `8082`
37+
- `httpListener`: The running state of the HTTP endpoint flows. Defaults to `started`. Options: `started` or `stopped`. Stop this to disable HTTP endpoint on CloudHub 1.0 or non-RTF infrastructure. This doesn't affect RTF or CloudHub 2.0 because only a single HTTP port is used.
38+
- `ignoreFiles`: Comma-delimited list of browser-requested resource files for this app to ignore. Defaults to `favicon.ico`.
39+
40+
## Network Considerations
41+
42+
- `httpsPort` and `httpPort` **must always** be different numbers, even if `httpListener=stopped`. This is because both HTTP and HTTPS listener configurations are always created, even if the HTTP endpoint is not enabled.
43+
- CloudHub 2.0 and RTF only use a single port for the HTTP listener. This means you can only run either HTTP or HTTPS, but not both at the same time. Make sure the property you want to use is set to the proper port and the other is set to another unused port.
44+
- When using CloudHub 2.0 and RTF, you must enable *Last-Mile Security* in the app's Ingress tab if you want to use HTTPS.
45+
- This does not use `http.port` and `https.port` properties since those are overrriden on Cloudhub 2.0 and RTF to the same port and will prevent the app from starting because of a port conflict.
46+
47+
### References
48+
- [CloudHub 2.0 Infrastructure Considerations](https://docs.mulesoft.com/cloudhub-2/ch2-comparison#infrastructure-considerations)
49+
- [CloudHub 1.0 Load Balancer Architecture](https://docs.mulesoft.com/cloudhub-1/lb-architecture)
50+
- [Enable Last Mile Security in RTF](https://help.mulesoft.com/s/article/How-to-Enable-both-Last-Mile-Security-and-Mutual-TLS-in-Runtime-Fabric)

exchange-docs/home.md

Whitespace-only changes.

pom.xml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.mycompany</groupId>
66
<artifactId>net-tools-api</artifactId>
7-
<version>2.4.0</version>
7+
<version>2.4.1</version>
88
<packaging>mule-application</packaging>
99

1010
<name>net-tools-api</name>
@@ -13,15 +13,15 @@
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1414
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1515

16-
<app.runtime>4.3.0</app.runtime>
17-
<mule.maven.plugin.version>3.4.2</mule.maven.plugin.version>
18-
<apikit.module.version>1.5.9</apikit.module.version>
19-
<http.connector.version>1.6.0</http.connector.version>
20-
<sockets.connector.version>1.2.2</sockets.connector.version>
21-
<spring.module.version>1.3.6</spring.module.version>
16+
<app.runtime>4.4.0</app.runtime>
17+
<mule.maven.plugin.version>3.8.0</mule.maven.plugin.version>
18+
<apikit.module.version>1.8.0</apikit.module.version>
19+
<http.connector.version>1.7.3</http.connector.version>
20+
<sockets.connector.version>1.2.3</sockets.connector.version>
21+
<spring.module.version>1.3.7</spring.module.version>
2222

23-
<spring.version>5.3.15</spring.version>
24-
<spring-security.version>5.6.1</spring-security.version>
23+
<spring.version>5.3.22</spring.version>
24+
<spring-security.version>5.7.3</spring-security.version>
2525
</properties>
2626

2727
<build>
@@ -125,6 +125,12 @@
125125
<url>https://repository.mulesoft.org/releases/</url>
126126
<layout>default</layout>
127127
</repository>
128+
<repository>
129+
<id>anypoint-exchange-v3</id>
130+
<name>Anypoint Exchange V3</name>
131+
<url>https://maven.anypoint.mulesoft.com/api/v3/maven</url>
132+
<layout>default</layout>
133+
</repository>
128134
</repositories>
129135
<pluginRepositories>
130136
<pluginRepository>

src/main/mule/global.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ http://www.mulesoft.org/schema/mule/tls http://www.mulesoft.org/schema/mule/tls/
3131
<apikit:config name="net-tools-config" raml="net-tools.raml" outboundHeadersMapName="outboundHeaders" httpStatusVarName="httpStatus" />
3232

3333
<spring:config name="Spring_Config" doc:id="45181472-36fd-44e6-b710-296481c3c450" files="beans.xml" />
34-
<spring:security-manager>
34+
<spring:security-manager>
3535
<spring:delegate-security-provider name="memory-provider" delegate-ref="authenticationManager" />
3636
</spring:security-manager>
3737
</mule>

src/main/mule/http.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
4+
xmlns="http://www.mulesoft.org/schema/mule/core"
5+
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
6+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7+
xsi:schemaLocation="
8+
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
9+
10+
<flow name="http-ui" doc:id="26329426-60ba-49ad-ae04-ac3bfb607dea" initialState="${httpListener}">
11+
<http:listener doc:name="Listener"
12+
doc:id="945b4a80-dcdd-460e-a520-24f510d84be8" config-ref="http"
13+
path="/*" outputMimeType="text/html" />
14+
<flow-ref doc:name="ui"
15+
doc:id="e74273e3-e138-414c-b6bf-58728820b208" name="ui" />
16+
</flow>
17+
18+
<flow name="http-net-tools-main" initialState="${httpListener}">
19+
<http:listener config-ref="http" path="/api/*">
20+
<http:response
21+
statusCode="#[vars.httpStatus default 200]">
22+
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
23+
</http:response>
24+
<http:error-response
25+
statusCode="#[vars.httpStatus default 500]">
26+
<http:body>#[payload]</http:body>
27+
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
28+
</http:error-response>
29+
</http:listener>
30+
<flow-ref doc:name="net-tools-main" doc:id="7b7d5435-a4ae-4c67-9159-cf238285bd32" name="net-tools-main"/>
31+
32+
</flow>
33+
</mule>

src/main/mule/net-tools.xml

Lines changed: 56 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,75 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:spring="http://www.mulesoft.org/schema/mule/spring" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit="http://www.mulesoft.org/schema/mule/mule-apikit" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/mule-apikit http://www.mulesoft.org/schema/mule/mule-apikit/current/mule-apikit.xsd
2+
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
3+
xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
4+
xmlns:spring="http://www.mulesoft.org/schema/mule/spring"
5+
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
6+
xmlns="http://www.mulesoft.org/schema/mule/core"
7+
xmlns:apikit="http://www.mulesoft.org/schema/mule/mule-apikit"
8+
xmlns:http="http://www.mulesoft.org/schema/mule/http"
9+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/mule-apikit http://www.mulesoft.org/schema/mule/mule-apikit/current/mule-apikit.xsd
311
http://www.mulesoft.org/schema/mule/spring http://www.mulesoft.org/schema/mule/spring/current/mule-spring.xsd
412
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
513
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
6-
7-
<flow name="ui" doc:id="94b97777-bd63-4abb-8093-a5c8ac97aa17" >
8-
<http:listener doc:name="Listener" doc:id="7e20b485-577c-4530-b2b1-66b6a84d5694" config-ref="${protocol}" path="/*" outputMimeType="text/html"/>
9-
<http:basic-security-filter doc:name="Basic security filter" doc:id="cb77f47e-923a-4195-86fc-23bbf2f01311" realm="mule" />
10-
<spring:authorization-filter requiredAuthorities="ROLE_ADMIN" />
11-
<ee:transform doc:name="Transform Message" doc:id="610d96e5-97f6-407d-ab81-fa234a5794bc" >
12-
<ee:message >
13-
<ee:set-payload ><![CDATA[%dw 2.0
14-
output text/plain
1514

16-
var uriPath = attributes.requestPath
17-
var path = if ("/" == uriPath)
18-
"web/index.html"
19-
else
20-
"web" ++ uriPath
21-
---
22-
readUrl("classpath://" ++ path, "text/plain")]]></ee:set-payload>
15+
<flow name="ui" doc:id="94b97777-bd63-4abb-8093-a5c8ac97aa17">
16+
<http:listener doc:name="Listener"
17+
doc:id="7e20b485-577c-4530-b2b1-66b6a84d5694" config-ref="https"
18+
path="/*" outputMimeType="text/html" />
19+
<http:basic-security-filter
20+
doc:name="Basic security filter"
21+
doc:id="cb77f47e-923a-4195-86fc-23bbf2f01311" realm="mule" />
22+
<spring:authorization-filter
23+
requiredAuthorities="ROLE_ADMIN" />
24+
<ee:transform doc:name="Transform Message"
25+
doc:id="610d96e5-97f6-407d-ab81-fa234a5794bc">
26+
<ee:message>
27+
<ee:set-payload
28+
resource="dwl/setWebResourcePayload.dwl" />
2329
</ee:message>
24-
<ee:variables >
25-
<ee:set-variable variableName="mimeType" ><![CDATA[%dw 2.0
26-
output application/java
27-
---
28-
splitBy(attributes.requestPath, ".")[-1] default ""]]></ee:set-variable>
30+
<ee:variables>
31+
<ee:set-variable
32+
resource="dwl/setWebResourceMimeType.dwl" variableName="mimeType" />
2933
</ee:variables>
3034
</ee:transform>
31-
<choice doc:name="Which MIME type?" doc:id="7fa94994-1832-4b21-b557-691274259e46" >
35+
<choice doc:name="Which MIME type?"
36+
doc:id="7fa94994-1832-4b21-b557-691274259e46">
3237
<when expression='#[vars.mimeType == "css"]'>
33-
<set-payload value="#[payload]" doc:name="Set MIME type as CSS" doc:id="d8334850-64ab-448a-abe3-1611772f58b8" mimeType="text/css" />
38+
<set-payload value="#[payload]"
39+
doc:name="Set MIME type as CSS"
40+
doc:id="d8334850-64ab-448a-abe3-1611772f58b8" mimeType="text/css" />
3441
</when>
3542
<when expression='#[vars.mimeType == "js"]'>
36-
<set-payload value="#[payload]" doc:name="Set MIME type as JavaScript" doc:id="9595f13e-4c58-4707-9818-c3bcc1d33a0a" mimeType="application/javascript" />
43+
<set-payload value="#[payload]"
44+
doc:name="Set MIME type as JavaScript"
45+
doc:id="9595f13e-4c58-4707-9818-c3bcc1d33a0a"
46+
mimeType="application/javascript" />
3747
</when>
38-
<otherwise >
39-
<set-payload value="#[payload]" doc:name="Set MIME type as HTML" doc:id="1e21a771-c190-40db-984f-9805208c3ca2" mimeType="text/html" />
48+
<otherwise>
49+
<set-payload value="#[payload]"
50+
doc:name="Set MIME type as HTML"
51+
doc:id="1e21a771-c190-40db-984f-9805208c3ca2" mimeType="text/html" />
4052
</otherwise>
4153
</choice>
4254
</flow>
43-
<flow name="net-tools-main">
44-
<http:listener config-ref="${protocol}" path="/api/*">
45-
<http:response statusCode="#[vars.httpStatus default 200]">
46-
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
47-
</http:response>
48-
<http:error-response statusCode="#[vars.httpStatus default 500]">
49-
<http:body>#[payload]</http:body>
50-
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
51-
</http:error-response>
52-
</http:listener>
55+
<flow name="net-tools-main"
56+
doc:id="6f86a93f-9de9-4cf8-b092-b6a4b23c42f4">
57+
<http:listener config-ref="https" path="/api/*">
58+
<http:response
59+
statusCode="#[vars.httpStatus default 200]">
60+
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
61+
</http:response>
62+
<http:error-response
63+
statusCode="#[vars.httpStatus default 500]">
64+
<http:body>#[payload]</http:body>
65+
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
66+
</http:error-response>
67+
</http:listener>
5368
<http:basic-security-filter doc:name="Basic security filter" realm="mule" />
54-
<apikit:router config-ref="net-tools-config" />
69+
<logger level="INFO"
70+
message='#["$(attributes.scheme default "") $(attributes.method default "") $(attributes.requestUri default "")"]'
71+
doc:name="Log Endpoint" />
72+
<apikit:router config-ref="net-tools-config" />
5573
<error-handler>
5674
<on-error-propagate type="APIKIT:BAD_REQUEST">
5775
<ee:transform xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
@@ -132,36 +150,8 @@ output application/json
132150
</ee:transform>
133151
</on-error-propagate>
134152
</error-handler>
135-
</flow>
136-
<flow name="net-tools-console">
137-
<http:listener config-ref="${protocol}" path="/console/*">
138-
<http:response statusCode="#[vars.httpStatus default 200]">
139-
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
140-
</http:response>
141-
<http:error-response statusCode="#[vars.httpStatus default 500]">
142-
<http:body>#[payload]</http:body>
143-
<http:headers>#[vars.outboundHeaders default {}]</http:headers>
144-
</http:error-response>
145-
</http:listener>
146-
<apikit:console config-ref="net-tools-config" />
147-
<error-handler>
148-
<on-error-propagate type="APIKIT:NOT_FOUND">
149-
<ee:transform xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
150-
<ee:message>
151-
<ee:set-payload><![CDATA[%dw 2.0
152-
output application/json
153-
---
154-
{message: "Resource not found"}]]></ee:set-payload>
155-
</ee:message>
156-
<ee:variables>
157-
<ee:set-variable variableName="httpStatus">404</ee:set-variable>
158-
</ee:variables>
159-
</ee:transform>
160-
</on-error-propagate>
161-
</error-handler>
162153
</flow>
163154
<flow name="get:\curl:net-tools-config">
164-
<logger level="INFO" message="get:\curl:net-tools-config" />
165155
<ee:transform doc:name="Transform Message" doc:id="c96eaddb-f56e-4f1a-81ff-ec15df7cb6d6" >
166156
<ee:message >
167157
<ee:set-payload ><![CDATA[%dw 2.0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<types:mule xmlns:types="http://www.mulesoft.org/schema/mule/types">
3+
<types:catalog/>
4+
</types:mule>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%dw 2.0
2+
output application/java
3+
import substringAfterLast from dw::core::Strings
4+
---
5+
substringAfterLast(attributes.requestPath, ".") default ""
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
%dw 2.0
2+
output text/plain
3+
import substringAfterLast from dw::core::Strings
4+
5+
var ignoreFiles = p("ignoreFiles") splitBy ","
6+
var uriPath = attributes.requestPath
7+
var path = if ("/" == uriPath)
8+
"web/index.html"
9+
else
10+
"web" ++ uriPath
11+
---
12+
if (ignoreFiles contains substringAfterLast(uriPath, "/"))
13+
null
14+
else
15+
readUrl("classpath://" ++ path, "text/plain")

src/main/resources/properties.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ user: "vpc-tools"
33
pass: "SomePass"
44
httpPort: "8081"
55
httpsPort: "8082"
6-
protocol: "http"
6+
httpListener: "started"
7+
ignoreFiles: "favicon.ico" # comma-delimited list of resource files to ignore

0 commit comments

Comments
 (0)