|
|
|
@ -45,7 +45,8 @@ func (ac *applicationClient) handleEvent(ev *event.Event) {
|
|
|
|
|
key := ev.Data[event.Key]
|
|
|
|
|
salt := ev.Data[event.Salt]
|
|
|
|
|
reload := ev.Data[event.Status] == event.StorageRunning
|
|
|
|
|
ac.newPeer(localID, key, salt, reload)
|
|
|
|
|
created := ev.Data[event.Created]
|
|
|
|
|
ac.newPeer(localID, key, salt, reload, created)
|
|
|
|
|
case event.DeletePeer:
|
|
|
|
|
onion := ev.Data[event.Identity]
|
|
|
|
|
ac.handleDeletedPeer(onion)
|
|
|
|
@ -60,7 +61,7 @@ func (ac *applicationClient) handleEvent(ev *event.Event) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ac *applicationClient) newPeer(localID, key, salt string, reload bool) {
|
|
|
|
|
func (ac *applicationClient) newPeer(localID, key, salt string, reload bool, created string) {
|
|
|
|
|
var keyBytes [32]byte
|
|
|
|
|
var saltBytes [128]byte
|
|
|
|
|
copy(keyBytes[:], key)
|
|
|
|
@ -87,9 +88,9 @@ func (ac *applicationClient) newPeer(localID, key, salt string, reload bool) {
|
|
|
|
|
defer ac.peerLock.Unlock()
|
|
|
|
|
ac.peers[profile.Onion] = peer
|
|
|
|
|
ac.eventBuses[profile.Onion] = eventBus
|
|
|
|
|
npEvent := event.NewEvent(event.NewPeer, map[event.Field]string{event.Identity: profile.Onion})
|
|
|
|
|
npEvent := event.NewEvent(event.NewPeer, map[event.Field]string{event.Identity: profile.Onion, event.Created: created})
|
|
|
|
|
if reload {
|
|
|
|
|
npEvent.Data[event.Status] = "running"
|
|
|
|
|
npEvent.Data[event.Status] = event.StorageRunning
|
|
|
|
|
}
|
|
|
|
|
ac.appBus.Publish(npEvent)
|
|
|
|
|
|
|
|
|
|