Skip to content

Commit 866c941

Browse files
committed
patch readme, and improve log format
1 parent f2741e4 commit 866c941

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ package
3434

3535
local_dist.ps1
3636
bak
37-
docker/local_build.ps1
37+
docker/local_build.ps1
38+
src/main/resources/private.conf

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,25 @@ If you want to get all requests and responses about `https://www.exmample.com (1
1515
2. run commands below:
1616
```shell
1717
# run with sbt
18-
1918
sbt "runMain Main --dns=192.168.3.3:www.example.com --jks-path=jks.jks --jks-password=123456 --websocketPort=9000"
20-
# open your browser to access http://127.0.0.1:9000/viewer
19+
20+
21+
# run with docker
22+
# config file would be:
23+
24+
# jks {
25+
# path=/server/config/jks.jks
26+
# password=123456
27+
# }
28+
# resolver=[114.114.114.114]
29+
# viewerPort=9000
30+
# ##selfSignedCert = "" # if you use self signed cert.
31+
32+
docker run --rm -v ${pwd}/private.conf:/server/config/application.conf -v${pwd}/jks.jks:/server/config/jks.jks -p 443:443 -p 9000:9000 ghcr.io/timzaak/log-http-proxy:latest
33+
34+
35+
# open your browser to access http://127.0.0.1:9000
36+
2137
```
2238
The params are:
2339

src/main/scala/Main.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ object Main {
7171
val bindAndCheck = proxy.startServer()
7272
Await.result(
7373
bindAndCheck.flatMap { v =>
74-
val changedHosts = dnsPairs.map((domain, _) => s"127.0.0.1 $domain").mkString("\n")
75-
val buf = StringBuffer("proxy server is up, listening 443 port.\n")
74+
val changedHosts = config.dns.map( v => s"127.0.0.1 ${v.domain}").mkString("\n")
75+
val buf = StringBuffer(s"proxy server is up, listening ${v.localAddress.getPort} port.\n")
7676
if (changedHosts.nonEmpty) {
7777
buf.append(s"additional host config:\n$changedHosts\n")
7878
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ case class Record2(
4242
} else {
4343
buf.append(s"ContentType: ${req.entity.contentType}\nBody:\n")
4444
}
45-
45+
4646

4747
req.method match {
48-
case v if v != HttpMethods.GET || v!= HttpMethods.OPTIONS =>
48+
case v if v != HttpMethods.GET && v!= HttpMethods.OPTIONS =>
4949
req.entity.contentType.mediaType match {
5050
case mediaType if mediaType.isMultipart =>
5151
Option(mediaType.getParams.get("boundary")) match {
@@ -68,7 +68,7 @@ case class Record2(
6868
}
6969

7070
case mediaType
71-
if mediaType.isText || mediaType.isApplication || mediaType.isMessage || mediaType.isMultipart =>
71+
if mediaType.isText || mediaType.isApplication || mediaType.isMessage || req.entity.contentLengthOption.getOrElse(0) == 0 =>
7272
req.withEntity(
7373
req.entity.transformDataBytes(
7474
Flow[ByteString].alsoTo(

0 commit comments

Comments
 (0)