Skip to content

Commit

Permalink
treat CGNAT address range as local IPs
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn authored and Chocobo1 committed Oct 11, 2023
1 parent d28ee4e commit eef94a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* back-port fix last_upload and last_download resume data fields to use posix time
* treat CGNAT address range as local IPs

1.2.19 released

Expand Down
4 changes: 3 additions & 1 deletion src/broadcast_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ namespace libtorrent {
|| (ip & 0xfff00000) == 0xac100000 // 172.16.x.x
|| (ip & 0xffff0000) == 0xc0a80000 // 192.168.x.x
|| (ip & 0xffff0000) == 0xa9fe0000 // 169.254.x.x
|| (ip & 0xff000000) == 0x7f000000); // 127.x.x.x
|| (ip & 0xff000000) == 0x7f000000 // 127.x.x.x
|| (ip & 0xffc00000) == 0x64400000 // 100.64.0.0/10
);
}

// TODO: this function is pointless
Expand Down
4 changes: 4 additions & 0 deletions test/test_enum_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ TORRENT_TEST(is_local)
TEST_CHECK(!ec);
TEST_CHECK(is_local(address::from_string("10.1.1.56", ec)));
TEST_CHECK(!ec);
TEST_CHECK(is_local(address::from_string("100.64.0.0", ec)));
TEST_CHECK(!ec);
TEST_CHECK(is_local(address::from_string("100.127.255.255", ec)));
TEST_CHECK(!ec);
TEST_CHECK(!is_local(address::from_string("14.14.251.63", ec)));
TEST_CHECK(!ec);
}
Expand Down

0 comments on commit eef94a7

Please sign in to comment.