Skip to content

Commit

Permalink
Add options to disable_preferred_hotspot (#1015)
Browse files Browse the repository at this point in the history
* Add options to disable_preferred_hotspot

* Add to template

* Update .env-template
  • Loading branch information
macpie authored Oct 20, 2023
1 parent 53122ca commit 77dd7dd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .env-template
Original file line number Diff line number Diff line change
Expand Up @@ -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

# Flag to disable preferred hotspot feature (default: false).
ROUTER_DISABLE_PREFERRED_HOTSPOT=true
1 change: 1 addition & 0 deletions config/sys.config.src
Original file line number Diff line number Diff line change
Expand Up @@ -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}"},
Expand Down
1 change: 1 addition & 0 deletions config/test.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
%% -*- erlang -*-
[
{router, [
{disable_preferred_hotspot, "false"},
{oui, 1},
{devaddr_prefix, "72"},
{metrics_port, 3001},
Expand Down
21 changes: 13 additions & 8 deletions src/device/router_device_routing.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 77dd7dd

Please sign in to comment.