net: open p2p connections to nodes that listen on non-default ports #23542

pull vasild wants to merge 4 commits into bitcoin:master from vasild:connect_to_any_port changing 11 files +274 −20
  1. vasild commented at 10:14 am on November 18, 2021: contributor

    By default, for mainnet, the p2p listening port is 8333. Bitcoin Core has a strong preference for only connecting to nodes that listen on that port.

    Remove that preference because connections over clearnet that involve port 8333 make it easy to detect, analyze, block or divert Bitcoin p2p traffic before the connection is even established (at TCP SYN time).

    For further justification see the OP of: #23306

  2. ghost commented at 10:31 am on November 18, 2021: none
    Concept ACK
  3. in src/netbase.cpp:837 in 38a7cf975c outdated
    836+    case 6666:  // Alternate IRC [Apple addition]
    837+    case 6667:  // Standard IRC [Apple addition]
    838+    case 6668:  // Alternate IRC [Apple addition]
    839+    case 6669:  // Alternate IRC [Apple addition]
    840+    case 6697:  // IRC + TLS
    841+    case 10080: // Amanda
    


    unknown commented at 10:45 am on November 18, 2021:
    Not sure about this list of bad ports because more ports can be added to this list if we need it in Bitcoin Core. I had followed the comments in other PR: #23306 (comment)

    michaelfolkson commented at 7:40 pm on November 18, 2021:
    @prayank23: You just mean additional ports can always be added at a later date? I agree the comment seems reasonable

    unknown commented at 8:39 pm on November 18, 2021:
    If there is a clear definition of what Bitcoin Core is considering a bad port maybe they can be added right now

    vasild commented at 10:47 am on November 19, 2021:
    There is/was not a definition before, but I guess that will be settled up with this PR.
  4. DrahtBot added the label P2P on Nov 18, 2021
  5. 0xB10C commented at 10:57 am on November 18, 2021: contributor
    Concept ACK
  6. vasild force-pushed on Nov 18, 2021
  7. vasild commented at 11:01 am on November 18, 2021: contributor
    38a7cf975c...a47716aa5a: warn if configured to listen on a “bad” port.
  8. theStack commented at 11:53 am on November 18, 2021: contributor
    Concept ACK
  9. naumenkogs commented at 12:00 pm on November 18, 2021: member
    Concept ACK
  10. in src/test/netbase_tests.cpp:586 in a47716aa5a outdated
    581+    BOOST_CHECK(IsBadPort(1));
    582+    BOOST_CHECK(IsBadPort(22));
    583+    BOOST_CHECK(IsBadPort(6000));
    584+
    585+    BOOST_CHECK(!IsBadPort(80));
    586+    BOOST_CHECK(!IsBadPort(443));
    


    benthecarman commented at 4:35 pm on November 18, 2021:
    any reason these 2 shouldn’t be bad ports?

    vasild commented at 4:52 pm on November 18, 2021:

    I guess, on one side a lot of connections and connection attempts are to be expected by operators of web servers which are often open to the public and everybody is expected to be able to connect to them, so it is not likely that a web server operator complains like “why are you trying to connect to my web server?”.

    On the other side, there are lots of restrictive firewalls that only allow outbound traffic to the internet to ports 80 and 443. So, I think it is good that 80 and 443 are not “bad”. Ideally Bitcoin Core should listen on 443 and talk SSL, so it is indistinguishable from normal HTTPS traffic.

  11. in src/init.cpp:1692 in a47716aa5a outdated
    1769@@ -1770,6 +1770,13 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
    1770         if (index == std::string::npos) {
    1771             if (Lookup(bind_arg, bind_addr, GetListenPort(), false)) {
    1772                 connOptions.vBinds.push_back(bind_addr);
    1773+                if (IsBadPort(bind_addr.GetPort())) {
    1774+                    InitWarning(strprintf(
    1775+                        _("-bind request to listen on port %u. This port is considered \"bad\" and "
    1776+                          "thus it is unlikely that any Bitcoin Core peers connect to it. See "
    1777+                          "https://fetch.spec.whatwg.org/#port-blocking"),
    


    jb55 commented at 7:41 pm on November 18, 2021:
    I’m a bit confused as to why bitcoin cares about what a brower’s fetch api considers a “bad port”, it’s not clear what this even means? Maybe I’m missing something.

    jb55 commented at 7:46 pm on November 18, 2021:
    looks like I was missing this context: #23306 (comment)

    michaelfolkson commented at 7:47 pm on November 18, 2021:
    Just to get a starting list of bad ports I think. Can adjust from there if certain ports should be added or removed from that.

    sipa commented at 7:49 pm on November 18, 2021:

    Adding entries to the list may be undesirable, as it may mean that someone running a node on such a port silently stops getting connections.

    Not a very serious concern, as this would happen spread over some amount of time anyway, but still a reason I think to err on the side of caution and start with a possibly overly expansive list here


    jb55 commented at 8:08 pm on November 18, 2021:
    I’ll still point out that the link provided doesn’t explain why a particular port is “bad”. Following the link to get an explaination leads to: “A port is a bad port if it is listed in the first column of the following table”. ok…??? 😕 I found this pretty confusing from a user perspective trying to understand this warning.

    vasild commented at 9:36 am on November 19, 2021:

    For me, the following comment answers the question:

    “why am I seeing a failed SSH-login to my server on port 22 from your IP-address w.x.y.z?”

    (from #23306 (comment))

    There is some similarity between browser logic and Bitcoin node logic in this aspect where a malicious actor may trick a honest node to try to open a connection to a “victim” target:

    • a honest web-browser user may be tricked to click specially crafted (malicious) links like e.g. http://area51.gov:22/
    • a honest node may be tricked to try to open connection to area51.gov:22 if that address gets gossiped over the bitcoin network

    jb55 commented at 4:51 pm on November 19, 2021:
    I understand that from reading the comment on github, but I was just pointing out from a user perspective there is no insight from the link in the warning in this commit. Perhaps it could be reworded: “See https://fetch.spec.whatwg.org/#port-blocking for a list of bad ports”. Or perhaps (eventually? :sweat_smile: ) a link to docs within bitcoin itself that lists our bad ports with an explanation of why they are bad.

    unknown commented at 6:51 pm on December 10, 2021:

    There is some similarity between browser logic and Bitcoin node logic in this aspect where a malicious actor may trick a honest node to try to open a connection to a “victim” target: a honest web-browser user may be tricked to click specially crafted (malicious) links like e.g. http://area51.gov:22/ a honest node may be tricked to try to open connection to area51.gov:22 if that address gets gossiped over the bitcoin network

    If this is the reason for adding a list of bad ports then we can add lot of other port numbers. Right now there are only 80 ports in the list. Example: 3389

    Also this goes against the main reason we are allowing p2p connections to non-default ports: #23542 (review)


    vasild commented at 12:33 pm on February 3, 2022:

    Or perhaps (eventually? sweat_smile ) a link to docs within bitcoin itself that lists our bad ports with an explanation of why they are bad.

    Done.

  12. in src/netbase.cpp:784 in a47716aa5a outdated
    779+    case 69:    // tftp
    780+    case 77:    // priv-rjs
    781+    case 79:    // finger
    782+    case 87:    // ttylink
    783+    case 95:    // supdup
    784+    case 101:   // hostriame
    


    mzumsande commented at 7:58 pm on November 18, 2021:
    nit: hostname (looks like a OCR fail that made it to the browsers’ lists)

    vasild commented at 10:29 am on November 19, 2021:
    Good catch! Fixed.
  13. in src/netbase.h:254 in a47716aa5a outdated
    245@@ -246,4 +246,17 @@ void InterruptSocks5(bool interrupt);
    246  */
    247 bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* auth, const Sock& socket);
    248 
    249+/**
    250+ * Determine if a port is "bad" from the perspective of attempting to connect
    251+ * to a node on that port.
    252+ * See
    253+ * https://fetch.spec.whatwg.org/#port-blocking
    


    mzumsande commented at 8:24 pm on November 18, 2021:
    I was wondering which of the 3 sources the used list is based on, but they seem to be identical with the exception of port 0, which is considered bad by Mozilla. Should we add port 0 too?

    benthecarman commented at 9:22 pm on November 18, 2021:
    I think i2p uses port 0, so we’d need to make an exception for that

    sipa commented at 9:24 pm on November 18, 2021:
    TCP port 0 does not exist. It also doesn’t appear in the Mozilla list; it’s just a terminator to indicate “end of list” there. @benthecarman Right; this list should only apply to IPv4/IPv6.

    vasild commented at 10:34 am on November 19, 2021:

    All 3 sources agree on which ports are bad (which is good, pun intended). Can ignore port 0, that is something like opening connection to port 70000 or to IP address 1.2.3.500.

    Changed the logic to apply only to clearnet (IPv4 and IPv6).

  14. mzumsande commented at 8:48 pm on November 18, 2021: contributor
    Concept ACK
  15. vasild force-pushed on Nov 19, 2021
  16. vasild commented at 10:28 am on November 19, 2021: contributor
    a47716aa5a...cb3887ee36: avoid connections to bad ports only over clearnet (https://github.com/bitcoin/bitcoin/pull/23542#discussion_r752635951), minor other changes.
  17. vasild force-pushed on Nov 19, 2021
  18. vasild commented at 10:44 am on November 19, 2021: contributor
    cb3887ee36...634f2838ee: fix arguments to AddArg()
  19. rebroad commented at 6:20 pm on November 21, 2021: contributor
    tACK
  20. vasild commented at 11:13 am on November 29, 2021: contributor
    634f2838ee..0671bc5313: include the port when deciding a relay destination (append 3 commits)
  21. DrahtBot commented at 7:26 pm on November 29, 2021: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #24213 (refactor: use Span in random.*; make GetRand a template, remove GetRandInt by PastaPastaPasta)
    • #20196 (net: fix GetListenPort() to derive the proper port by vasild)
    • #18642 (Use std::chrono for the time to rotate destination of addr messages + tests by naumenkogs)

    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.

  22. kristapsk commented at 7:48 pm on November 29, 2021: contributor
    Concept ACK
  23. jnewbery commented at 2:10 pm on December 2, 2021: member
    Concept ACK
  24. in src/net.cpp:2088 in 0671bc5313 outdated
    2089-            // from advertising themselves as a service on another host and
    2090-            // port, causing a DoS attack as nodes around the network attempt
    2091-            // to connect to it fruitlessly.
    2092-            if (addr.GetPort() != Params().GetDefaultPort(addr.GetNetwork()) && nTries < 50) {
    2093+            // Do not connect to bad ports, unless 50 invalid addresses have been selected already.
    2094+            if (IsBadPort(addr.GetPort()) && (addr.IsIPv4() || addr.IsIPv6()) && nTries < 50) {
    


    jonatack commented at 12:52 pm on December 9, 2021:

    634f283 maybe perform less expensive checks first

    0            if (nTries < 50 && (addr.IsIPv4() || addr.IsIPv6()) && IsBadPort(addr.GetPort())) {
    

    vasild commented at 1:28 pm on December 10, 2021:
    Done. Although I think that in practice this is irrelevant (a few CPU cycles saved in a code that is not executed in a hot loop). Also, in most of the cases nTries < 50 will be true, so the other conditions will be executed anyway.

    jonatack commented at 1:32 pm on December 10, 2021:
    True; my initial thought was to suggest only the IP m_net check first.
  25. in src/test/netbase_tests.cpp:591 in 0671bc5313 outdated
    586+    BOOST_CHECK(!IsBadPort(443));
    587+    BOOST_CHECK(!IsBadPort(8333));
    588+
    589+    // Check all ports, there must be 80 bad ports in total.
    590+    size_t total_bad_ports{0};
    591+    for (uint16_t port = std::numeric_limits<uint16_t>::max(); port > 0; --port) {
    


    jonatack commented at 1:17 pm on December 9, 2021:

    634f2838ee137234093a1fc89162f395366a387f might be a good place to use std::count_if, or alternatively, possibly faster given the number of iterations with

    0    for (uint16_t port = std::numeric_limits<uint16_t>::max(); port != 0; --port) {
    

    vasild commented at 1:31 pm on December 10, 2021:
    std::count_if works with iterators, how could I use it to go over the numbers 1..64k? Are you saying != is faster than >? Even if “yes”, I would leave it as is coz I find the > more natural/readable.

    jonatack commented at 1:53 pm on December 10, 2021:

    Right, and std::ranges::count_if is C++20 (and test code doesn’t need to be elegant).

    != 0 might be a faster iterator comparator (e.g. https://www.youtube.com/watch?v=oelQ4uAw2WQ) but in this case of a “manual” loop it may also be inlined by compilers in optimized non-debug modes. A non-blocking thought in any case.


    jonatack commented at 2:14 pm on December 10, 2021:
    Huh, just rewatched the video and it seems != (jump if not equal instead of jump if not greater/less than) was also what a ranged for-loop generated (GCC 10.2 -O3). Ofc feel free to ignore.
  26. in src/net_processing.cpp:1710 in 0671bc5313 outdated
    1706@@ -1707,8 +1707,10 @@ void PeerManagerImpl::RelayAddress(NodeId originator,
    1707     // Relay to a limited number of other nodes
    1708     // Use deterministic randomness to send to the same nodes for 24 hours
    1709     // at a time so the m_addr_knowns of the chosen nodes prevent repeats
    1710-    uint64_t hashAddr = addr.GetHash();
    1711-    const CSipHasher hasher = m_connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY).Write(hashAddr << 32).Write((GetTime() + hashAddr) / (24 * 60 * 60));
    1712+    const uint64_t hash_addr = CServiceHash(0, 0)(addr);
    


    jonatack commented at 1:26 pm on December 9, 2021:
    b3a1a3ba A comment documenting why (0, 0) is passed to CServiceHash may be nice (or perhaps a dedicated/named ctor).

    vasild commented at 1:32 pm on December 10, 2021:
    The comment above says // Use deterministic randomness .... I think that is sufficient but would be happy to reword the existent comment if you have a suggestion.
  27. jonatack commented at 1:34 pm on December 9, 2021: contributor

    Code review ACK 0671bc5313b0a5fd125ef40c7ed4590bdca6b347 rebased to master, debug build clean, unit tests green, briefly ran a signet node.

    Some non-blocking review thoughts.

  28. in src/netbase.h:257 in 634f2838ee outdated
    251+ * to a node on that port.
    252+ * See
    253+ * https://fetch.spec.whatwg.org/#port-blocking
    254+ * https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/net/base/port_util.cc
    255+ * https://hg.mozilla.org/mozilla-central/file/tip/netwerk/base/nsIOService.cpp
    256+ * https://github.com/bitcoin/bitcoin/pull/23306#issuecomment-947516736
    


    unknown commented at 3:21 pm on December 9, 2021:

    Still not sure about few things and comment above was marked as resolved even though few other reviewers have similar confusion about ports:

    1. What is a BAD port for Bitcoin Core?
    2. Why browsers (bad ports) are referenced here because Bitcoin Core is not a browser and I was unable to find anything relevant for other P2P networks. Example: i2p
    3. #23306 (comment) this doesn’t look like a big issue or maybe there is some misunderstanding
    4. What was the reason to allow p2p connections to nodes that are not using default ports? Why would someone use non-default port? Two reasons that I could think of: Privacy and Security. If someone wants to use a port that looks like other service but is Bitcoin Core, isn’t that something we should encourage/allow?

    vasild commented at 1:40 pm on December 10, 2021:

    … comment above was marked as resolved even though …

    Which comment? #23542 (review) is still open.

    1. What is a BAD port for Bitcoin Core?

    Since this PR, if it gets merged, a bad port (for making automatic outgoing connections to) is one for which IsBadPort() returns true.

    1. Why browsers (bad ports) are referenced here because Bitcoin Core is not a browser …

    #23542 (review)

    1. What was the reason to allow p2p connections to nodes that are not using default ports?

    From this PR OP: “because connections over clearnet that involve port 8333 make it easy to detect, analyze, block or divert Bitcoin p2p traffic before the connection is even established (at TCP SYN time)”

    Why would someone use non-default port?

    See above, and also the reasons you state below:

    Two reasons that I could think of: Privacy and Security. If someone wants to use a port that looks like other service but is Bitcoin Core, isn’t that something we should encourage/allow?

    Yes. This is what the current PR aims to achieve.


    unknown commented at 6:51 pm on December 10, 2021:
    Replied here: #23542 (review)
  29. vasild force-pushed on Dec 10, 2021
  30. vasild commented at 1:25 pm on December 10, 2021: contributor
    0671bc5313...36bae788e1: address #23542 (review)
  31. jonatack commented at 2:00 pm on December 10, 2021: contributor
    ACK 36bae788e1c34261b108d57fc2ffff0954a33848
  32. DrahtBot added the label Needs rebase on Jan 6, 2022
  33. vasild force-pushed on Jan 6, 2022
  34. vasild commented at 5:12 pm on January 6, 2022: contributor

    36bae788e1...8f40ea6e45: rebase due to conflicts

    Invalidates ACK from @jonatack

  35. DrahtBot removed the label Needs rebase on Jan 6, 2022
  36. jonatack approved
  37. jonatack commented at 1:44 pm on January 7, 2022: contributor
    ACK 8f40ea6e4569ceea3b55e9dee94664f6c3c4bd9f per git range-diff 711ce2e 36bae78 8f40ea6 change since last review is rebase only
  38. wpeckr commented at 7:57 pm on January 9, 2022: none
    It might be worthwhile to add an option to just use the vanilla port for outgoing connections in the case that the node software is triggering abuse complaints on your own network by reaching out to things it can’t handshake with. Without an option to only consider 8333 as valid, you would need to use external tools to achieve the same, or shut down the software.
  39. sipa commented at 10:59 pm on January 9, 2022: member

    Concept ACK on moving away from the 8333-only policy.

    While this is purely client policy, I think it’s a pretty impactful for the network. It may be worth at least sending a mail to the bitcoin-dev list for discussion.

    The explanation of the bad ports in the current PR is pretty minimal and unclear, I think. I’d like to see those addressed (exactly why do we care about not connecting to some ports? I know there are links one can follow, but I feel it should be clearer in the documentation itself.

    As far as which ports are included in the bad ports list, I’d prefer to include too many over too little at this point. Effectively, right now every port except 8333 is a bad port, and we’re reducing the list to just the explicitly included ones. Reducing further is always possible later, but adding ones may be hard if people start relying on being able to certain ports.

    Also, being able to run Bitcoin nodes on well-known ports (particularly 443, https) would be the most useful way to hide traffic, but I think that’s a bit premature, and we should keep it in the bad ports list for now. With the work underway on BIP324 we may get encrypted P2P traffic, and with that, it should be (in a next step) be much easier to masquerade traffic as actual HTTPS running on port 443. Avoiding that port for now would make such a transition a lot easier.

    It might be worthwhile to add an option to just use the vanilla port for outgoing connections in the case that the node software is triggering abuse complaints on your own network by reaching out to things it can’t handshake with. @wpeckr I believe that’s exactly why certain ports are blacklisted (the whole “bad ports” discussion). I think it may be useful to permit providing a custom list for that.

  40. wpeckr commented at 4:40 am on January 10, 2022: none

    --vanilla-p2p-port-only is much easier than providing a custom blacklist, parsing or loading that from the configuration. With a blacklist to achieve this I need to include 2**16-1 entries to my bitcoin.conf.

    This should definitely go to the mailing list for discussion though, it seems to me like is a very significant change with unclear advantages; I don’t think it meaningfully improves censorship resistance enough to warrant it. Bitcoin’s traffic is always very obvious and it’s unlikely that’s ever going to be obscured, given it is almost entirely an open network where the participants advertise their sockets.

  41. sipa commented at 2:54 pm on January 10, 2022: member

    --vanilla-p2p-port-only is much easier than providing a custom blacklist, parsing or loading that from the configuration. With a blacklist to achieve this I need to include 2**16-1 entries to my bitcoin.conf.

    Is there a particular scenario you’re thinking of where you care about specifically only making connections to 8333? If there are particular services/ports you worry about angering, I think those should just be included in the bad ports list. Note that there are also non-Bitcoin Core clients on the network already which connect out to everything (including moderately aggressive crawlers), so all IP:port combinations rumoured on the network do get some traffic already.

    I don’t think it meaningfully improves censorship resistance enough to warrant it. Bitcoin’s traffic is always very obvious and it’s unlikely that’s ever going to be obscured, given it is almost entirely an open network where the participants advertise their sockets.

    I think that’s too black-and-white. Clearly, it is very hard to protect against targetted censorship attack with unbounded resources, but costs matter. Indiscriminately blocking port 8333 is extremely simple and effective right now. Needing to do packet inspection to detect the Bitcoin P2P traffic is more complex and costly, and will stop working if BIP324 gets adopted. Needing to update censoring rules based on what gets rumoured on the P2P network is even more complex, and can easily be triggered to block legitimate services too. Disguising traffic as HTTPS or another popular service is nontrivial but doable, I believe, and even harder to block reliably. Lastly, of course powerful attackers can also just try sybiling the network, or eclipsing specific nodes, but ideas like optional authentication can make that more detectable as well.

    Overall, I don’t want to claim that this is an easy problem, or that silver bullet solutions exist. But I do think that very meaningful improvements are possible, and all of them depend on at the very least not gratuitously revealing “Bitcoin node here!” by using port 8333.

    Yet, I agree this deserves wider discussion.

  42. wpeckr commented at 6:27 pm on January 10, 2022: none

    Is there a particular scenario you’re thinking of where you care about specifically only making connections to 8333?

    No, just if there is an issue caused by it, having a simple toggle to disable non-8333 ports seems trivial to implement, and may come in useful.

  43. unknown approved
  44. unknown commented at 9:43 pm on January 23, 2022: none

    tACK https://github.com/bitcoin/bitcoin/pull/23542/commits/8f40ea6e4569ceea3b55e9dee94664f6c3c4bd9f

    1. Would be great if we had functional test for this however I could not figure out a way to test it using regtest so not sure how would this work with test framework. I had asked question on SE which was answered by @sipa : https://bitcoin.stackexchange.com/questions/111957/automatic-outbound-connection-using-regtest-nodes
    2. Tried doing some tests on signet yesterday using v22.0 and PR branch: https://bitcoin-irc.chaincode.com/bitcoin-core-dev/2022-01-22#768549; sipa had also helped with some related question in IRC
    3. Wrote a PowerShell script and tested it on v22.0 and PR branch which bans all peers that are using default port. It works as expected and I could see one peer using port 3111 on signet: https://github.com/prayank23/bitcoin-ps-scripts/blob/main/Scripts/Node/ban_default_peers.ps1

    ℹ️ Anyone can run the PowerShell script. I had tested it on Fedora

    nit:

    1. Please write an email about this and share with bitcoin-dev mailing list subscribers
    2. We can avoid using ports used by browser, define ‘bad port’ for bitcoin core and create a list accordingly.
  45. ghost commented at 4:26 pm on January 31, 2022: none
    I had shared this pull request and related things in an email sent to bitcoin dev mailing list: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-January/019837.html
  46. RandyMcMillan commented at 3:34 am on February 1, 2022: contributor

    Deriving a “good list” based on difficulty

    If for example the difficulty is 26643185256535.46 We could parse the value into 4 and 5 digit values (removing the decimal) to get a list of values: 2664 6643 6431 4318 3185 1852 8525 5256 5653 6535 5354 3546 26643 etc…

    Basing these values on difficulty - the proposed good list would be in lock step over the network. The node could open and listen on each of these possible ports (excluding any values hard coded on a bad list) every new day UTC Time. If a threshold of other listeners (10-100?) are also listening on that port - that port value is marked as good. If it is not - it is purged from the potential candidates and the next port is tried. If no good candidates are found - the entire list is incremented by 1 and tried again.

    While network quality and availability may vary in different regions - we can use the difficulty. This gives flexibility to the “good list” based on local conditions. IMO a process like this is robust and dynamic. It also removes developers from making this decision.

  47. vasild commented at 9:57 am on February 1, 2022: contributor

    @RandyMcMillan, this PR and all the discussion is about whether to connect to a peer who listens on port X. Not whether to listen on port X. On which port to listen ourselves is a separate topic.

    Currently on which port to listen is statically configured by the user using the -bind= and -port arguments and is more or less constant - you do not want to change your listening port often or automatically because that may require adjusting your firewall to allow incoming connections to it and also, more importantly, your addr+port need some time to propagate to the network so that other peers are aware of it.

    But please, do not dilute this PR with discussion about on which port to listen.

  48. RandyMcMillan commented at 7:53 pm on February 1, 2022: contributor

    Concept ACK

    It seems impossible to know the reason a node is using a particular port - not sure why this is a debate. In fact - this should be a high priority change. (see off topic)

    To my previous comment - it would be useful to derive a list of alternate qualified ports for a user to select from, if circumstances dictated they could not use 8333. In a worst case scenario (or IBD) - all the user would need to know is the current difficulty - to have a predictable list of ports to use with a higher degree of certainty that multiple honest nodes would be using them (due to local network/political/whatever conditions). In a desperate situation the user would not want to eclipse themself unknowingly.

    A rolling port list may augment obfuscation and censorship resistance.

    No further off topic comments - my apologize.

  49. in src/init.cpp:450 in 8f40ea6e45 outdated
    446@@ -447,7 +447,7 @@ void SetupServerArgs(ArgsManager& argsman)
    447     argsman.AddArg("-peerbloomfilters", strprintf("Support filtering of blocks and transaction with bloom filters (default: %u)", DEFAULT_PEERBLOOMFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
    448     argsman.AddArg("-peerblockfilters", strprintf("Serve compact block filters to peers per BIP 157 (default: %u)", DEFAULT_PEERBLOCKFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
    449     argsman.AddArg("-permitbaremultisig", strprintf("Relay non-P2SH multisig (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
    450-    argsman.AddArg("-port=<port>", strprintf("Listen for connections on <port>. Nodes not using the default ports (default: %u, testnet: %u, signet: %u, regtest: %u) are unlikely to get incoming connections. Not relevant for I2P (see doc/i2p.md).", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), signetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
    451+    argsman.AddArg("-port=<port>", "Listen for connections on <port>. Not relevant for I2P (see doc/i2p.md).", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
    


    vasild commented at 11:42 am on February 3, 2022:
    I will revert this change because the original text will still be true even after this PR is released. It will be true for some time and will start becoming less true once this PR becomes widely used. The text should be removed then.
  50. vasild force-pushed on Feb 3, 2022
  51. vasild commented at 12:36 pm on February 3, 2022: contributor

    8f40ea6e45...794319bc77: add a formal definition of a “bad” port in doc/p2p-bad-ports.md together with an explanation why it is considered bad.

    Invalidates ACKs from @jonatack, @prayank23

  52. in doc/p2p-bad-ports.md:102 in 10a08ce771 outdated
     97+6666
     98+6667
     99+6668
    100+6669
    101+6697
    102+10080
    


    unknown commented at 6:00 pm on February 3, 2022:

    Added 4 spaces before each line to get code block and info about each port:

     0    1:     tcpmux
     1    7:     echo
     2    9:     discard
     3    11:    systat
     4    13:    daytime
     5    15:    netstat
     6    17:    qotd
     7    19:    chargen
     8    20:    ftp data
     9    21:    ftp access
    10    22:    ssh
    11    23:    telnet
    12    25:    smtp
    13    37:    time
    14    42:    name
    15    43:    nicname
    16    53:    domain
    17    69:    tftp
    18    77:    priv-rjs
    19    79:    finger
    20    87:    ttylink
    21    95:    supdup
    22    101:   hostname
    23    102:   iso-tsap
    24    103:   gppitnp
    25    104:   acr-nema
    26    109:   pop2
    27    110:   pop3
    28    111:   sunrpc
    29    113:   auth
    30    115:   sftp
    31    117:   uucp-path
    32    119:   nntp
    33    123:   NTP
    34    135:   loc-srv /epmap
    35    137:   netbios
    36    139:   netbios
    37    143:   imap2
    38    161:   snmp
    39    179:   BGP
    40    389:   ldap
    41    427:   SLP (Also used by Apple Filing Protocol)
    42    465:   smtp+ssl
    43    512:   print / exec
    44    513:   login
    45    514:   shell
    46    515:   printer
    47    526:   tempo
    48    530:   courier
    49    531:   chat
    50    532:   netnews
    51    540:   uucp
    52    548:   AFP (Apple Filing Protocol)
    53    554:   rtsp
    54    556:   remotefs
    55    563:   nntp+ssl
    56    587:   smtp (rfc6409)
    57    601:   syslog-conn (rfc3195)
    58    636:   ldap+ssl
    59    989:   ftps-data
    60    990:   ftps
    61    993:   ldap+ssl
    62    995:   pop3+ssl
    63    1719:  h323gatestat
    64    1720:  h323hostcall
    65    1723:  pptp
    66    2049:  nfs
    67    3659:  apple-sasl / PasswordServer
    68    4045:  lockd
    69    5060:  sip
    70    5061:  sips
    71    6000:  X11
    72    6566:  sane-port
    73    6665:  Alternate IRC [Apple addition]
    74    6666:  Alternate IRC [Apple addition]
    75    6667:  Standard IRC [Apple addition]
    76    6668:  Alternate IRC [Apple addition]
    77    6669:  Alternate IRC [Apple addition]
    78    6697:  IRC + TLS
    79    10080: Amanda
    

    jonatack commented at 3:38 pm on February 7, 2022:

    Added 4 spaces before each line to get code block and info about each port:

    Nice. @prayank23, consider using HTML details tags to hide long diffs in review comments, see https://github.com/bitcoin/bitcoin/pull/23542/files#r800765686 for an example.


    vasild commented at 1:44 pm on February 11, 2022:
    Done.
  53. in doc/p2p-bad-ports.md:114 in 10a08ce771 outdated
    104+For further information see:
    105+[pull/23306](https://github.com/bitcoin/bitcoin/pull/23306#issuecomment-947516736)
    106+[pull/23542](https://github.com/bitcoin/bitcoin/pull/23542)
    107+[fetch.spec.whatwg.org](https://fetch.spec.whatwg.org/#port-blocking)
    108+[chromium.googlesource.com](https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/net/base/port_util.cc)
    109+[hg.mozilla.org](https://hg.mozilla.org/mozilla-central/file/tip/netwerk/base/nsIOService.cpp)
    


    unknown commented at 6:15 pm on February 3, 2022:

    Added 2 spaces after each link for line break:

    0For further information see:
    1
    2[pull/23306](/bitcoin-bitcoin/23306/#issuecomment-947516736)  
    3[pull/23542](https://github.com/bitcoin/bitcoin/pull/23542)  
    4[fetch.spec.whatwg.org](https://fetch.spec.whatwg.org/#port-blocking)  
    5[chromium.googlesource.com](https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/net/base/port_util.cc)  
    6[hg.mozilla.org](https://hg.mozilla.org/mozilla-central/file/tip/netwerk/base/nsIOService.cpp)
    

    Sjors commented at 9:51 am on February 7, 2022:
    Trailing whitespace often gets removed by editors. This change would also trigger test/lint/lint-whitespace.sh. Maybe use bullet points or a blank line between items?

    jonatack commented at 3:39 pm on February 7, 2022:
    My editor highlights extra whitespace but sees only a line break here and test/lint/lint-whitespace.sh seems happy.

    vasild commented at 1:45 pm on February 11, 2022:
    Added empty lines.
  54. laanwj added this to the milestone 23.0 on Feb 3, 2022
  55. in src/netbase.cpp:835 in 794319bc77 outdated
    830+    case 6566:  // sane-port
    831+    case 6665:  // Alternate IRC [Apple addition]
    832+    case 6666:  // Alternate IRC [Apple addition]
    833+    case 6667:  // Standard IRC [Apple addition]
    834+    case 6668:  // Alternate IRC [Apple addition]
    835+    case 6669:  // Alternate IRC [Apple addition]
    


    kristapsk commented at 9:31 am on February 7, 2022:
    Guess this was copied from /etc/services from macOS? I think [Apple addition] in context of Bitcoin Core is redundant. For example, 6667 on Linux machines is just “Internet Relay Chat”.

    vasild commented at 1:46 pm on February 11, 2022:
    Removed [Apple addition].
  56. in src/init.cpp:1706 in 794319bc77 outdated
    1700@@ -1701,6 +1701,13 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
    1701         if (index == std::string::npos) {
    1702             if (Lookup(bind_arg, bind_addr, GetListenPort(), false)) {
    1703                 connOptions.vBinds.push_back(bind_addr);
    1704+                if (IsBadPort(bind_addr.GetPort())) {
    1705+                    InitWarning(strprintf(
    1706+                        _("-bind request to listen on port %u. This port is considered \"bad\" and "
    


    Sjors commented at 9:39 am on February 7, 2022:
    Maybe add “because it is typically used by SERVICE”.

    vasild commented at 2:02 pm on February 11, 2022:
    I think that would be an overkill. It would require getting the service name from the port somehow, like in your suggestion below. But then IsBadPort() would not be a suitable name anymore, it should be renamed to something like GetBadPortName() which would imply that the passed value is bad. Maybe IsBadPortAndIfYesThenReturnItsName() :-( I would Keep It Simple, Stupid. The names are now in doc/p2p-bad-ports.md which is mentioned in this message.

    laanwj commented at 5:41 pm on March 1, 2022:
    Agree that that would be overkill. The ports are well-known and if not it’s only a web search away.
  57. in src/netbase.cpp:753 in 794319bc77 outdated
    748@@ -749,3 +749,93 @@ void InterruptSocks5(bool interrupt)
    749 {
    750     interruptSocks5Recv = interrupt;
    751 }
    752+
    753+bool IsBadPort(uint16_t port)
    


    Sjors commented at 9:40 am on February 7, 2022:
    std::optional<string> IsBadPort(uint16_t port)

    vasild commented at 2:02 pm on February 11, 2022:
    See #23542 (review). Marking this as resolved as the discussion can continue there.
  58. in src/netbase.cpp:758 in 794319bc77 outdated
    753+bool IsBadPort(uint16_t port)
    754+{
    755+    /* Don't forget to update doc/p2p-bad-ports.md if you change this list. */
    756+
    757+    switch (port) {
    758+    case 1:     // tcpmux
    


    Sjors commented at 9:40 am on February 7, 2022:
    case 1: return "tcpmux";

    vasild commented at 2:02 pm on February 11, 2022:
    See #23542 (review). Marking this as resolved as the discussion can continue there.
  59. Sjors commented at 10:10 am on February 7, 2022: member

    In 10a08ce771dc08750a0e8dfe1d17f864284fb19b: the warning only shows when using -bind, not when using -port.

    Also, when the user has -printtoconsole=1 they’ll probably miss it, but we can deal with that later perhaps.

    You could add a TODO near the help text for -port that “Nodes not using the default ports are unlikely to get incoming connections” will no longer be true once this has been live for a while.

  60. in doc/p2p-bad-ports.md:21 in 794319bc77 outdated
    16+authentication are unlikely to be considered a malicious action,
    17+e.g. port 80 (http).
    18+
    19+Following is a list of "bad" ports which Bitcoin Core avoids when choosing a
    20+peer to connect to. If a node is listening on such a port, it will likely get
    21+less incoming connections.
    


    jonatack commented at 3:21 pm on February 7, 2022:

    This text could maybe be pithier and has a few grammar issues.

     0When Bitcoin Core automatically opens outgoing P2P connections, it chooses a
     1peer from the potential peers in `peers.dat` gossiped over the P2P network by
     2other peers.
     3
     4A malicious actor can gossip an address:port where no Bitcoin node is listening,
     5or one where a service is listening that is not related to the Bitcoin
     6network.  These may receive connection attempts from Bitcoin nodes.
     7
     8"Bad" ports are ones used by services which are usually not open to the public
     9and require authentication. A connection attempt to such a service by a Bitcoin
    10Core node may be considered a malicious action by a paranoid administrator. An
    11example for such a port is 22 (ssh). On the other hand, connection attempts to
    12public services that usually do not require authentication are unlikely to be
    13considered malicious, e.g. port 80 (http).
    14
    15Below is a list of "bad" ports which Bitcoin Core avoids when choosing a
    16peer to connect to. If a node is listening on such a port, it will likely
    17receive fewer incoming connections.
    

    vasild commented at 2:03 pm on February 11, 2022:
    Picked some of that, thanks!
  61. in src/netbase.cpp:755 in 794319bc77 outdated
    748@@ -749,3 +749,93 @@ void InterruptSocks5(bool interrupt)
    749 {
    750     interruptSocks5Recv = interrupt;
    751 }
    752+
    753+bool IsBadPort(uint16_t port)
    754+{
    755+    /* Don't forget to update doc/p2p-bad-ports.md if you change this list. */
    


    jonatack commented at 3:24 pm on February 7, 2022:

    Not sure if this should be a doxygen comment. You did update the doxygen in the declaration :+1:

    0    // Don't forget to update doc/p2p-bad-ports.md if you change this list.
    

    glozow commented at 5:11 pm on February 15, 2022:
    Question. Given that this code is nicely commented with ports’ corresponding services, and there is a maintenance cost to keeping the lists the same, why does the list need to be duplicated in two places?

    vasild commented at 2:23 pm on February 16, 2022:

    It is good for the user to be able to see the list of the ports and I think it would be too rough to refer the user to go to look into some .cpp file on line 753.

    The other way around would be to generate the .cpp file from the user-facing p2p-bad-ports.md but I think that would be an overkill, given that this list is not supposed to be updated often, if ever.


    stickies-v commented at 6:18 pm on February 16, 2022:

    I had the same consideration as glozow initially but agree that we shouldn’t point users to .cpp files, especially since the line number is variable over time.

    I also agree generating .cpp from .md is overkill - and it wouldn’t even guarantee that future contributions don’t just update one without the other I think? I think adding a test that parses the .md file and compares all ports could be an alternative, but personally I think that’s overkill too. There’s a clear reference to update the doc in IsBadPort, I think after this initial review any changes should be quite trivial to review.


    glozow commented at 10:09 am on February 17, 2022:
    Sure, makes sense
  62. in src/netbase.h:255 in 794319bc77 outdated
    246@@ -247,4 +247,13 @@ void InterruptSocks5(bool interrupt);
    247  */
    248 bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* auth, const Sock& socket);
    249 
    250+/**
    251+ * Determine if a port is "bad" from the perspective of attempting to connect
    252+ * to a node on that port.
    253+ * @see doc/p2p-bad-ports.md
    254+ * @param[in] port Port to check.
    255+ * @return true if the port is bad
    


    jonatack commented at 3:31 pm on February 7, 2022:

    nit, returns both true and false

    0 * [@returns](/bitcoin-bitcoin/contributor/returns/) whether the port is bad
    

    vasild commented at 2:03 pm on February 11, 2022:
    Done.
  63. jonatack commented at 3:34 pm on February 7, 2022: contributor

    Diff-review re-ACK 794319bc7787fb47f3de58f9526d33f9a7e90fea per git range-diff f7a3647 8f40ea6 794319b

    A few minor comments follow.

  64. jonatack commented at 3:43 pm on February 7, 2022: contributor

    Did you mean to drop this change in the latest push, and should doc/p2p-bad-ports.md be mentioned in the -port help?

    0-    argsman.AddArg("-port=<port>", strprintf("Listen for connections on <port>. Nodes not using the default ports (default: %u, testnet: %u, signet: %u, regtest: %u) are unlikely to get incoming connections. Not relevant for I2P (see doc/i2p.md).", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), signetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
    1+    argsman.AddArg("-port=<port>", "Listen for connections on <port>. Not relevant for I2P (see doc/i2p.md).", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
    
  65. vasild force-pushed on Feb 11, 2022
  66. vasild commented at 1:44 pm on February 11, 2022: contributor

    794319bc77...a13278afd0: rebase and address some suggestions

    the warning only shows when using -bind, not when using -port

    Good catch, fixed!

    You could add a TODO near the help text for -port

    Done.

    Did you mean to drop this change in the latest push…

    Yes, because that sentence will still be true after this PR is merged. It has to be removed later, not now. See the added TODO comment, suggested above.

  67. net: open p2p connections to nodes that listen on non-default ports
    By default, for mainnet, the p2p listening port is 8333. Bitcoin Core
    has a strong preference for only connecting to nodes that listen on that
    port.
    
    Remove that preference because connections over clearnet that involve
    port 8333 make it easy to detect, analyze, block or divert Bitcoin p2p
    traffic before the connection is even established (at TCP SYN time).
    
    For further justification see the OP of:
    https://github.com/bitcoin/bitcoin/pull/23306
    97208634b9
  68. net: add CServiceHash constructor so the caller can provide the salts
    This new constructor will be useful if we just want to hash a `CService`
    object without the two `GetRand()` calls (in `RelayAddress()` in a
    subsequent commit).
    2e38a0e686
  69. net: include the port when deciding a relay destination
    In `PeerManagerImpl::RelayAddress()` we used just the hash of the
    address that is being relayed to decide where to relay it to. Include
    the port in that hash, so that e.g. `1.1.1.1:5555` and `1.1.1.1:6666`
    get relayed to different peers. Those are two different, distinct
    services after all.
    d0abce9a50
  70. net: remove unused CNetAddr::GetHash() 36ee76d1af
  71. vasild force-pushed on Feb 11, 2022
  72. vasild commented at 2:23 pm on February 11, 2022: contributor
    a13278afd0...36ee76d1af: pet bogus lint warning src/init.cpp: Expected 0 argument(s) after format string but found 1 argument(s): strprintf(bad_port_warning, port_arg)
  73. unknown approved
  74. mzumsande commented at 4:24 pm on February 11, 2022: contributor

    One possible issue is that DNS seeds return IPs without port information (try e.g. dig seed.bitcoin.sipa.be), and bitcoind just adds the standard port when creating an address entry from the seeder data.

    That means that in the unlikely event that suddenly everyone switched to a non-default port after this is merged, the DNS seeds would become dysfunctional. I think that the seeder code wouldn’t mark peers with non-default ports as good and return them though, so at least it wouldn’t lead to conflicting entries with the standard port being advertised in addr relay.

    But it seems to me that we shouldn’t be too offensive in advertising the use of non-standard ports before a solution for the DNS seeds exists.

  75. vasild commented at 4:40 pm on February 11, 2022: contributor
    @mzumsande, if a DNS seed (e.g. seed.bitcoin.sipa.be) is listening on a non-default port, then it will be dysfunctional even without this PR.
  76. mzumsande commented at 4:51 pm on February 11, 2022: contributor
    @vasild: This is is not about the port the DNS seed itself listens on. The DNS seeder software has a crawler that connects to listening nodes of the network to check whether they are reachable, and returns a list of IPs (but not ports!) of reachable nodes to help new nodes find peers initially. It can’t include results from nodes listening on non-default ports in these responses.
  77. vasild commented at 4:57 pm on February 11, 2022: contributor
    uff, of course the seeder itself does not run a bitcoin node 🤦, sorry for the confusion (or it could, but that is not relevant)
  78. in src/net_processing.cpp:1781 in 36ee76d1af
    1774@@ -1775,8 +1775,10 @@ void PeerManagerImpl::RelayAddress(NodeId originator,
    1775     // Relay to a limited number of other nodes
    1776     // Use deterministic randomness to send to the same nodes for 24 hours
    1777     // at a time so the m_addr_knowns of the chosen nodes prevent repeats
    1778-    const uint64_t hashAddr{addr.GetHash()};
    1779-    const CSipHasher hasher{m_connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY).Write(hashAddr).Write((GetTime() + hashAddr) / (24 * 60 * 60))};
    1780+    const uint64_t hash_addr{CServiceHash(0, 0)(addr)};
    1781+    const CSipHasher hasher{m_connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY)
    1782+                                .Write(hash_addr)
    1783+                                .Write((GetTime() + hash_addr) / (24 * 60 * 60))};
    


    stickies-v commented at 10:55 pm on February 13, 2022:

    Since you’re touching this line, maybe now is a good time to phase out the deprecated GetTime()?

    0DEPRECATED
    1Use either GetTimeSeconds (not mockable) or GetTime<T> (mockable)
    

    vasild commented at 1:36 pm on February 15, 2022:

    I really like doing such changes in a separate commit. It looks like that a GetTime() -> GetTime<T>() replacement “cannot possibly break anything”. My experience is that once in 100 times, something gets affected by such “innocent” changes. And the last thing I want when investigating with e.g. git bisect is to stumble on one commit that combines a logical change + mechanical “innocent” replacement that requires extra effort to decouple (and revert).

    I will append a commit to use GetTime<T>() if retouching.


    jonatack commented at 1:45 pm on February 15, 2022:
    I agree. Best as a separate pull (or commit, but it’s unrelated to the change here).
  79. in src/net_processing.cpp:1778 in 36ee76d1af
    1774@@ -1775,8 +1775,10 @@ void PeerManagerImpl::RelayAddress(NodeId originator,
    1775     // Relay to a limited number of other nodes
    1776     // Use deterministic randomness to send to the same nodes for 24 hours
    1777     // at a time so the m_addr_knowns of the chosen nodes prevent repeats
    1778-    const uint64_t hashAddr{addr.GetHash()};
    1779-    const CSipHasher hasher{m_connman.GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY).Write(hashAddr).Write((GetTime() + hashAddr) / (24 * 60 * 60))};
    1780+    const uint64_t hash_addr{CServiceHash(0, 0)(addr)};
    


    stickies-v commented at 11:43 pm on February 13, 2022:
    This doesn’t seem like security-critical code, but maybe worth noting in the commit message that in addition to hashing the port we now use SipHash instead of SHA256? Since we apply rate limiting to relaying ADDR messages I don’t think this is performance critical either, so I suppose any performance changes should be negligible.

    vasild commented at 1:26 pm on February 15, 2022:

    I think the SipHash vs SHA256 is a detail that need not be put in the commit message. It is really not relevant here. I changed it because we already have the CServiceHash which uses SipHash.

    I played with bench_bitcoin and the SHA256_32b and SipHash_32b tests (the SipHash needs to be changed to bench.batch(32).unit("byte").run(... to print the same units - ns/byte). It looks like SipHash is about 7 times faster than the double-SHA256. But as you say, this code is not performance hot spot.

  80. in src/init.cpp:1751 in 36ee76d1af
    1742@@ -1730,6 +1743,15 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
    1743     // on any address - 0.0.0.0 (IPv4) and :: (IPv6).
    1744     connOptions.bind_on_any = args.GetArgs("-bind").empty() && args.GetArgs("-whitebind").empty();
    1745 
    1746+    // Emit a warning if a bad port is given to -port= but only if -bind and -whitebind are not
    1747+    // given, because if they are, then -port= is ignored.
    1748+    if (connOptions.bind_on_any && args.IsArgSet("-port")) {
    1749+        const uint16_t port_arg = args.GetIntArg("-port", 0);
    1750+        if (IsBadPort(port_arg)) {
    1751+            InitWarning(BadPortWarning("-port", port_arg));
    


    stickies-v commented at 0:30 am on February 14, 2022:

    I’m getting duplicated warnings in my console, is this on purpose?

    0...
    12022-02-14T00:27:34Z Warning: -port request to listen on port 587. This port is considered "bad" and thus it is unlikely that any Bitcoin Core peers connect to it. See doc/p2p-bad-ports.md for details and a full list.
    2Warning: -port request to listen on port 587. This port is considered "bad" and thus it is unlikely that any Bitcoin Core peers connect to it. See doc/p2p-bad-ports.md for details and a full list.
    32022-02-14T00:27:34Z Imported mempool transactions from disk: 0 succeeded, 0 failed, 0 expired, 0 already there, 0 waiting for initial broadcast
    4...
    

    unknown commented at 2:43 am on February 14, 2022:
    Is this in debug.log or terminal running bitcoind? If in terminal I think it’s expected and happens for a few other logs as well.

    jonatack commented at 11:01 am on February 14, 2022:
    Yes, the seeing the duplicated warning in the terminal output (not in the debug log file).

    stickies-v commented at 6:14 pm on February 14, 2022:
    Got it - this can be marked as resolved then.
  81. stickies-v approved
  82. stickies-v commented at 0:31 am on February 14, 2022: contributor
    tACK 36ee76d1a Left some very minor comments but nothing blocking - feel free to ignore.
  83. in doc/p2p-bad-ports.md:1 in 36ee76d1af
    0@@ -0,0 +1,114 @@
    1+When Bitcoin Core automatically opens outgoing P2P connections it chooses
    


    jonatack commented at 10:14 am on February 14, 2022:
    0When Bitcoin Core automatically opens outgoing P2P connections, it chooses
    
  84. in doc/p2p-bad-ports.md:3 in 36ee76d1af
    0@@ -0,0 +1,114 @@
    1+When Bitcoin Core automatically opens outgoing P2P connections it chooses
    2+a peer (address and port) from its list of potential peers. This list is
    3+populated with unchecked data, gossiped over the P2P network by other peers.
    


    jonatack commented at 10:15 am on February 14, 2022:
    0populated with unchecked data gossiped over the P2P network by other peers.
    

    (or s/data,/data that is/ or s/data,/data, which is/)

  85. in doc/p2p-bad-ports.md:20 in 36ee76d1af
    15+other hand, connection attempts to public services that usually do not require
    16+authentication are unlikely to be considered a malicious action,
    17+e.g. port 80 (http).
    18+
    19+Below is a list of "bad" ports which Bitcoin Core avoids when choosing a peer to
    20+connect to. If a node is listening on such a port, it will likely receive less
    


    jonatack commented at 10:15 am on February 14, 2022:

    “fewer” for countable quantities

    0connect to. If a node is listening on such a port, it will likely receive fewer
    

    jonatack commented at 3:22 pm on March 3, 2022:

    “fewer” for countable quantities

    Tucked these fixups into #24468.

  86. jonatack commented at 11:00 am on February 14, 2022: contributor

    ACK 36ee76d1afbb278500fc8aa01606ec933b52c17d

    Some minor grammar issues from my previous review subsist wrt the doc.

  87. glozow commented at 5:13 pm on February 15, 2022: member
    utACK 36ee76d1afbb278500fc8aa01606ec933b52c17d light code review, I’m not very familiar with this area of code
  88. Sjors commented at 10:27 am on February 17, 2022: member

    This is is not about the port the DNS seed itself listens on. The DNS seeder software has a crawler that connects to listening nodes of the network to check whether they are reachable, and returns a list of IPs (but not ports!) of reachable nodes to help new nodes find peers initially. It can’t include results from nodes listening on non-default ports in these responses.

    For now it seems fine if DNS seeds only return nodes that listen on port 8333. As soon as your node finds a single peer, it will get nodes at other ports. We could later have port.someseed.com return nodes for port, or something like that.

    This would be relevant for nodes that, during their bootstrapping phase, are not able to connect to anything on port 8333. In that case the first place to start might 80.someseed.com.

    If blocking 8333 becomes a very common problem (as opposed to just annoying firewalls that only allow port 80 and 443), I would not be surprised if DNS seed domains are blocked by most ISP’s too in that dystopia.

  89. laanwj commented at 8:32 am on March 2, 2022: member
    Concept and light code review ACK 36ee76d1afbb278500fc8aa01606ec933b52c17d
  90. laanwj merged this on Mar 2, 2022
  91. laanwj closed this on Mar 2, 2022

  92. vasild deleted the branch on Mar 2, 2022
  93. mzumsande commented at 2:15 pm on March 2, 2022: contributor
    Should there be a release note for this?
  94. fanquake added the label Needs release note on Mar 2, 2022
  95. sidhujag referenced this in commit 76d2b6523d on Mar 2, 2022
  96. laanwj referenced this in commit f6d335e828 on Mar 7, 2022
  97. vasild commented at 3:36 pm on March 7, 2022: contributor
  98. sidhujag referenced this in commit c561f58099 on Mar 7, 2022
  99. fanquake removed the label Needs release note on Sep 15, 2022
  100. fanquake commented at 3:18 pm on September 15, 2022: member
    This was part of 23.0 and got a release note. Removing “Needs release note”.
  101. Fabcien referenced this in commit af4f12ab06 on Oct 21, 2022
  102. delta1 referenced this in commit 1dc6ad6ea9 on Jul 3, 2023
  103. bitcoin locked this on Sep 15, 2023

github-metadata-mirror

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-21 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me