Skip to content

Commit

Permalink
Fix endpoint undefined situation
Browse files Browse the repository at this point in the history
  • Loading branch information
beef9999 committed Mar 2, 2024
1 parent 47de87b commit 547c30d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 0 additions & 2 deletions net/kernel_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1043,8 +1043,6 @@ EndPoint::EndPoint(const char* _ep) {
// Detect IPv6 or IPv4
estring ip_str = ep[pos - 1] == ']' ? ep.substr(1, pos - 2) : ep.substr(0, pos);
auto ip = IPAddr(ip_str.c_str());
if (ip.undefined())
return;
auto port_str = ep.substr(pos + 1);
if (!port_str.all_digits())
return;
Expand Down
7 changes: 7 additions & 0 deletions net/test/test-ipv6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ TEST(ipv6, endpoint) {
EXPECT_FALSE(c.undefined());
c = photon::net::EndPoint("[::1]:8888");
EXPECT_FALSE(c.undefined());
c = photon::net::EndPoint("0.0.0.0:8888");
EXPECT_TRUE(c.undefined());
EXPECT_EQ(8888, c.port);
c = photon::net::EndPoint("::", 8888);
EXPECT_TRUE(!c.undefined());
EXPECT_TRUE(!c.is_ipv4());
EXPECT_EQ(8888, c.port);
}

TEST(ipv6, addr) {
Expand Down

0 comments on commit 547c30d

Please sign in to comment.