Skip to content

Commit 18d1dfc

Browse files
committed
add ip parameter
1 parent 48a1eed commit 18d1dfc

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ docker run --rm \
4545
ghcr.io/timzaak/log-http-proxy:latest
4646

4747
```
48-
> Open your browser and navigate to http://127.0.0.1:9000 to view traffic logs.
48+
> Open your browser and navigate to `http://127.0.0.1:9000` to view traffic logs. or with ip `http://127.0.0.1:9000?ip=${http client ip}`
4949
5050
<img src="/doc/usage.png" alt="Usage screenshot" width="500" />
5151

src/main/scala/com/timzaak/proxy/LogWebViewer.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ class LogWebViewer(certPath: Option[String])(using system: ActorSystem) {
3636

3737
private val viewerEndpoint = endpoint.get
3838
.in("")
39+
.in(query[Option[String]]("ip"))
3940
.in(extractFromRequest(identity))
4041
.out(htmlBodyUtf8)
41-
.serverLogicSuccess { request =>
42-
val ip = extractClientIP(request)
42+
.serverLogicSuccess { (ipParam, request) =>
43+
val ip = ipParam.getOrElse(extractClientIP(request))
4344
val certDesc = certPath match {
4445
case Some(_) =>
4546
s"""<p>the server use self signed cert, you may need to register the self signed rootCA.pem to your system. </p>

0 commit comments

Comments
 (0)