Skip to content

Commit b7b64b8

Browse files
committed
fix stuff
1 parent df1e91c commit b7b64b8

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

portalProxy/src/main/kotlin/Main.kt

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,42 +39,42 @@ class MainVerticle : CoroutineVerticle() {
3939
}
4040

4141
val proxyRequestHandler: (HttpServerRequest) -> Unit = { request ->
42-
log(buildString {
43-
append("< ")
44-
append(request.method())
45-
append(" ")
46-
append(request.uri())
47-
append(" -> ")
48-
append(request.scheme())
49-
append(" ")
50-
append(request.authority()?.host())
51-
append(" : ")
52-
append(request.authority()?.port())
53-
append(" ")
54-
append(request.path())
55-
append(" from ")
56-
append(request.remoteAddress().host().replace("0:0:0:0:0:0:0:1", "::1"))
57-
append(":")
58-
append(request.remoteAddress().port())
59-
})
60-
61-
if (request.method() == HttpMethod.CONNECT) {
62-
launch(Dispatchers.IO) {
42+
launch(Dispatchers.IO) {
43+
log(buildString {
44+
append("< ")
45+
append(request.method())
46+
append(" ")
47+
append(request.uri())
48+
append(" -> ")
49+
append(request.scheme())
50+
append(" ")
51+
append(request.authority()?.host())
52+
append(" : ")
53+
append(request.authority()?.port())
54+
append(" ")
55+
append(request.path())
56+
append(" from ")
57+
append(request.remoteAddress().host().replace("0:0:0:0:0:0:0:1", "::1"))
58+
append(":")
59+
append(request.remoteAddress().port())
60+
})
61+
62+
if (request.method() == HttpMethod.CONNECT) {
6363
forwardConnect(request, vertx)
64+
} else {
65+
proxyRouter.handle(request)
6466
}
65-
} else {
66-
proxyRouter.handle(request)
67+
68+
log(buildString {
69+
append("> ")
70+
append(request.response()?.statusCode)
71+
append(" ")
72+
append(request.response()?.statusMessage)
73+
append(" [")
74+
append(request.response()?.headers()?.joinToString { "${it.key}: ${it.value}" })
75+
append("] ")
76+
})
6777
}
68-
69-
log(buildString {
70-
append("> ")
71-
append(request.response()?.statusCode)
72-
append(" ")
73-
append(request.response()?.statusMessage)
74-
append(" [")
75-
append(request.response()?.headers()?.joinToString { "${it.key}: ${it.value}" })
76-
append("] ")
77-
})
7878
}
7979

8080
val portalRequestHandler: (HttpServerRequest) -> Unit = { request ->
@@ -88,14 +88,14 @@ class MainVerticle : CoroutineVerticle() {
8888
val proxyServer = vertx.createHttpServer()
8989
.requestHandler(proxyRequestHandler)
9090
.exceptionHandler(exceptionHandler)
91-
.listen(proxyPort, "::")
91+
.listen(proxyPort, "0.0.0.0")
9292
.coAwait()
9393
log("Started proxy server on port " + proxyServer.actualPort())
9494

9595
val portalServer = vertx.createHttpServer()
9696
.requestHandler(portalRequestHandler)
9797
.exceptionHandler(exceptionHandler)
98-
.listen(portalPort, "::")
98+
.listen(portalPort, "0.0.0.0")
9999
.coAwait()
100100
log("Started portal server on port " + portalServer.actualPort())
101101
}
@@ -104,6 +104,9 @@ class MainVerticle : CoroutineVerticle() {
104104
fun main() {
105105
Logger.Config.debugDump = true
106106

107+
// disable ipv6 so entries in the portal database are deterministic for dual stack clients
108+
System.setProperty("java.net.preferIPv4Stack", "true")
109+
107110
val vertx = Vertx.builder()/*.withTracer { o -> DebugTracer() }*/.build()
108111
vertx.exceptionHandler { e ->
109112
log("Unhandled exception", e)

0 commit comments

Comments
 (0)