gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: Optionally listen to all interfaces.


From: gnunet
Subject: [libeufin] branch master updated: Optionally listen to all interfaces.
Date: Wed, 28 Sep 2022 20:25:24 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 9d87533e Optionally listen to all interfaces.
9d87533e is described below

commit 9d87533ef9e43679ec5e84188042afb6f42283fb
Author: MS <ms@taler.net>
AuthorDate: Wed Sep 28 20:22:11 2022 +0200

    Optionally listen to all interfaces.
---
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt            | 11 ++++++-----
 .../main/kotlin/tech/libeufin/nexus/server/NexusServer.kt    |  6 +++---
 sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt        | 12 ++++++++----
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 18ed288a..8be04d58 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -21,9 +21,6 @@ package tech.libeufin.nexus
 
 import com.github.ajalt.clikt.output.CliktHelpFormatter
 import com.github.ajalt.clikt.parameters.arguments.argument
-import com.github.ajalt.clikt.parameters.options.default
-import com.github.ajalt.clikt.parameters.options.option
-import com.github.ajalt.clikt.parameters.options.prompt
 import org.jetbrains.exposed.sql.transactions.transaction
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
@@ -33,7 +30,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
 import com.github.ajalt.clikt.parameters.types.int
 import execThrowableOrTerminate
 import com.github.ajalt.clikt.core.*
-import com.github.ajalt.clikt.parameters.options.versionOption
+import com.github.ajalt.clikt.parameters.options.*
 import startServer
 import tech.libeufin.nexus.iso20022.parseCamtMessage
 import tech.libeufin.nexus.server.client
@@ -58,6 +55,10 @@ class Serve : CliktCommand("Run nexus HTTP server") {
             helpFormatter = CliktHelpFormatter(showDefaultValues = true)
         }
     }
+    private val localhostOnly by option(
+        "--localhost-only",
+        help = "Bind only to localhost.  On all interfaces otherwise"
+    ).flag("--no-localhost-only", default = true)
     // Prevent IPv6 mode:
     // private val host by option().default("127.0.0.1")
     private val port by option().int().default(5001)
@@ -79,7 +80,7 @@ class Serve : CliktCommand("Run nexus HTTP server") {
             )
             exitProcess(0)
         }
-        serverMain(port)
+        serverMain(port, localhostOnly)
     }
 }
 
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index 4f1abc81..ea019d6b 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -1051,17 +1051,17 @@ val nexusApp: Application.() -> Unit = {
         }
     }
 }
-fun serverMain(port: Int) {
+fun serverMain(port: Int, localhostOnly: Boolean) {
     val server = embeddedServer(
         Netty,
         environment = applicationEngineEnvironment {
             connector {
                 this.port = port
-                this.host = "127.0.0.1"
+                this.host = if (localhostOnly) "127.0.0.1" else "0.0.0.0"
             }
             connector {
                 this.port = port
-                this.host = "[::1]"
+                this.host = if (localhostOnly) "[::1]" else "[::]"
             }
             module(nexusApp)
         }
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 9f67e193..b4955783 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -335,6 +335,10 @@ class Serve : CliktCommand("Run sandbox HTTP server") {
         "--auth",
         help = "Disable authentication."
     ).flag("--no-auth", default = true)
+    private val localhostOnly by option(
+        "--localhost-only",
+        help = "Bind only to localhost.  On all interfaces otherwise"
+    ).flag("--no-localhost-only", default = true)
     private val logLevel by option()
     private val port by option().int().default(5000)
     private val withUnixSocket by option(
@@ -364,7 +368,7 @@ class Serve : CliktCommand("Run sandbox HTTP server") {
             )
             exitProcess(0)
         }
-        serverMain(port)
+        serverMain(port, localhostOnly)
     }
 }
 
@@ -1594,17 +1598,17 @@ val sandboxApp: Application.() -> Unit = {
     }
 }
 
-fun serverMain(port: Int) {
+fun serverMain(port: Int, localhostOnly: Boolean) {
     val server = embeddedServer(
         Netty,
         environment = applicationEngineEnvironment{
             connector {
                 this.port = port
-                this.host = "127.0.0.1"
+                this.host = if (localhostOnly) "127.0.0.1" else "0.0.0.0"
             }
             connector {
                 this.port = port
-                this.host = "[::1]"
+                this.host = if (localhostOnly) "[::1]" else "[::]"
             }
             parentCoroutineContext = Dispatchers.Main
             module(sandboxApp)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]