This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
Args=-O3 -march=x86-64-v2 --gc=serial --install-exit-handlers --initialize-at-run-time=io.netty --enable-url-protocols=jpms --initialize-at-build-time=net.woggioni.rbcs.common.RbcsUrlStreamHandlerFactory,net.woggioni.rbcs.common.RbcsUrlStreamHandlerFactory$JpmsHandler
|
Args=-O3 -march=x86-64-v2 --gc=serial --initialize-at-run-time=io.netty --enable-url-protocols=jpms -H:+UnlockExperimentalVMOptions -H:+SharedArenaSupport --initialize-at-build-time=net.woggioni.rbcs.common.RbcsUrlStreamHandlerFactory,net.woggioni.rbcs.common.RbcsUrlStreamHandlerFactory$JpmsHandler
|
||||||
#-H:TraceClassInitialization=io.netty.handler.ssl.BouncyCastleAlpnSslUtils
|
#-H:TraceClassInitialization=io.netty.handler.ssl.BouncyCastleAlpnSslUtils
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package net.woggioni.rbcs.common
|
||||||
|
|
||||||
|
import java.net.InetAddress
|
||||||
|
import org.junit.jupiter.api.Assertions
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
class CidrTest {
|
||||||
|
class CidrTest {
|
||||||
|
@Test
|
||||||
|
fun test() {
|
||||||
|
val cidr = Cidr.from("2a02:4780:12:368b::1/128")
|
||||||
|
Assertions.assertTrue {
|
||||||
|
cidr.contains(InetAddress.ofLiteral("2a02:4780:12:368b::1"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,14 +24,21 @@ class ProxyProtocolHandler(private val trustedProxyIPs : List<Cidr>) : SimpleCha
|
|||||||
val sourceAddress = ctx.channel().remoteAddress()
|
val sourceAddress = ctx.channel().remoteAddress()
|
||||||
if (sourceAddress is InetSocketAddress &&
|
if (sourceAddress is InetSocketAddress &&
|
||||||
trustedProxyIPs.isEmpty() ||
|
trustedProxyIPs.isEmpty() ||
|
||||||
trustedProxyIPs.any { it.contains((sourceAddress as InetSocketAddress).address) }) {
|
trustedProxyIPs.any { it.contains((sourceAddress as InetSocketAddress).address) }.also {
|
||||||
|
if(!it && log.isTraceEnabled) {
|
||||||
|
log.trace {
|
||||||
|
"Received a proxied connection request from $sourceAddress which is not a trusted proxy address, " +
|
||||||
|
"the proxy server address will be used instead"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) {
|
||||||
val proxiedClientAddress = InetSocketAddress(
|
val proxiedClientAddress = InetSocketAddress(
|
||||||
InetAddress.ofLiteral(msg.sourceAddress()),
|
InetAddress.ofLiteral(msg.sourceAddress()),
|
||||||
msg.sourcePort()
|
msg.sourcePort()
|
||||||
)
|
)
|
||||||
if(log.isTraceEnabled) {
|
if(log.isTraceEnabled) {
|
||||||
log.trace {
|
log.trace {
|
||||||
"Received proxied request from $sourceAddress forwarded for $proxiedClientAddress"
|
"Received proxied connection request from $sourceAddress forwarded for $proxiedClientAddress"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.channel().attr(RemoteBuildCacheServer.clientIp).set(proxiedClientAddress)
|
ctx.channel().attr(RemoteBuildCacheServer.clientIp).set(proxiedClientAddress)
|
||||||
|
|||||||
Reference in New Issue
Block a user