Use old ip checks and fix dev-ui-build script

These checks could be improved to not use javas InetAddress. But for
now it should have the same behaviour as before.
This commit is contained in:
eikek 2021-06-26 14:43:16 +02:00
parent 0bdfcd531d
commit 7dcb61ef56
3 changed files with 7 additions and 6 deletions

View File

@ -42,14 +42,13 @@ object Config {
case class HttpHeader(enabled: Boolean, headerName: String, headerValue: String) case class HttpHeader(enabled: Boolean, headerName: String, headerValue: String)
case class AllowedIps(enabled: Boolean, ips: Set[String]) { case class AllowedIps(enabled: Boolean, ips: Set[String]) {
def containsAddress(inet: IpAddress): Boolean = { def containsAddress(ipa: IpAddress): Boolean = {
val ip = inet.fold(_.toUriString, _.toUriString) //.getHostAddress val inet = ipa.toInetAddress
val ip = inet.getHostAddress
lazy val ipParts = ip.split('.') lazy val ipParts = ip.split('.')
def checkSingle(pattern: String): Boolean = def checkSingle(pattern: String): Boolean =
pattern == ip || (ip.contains( pattern == ip || (inet.isLoopbackAddress && pattern == "127.0.0.1") || (pattern
"localhost"
) && pattern == "127.0.0.1") || (pattern
.split('.') .split('.')
.zip(ipParts) .zip(ipParts)
.foldLeft(true) { case (r, (a, b)) => .foldLeft(true) { case (r, (a, b)) =>

View File

@ -41,7 +41,8 @@ object ClientRequestInfo {
req.headers req.headers
.get[`X-Forwarded-For`] .get[`X-Forwarded-For`]
.flatMap(_.values.head) .flatMap(_.values.head)
.map(ip => ip.fold(_.toUriString, _.toUriString)) .map(_.toInetAddress)
.flatMap(inet => Option(inet.getHostName).orElse(Option(inet.getHostAddress)))
private def xForwardedHost[F[_]](req: Request[F]): Option[String] = private def xForwardedHost[F[_]](req: Request[F]): Option[String] =
req.headers req.headers

View File

@ -48,6 +48,7 @@ watch_both() {
} }
cd "$wdir/modules/webapp"
case "$1" in case "$1" in
all) all)
compile_js compile_js