|
|
|
@ -29,9 +29,10 @@ type application struct {
|
|
|
|
|
acn connectivity.ACN
|
|
|
|
|
plugins sync.Map //map[string] []plugins.Plugin
|
|
|
|
|
|
|
|
|
|
engines map[string]connections.Engine
|
|
|
|
|
appBus event.Manager
|
|
|
|
|
appmutex sync.Mutex
|
|
|
|
|
engines map[string]connections.Engine
|
|
|
|
|
appBus event.Manager
|
|
|
|
|
appmutex sync.Mutex
|
|
|
|
|
engineHooks connections.EngineHooks
|
|
|
|
|
|
|
|
|
|
settings *settings.GlobalSettingsFile
|
|
|
|
|
}
|
|
|
|
@ -94,11 +95,11 @@ func LoadAppSettings(appDirectory string) *settings.GlobalSettingsFile {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewApp creates a new app with some environment awareness and initializes a Tor Manager
|
|
|
|
|
func NewApp(acn connectivity.ACN, appDirectory string, settings *settings.GlobalSettingsFile) Application {
|
|
|
|
|
func NewApp(acn connectivity.ACN, appDirectory string, settings *settings.GlobalSettingsFile, engineHooks connections.EngineHooks) Application {
|
|
|
|
|
|
|
|
|
|
app := &application{engines: make(map[string]connections.Engine), eventBuses: make(map[string]event.Manager), directory: appDirectory, appBus: event.NewEventManager(), settings: settings}
|
|
|
|
|
app.peers = make(map[string]peer.CwtchPeer)
|
|
|
|
|
|
|
|
|
|
app.engineHooks = engineHooks
|
|
|
|
|
app.acn = acn
|
|
|
|
|
statusHandler := app.getACNStatusHandler()
|
|
|
|
|
acn.SetStatusCallback(statusHandler)
|
|
|
|
@ -373,7 +374,7 @@ func (app *application) ActivateEngines(doListen, doPeers, doServers bool) {
|
|
|
|
|
log.Debugf("ActivateEngines")
|
|
|
|
|
|
|
|
|
|
for _, profile := range app.peers {
|
|
|
|
|
app.engines[profile.GetOnion()], _ = profile.GenerateProtocolEngine(app.acn, app.eventBuses[profile.GetOnion()])
|
|
|
|
|
app.engines[profile.GetOnion()], _ = profile.GenerateProtocolEngine(app.acn, app.eventBuses[profile.GetOnion()], app.engineHooks)
|
|
|
|
|
app.eventBuses[profile.GetOnion()].Publish(event.NewEventList(event.ProtocolEngineCreated))
|
|
|
|
|
}
|
|
|
|
|
app.QueryACNStatus()
|
|
|
|
@ -398,7 +399,7 @@ func (app *application) ActivatePeerEngine(onion string) {
|
|
|
|
|
profile := app.GetPeer(onion)
|
|
|
|
|
if profile != nil {
|
|
|
|
|
if _, exists := app.engines[onion]; !exists {
|
|
|
|
|
app.engines[profile.GetOnion()], _ = profile.GenerateProtocolEngine(app.acn, app.eventBuses[profile.GetOnion()])
|
|
|
|
|
app.engines[profile.GetOnion()], _ = profile.GenerateProtocolEngine(app.acn, app.eventBuses[profile.GetOnion()], app.engineHooks)
|
|
|
|
|
|
|
|
|
|
app.eventBuses[profile.GetOnion()].Publish(event.NewEventList(event.ProtocolEngineCreated))
|
|
|
|
|
app.QueryACNStatus()
|
|
|
|
|