diff --git a/lib/feature/network/data/network_manager.dart b/lib/feature/network/data/network_manager.dart index 703e30c2..19f315f2 100644 --- a/lib/feature/network/data/network_manager.dart +++ b/lib/feature/network/data/network_manager.dart @@ -168,6 +168,7 @@ class NetworkManager { PreferencesKeys.keyIsBootstrapEnabled, isEnabled, ); + _routerService.toggleBootstrap(isActive: isEnabled); _updateState(); } diff --git a/lib/feature/network/data/router_service.dart b/lib/feature/network/data/router_service.dart index ebdfc9a0..7cae3f5a 100644 --- a/lib/feature/network/data/router_service.dart +++ b/lib/feature/network/data/router_service.dart @@ -20,7 +20,6 @@ class RouterService { late final p2p.RouterL2 _router; - late final init = _router.init; late final selfId = _router.selfId.value; late final messageStream = _router.messageStream @@ -30,8 +29,14 @@ class RouterService { late final peerStatusChanges = _router.lastSeenStream .map((e) => (PeerId(token: e.peerId.value), e.isOnline)); + Future init([Uint8List? seed]) => _router.init(seed); + Future start(int port) async { - for (final address in await _getIPs()) { + final ifs = {}; + for (final nIf in await NetworkInterface.list()) { + ifs.addAll(nIf.addresses); + } + for (final address in ifs) { _router.transports.add(p2p.TransportUdp( bindAddress: p2p.FullAddress(address: address, port: port), )); @@ -110,12 +115,4 @@ class RouterService { _router.removePeerAddress(peerId); } } - - Future> _getIPs() async { - final result = {}; - for (final nIf in await NetworkInterface.list()) { - result.addAll(nIf.addresses); - } - return result; - } }