From 942a80c47ffe88946b256ac4525aa33962a99f15 Mon Sep 17 00:00:00 2001 From: Macpie Date: Fri, 20 Oct 2023 15:23:18 -0700 Subject: [PATCH 1/3] Add options to disable_preferred_hotspot --- config/sys.config.src | 1 + config/test.config | 1 + src/device/router_device_routing.erl | 21 +++++++++++++-------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/config/sys.config.src b/config/sys.config.src index f929ed1fe..d69b4d8c6 100644 --- a/config/sys.config.src +++ b/config/sys.config.src @@ -35,6 +35,7 @@ {router, [ {devaddr_prefix, "${ROUTER_DEVADDR_PREFIX}"}, {is_chain_dead, "${ROUTER_IS_CHAIN_DEAD}"}, + {disable_preferred_hotspot, "${ROUTER_DISABLE_PREFERRED_HOTSPOT}"}, {grpc_port, ${GRPC_PORT:-8080}}, {max_v8_context, 1000}, {oui, "${ROUTER_OUI}"}, diff --git a/config/test.config b/config/test.config index b12634468..0c323a232 100644 --- a/config/test.config +++ b/config/test.config @@ -1,6 +1,7 @@ %% -*- erlang -*- [ {router, [ + {disable_preferred_hotspot, "false"}, {oui, 1}, {devaddr_prefix, "72"}, {metrics_port, 3001}, diff --git a/src/device/router_device_routing.erl b/src/device/router_device_routing.erl index 4c4ccaa91..17e99bd4f 100644 --- a/src/device/router_device_routing.erl +++ b/src/device/router_device_routing.erl @@ -572,15 +572,20 @@ maybe_multi_buy_offer(Device, PHash) -> Hotspot :: libp2p_crypto:pubkey_bin() ) -> none_preferred | preferred | not_preferred_hotspot. check_device_preferred_hotspots(Device, Hotspot) -> - case router_device:preferred_hotspots(Device) of - [] -> + case router_utils:get_env_bool(disable_preferred_hotspot, false) of + true -> none_preferred; - PreferredHotspots when is_list(PreferredHotspots) -> - case lists:member(Hotspot, PreferredHotspots) of - true -> - preferred; - _ -> - not_preferred_hotspot + false -> + case router_device:preferred_hotspots(Device) of + [] -> + none_preferred; + PreferredHotspots when is_list(PreferredHotspots) -> + case lists:member(Hotspot, PreferredHotspots) of + true -> + preferred; + _ -> + not_preferred_hotspot + end end end. From 477b5e7cfcd9bc14b1e238b86e35772f827cce5f Mon Sep 17 00:00:00 2001 From: Macpie Date: Fri, 20 Oct 2023 15:25:35 -0700 Subject: [PATCH 2/3] Add to template --- .env-template | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.env-template b/.env-template index 33a7bb984..fdb5b3b81 100644 --- a/.env-template +++ b/.env-template @@ -71,3 +71,6 @@ ROUTER_CHARGE_JOINS=true # Charge an org for a packet received late or replayed (default: false). ROUTER_CHARGE_LATE_PACKETS=false + +# Flad to disable preferred hotspot feature (default: false). +ROUTER_DISABLE_PREFERRED_HOTSPOT=true \ No newline at end of file From ce3128d91cb471c74ab546846fcb4caa4f3bcfb9 Mon Sep 17 00:00:00 2001 From: macpie Date: Fri, 20 Oct 2023 16:11:18 -0700 Subject: [PATCH 3/3] Update .env-template --- .env-template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env-template b/.env-template index fdb5b3b81..7b4c9b288 100644 --- a/.env-template +++ b/.env-template @@ -72,5 +72,5 @@ ROUTER_CHARGE_JOINS=true # Charge an org for a packet received late or replayed (default: false). ROUTER_CHARGE_LATE_PACKETS=false -# Flad to disable preferred hotspot feature (default: false). +# Flag to disable preferred hotspot feature (default: false). ROUTER_DISABLE_PREFERRED_HOTSPOT=true \ No newline at end of file