Skip to content

Commit fb2c16c

Browse files
committed
Merge bitcoin/bitcoin#32826: p2p: add more bad ports
6967e8e add more bad p2p ports (Jameson Lopp) Pull request description: Add a few more ports used by extremely well adopted services that require authentication and really ought not be used by bitcoin nodes for p2p traffic. ACKs for top commit: Sjors: utACK 6967e8e l0rinc: ACK 6967e8e glozow: ACK 6967e8e Tree-SHA512: bbe86aef2be9727338712ded8f90227f5d12f633ab5d324c8907c01173945d1c4d9899e05565f78688842bbf5ebb010d22173969e4168ea08d4e33f01fe9569d
2 parents f5f3e1f + 6967e8e commit fb2c16c

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

doc/p2p-bad-ports.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,14 @@ incoming connections.
8787
1720: h323hostcall
8888
1723: pptp
8989
2049: nfs
90+
3306: MySQL
91+
3389: RDP / Windows Remote Desktop
9092
3659: apple-sasl / PasswordServer
9193
4045: lockd
9294
5060: sip
9395
5061: sips
96+
5432: PostgreSQL
97+
5900: VNC
9498
6000: X11
9599
6566: sane-port
96100
6665: Alternate IRC
@@ -100,6 +104,7 @@ incoming connections.
100104
6669: Alternate IRC
101105
6697: IRC + TLS
102106
10080: Amanda
107+
27017: MongoDB
103108

104109
For further information see:
105110

src/netbase.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,14 @@ bool IsBadPort(uint16_t port)
920920
case 1720: // h323hostcall
921921
case 1723: // pptp
922922
case 2049: // nfs
923+
case 3306: // MySQL
924+
case 3389: // RDP / Windows Remote Desktop
923925
case 3659: // apple-sasl / PasswordServer
924926
case 4045: // lockd
925927
case 5060: // sip
926928
case 5061: // sips
929+
case 5432: // PostgreSQL
930+
case 5900: // VNC
927931
case 6000: // X11
928932
case 6566: // sane-port
929933
case 6665: // Alternate IRC
@@ -933,6 +937,7 @@ bool IsBadPort(uint16_t port)
933937
case 6669: // Alternate IRC
934938
case 6697: // IRC + TLS
935939
case 10080: // Amanda
940+
case 27017: // MongoDB
936941
return true;
937942
}
938943
return false;

src/test/netbase_tests.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <util/translation.h>
1515

1616
#include <string>
17+
#include <numeric>
1718

1819
#include <boost/test/unit_test.hpp>
1920

@@ -603,14 +604,10 @@ BOOST_AUTO_TEST_CASE(isbadport)
603604
BOOST_CHECK(!IsBadPort(443));
604605
BOOST_CHECK(!IsBadPort(8333));
605606

606-
// Check all ports, there must be 80 bad ports in total.
607-
size_t total_bad_ports{0};
608-
for (uint16_t port = std::numeric_limits<uint16_t>::max(); port > 0; --port) {
609-
if (IsBadPort(port)) {
610-
++total_bad_ports;
611-
}
612-
}
613-
BOOST_CHECK_EQUAL(total_bad_ports, 80);
607+
// Check all possible ports and ensure we only flag the expected amount as bad
608+
std::list<int> ports(std::numeric_limits<uint16_t>::max());
609+
std::iota(ports.begin(), ports.end(), 1);
610+
BOOST_CHECK_EQUAL(std::ranges::count_if(ports, IsBadPort), 85);
614611
}
615612

616613
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)