Skip to content

Commit 1c145de

Browse files
author
babenko
committed
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
1 parent c34ff41 commit 1c145de

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

yt/yt/core/net/address.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,13 @@ bool TIP6Address::FromString(TStringBuf str, TIP6Address* address)
709709
return true;
710710
}
711711

712+
bool TIP6Address::IsMtn() const
713+
{
714+
static const auto BackboneNetwork = TIP6Network::FromString("2a02:6b8:c00::/40");
715+
static const auto FastboneNetwork = TIP6Network::FromString("2a02:6b8:fc00::/40");
716+
return BackboneNetwork.Contains(*this) || FastboneNetwork.Contains(*this);
717+
}
718+
712719
void FormatValue(TStringBuilderBase* builder, const TIP6Address& address, TStringBuf /*spec*/)
713720
{
714721
const auto* parts = reinterpret_cast<const ui16*>(address.GetRawBytes());
@@ -1187,7 +1194,7 @@ TMtnAddress& TMtnAddress::SetHost(ui64 host)
11871194
return *this;
11881195
}
11891196

1190-
const TIP6Address& TMtnAddress::ToIP6Address() const
1197+
TIP6Address TMtnAddress::ToIP6Address() const
11911198
{
11921199
return Address_;
11931200
}

yt/yt/core/net/address.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class TIP6Address
123123
const ui32* GetRawDWords() const;
124124
ui32* GetRawDWords();
125125

126+
bool IsMtn() const;
127+
126128
private:
127129
std::array<ui8, ByteSize> Raw_ = {};
128130
};
@@ -226,7 +228,6 @@ class TMtnAddress
226228
{
227229
public:
228230
TMtnAddress() = default;
229-
230231
TMtnAddress(TIP6Address address);
231232

232233
ui64 GetPrefix() const;
@@ -241,11 +242,10 @@ class TMtnAddress
241242
ui64 GetHost() const;
242243
TMtnAddress& SetHost(ui64 host);
243244

244-
const TIP6Address& ToIP6Address() const;
245+
TIP6Address ToIP6Address() const;
245246

246247
private:
247248
ui64 GetBytesRangeValue(int leftIndex, int rightIndex) const;
248-
249249
void SetBytesRangeValue(int leftIndex, int rightIndex, ui64 value);
250250

251251
static constexpr int HostOffsetInBytes = 0;

yt/yt/core/net/unittests/network_address_ut.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,16 @@ TEST(TIP6AddressTest, ToStringFromStringRandom)
325325
}
326326
}
327327

328-
TEST(TMtnAddressTest, SimpleTest)
328+
TEST(TIP6AddressTest, IsMtn)
329+
{
330+
EXPECT_TRUE(TIP6Address::FromString("2a02:6b8:c23:130:0:4397:571f:0").IsMtn());
331+
EXPECT_TRUE(TIP6Address::FromString("2a02:6b8:fc00:c21b:0:4397:ead:0").IsMtn());
332+
EXPECT_FALSE(TIP6Address::FromString("fe80::5054:ff:fe12:3456").IsMtn());
333+
}
334+
335+
////////////////////////////////////////////////////////////////////////////////
336+
337+
TEST(TMtnAddressTest, Simple)
329338
{
330339
TMtnAddress address(TIP6Address::FromString("1361:24ad:4326:bda1:8432:a3fe:3f6c:4b38"));
331340
EXPECT_EQ(address.GetPrefix(), 0x136124ad43u);
@@ -353,7 +362,7 @@ TEST(TMtnAddressTest, SimpleTest)
353362

354363
////////////////////////////////////////////////////////////////////////////////
355364

356-
TEST(InferYPCluster, ValidFqdns)
365+
TEST(TInferYPClusterTest, ValidFqdns)
357366
{
358367
TString gencfgHostName = "sas1-5535-9d7.sas-test.yp.gencfg-c.yandex.net";
359368
TString ypHostName = "noqpmfiudzbb4hvs.man.yp-c.yandex.net";
@@ -362,7 +371,7 @@ TEST(InferYPCluster, ValidFqdns)
362371
EXPECT_EQ(InferYPClusterFromHostName(ypHostName), "man");
363372
}
364373

365-
TEST(InferYPCluster, InvalidFqdn)
374+
TEST(TInferYPClusterTest, InvalidFqdn)
366375
{
367376
TString hostName = "noqpmfiudzbb4hvs..yp-c.yandex.net";
368377

@@ -372,9 +381,7 @@ TEST(InferYPCluster, InvalidFqdn)
372381
EXPECT_EQ(InferYPClusterFromHostName("yandex.net"), std::nullopt);
373382
}
374383

375-
////////////////////////////////////////////////////////////////////////////////
376-
377-
TEST(InferYTCluster, ClusterUrls)
384+
TEST(TInferYPClusterTest, ClusterUrls)
378385
{
379386
EXPECT_EQ(InferYTClusterFromClusterUrl("hume"), "hume");
380387
EXPECT_EQ(InferYTClusterFromClusterUrl("http://yp-sas.yt.yandex.net"), "yp-sas");

0 commit comments

Comments
 (0)