@@ -1392,6 +1392,32 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1392
1392
// Check port numbers
1393
1393
if (!CheckHostPortOptions (args)) return false ;
1394
1394
1395
+ // Configure reachable networks before we start the RPC server.
1396
+ // This is necessary for -rpcallowip to distinguish CJDNS from other RFC4193
1397
+ const auto onlynets = args.GetArgs (" -onlynet" );
1398
+ if (!onlynets.empty ()) {
1399
+ g_reachable_nets.RemoveAll ();
1400
+ for (const std::string& snet : onlynets) {
1401
+ enum Network net = ParseNetwork (snet);
1402
+ if (net == NET_UNROUTABLE)
1403
+ return InitError (strprintf (_ (" Unknown network specified in -onlynet: '%s'" ), snet));
1404
+ g_reachable_nets.Add (net);
1405
+ }
1406
+ }
1407
+
1408
+ if (!args.IsArgSet (" -cjdnsreachable" )) {
1409
+ if (!onlynets.empty () && g_reachable_nets.Contains (NET_CJDNS)) {
1410
+ return InitError (
1411
+ _ (" Outbound connections restricted to CJDNS (-onlynet=cjdns) but "
1412
+ " -cjdnsreachable is not provided" ));
1413
+ }
1414
+ g_reachable_nets.Remove (NET_CJDNS);
1415
+ }
1416
+ // Now g_reachable_nets.Contains(NET_CJDNS) is true if:
1417
+ // 1. -cjdnsreachable is given and
1418
+ // 2.1. -onlynet is not given or
1419
+ // 2.2. -onlynet=cjdns is given
1420
+
1395
1421
/* Start the RPC server already. It will be started in "warmup" mode
1396
1422
* and not really process calls already (but it will signify connections
1397
1423
* that the server is there and will be ready later). Warmup mode will
@@ -1504,30 +1530,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
1504
1530
strSubVersion.size (), MAX_SUBVERSION_LENGTH));
1505
1531
}
1506
1532
1507
- const auto onlynets = args.GetArgs (" -onlynet" );
1508
- if (!onlynets.empty ()) {
1509
- g_reachable_nets.RemoveAll ();
1510
- for (const std::string& snet : onlynets) {
1511
- enum Network net = ParseNetwork (snet);
1512
- if (net == NET_UNROUTABLE)
1513
- return InitError (strprintf (_ (" Unknown network specified in -onlynet: '%s'" ), snet));
1514
- g_reachable_nets.Add (net);
1515
- }
1516
- }
1517
-
1518
- if (!args.IsArgSet (" -cjdnsreachable" )) {
1519
- if (!onlynets.empty () && g_reachable_nets.Contains (NET_CJDNS)) {
1520
- return InitError (
1521
- _ (" Outbound connections restricted to CJDNS (-onlynet=cjdns) but "
1522
- " -cjdnsreachable is not provided" ));
1523
- }
1524
- g_reachable_nets.Remove (NET_CJDNS);
1525
- }
1526
- // Now g_reachable_nets.Contains(NET_CJDNS) is true if:
1527
- // 1. -cjdnsreachable is given and
1528
- // 2.1. -onlynet is not given or
1529
- // 2.2. -onlynet=cjdns is given
1530
-
1531
1533
// Requesting DNS seeds entails connecting to IPv4/IPv6, which -onlynet options may prohibit:
1532
1534
// If -dnsseed=1 is explicitly specified, abort. If it's left unspecified by the user, we skip
1533
1535
// the DNS seeds by adjusting -dnsseed in InitParameterInteraction.
0 commit comments