Skip to content

Commit 58b1a65

Browse files
jloppfanquake
authored andcommitted
add more bad p2p ports
Github-Pull: #32826 Rebased-From: 6967e8e
1 parent f85d41c commit 58b1a65

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
@@ -861,10 +861,14 @@ bool IsBadPort(uint16_t port)
861861
case 1720: // h323hostcall
862862
case 1723: // pptp
863863
case 2049: // nfs
864+
case 3306: // MySQL
865+
case 3389: // RDP / Windows Remote Desktop
864866
case 3659: // apple-sasl / PasswordServer
865867
case 4045: // lockd
866868
case 5060: // sip
867869
case 5061: // sips
870+
case 5432: // PostgreSQL
871+
case 5900: // VNC
868872
case 6000: // X11
869873
case 6566: // sane-port
870874
case 6665: // Alternate IRC
@@ -874,6 +878,7 @@ bool IsBadPort(uint16_t port)
874878
case 6669: // Alternate IRC
875879
case 6697: // IRC + TLS
876880
case 10080: // Amanda
881+
case 27017: // MongoDB
877882
return true;
878883
}
879884
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)