From 3c09697437d2056b4bdb1676f1ea9784f89e2518 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Tue, 14 May 2024 15:45:58 +0200 Subject: [PATCH] add passthrogh mode --- README.md | 4 ++++ config.yaml.example | 12 +++++++----- config/config.go | 10 +++++----- main.go | 8 ++++++-- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index fcb9d69..acbd965 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,10 @@ Edit `config.yaml.example` and rename to `config.yaml`. # Rules +## Passthrough + +The `passthrough` option is a mode for both `ChannelMode` and `ForwardMode` in the `config.yaml` file. When set to `passthrough`, electronwall will not apply any allowlist, denylist, or programmable rules to channel open requests or HTLC forwards. Instead, it will simply pass through all requests without any checks. + ## Allowlist and denylist Allowlist and denylist rules are set in `config.yaml` under the appropriate keys. See the [example](config.yaml.example) config. diff --git a/config.yaml.example b/config.yaml.example index cd6b196..2537500 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -12,9 +12,10 @@ debug: true # ----- Channel openings ----- -# Mode can either be "denylist" or "allowlist" -# Only one mode can be used at a time, the other list is ignored. -channel-mode: "denylist" +# Mode can be "denylist", "allowlist", or "passthrough". Only one mode can be active. +# If "denylist" is active, "allowlist" is ignored, and vice versa. +# "passthrough" passes all requests through without checks, ignoring both lists. +channel-mode: "denylist" # This error message will be sent to the other party upon a reject channel-reject-message: "Contact me at user@email.com" @@ -29,8 +30,9 @@ channel-denylist: # ----- HTLC forwarding ----- -# Mode can either be "denylist" or "allowlist" -# Only one mode can be used at a time, the other list is ignored. +# Mode can be "denylist", "allowlist", or "passthrough". Only one mode can be active. +# If "denylist" is active, "allowlist" is ignored, and vice versa. +# "passthrough" passes all requests through without checks, ignoring both lists. forward-mode: "denylist" # List of channel IDs to allowlist or denylist diff --git a/config/config.go b/config/config.go index e26c51c..5aaffae 100644 --- a/config/config.go +++ b/config/config.go @@ -61,8 +61,8 @@ func checkConfig() { if len(Configuration.ChannelMode) == 0 { Configuration.ChannelMode = "denylist" } - if Configuration.ChannelMode != "allowlist" && Configuration.ChannelMode != "denylist" { - panic(fmt.Errorf("channel mode must be either allowlist or denylist")) + if Configuration.ChannelMode != "allowlist" && Configuration.ChannelMode != "denylist" && Configuration.ChannelMode != "passthrough" { + panic(fmt.Errorf("channel mode must be either allowlist, denylist or passthrough")) } log.Infof("Channel acceptor running in %s mode", Configuration.ChannelMode) @@ -70,9 +70,9 @@ func checkConfig() { if len(Configuration.ForwardMode) == 0 { Configuration.ForwardMode = "denylist" } - if Configuration.ForwardMode != "allowlist" && Configuration.ForwardMode != "denylist" { - panic(fmt.Errorf("channel mode must be either allowlist or denylist")) + if Configuration.ForwardMode != "allowlist" && Configuration.ForwardMode != "denylist" && Configuration.ForwardMode != "passthrough" { + panic(fmt.Errorf("forward mode must be either allowlist, denylist or passthrough")) } log.Infof("HTLC forwarder running in %s mode", Configuration.ForwardMode) -} +} \ No newline at end of file diff --git a/main.go b/main.go index c00f9eb..4eb5b72 100644 --- a/main.go +++ b/main.go @@ -108,10 +108,14 @@ func main() { wg.Add(2) // channel acceptor - app.DispatchChannelAcceptor(ctx) + if config.Configuration.ChannelMode != "passthrough" { + app.DispatchChannelAcceptor(ctx) + } // htlc acceptor - app.DispatchHTLCAcceptor(ctx) + if config.Configuration.ForwardMode != "passthrough" { + app.DispatchHTLCAcceptor(ctx) + } wg.Wait() log.Info("All routines stopped. Waiting for new connection.")