aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbabenko <babenko@yandex-team.com>2024-10-07 15:19:25 +0300
committerbabenko <babenko@yandex-team.com>2024-10-07 15:30:30 +0300
commit1c145de846055758e1cf1a78a53d9b06ecf4e697 (patch)
treeff4ca99a67593f7afc5855acc356fcff62350818
parentc34ff415b4a1bf62ccc797637adcb0ac6f79d9aa (diff)
downloadydb-1c145de846055758e1cf1a78a53d9b06ecf4e697.tar.gz
YT-21317: Introduce cache_key_mode
### Changelog entry Type: feature Component: proxy Add cache_key_mode to control the granularity of credential caching. commit_hash:1f185fd948ee1c4d7dcd65c757425b8e88794424
-rw-r--r--yt/yt/core/net/address.cpp9
-rw-r--r--yt/yt/core/net/address.h6
-rw-r--r--yt/yt/core/net/unittests/network_address_ut.cpp19
3 files changed, 24 insertions, 10 deletions
diff --git a/yt/yt/core/net/address.cpp b/yt/yt/core/net/address.cpp
index 40107c3278..c08fb94226 100644
--- a/yt/yt/core/net/address.cpp
+++ b/yt/yt/core/net/address.cpp
@@ -709,6 +709,13 @@ bool TIP6Address::FromString(TStringBuf str, TIP6Address* address)
return true;
}
+bool TIP6Address::IsMtn() const
+{
+ static const auto BackboneNetwork = TIP6Network::FromString("2a02:6b8:c00::/40");
+ static const auto FastboneNetwork = TIP6Network::FromString("2a02:6b8:fc00::/40");
+ return BackboneNetwork.Contains(*this) || FastboneNetwork.Contains(*this);
+}
+
void FormatValue(TStringBuilderBase* builder, const TIP6Address& address, TStringBuf /*spec*/)
{
const auto* parts = reinterpret_cast<const ui16*>(address.GetRawBytes());
@@ -1187,7 +1194,7 @@ TMtnAddress& TMtnAddress::SetHost(ui64 host)
return *this;
}
-const TIP6Address& TMtnAddress::ToIP6Address() const
+TIP6Address TMtnAddress::ToIP6Address() const
{
return Address_;
}
diff --git a/yt/yt/core/net/address.h b/yt/yt/core/net/address.h
index 6f77b1b65f..6f507b2900 100644
--- a/yt/yt/core/net/address.h
+++ b/yt/yt/core/net/address.h
@@ -123,6 +123,8 @@ public:
const ui32* GetRawDWords() const;
ui32* GetRawDWords();
+ bool IsMtn() const;
+
private:
std::array<ui8, ByteSize> Raw_ = {};
};
@@ -226,7 +228,6 @@ class TMtnAddress
{
public:
TMtnAddress() = default;
-
TMtnAddress(TIP6Address address);
ui64 GetPrefix() const;
@@ -241,11 +242,10 @@ public:
ui64 GetHost() const;
TMtnAddress& SetHost(ui64 host);
- const TIP6Address& ToIP6Address() const;
+ TIP6Address ToIP6Address() const;
private:
ui64 GetBytesRangeValue(int leftIndex, int rightIndex) const;
-
void SetBytesRangeValue(int leftIndex, int rightIndex, ui64 value);
static constexpr int HostOffsetInBytes = 0;
diff --git a/yt/yt/core/net/unittests/network_address_ut.cpp b/yt/yt/core/net/unittests/network_address_ut.cpp
index 0c2e463516..10ae29d1f1 100644
--- a/yt/yt/core/net/unittests/network_address_ut.cpp
+++ b/yt/yt/core/net/unittests/network_address_ut.cpp
@@ -325,7 +325,16 @@ TEST(TIP6AddressTest, ToStringFromStringRandom)
}
}
-TEST(TMtnAddressTest, SimpleTest)
+TEST(TIP6AddressTest, IsMtn)
+{
+ EXPECT_TRUE(TIP6Address::FromString("2a02:6b8:c23:130:0:4397:571f:0").IsMtn());
+ EXPECT_TRUE(TIP6Address::FromString("2a02:6b8:fc00:c21b:0:4397:ead:0").IsMtn());
+ EXPECT_FALSE(TIP6Address::FromString("fe80::5054:ff:fe12:3456").IsMtn());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+TEST(TMtnAddressTest, Simple)
{
TMtnAddress address(TIP6Address::FromString("1361:24ad:4326:bda1:8432:a3fe:3f6c:4b38"));
EXPECT_EQ(address.GetPrefix(), 0x136124ad43u);
@@ -353,7 +362,7 @@ TEST(TMtnAddressTest, SimpleTest)
////////////////////////////////////////////////////////////////////////////////
-TEST(InferYPCluster, ValidFqdns)
+TEST(TInferYPClusterTest, ValidFqdns)
{
TString gencfgHostName = "sas1-5535-9d7.sas-test.yp.gencfg-c.yandex.net";
TString ypHostName = "noqpmfiudzbb4hvs.man.yp-c.yandex.net";
@@ -362,7 +371,7 @@ TEST(InferYPCluster, ValidFqdns)
EXPECT_EQ(InferYPClusterFromHostName(ypHostName), "man");
}
-TEST(InferYPCluster, InvalidFqdn)
+TEST(TInferYPClusterTest, InvalidFqdn)
{
TString hostName = "noqpmfiudzbb4hvs..yp-c.yandex.net";
@@ -372,9 +381,7 @@ TEST(InferYPCluster, InvalidFqdn)
EXPECT_EQ(InferYPClusterFromHostName("yandex.net"), std::nullopt);
}
-////////////////////////////////////////////////////////////////////////////////
-
-TEST(InferYTCluster, ClusterUrls)
+TEST(TInferYPClusterTest, ClusterUrls)
{
EXPECT_EQ(InferYTClusterFromClusterUrl("hume"), "hume");
EXPECT_EQ(InferYTClusterFromClusterUrl("http://yp-sas.yt.yandex.net"), "yp-sas");