}
}
+#[derive(Debug)]
+enum Which<T> {
+ All,
+ These(T),
+}
+
+struct MeansForEnd<'m,U,P> {
+ us_spec: Which<&'m U>,
+ peer: Which<&'m P>,
+}
+
+trait InstancesForEnd: Eq {
+ type Peer: Ord + Eq + Hash + Debug;
+ fn section_means<'s>(&self, s: &'s SectionName)
+ -> MeansForEnd<'s, Self, Peer>
+}
+
+impl InstanceForEnd for ServerName {
+ type Peer = ClientName;
+ fn section_means<'s>(&'_ self, s: &'s SectionName)
+ -> Option<MeansForEnd<'s>> {
+ use Which:*;
+ let (us_spec, peer) = match s {
+ SN::Link(l) => (These(l.server), These(l.client)),
+ SN::Server(server) => (These( server), All),
+ SN::Client(client) => (All, These( client)),
+ SN::Common => (All, All),
+ _ => return None,
+ };
+ MeansForEnd { us_spec, peer }
+ }
+}
+
+impl Aggregate {
+ fn instances_for<N>(&self, us: N) -> Vec<LinkName>
+ where N: InstancesForEnd,
+ {
+ use Which::*;
+ let mut secrets = Which::These(BTreeSet::new());
+ let mut putative_selves = BTreeSet::new();
+ let mut putative_peers = BTreeSet::new();
+
+ let matching_means = |section: &SectionName| {
+ let means = us.section_means(section)?;
+ if match means.us_spec {
+ These(u) => if u == us,
+ All => true,
+ } { Some(means) } else { None }
+ };
+
+ for (section, vars) in &self.agg.sections {
+
+ if let Some(means) = matching_means(section) {
+
+
+ if ! vars.has_key("secret") { continue }
+
+ let tsecrets = match secrets {
+ These(ref mut s) => s,
+ All => break,
+ };
+
+ if let Some(means) = matching_means(section) {
+ match means.peer {
+ Which::These(ypeer) => tsecrets.insert(ypeer),
+ Which::All => secrets = Which::All,
+ }
+ }
+
+ }
+
+ let links = vec![];
+
+ for (section, vars) in &self.agg.sections {
+
+ if let Some(means) = matching_means(section) {
+
+ if match secrets {
+ All => true,
+ These(s) => s.contains(means.peer),
+ } {
+
+ links.push( us.
+
+
+ match section {
+ SN::Link(LinkName { ref client, ref srver })
+ if server == &server_name
+ => tclients.insert(client),
+
+ SN::Client(ref client)
+ => tclients.insert(client),
+
+ SN::Server(ref server) | SN::Common
+ => tclients.
+
+ }
+
+
+ let has_secret = .iter().filter_map(|section, vars| {
+
+
+
+ match section {
+
+ SN::
+
+
+
+ let links = self.agg.sections.iter().filter_map(|section| match section {
+
+ SN::Link(LinkName { ref client, .. }) |
+ SN::Client(ref client) => Some(client.clone()),
+
+ SN::Server(_) | SN::ServerLimit(_) |
+ SN::GlobalLimit : SN::Common => None => None,
+
+ }).filter(|client| {
+
+ self.lookup_raw("secret", SKL::Ordinary).is_some()
+
+ }).map(|client| {
+
+
+
+
+ |
+ }
+}
+
struct ResolveContext<'c> {
agg: &'c Aggregate,
link: &'c LinkName,
],
};
+ let server_name = self.establish_server_name()
+ .context("establish server name")?;
+
let ic = InstanceConfig::resolve_instance(&rctx)
.context("resolve config xxx for")?;