Browse Source

reworked ip_filter to ipmath

zheglov 2 years ago
parent
commit
95d4076add
2 changed files with 9 additions and 1 deletions
  1. 1 1
      library/cpp/ipmath/ipmath.cpp
  2. 8 0
      library/cpp/ipmath/ipmath_ut.cpp

+ 1 - 1
library/cpp/ipmath/ipmath.cpp

@@ -135,7 +135,7 @@ TIpAddressRange::TIpAddressRangeBuilder& TIpAddressRange::TIpAddressRangeBuilder
 
 TIpAddressRange::TIpAddressRangeBuilder& TIpAddressRange::TIpAddressRangeBuilder::To(TIpv6Address to) {
     Y_ENSURE_EX(IsValid(to), TInvalidIpRangeException() << "Address " << to.ToString() << " is invalid");
-    Start_ = to;
+    End_ = to;
     return *this;
 }
 

+ 8 - 0
library/cpp/ipmath/ipmath_ut.cpp

@@ -188,6 +188,14 @@ public:
         ASSERT_THAT(range.Size(), Eq(256));
     }
 
+    void IpRangeFromIpv4BuilderFromTIpv6Address() {
+        const auto s = TIpv6Address::FromString("192.168.0.0");
+        const auto e = TIpv6Address::FromString("192.168.0.255");
+        auto range = TIpAddressRange::From(s).To(e).Build();
+
+        ASSERT_THAT(range.Size(), Eq(256));
+    }
+
     void IpRangeFromInvalidIpv4() {
         auto build = [] (auto from, auto to) {
             return TIpAddressRange::From(from).To(to).Build();