rename list

This commit is contained in:
callebtc
2022-07-09 12:56:11 +02:00
parent bf3e36f134
commit f5a8c01d7d
5 changed files with 40 additions and 36 deletions

View File

@@ -1,5 +1,5 @@
# ⚡️🛡 electronwall # ⚡️🛡 electronwall
A tiny firewall for LND that can filter Lightning channel opening requests and HTLC forwards on your node. electronwall runs in the background and either allows (whitelist) or rejects (blacklist) events from a list of node public keys for channel openings, or channel IDs and channel pairs for payment routings. A tiny firewall for LND that can filter Lightning channel opening requests and HTLC forwards on your node. electronwall runs in the background and either allows (allowlist) or rejects (denylist) events from a list of node public keys for channel openings, or channel IDs and channel pairs for payment routings.
![Screenshot 2022-07-09 at 01 38 02](https://user-images.githubusercontent.com/93376500/178082329-9348b673-ee96-4147-a68b-08519457a4dd.jpg) ![Screenshot 2022-07-09 at 01 38 02](https://user-images.githubusercontent.com/93376500/178082329-9348b673-ee96-4147-a68b-08519457a4dd.jpg)

View File

@@ -44,17 +44,17 @@ func (app *app) dispatchChannelAcceptor(ctx context.Context) {
var accept bool var accept bool
if Configuration.ChannelMode == "whitelist" { if Configuration.ChannelMode == "allowlist" {
accept = false accept = false
for _, pubkey := range Configuration.ChannelWhitelist { for _, pubkey := range Configuration.ChannelAllowlist {
if hex.EncodeToString(req.NodePubkey) == pubkey { if hex.EncodeToString(req.NodePubkey) == pubkey {
accept = true accept = true
break break
} }
} }
} else if Configuration.ChannelMode == "blacklist" { } else if Configuration.ChannelMode == "denylist" {
accept = true accept = true
for _, pubkey := range Configuration.ChannelBlacklist { for _, pubkey := range Configuration.ChannelDenylist {
if hex.EncodeToString(req.NodePubkey) == pubkey { if hex.EncodeToString(req.NodePubkey) == pubkey {
accept = false accept = false
break break

View File

@@ -13,12 +13,12 @@ var Configuration = struct {
MacaroonPath string `yaml:"macaroon_path"` MacaroonPath string `yaml:"macaroon_path"`
TLSPath string `yaml:"tls-path"` TLSPath string `yaml:"tls-path"`
Debug bool `yaml:"debug"` Debug bool `yaml:"debug"`
ChannelWhitelist []string `yaml:"channel-whitelist"` ChannelAllowlist []string `yaml:"channel-allowlist"`
ChannelBlacklist []string `yaml:"channel-blacklist"` ChannelDenylist []string `yaml:"channel-denylist"`
ChannelRejectMessage string `yaml:"channel-reject-message"` ChannelRejectMessage string `yaml:"channel-reject-message"`
ForwardMode string `yaml:"forward-mode"` ForwardMode string `yaml:"forward-mode"`
ForwardWhitelist []string `yaml:"forward-whitelist"` ForwardAllowlist []string `yaml:"forward-allowlist"`
ForwardBlacklist []string `yaml:"forward-blacklist"` ForwardDenylist []string `yaml:"forward-denylist"`
}{} }{}
func init() { func init() {
@@ -49,19 +49,19 @@ func checkConfig() {
} }
if len(Configuration.ChannelMode) == 0 { if len(Configuration.ChannelMode) == 0 {
Configuration.ChannelMode = "blacklist" Configuration.ChannelMode = "denylist"
} }
if Configuration.ChannelMode != "whitelist" && Configuration.ChannelMode != "blacklist" { if Configuration.ChannelMode != "allowlist" && Configuration.ChannelMode != "denylist" {
panic(fmt.Errorf("channel mode must be either whitelist or blacklist")) panic(fmt.Errorf("channel mode must be either allowlist or denylist"))
} }
log.Infof("Channel acceptor running in %s mode", Configuration.ChannelMode) log.Infof("Channel acceptor running in %s mode", Configuration.ChannelMode)
if len(Configuration.ForwardMode) == 0 { if len(Configuration.ForwardMode) == 0 {
Configuration.ForwardMode = "blacklist" Configuration.ForwardMode = "denylist"
} }
if Configuration.ForwardMode != "whitelist" && Configuration.ForwardMode != "blacklist" { if Configuration.ForwardMode != "allowlist" && Configuration.ForwardMode != "denylist" {
panic(fmt.Errorf("channel mode must be either whitelist or blacklist")) panic(fmt.Errorf("channel mode must be either allowlist or denylist"))
} }
log.Infof("HTLC forwarder running in %s mode", Configuration.ForwardMode) log.Infof("HTLC forwarder running in %s mode", Configuration.ForwardMode)

View File

@@ -10,28 +10,28 @@ debug: true
# ----- Channel openings ----- # ----- Channel openings -----
# Mode can either be "blacklist" or "whitelist" # Mode can either be "denylist" or "allowlist"
channel-mode: "blacklist" channel-mode: "denylist"
# This error message will be sent to the other party upon a reject # This error message will be sent to the other party upon a reject
channel-reject-message: "Contact me at user@email.com" channel-reject-message: "Contact me at user@email.com"
# List of nodes to whitelist or blacklist # List of nodes to allowlist or denylist
channel-whitelist: channel-allowlist:
- "03de70865239e99460041e127647b37101b9eb335b3c22de95c944671f0dabc2d0" - "03de70865239e99460041e127647b37101b9eb335b3c22de95c944671f0dabc2d0"
- "0307299a290529c5ccb3a5e3bd2eb504daf64cc65c6d65b582c01cbd7e5ede14b6" - "0307299a290529c5ccb3a5e3bd2eb504daf64cc65c6d65b582c01cbd7e5ede14b6"
channel-blacklist: channel-denylist:
- "02853f9c1d15d479b433039885373b681683b84bb73e86dff861bee6697c17c1de" - "02853f9c1d15d479b433039885373b681683b84bb73e86dff861bee6697c17c1de"
# ----- HTLC forwarding ----- # ----- HTLC forwarding -----
# Mode can either be "blacklist" or "whitelist" # Mode can either be "denylist" or "allowlist"
forward-mode: "blacklist" forward-mode: "denylist"
# List of channel IDs to whitelist or blacklist # List of channel IDs to allowlist or denylist
forward-whitelist: forward-allowlist:
- "7143424x65537x0" - "7143424x65537x0"
- "12320768x65536x0->7143424x65537x0" - "12320768x65536x0->7143424x65537x0"
forward-blacklist: forward-denylist:
- "12320768x65536x0" - "12320768x65536x0"
- "7929856x65537x1->12320768x65536x0" - "7929856x65537x1->12320768x65536x0"

View File

@@ -154,19 +154,23 @@ func (app *app) interceptHtlcEvents(ctx context.Context, interceptor routerrpc.R
// decision is made whether or not to relay an HTLC to the next // decision is made whether or not to relay an HTLC to the next
// peer. // peer.
// The decision is made based on the following rules: // The decision is made based on the following rules:
// 1. Either use a whitelist (accept) or a blacklist (deny). // 1. Either use a allowlist or a denylist.
// 2. If a single channel ID is used (12320768x65536x0), check the incoming ID of the HTLC against the list. // 2. If a single channel ID is used (12320768x65536x0), check the incoming ID of the HTLC against the list.
// 3. If two channel IDs are used (7929856x65537x0->7143424x65537x0), check the incoming ID and the outgoing ID of the HTLC against the list. // 3. If two channel IDs are used (7929856x65537x0->7143424x65537x0), check the incoming ID and the outgoing ID of the HTLC against the list.
func (app *app) htlcInterceptDecision(ctx context.Context, event *routerrpc.ForwardHtlcInterceptRequest, decision_chan chan bool) { func (app *app) htlcInterceptDecision(ctx context.Context, event *routerrpc.ForwardHtlcInterceptRequest, decision_chan chan bool) {
var accept bool var accept bool
// sleep for 10 seconds
log.Infof("Sleeping for 15 seconds")
time.Sleep(15 * time.Second)
switch Configuration.ForwardMode { switch Configuration.ForwardMode {
case "whitelist": case "allowlist":
accept = false accept = false
for _, forward_whitelist_entry := range Configuration.ForwardWhitelist { for _, forward_allowlist_entry := range Configuration.ForwardAllowlist {
if len(strings.Split(forward_whitelist_entry, "->")) == 2 { if len(strings.Split(forward_allowlist_entry, "->")) == 2 {
// check if channel_id is actually from-to channel // check if channel_id is actually from-to channel
split := strings.Split(forward_whitelist_entry, "->") split := strings.Split(forward_allowlist_entry, "->")
from_channel_id, to_channel_id := split[0], split[1] from_channel_id, to_channel_id := split[0], split[1]
if parse_channelID(event.IncomingCircuitKey.ChanId) == from_channel_id && if parse_channelID(event.IncomingCircuitKey.ChanId) == from_channel_id &&
parse_channelID(event.OutgoingRequestedChanId) == to_channel_id { parse_channelID(event.OutgoingRequestedChanId) == to_channel_id {
@@ -175,18 +179,18 @@ func (app *app) htlcInterceptDecision(ctx context.Context, event *routerrpc.Forw
} }
} else { } else {
// single entry // single entry
if parse_channelID(event.IncomingCircuitKey.ChanId) == forward_whitelist_entry { if parse_channelID(event.IncomingCircuitKey.ChanId) == forward_allowlist_entry {
accept = true accept = true
break break
} }
} }
} }
case "blacklist": case "denylist":
accept = true accept = true
for _, forward_whitelist_entry := range Configuration.ForwardWhitelist { for _, forward_allowlist_entry := range Configuration.ForwardAllowlist {
if len(strings.Split(forward_whitelist_entry, "->")) == 2 { if len(strings.Split(forward_allowlist_entry, "->")) == 2 {
// check if channel_id is actually from-to channel // check if channel_id is actually from-to channel
split := strings.Split(forward_whitelist_entry, "->") split := strings.Split(forward_allowlist_entry, "->")
from_channel_id, to_channel_id := split[0], split[1] from_channel_id, to_channel_id := split[0], split[1]
if parse_channelID(event.IncomingCircuitKey.ChanId) == from_channel_id && if parse_channelID(event.IncomingCircuitKey.ChanId) == from_channel_id &&
parse_channelID(event.OutgoingRequestedChanId) == to_channel_id { parse_channelID(event.OutgoingRequestedChanId) == to_channel_id {
@@ -195,7 +199,7 @@ func (app *app) htlcInterceptDecision(ctx context.Context, event *routerrpc.Forw
} }
} else { } else {
// single entry // single entry
if parse_channelID(event.IncomingCircuitKey.ChanId) == forward_whitelist_entry { if parse_channelID(event.IncomingCircuitKey.ChanId) == forward_allowlist_entry {
accept = false accept = false
break break
} }