mirror of
https://github.com/openziti/ziti.git
synced 2026-10-12 23:32:02 +00:00
check idle circuits against path
This commit is contained in:
@@ -39,18 +39,19 @@ func (self *circuitConfirmationHandler) ContentType() int32 {
|
||||
}
|
||||
|
||||
func (self *circuitConfirmationHandler) HandleReceive(msg *channel.Message, _ channel.Channel) {
|
||||
logrus.Infof("received circuit confirmation request from [r/%s]", self.r.Id)
|
||||
log := logrus.WithField("routerId", self.r.Id)
|
||||
log.Info("received circuit confirmation request")
|
||||
confirm := &ctrl_pb.CircuitConfirmation{}
|
||||
if err := proto.Unmarshal(msg.Body, confirm); err == nil {
|
||||
for _, circuitId := range confirm.CircuitIds {
|
||||
if _, found := self.n.GetCircuit(circuitId); !found {
|
||||
go self.sendUnroute(circuitId)
|
||||
if circuit, found := self.n.GetCircuit(circuitId); found && circuit.HasRouter(self.r) {
|
||||
log.WithField("circuitId", circuitId).Debug("circuit found, ignoring")
|
||||
} else {
|
||||
logrus.Debugf("[s/%s] found, ignoring", circuitId)
|
||||
go self.sendUnroute(circuitId)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logrus.Errorf("error unmarshaling circuit confirmation from [r/%s] (%v)", self.r.Id, err)
|
||||
log.WithError(err).Error("error unmarshalling circuit confirmation")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,18 @@ func (self *Circuit) latency() int64 {
|
||||
return latency
|
||||
}
|
||||
|
||||
func (self *Circuit) HasRouter(r *Router) bool {
|
||||
if self == nil || self.Path == nil {
|
||||
return false
|
||||
}
|
||||
for _, node := range self.Path.Nodes {
|
||||
if node.Id == r.Id {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type circuitController struct {
|
||||
circuits cmap.ConcurrentMap // map[string]*Circuit
|
||||
idGenerator idgen.Generator
|
||||
|
||||
Reference in New Issue
Block a user