Skip to content

Commit b037574

Browse files
committed
refactor: share proxy network parsing
Use the shared network parser to select each per-network proxy, matching `-onlynet` and `getnodeaddresses`. Keep accepted names, proxy assignments, and error messages unchanged.
1 parent 332c3e8 commit b037574

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

‎src/init.cpp‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,16 +1782,18 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
17821782

17831783
if (net_str.empty()) { // For all networks.
17841784
ipv4_proxy = ipv6_proxy = name_proxy = cjdns_proxy = onion_proxy = proxy;
1785-
} else if (net_str == "ipv4") {
1786-
ipv4_proxy = name_proxy = proxy;
1787-
} else if (net_str == "ipv6") {
1788-
ipv6_proxy = name_proxy = proxy;
1789-
} else if (net_str == "onion") {
1790-
onion_proxy = proxy;
1791-
} else if (net_str == "cjdns") {
1792-
cjdns_proxy = proxy;
17931785
} else {
1794-
return InitError(strprintf(_("Unrecognized network in -proxy='%s': '%s'"), param_value, net_str));
1786+
switch (ParseNetwork(net_str)) {
1787+
case NET_IPV4: ipv4_proxy = name_proxy = proxy; break;
1788+
case NET_IPV6: ipv6_proxy = name_proxy = proxy; break;
1789+
case NET_ONION: onion_proxy = proxy; break;
1790+
case NET_CJDNS: cjdns_proxy = proxy; break;
1791+
case NET_UNROUTABLE:
1792+
case NET_I2P:
1793+
case NET_INTERNAL:
1794+
case NET_MAX:
1795+
return InitError(strprintf(_("Unrecognized network in -proxy='%s': '%s'"), param_value, net_str));
1796+
} // no default case, so the compiler can warn about missing cases
17951797
}
17961798
}
17971799
if (ipv4_proxy.IsValid()) {

0 commit comments

Comments
 (0)