-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
309 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@echo off | ||
|
||
cd %~dp0 | ||
|
||
set TARGET=..\generated\quickstartproxy.md | ||
set SOURCE=..\gen_sources | ||
|
||
type noedit.htm > %TARGET% | ||
echo In this demo you will >> %TARGET% | ||
type quickstartproxy.md >> %TARGET% | ||
type %SOURCE%\proxy.md >> %TARGET% | ||
type %SOURCE%\approxy.md >> %TARGET% | ||
type %SOURCE%\runproxyham.md >> %TARGET% | ||
type %SOURCE%\createrecording.md >> %TARGET% |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
* Install Java 11 | ||
* Start locally HAM server | ||
* Connect to it through proxy | ||
|
||
Download the ham tar.gz from [github releases](https://github.com/kendarorg/HttpAnsweringMachine/releases) | ||
and extract it | ||
|
||
|
||
<b>Ensure your application is calling -ONLY- http pages or it will not record the | ||
interactions content</b> | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
## Configure the application proxy<a id="appproxy_01"></a> | ||
|
||
Here is configured for both http and https BUT only http traffic will be intercepted | ||
|
||
### On the application | ||
|
||
* [On Baeldung for java](https://www.baeldung.com/java-connect-via-proxy-server) | ||
|
||
Just add to the java command to start the application the following: | ||
|
||
<pre> | ||
-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=1081 | ||
-Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=1081 | ||
</pre> | ||
|
||
* [Some C# suggestions](https://dotnetcoretutorials.com/2021/07/11/socks-proxy-support-in-net/?series) | ||
|
||
### On HAM configuration | ||
|
||
First ensure that all the ports called by your application are set on the | ||
file httpproxy.external.json in the "http" section. In the example here the | ||
http listen on 80, 8081 and 8082 | ||
|
||
<pre> | ||
{ | ||
"id": "http", | ||
"system": true, | ||
"active": true, | ||
"port": "80;8081;8082", | ||
"backlog": 50, | ||
"useCachedExecutor": true | ||
}, | ||
</pre> | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
## Record some interaction<a id="createrecording_01"></a> | ||
|
||
You can now check ham application going on http://localhost | ||
|
||
* You can create a recording on the [recording page](http://www.local.test/plugins/recording) | ||
|
||
<img alt="Create recording" src="../images/create_recording.gif" width="500"/> | ||
|
||
* Once you create the recording you can start recording! | ||
|
||
<img alt="Start recording" src="../images/start_recording.gif" width="500"/> | ||
|
||
* Do some interaction on your application | ||
* And stop the recording! | ||
* Now you will se all the calls on the just created recording! | ||
|
||
<img alt="Start recording" src="../images/calendar_recorded.gif" width="500"/> | ||
|
||
* "Download" the recording as "Sample.json" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
## Run!! | ||
|
||
Start the HAM application with the "httpproxy.run.bat/sh" | ||
Start your appplication |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
|
||
<!--This file is autogenerated. Do not edit!--> | ||
In this demo you will | ||
|
||
* Install Java 11 | ||
* Start locally HAM server | ||
* Connect to it through proxy | ||
|
||
Download the ham tar.gz from [github releases](https://github.com/kendarorg/HttpAnsweringMachine/releases) | ||
and extract it | ||
|
||
|
||
<b>Ensure your application is calling -ONLY- http pages or it will not record the | ||
interactions content</b> | ||
|
||
|
||
## Configure proxy<a id="proxy_01"></a> | ||
|
||
Should set the proxy to 127.0.0.1 And port 1080 for socks5 or 1081 for http/https | ||
|
||
<details> | ||
<summary>Click me for more explanations</summary> | ||
|
||
* Chrome: | ||
* Install [Proxy Switch Omega](https://chrome.google.com/webstore/detail/proxy-switchyomega/padekgcemlokbadohgkifijomclgjgif) | ||
* Go to options | ||
* Add http and https proxy server with | ||
* Address: 127.0.0.1 | ||
* Port 1081. | ||
|
||
<img alt="Ham Proxyes" src="../images/chrome_proxy.gif" width="500"/> | ||
* Select "proxy" from the extension menu and back to "direct" when you want to disconnect | ||
* | ||
<img alt="Ham Proxyes" src="../images/chrome_proxy_switch.gif" width="100"/> | ||
* Firefox | ||
* Navigate to [about:preferences](about:preferences) | ||
* Search for "proxy" | ||
* Click on "Settings" | ||
* Go to "Manual proxy Configuration" | ||
* Select the socks5 proxy | ||
* Address: 127.0.0.1 | ||
* Port 1080 | ||
* Check the "Proxy DNS when using SOCKS v5" flag | ||
* Clean the settings when needed | ||
|
||
<img alt="Ham Proxyes" src="../images/firefox_proxy.gif" width="500"/> | ||
|
||
</details> | ||
|
||
|
||
## Configure the application proxy<a id="appproxy_01"></a> | ||
|
||
Here is configured for both http and https BUT only http traffic will be intercepted | ||
|
||
### On the application | ||
|
||
* [On Baeldung for java](https://www.baeldung.com/java-connect-via-proxy-server) | ||
|
||
Just add to the java command to start the application the following: | ||
|
||
<pre> | ||
-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=1081 | ||
-Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=1081 | ||
</pre> | ||
|
||
* [Some C# suggestions](https://dotnetcoretutorials.com/2021/07/11/socks-proxy-support-in-net/?series) | ||
|
||
### On HAM configuration | ||
|
||
First ensure that all the ports called by your application are set on the | ||
file httpproxy.external.json in the "http" section. In the example here the | ||
http listen on 80, 8081 and 8082 | ||
|
||
<pre> | ||
{ | ||
"id": "http", | ||
"system": true, | ||
"active": true, | ||
"port": "80;8081;8082", | ||
"backlog": 50, | ||
"useCachedExecutor": true | ||
}, | ||
</pre> | ||
|
||
|
||
|
||
## Run!! | ||
|
||
Start the HAM application with the "httpproxy.run.bat/sh" | ||
Start your appplication | ||
## Record some interaction<a id="createrecording_01"></a> | ||
|
||
You can now check ham application going on http://localhost | ||
|
||
* You can create a recording on the [recording page](http://www.local.test/plugins/recording) | ||
|
||
<img alt="Create recording" src="../images/create_recording.gif" width="500"/> | ||
|
||
* Once you create the recording you can start recording! | ||
|
||
<img alt="Start recording" src="../images/start_recording.gif" width="500"/> | ||
|
||
* Do some interaction on your application | ||
* And stop the recording! | ||
* Now you will se all the calls on the just created recording! | ||
|
||
<img alt="Start recording" src="../images/calendar_recorded.gif" width="500"/> | ||
|
||
* "Download" the recording as "Sample.json" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
[ | ||
"#include:external/dns.json", | ||
{ | ||
"id": "staticPage", | ||
"system": true, | ||
"staticPages": [ | ||
] | ||
}, | ||
{ | ||
"id": "http", | ||
"system": true, | ||
"active": true, | ||
"port": "80", | ||
"backlog": 50, | ||
"useCachedExecutor": true | ||
}, | ||
"#include:external/proxy.json", | ||
"#include:external/dbproxy.json", | ||
"#include:external/ssl.json", | ||
"#include:external/https.json", | ||
"#include:external/mongo.json", | ||
{ | ||
"id": "global", | ||
"system": true, | ||
"db": { | ||
"url": "jdbc:h2:tcp://localhost/ham;MODE=MYSQL;", | ||
"login": "sa", | ||
"password": "sa", | ||
"startInternalH2": true, | ||
"driver": "org.h2.Driver", | ||
"hibernateDialect": "org.hibernate.dialect.MySQLDialect" | ||
}, | ||
"localAddress": "localhost", | ||
"logging": { | ||
"logLevel": "INFO", | ||
"loggers": { | ||
"org.kendar.servers.http.Request": "OFF", | ||
"org.kendar.servers.http.Response": "OFF", | ||
"org.kendar.servers.http.StaticRequest": "OFF", | ||
"org.kendar.servers.http.DynamicRequest": "OFF", | ||
"org.kendar.dns.DnsQueries": "OFF", | ||
"org.kendar.servers.http.InternalRequest": "OFF", | ||
"org.hibernate": "OFF", | ||
"org.kendar.mongo.logging.MongoLogClient": "OFF", | ||
"org.kendar.mongo.logging.MongoLogServer": "OFF", | ||
"org.mongodb.driver": "OFF", | ||
"com.sun.net.httpserver": "ERROR" | ||
} | ||
}, | ||
"filters": { | ||
"12363272": false | ||
} | ||
}, | ||
{ | ||
"id": "oidc.server", | ||
"tokenExpiration": 86400, | ||
"active": false | ||
}, | ||
{ | ||
"id": "js.filters", | ||
"path": "jsplugins", | ||
"active": true | ||
}, | ||
{ | ||
"id": "replayer.server", | ||
"path": "replayerdata", | ||
"active": true | ||
}, | ||
{ | ||
"id": "socks5.server", | ||
"port": 1080, | ||
"httpProxyPort": 1081, | ||
"interceptAllHttp":true, | ||
"active": true | ||
} | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@ECHO OFF | ||
|
||
REM Initialize | ||
set SCRIPT_DIR=%~dp0 | ||
cd %SCRIPT_DIR% | ||
|
||
REM Retrieve the jar name | ||
dir /b %SCRIPT_DIR%\*.jar > .temp.txt | ||
set /p JAR_NAME=<.temp.txt | ||
del /s /f /q .temp.txt 2>&1 1>NUL | ||
|
||
|
||
|
||
|
||
REM Start the application | ||
java "-Dloader.path=%SCRIPT_DIR%/libs" -Dloader.main=org.kendar.Main ^ | ||
"-Djsonconfig=%SCRIPT_DIR%\httpproxy.external.json" ^ | ||
-jar %JAR_NAME% org.springframework.boot.loader.PropertiesLauncher |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# Initialize | ||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
cd $SCRIPT_DIR | ||
|
||
# Retrieve the jar name | ||
ls -lA|grep -oE '[^ ]+$'|grep .jar$ > tmp_txt | ||
export JAR_NAME=$(head -1 tmp_txt) | ||
rm tmp_txt || true | ||
|
||
|
||
|
||
# Start the application | ||
java "-Dloader.path=$SCRIPT_DIR/libs" -Dloader.main=org.kendar.Main \ | ||
"-Djsonconfig=$SCRIPT_DIR/httpproxy.external.json" \ | ||
-jar "$JAR_NAME" org.springframework.boot.loader.PropertiesLauncher |