| 1091 | } |
| 1092 | |
| 1093 | bool ServerNegotiation::IsTrustedConnection(const Sockaddr& addr) { |
| 1094 | if (addr.family() == AF_UNIX) { |
| 1095 | return true; |
| 1096 | } |
| 1097 | |
| 1098 | static std::once_flag once; |
| 1099 | std::call_once(once, [] { |
| 1100 | g_trusted_subnets = new vector<Network>(); |
| 1101 | CHECK_OK(Network::ParseCIDRStrings(FLAGS_trusted_subnets, g_trusted_subnets)); |
| 1102 | |
| 1103 | // If --trusted_subnets is not set explicitly, local subnets of all local network |
| 1104 | // interfaces as well as the default private subnets will be used. |
| 1105 | if (google::GetCommandLineFlagInfoOrDie("trusted_subnets").is_default) { |
| 1106 | std::vector<Network> local_networks; |
| 1107 | WARN_NOT_OK(GetLocalNetworks(&local_networks), |
| 1108 | "Unable to get local networks."); |
| 1109 | |
| 1110 | g_trusted_subnets->insert(g_trusted_subnets->end(), |
| 1111 | local_networks.begin(), |
| 1112 | local_networks.end()); |
| 1113 | } |
| 1114 | }); |
| 1115 | |
| 1116 | return std::any_of(g_trusted_subnets->begin(), g_trusted_subnets->end(), |
| 1117 | [&](const Network& t) { return t.WithinNetwork(addr); }); |
| 1118 | } |
| 1119 | |
| 1120 | } // namespace rpc |
| 1121 | } // namespace kudu |
nothing calls this directly
no test coverage detected