Commit 04ff4676 authored by Kenton Varda's avatar Kenton Varda

Fix Harris' review comments.

parent 81b9bccc
...@@ -501,7 +501,7 @@ KJ_TEST("NetworkFilter") { ...@@ -501,7 +501,7 @@ KJ_TEST("NetworkFilter") {
_::NetworkFilter filter({"public"}, {}, base); _::NetworkFilter filter({"public"}, {}, base);
KJ_EXPECT(allowed4(filter, "8.8.8.8")); KJ_EXPECT(allowed4(filter, "8.8.8.8"));
KJ_EXPECT(!allowed4(base, "240.1.2.3")); KJ_EXPECT(!allowed4(filter, "240.1.2.3"));
KJ_EXPECT(!allowed4(filter, "192.168.0.1")); KJ_EXPECT(!allowed4(filter, "192.168.0.1"));
KJ_EXPECT(!allowed4(filter, "10.1.2.3")); KJ_EXPECT(!allowed4(filter, "10.1.2.3"));
...@@ -518,7 +518,7 @@ KJ_TEST("NetworkFilter") { ...@@ -518,7 +518,7 @@ KJ_TEST("NetworkFilter") {
_::NetworkFilter filter({"private"}, {"local"}, base); _::NetworkFilter filter({"private"}, {"local"}, base);
KJ_EXPECT(!allowed4(filter, "8.8.8.8")); KJ_EXPECT(!allowed4(filter, "8.8.8.8"));
KJ_EXPECT(!allowed4(base, "240.1.2.3")); KJ_EXPECT(!allowed4(filter, "240.1.2.3"));
KJ_EXPECT(allowed4(filter, "192.168.0.1")); KJ_EXPECT(allowed4(filter, "192.168.0.1"));
KJ_EXPECT(allowed4(filter, "10.1.2.3")); KJ_EXPECT(allowed4(filter, "10.1.2.3"));
...@@ -535,7 +535,7 @@ KJ_TEST("NetworkFilter") { ...@@ -535,7 +535,7 @@ KJ_TEST("NetworkFilter") {
_::NetworkFilter filter({"1.0.0.0/8", "1.2.3.0/24"}, {"1.2.0.0/16", "1.2.3.4/32"}, base); _::NetworkFilter filter({"1.0.0.0/8", "1.2.3.0/24"}, {"1.2.0.0/16", "1.2.3.4/32"}, base);
KJ_EXPECT(!allowed4(filter, "8.8.8.8")); KJ_EXPECT(!allowed4(filter, "8.8.8.8"));
KJ_EXPECT(!allowed4(base, "240.1.2.3")); KJ_EXPECT(!allowed4(filter, "240.1.2.3"));
KJ_EXPECT(allowed4(filter, "1.0.0.1")); KJ_EXPECT(allowed4(filter, "1.0.0.1"));
KJ_EXPECT(!allowed4(filter, "1.2.2.1")); KJ_EXPECT(!allowed4(filter, "1.2.2.1"));
......
...@@ -469,12 +469,12 @@ NetworkFilter::NetworkFilter(ArrayPtr<const StringPtr> allow, ArrayPtr<const Str ...@@ -469,12 +469,12 @@ NetworkFilter::NetworkFilter(ArrayPtr<const StringPtr> allow, ArrayPtr<const Str
if (rule == "local") { if (rule == "local") {
denyCidrs.addAll(localCidrs()); denyCidrs.addAll(localCidrs());
} else if (rule == "network") { } else if (rule == "network") {
KJ_FAIL_REQUIRE("don't deny 'network', allow 'local' isntead"); KJ_FAIL_REQUIRE("don't deny 'network', allow 'local' instead");
} else if (rule == "private") { } else if (rule == "private") {
denyCidrs.addAll(privateCidrs()); denyCidrs.addAll(privateCidrs());
} else if (rule == "public") { } else if (rule == "public") {
// Tricky: What if we allow 'network' and deny 'public'? // Tricky: What if we allow 'network' and deny 'public'?
KJ_FAIL_REQUIRE("don't deny 'public', allow 'private' isntead"); KJ_FAIL_REQUIRE("don't deny 'public', allow 'private' instead");
} else if (rule == "unix") { } else if (rule == "unix") {
allowUnix = false; allowUnix = false;
} else if (rule == "unix-abstract") { } else if (rule == "unix-abstract") {
......
...@@ -323,7 +323,7 @@ public: ...@@ -323,7 +323,7 @@ public:
virtual Own<Network> restrictPeers( virtual Own<Network> restrictPeers(
kj::ArrayPtr<const kj::StringPtr> allow, kj::ArrayPtr<const kj::StringPtr> allow,
kj::ArrayPtr<const kj::StringPtr> deny = nullptr) KJ_WARN_UNUSED_RESULT = 0; kj::ArrayPtr<const kj::StringPtr> deny = nullptr) KJ_WARN_UNUSED_RESULT = 0;
// Constructs a new Network instance wrappingc this one which restricts which peer addresses are // Constructs a new Network instance wrapping this one which restricts which peer addresses are
// permitted (both for outgoing and incoming connections). // permitted (both for outgoing and incoming connections).
// //
// Communication will be allowed only with peers whose addresses match one of the patterns // Communication will be allowed only with peers whose addresses match one of the patterns
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment