Skip to content

Commit a2a8b1a

Browse files
authored
Allow to set "force tcp" and "keep-socket" options for dns resolver. (ydb-platform#4123)
1 parent c7d8845 commit a2a8b1a

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

ydb/core/driver_lib/run/kikimr_services_initializers.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,8 @@ void TBasicServicesInitializer::InitializeServices(NActors::TActorSystemSetup* s
602602

603603
NDnsResolver::TOnDemandDnsResolverOptions resolverOptions;
604604
resolverOptions.MonCounters = GetServiceCounters(counters, "utils")->GetSubgroup("subsystem", "dns_resolver");
605+
resolverOptions.ForceTcp = nsConfig.GetForceTcp();
606+
resolverOptions.KeepSocket = nsConfig.GetKeepSocket();
605607
IActor *resolver = NDnsResolver::CreateOnDemandDnsResolver(resolverOptions);
606608

607609
setup->LocalServices.emplace_back(

ydb/core/protos/config.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ message TStaticNameserviceConfig {
158158
repeated string AcceptUUID = 3;
159159
optional bool SuppressVersionCheck = 4;
160160
optional ENameserviceType Type = 5;
161+
optional bool KeepSocket = 6 [default = true];
162+
optional bool ForceTcp = 7 [default = false];
161163
}
162164

163165
message TDynamicNameserviceConfig {

ydb/library/actors/dnsresolver/dnsresolver.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,13 @@ namespace NDnsResolver {
172172
memset(&options, 0, sizeof(options));
173173
int optmask = 0;
174174

175-
options.flags = ARES_FLAG_STAYOPEN;
175+
if (Options.ForceTcp) {
176+
options.flags |= ARES_FLAG_USEVC;
177+
}
178+
if (Options.KeepSocket) {
179+
options.flags |= ARES_FLAG_STAYOPEN;
180+
}
181+
176182
optmask |= ARES_OPT_FLAGS;
177183

178184
options.sock_state_cb = &TThis::SockStateCallback;

ydb/library/actors/dnsresolver/dnsresolver.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ namespace NDnsResolver {
8989
int Attempts = 2;
9090
// Optional list of custom dns servers (ip.v4[:port], ip::v6 or [ip::v6]:port format)
9191
TVector<TString> Servers;
92+
// Keep soket open between dns requests
93+
bool KeepSocket = true;
94+
// Force tcp to perform dns requests
95+
bool ForceTcp = false;
9296
};
9397

9498
IActor* CreateSimpleDnsResolver(TSimpleDnsResolverOptions options = TSimpleDnsResolverOptions());

0 commit comments

Comments
 (0)