Skip to content

Commit

Permalink
Allow to set "force tcp" and "keep-socket" options for dns resolver. (y…
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherednik authored Apr 26, 2024
1 parent c7d8845 commit a2a8b1a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ydb/core/driver_lib/run/kikimr_services_initializers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ void TBasicServicesInitializer::InitializeServices(NActors::TActorSystemSetup* s

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

setup->LocalServices.emplace_back(
Expand Down
2 changes: 2 additions & 0 deletions ydb/core/protos/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ message TStaticNameserviceConfig {
repeated string AcceptUUID = 3;
optional bool SuppressVersionCheck = 4;
optional ENameserviceType Type = 5;
optional bool KeepSocket = 6 [default = true];
optional bool ForceTcp = 7 [default = false];
}

message TDynamicNameserviceConfig {
Expand Down
8 changes: 7 additions & 1 deletion ydb/library/actors/dnsresolver/dnsresolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,13 @@ namespace NDnsResolver {
memset(&options, 0, sizeof(options));
int optmask = 0;

options.flags = ARES_FLAG_STAYOPEN;
if (Options.ForceTcp) {
options.flags |= ARES_FLAG_USEVC;
}
if (Options.KeepSocket) {
options.flags |= ARES_FLAG_STAYOPEN;
}

optmask |= ARES_OPT_FLAGS;

options.sock_state_cb = &TThis::SockStateCallback;
Expand Down
4 changes: 4 additions & 0 deletions ydb/library/actors/dnsresolver/dnsresolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ namespace NDnsResolver {
int Attempts = 2;
// Optional list of custom dns servers (ip.v4[:port], ip::v6 or [ip::v6]:port format)
TVector<TString> Servers;
// Keep soket open between dns requests
bool KeepSocket = true;
// Force tcp to perform dns requests
bool ForceTcp = false;
};

IActor* CreateSimpleDnsResolver(TSimpleDnsResolverOptions options = TSimpleDnsResolverOptions());
Expand Down

0 comments on commit a2a8b1a

Please sign in to comment.