libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 5822f89f770978303bfa2079854535b8e83831ec
parent d90fb73b1d1926ccbc11a4fdd89c253fab6fb626
Author: Sebastian <sebasjm@gmail.com>
Date:   Tue,  1 Nov 2022 15:35:53 -0300

add support for ipv4 only system

Diffstat:
M.gitignore | 3+++
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 6+++++-
Mnexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt | 4++--
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 10+++++++---
4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,3 +1,6 @@ +/nexus/bin/ +/sandbox/bin/ +/util/bin/ nexus/libeufin-nexus-dev sandbox/libeufin-sandbox-dev configure diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -59,6 +59,10 @@ class Serve : CliktCommand("Run nexus HTTP server") { "--localhost-only", help = "Bind only to localhost. On all interfaces otherwise" ).flag("--no-localhost-only", default = true) + private val ipv4Only by option( + "--ipv4-only", + help = "Bind only to ipv4" + ).flag(default = false) // Prevent IPv6 mode: // private val host by option().default("127.0.0.1") private val port by option().int().default(5001) @@ -80,7 +84,7 @@ class Serve : CliktCommand("Run nexus HTTP server") { ) exitProcess(0) } - serverMain(port, localhostOnly) + serverMain(port, localhostOnly, ipv4Only) } } diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt @@ -1051,7 +1051,7 @@ val nexusApp: Application.() -> Unit = { } } } -fun serverMain(port: Int, localhostOnly: Boolean) { +fun serverMain(port: Int, localhostOnly: Boolean, ipv4Only: Boolean) { val server = embeddedServer( Netty, environment = applicationEngineEnvironment { @@ -1059,7 +1059,7 @@ fun serverMain(port: Int, localhostOnly: Boolean) { this.port = port this.host = if (localhostOnly) "127.0.0.1" else "0.0.0.0" } - connector { + if (!ipv4Only) connector { this.port = port this.host = if (localhostOnly) "[::1]" else "[::]" } diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -339,6 +339,10 @@ class Serve : CliktCommand("Run sandbox HTTP server") { "--localhost-only", help = "Bind only to localhost. On all interfaces otherwise" ).flag("--no-localhost-only", default = true) + private val ipv4Only by option( + "--ipv4-only", + help = "Bind only to ipv4" + ).flag(default = false) private val logLevel by option() private val port by option().int().default(5000) private val withUnixSocket by option( @@ -368,7 +372,7 @@ class Serve : CliktCommand("Run sandbox HTTP server") { ) exitProcess(0) } - serverMain(port, localhostOnly) + serverMain(port, localhostOnly, ipv4Only) } } @@ -1559,7 +1563,7 @@ val sandboxApp: Application.() -> Unit = { } } -fun serverMain(port: Int, localhostOnly: Boolean) { +fun serverMain(port: Int, localhostOnly: Boolean, ipv4Only: Boolean) { val server = embeddedServer( Netty, environment = applicationEngineEnvironment{ @@ -1567,7 +1571,7 @@ fun serverMain(port: Int, localhostOnly: Boolean) { this.port = port this.host = if (localhostOnly) "127.0.0.1" else "0.0.0.0" } - connector { + if (!ipv4Only) connector { this.port = port this.host = if (localhostOnly) "[::1]" else "[::]" }