refactor: net: subnet lookup: use single-result LookupHost() #17160
pull theStack wants to merge 1 commits into bitcoin:master from theStack:20191016-net-simplify_function_lookupsubnet changing 1 files +6 −8-
theStack commented at 11:51 am on October 16, 2019: memberplus describe single IP subnet case for more clarity
-
fanquake added the label P2P on Oct 16, 2019
-
MarcoFalke added the label Refactoring on Oct 16, 2019
-
MarcoFalke commented at 12:11 pm on October 16, 2019: memberThis is refactor, right?
-
theStack force-pushed on Oct 16, 2019
-
theStack renamed this:
net: subnet lookup: use single-result LookupHost()
refactor: net: subnet lookup: use single-result LookupHost()
on Oct 16, 2019 -
theStack commented at 12:33 pm on October 16, 2019: member
This is refactor, right?
True, I added the
refactor
prefix to the pull request title and commit message. -
laanwj commented at 2:34 pm on October 16, 2019: memberas this concerns DNS: @TheBlueMatt
-
dongcarl commented at 2:50 pm on October 16, 2019: member
I added this
TODO
, this change merely changes our use of “thestd::vector<CNetAddr>&
out-parameter version ofLookupHost
” to “theCNetAddr&
out-parameter version ofLookupHost
”.Here’s the
CNetAddr&
version: https://github.com/bitcoin/bitcoin/blob/c34b88620dc8435b83e6744895f2ecd3c9ec8de7/src/netbase.cpp#L158-L172And here’s the
std::vector<CNetAddr>&
version: https://github.com/bitcoin/bitcoin/blob/c34b88620dc8435b83e6744895f2ecd3c9ec8de7/src/netbase.cpp#L131-L156 -
practicalswift commented at 12:35 pm on October 17, 2019: contributor
FWIW -
LookupHost(…)
usages:0CConnman::ThreadDNSAddressSeed() → LookupHost(char const*, std::vector<CNetAddr>&, unsigned int, bool) 1main → AppInit(int, char**) → AppInitMain(InitInterfaces&) → InitHTTPServer() → LookupHost(char const*, CNetAddr&, bool) 2main → AppInit(int, char**) → AppInitMain(InitInterfaces&) → InitHTTPServer() → LookupHost(char const*, CNetAddr&, bool) → LookupHost(char const*, std::vector<CNetAddr>&, unsigned int, bool) 3main → AppInit(int, char**) → AppInitMain(InitInterfaces&) → InitHTTPServer() → LookupSubNet(char const*, CSubNet&) → LookupHost(char const*, std::vector<CNetAddr>&, unsigned int, bool) 4main → AppInit(int, char**) → AppInitMain(InitInterfaces&) → LookupSubNet(char const*, CSubNet&) → LookupHost(char const*, std::vector<CNetAddr>&, unsigned int, bool) 5setban(JSONRPCRequest const&) → LookupHost(char const*, CNetAddr&, bool) 6setban(JSONRPCRequest const&) → LookupHost(char const*, CNetAddr&, bool) → LookupHost(char const*, std::vector<CNetAddr>&, unsigned int, bool) 7setban(JSONRPCRequest const&) → LookupSubNet(char const*, CSubNet&) → LookupHost(char const*, std::vector<CNetAddr>&, unsigned int, bool) 8ThreadMapPort() → LookupHost(char const*, CNetAddr&, bool) 9ThreadMapPort() → LookupHost(char const*, CNetAddr&, bool) → LookupHost(char const*, std::vector<CNetAddr>&, unsigned int, bool)
-
theStack commented at 1:11 pm on October 17, 2019: member
as this concerns DNS: @TheBlueMatt
Note that no real lookup (resolving) is performed in
LookupSubNet()
, as the calls toLookupHost()
pass the flagbool fAllowLookup
=false
. To quote the further called functionLookupIntern()
:Hence the calls to
LookupHost()
inLookupSubNet()
are only used to parse an IP-Address string and convert it to aCNetAddr
structure. -
DrahtBot commented at 4:31 pm on December 16, 2019: member
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #23219 (p2p: rm CNetAddr vector and copy in LookupSubNet() and update/tidy up by jonatack)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
-
DrahtBot added the label Needs rebase on Jan 22, 2020
-
theStack force-pushed on Feb 28, 2020
-
theStack commented at 9:04 am on February 28, 2020: memberRebased.
-
fanquake removed the label Needs rebase on Feb 28, 2020
-
DrahtBot added the label Needs rebase on Mar 15, 2021
-
refactor: net: subnet lookup: use single-result LookupHost()
plus describe single IP subnet case for more clarity
-
in src/netbase.cpp:829 in 8509cbad6d outdated
825@@ -826,14 +826,11 @@ bool LookupSubNet(const std::string& strSubnet, CSubNet& ret) 826 return false; 827 } 828 size_t slash = strSubnet.find_last_of('/'); 829- std::vector<CNetAddr> vIP; 830+ CNetAddr network, netmask;
practicalswift commented at 7:02 pm on March 15, 2021:The scope ofnetmask
could be reduce to make review somewhat easier?
theStack commented at 0:27 am on March 16, 2021:Good idea! Done.theStack force-pushed on Mar 16, 2021theStack commented at 0:27 am on March 16, 2021: memberRebased on master again and limited the scope ofnetmask
, as suggested by practicalswift.DrahtBot removed the label Needs rebase on Mar 16, 2021fanquake requested review from dongcarl on Oct 11, 2021jonatack approvedjonatack commented at 2:18 pm on October 20, 2021: memberThis looks like it is one of your first pulls!
utACK a989f98d240a84b5c798252acaa4a316ac711189 the patch rebases cleanly to master, the debug build is green, and it is essentially the same patch as c8991f0251dd2a modulo local variable naming, braced initialization, and a comment
vasild approvedvasild commented at 11:56 am on November 19, 2021: memberACK a989f98d240a84b5c798252acaa4a316ac711189laanwj merged this on Dec 6, 2021laanwj closed this on Dec 6, 2021
sidhujag referenced this in commit 75dd73382d on Dec 7, 2021laanwj referenced this in commit c006ab29ce on Dec 18, 2021sidhujag referenced this in commit 08c502ff3c on Dec 18, 2021RandyMcMillan referenced this in commit 8428fc2363 on Dec 23, 2021DrahtBot locked this on Dec 6, 2022
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 06:12 UTC
More mirrored repositories can be found on mirror.b10c.me