mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 05:23:04 +00:00
0fa828db76
When traversing an exported peered service, the discovery chain evaluation at the other side may re-route the request to a variety of endpoints. Furthermore we intend to terminate mTLS at the mesh gateway for arriving peered traffic that is http-like (L7), so the caller needs to know the mesh gateway's SpiffeID in that case as well. The following new SpiffeID values will be shipped back in the peerstream replication: - tcp: all possible SpiffeIDs resulting from the service-resolver component of the exported discovery chain - http-like: the SpiffeID of the mesh gateway
73 lines
2.0 KiB
Go
73 lines
2.0 KiB
Go
package structs
|
|
|
|
// PeeringToken identifies a peer in order for a connection to be established.
|
|
type PeeringToken struct {
|
|
CA []string
|
|
ServerAddresses []string
|
|
ServerName string
|
|
PeerID string
|
|
}
|
|
|
|
type IndexedExportedServiceList struct {
|
|
Services map[string]ServiceList
|
|
QueryMeta
|
|
}
|
|
|
|
// NOTE: this is not serialized via msgpack so it can be changed without concern.
|
|
type ExportedServiceList struct {
|
|
// Services is a list of exported services that apply to both standard
|
|
// service discovery and service mesh.
|
|
Services []ServiceName
|
|
|
|
// DiscoChains is a map of service names to their exported discovery chains
|
|
// for service mesh purposes as defined in the exported-services
|
|
// configuration entry.
|
|
DiscoChains map[ServiceName]ExportedDiscoveryChainInfo
|
|
}
|
|
|
|
// NOTE: this is not serialized via msgpack so it can be changed without concern.
|
|
type ExportedDiscoveryChainInfo struct {
|
|
// Protocol is the overall protocol associated with this discovery chain.
|
|
Protocol string
|
|
|
|
// TCPTargets is the list of discovery chain targets that are reachable by
|
|
// this discovery chain.
|
|
//
|
|
// NOTE: this is only populated if Protocol=tcp.
|
|
TCPTargets []*DiscoveryTarget
|
|
}
|
|
|
|
func (i ExportedDiscoveryChainInfo) Equal(o ExportedDiscoveryChainInfo) bool {
|
|
switch {
|
|
case i.Protocol != o.Protocol:
|
|
return false
|
|
case len(i.TCPTargets) != len(o.TCPTargets):
|
|
return false
|
|
}
|
|
|
|
for j := 0; j < len(i.TCPTargets); j++ {
|
|
if i.TCPTargets[j].ID != o.TCPTargets[j].ID {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// ListAllDiscoveryChains returns all discovery chains (union of Services and
|
|
// DiscoChains).
|
|
func (list *ExportedServiceList) ListAllDiscoveryChains() map[ServiceName]ExportedDiscoveryChainInfo {
|
|
chainsByName := make(map[ServiceName]ExportedDiscoveryChainInfo)
|
|
if list == nil {
|
|
return chainsByName
|
|
}
|
|
|
|
for _, svc := range list.Services {
|
|
chainsByName[svc] = list.DiscoChains[svc]
|
|
}
|
|
for chainName, info := range list.DiscoChains {
|
|
chainsByName[chainName] = info
|
|
}
|
|
return chainsByName
|
|
}
|