mirror of
https://github.com/openziti/ziti.git
synced 2026-10-13 15:51:21 +00:00
Merge pull request openziti/fabric#120 from openziti/expose.session.remove
adds session remove handler for openziti/edge#285
This commit is contained in:
@@ -60,6 +60,10 @@ func (db *Db) View(fn func(tx *bbolt.Tx) error) error {
|
||||
return db.db.View(fn)
|
||||
}
|
||||
|
||||
func (db *Db) Stats() bbolt.Stats {
|
||||
return db.db.Stats()
|
||||
}
|
||||
|
||||
func (db *Db) RootBucket(tx *bbolt.Tx) (*bbolt.Bucket, error) {
|
||||
ziti := tx.Bucket([]byte("ziti"))
|
||||
if ziti == nil {
|
||||
|
||||
@@ -73,10 +73,11 @@ func (handler *SessionsStreamHandler) SessionCreated(sessionId *identity.TokenId
|
||||
handler.sendEvent(event)
|
||||
}
|
||||
|
||||
func (handler *SessionsStreamHandler) SessionDeleted(sessionId *identity.TokenId) {
|
||||
func (handler *SessionsStreamHandler) SessionDeleted(sessionId *identity.TokenId, clientId *identity.TokenId) {
|
||||
event := &mgmt_pb.StreamSessionsEvent{
|
||||
EventType: mgmt_pb.StreamSessionEventType_SessionDeleted,
|
||||
SessionId: sessionId.Token,
|
||||
ClientId: clientId.Token,
|
||||
}
|
||||
handler.sendEvent(event)
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@ package network
|
||||
type RouterPresenceHandler interface {
|
||||
RouterConnected(r *Router)
|
||||
RouterDisconnected(r *Router)
|
||||
}
|
||||
}
|
||||
@@ -454,7 +454,7 @@ func (network *Network) RemoveSession(sessionId *identity.TokenId, now bool) err
|
||||
}
|
||||
}
|
||||
network.sessionController.remove(ss)
|
||||
network.SessionDeleted(sessionId)
|
||||
network.SessionDeleted(ss.Id, ss.ClientId)
|
||||
|
||||
if strategy, err := network.strategyRegistry.GetStrategy(ss.Service.TerminatorStrategy); strategy != nil {
|
||||
strategy.NotifyEvent(xt.NewSessionEnded(ss.Terminator))
|
||||
@@ -544,10 +544,6 @@ func (network *Network) AddRouterPresenceHandler(h RouterPresenceHandler) {
|
||||
network.routerPresenceHandlers = append(network.routerPresenceHandlers, h)
|
||||
}
|
||||
|
||||
func (network *Network) Debug() string {
|
||||
return "oh, wow"
|
||||
}
|
||||
|
||||
func (network *Network) Run() {
|
||||
log := pfxlog.Logger()
|
||||
defer log.Error("exited")
|
||||
|
||||
@@ -29,7 +29,7 @@ func getSessionEventHandlers() []SessionEventHandler {
|
||||
|
||||
type SessionEventHandler interface {
|
||||
SessionCreated(sessionId *identity.TokenId, clientId *identity.TokenId, serviceId string, circuit *Circuit)
|
||||
SessionDeleted(sessionId *identity.TokenId)
|
||||
SessionDeleted(sessionId *identity.TokenId, clientId *identity.TokenId)
|
||||
CircuitUpdated(sessionId *identity.TokenId, circuit *Circuit)
|
||||
}
|
||||
|
||||
@@ -43,9 +43,10 @@ func (network *Network) SessionCreated(sessionId *identity.TokenId, clientId *id
|
||||
network.eventDispatcher.Dispatch(event)
|
||||
}
|
||||
|
||||
func (network *Network) SessionDeleted(sessionId *identity.TokenId) {
|
||||
func (network *Network) SessionDeleted(sessionId *identity.TokenId, clientId *identity.TokenId) {
|
||||
event := &sessionDeletedEvent{
|
||||
sessionId: sessionId,
|
||||
clientId: clientId,
|
||||
}
|
||||
network.eventDispatcher.Dispatch(event)
|
||||
}
|
||||
@@ -74,12 +75,13 @@ func (event *sessionCreatedEvent) Handle() {
|
||||
|
||||
type sessionDeletedEvent struct {
|
||||
sessionId *identity.TokenId
|
||||
clientId *identity.TokenId
|
||||
}
|
||||
|
||||
func (event *sessionDeletedEvent) Handle() {
|
||||
handlers := getSessionEventHandlers()
|
||||
for _, handler := range handlers {
|
||||
go handler.SessionDeleted(event.sessionId)
|
||||
go handler.SessionDeleted(event.sessionId, event.clientId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user