Review Board Comments #2

This commit is contained in:
Sarah Jamie Lewis 2019-07-29 12:48:12 -07:00
parent 815ec2565b
commit 37b9c72abb
2 changed files with 7 additions and 7 deletions

View File

@ -101,7 +101,7 @@ func (e *engine) eventHandler() {
case event.StatusRequest:
e.eventManager.Publish(event.Event{EventType: event.ProtocolEngineStatus, EventID: ev.EventID})
case event.PeerRequest:
e.peerWithOnion(ev.Data[event.RemotePeer])
go e.peerWithOnion(ev.Data[event.RemotePeer])
case event.InvitePeerToGroup:
e.sendMessageToPeer(ev.EventID, ev.Data[event.RemotePeer], event.ContextInvite, []byte(ev.Data[event.GroupInvite]))
case event.JoinServer:
@ -160,8 +160,13 @@ func (e *engine) Shutdown() {
}
// peerWithOnion is the entry point for cwtchPeer relationships
// needs to be run in a goroutine as will block on Open.
func (e *engine) peerWithOnion(onion string) {
e.service.Connect(onion, e.createPeerTemplate())
e.ignoreOnShutdown(e.peerConnecting)(onion)
_,err := e.service.Connect(onion, e.createPeerTemplate())
if err != nil {
e.ignoreOnShutdown(e.peerDisconnected)(onion)
}
}
func (e * engine) ignoreOnShutdown(f func(string)) func(string){

View File

@ -40,11 +40,6 @@ func (pa PeerApp) NewInstance() tapir.Application {
// Init is run when the connection is first started.
func (pa *PeerApp) Init(connection *tapir.Connection) {
// We don't want to issue an event for unknown peers (we only know inbound peer hostnames once we have authenticated)
if connection.Outbound {
pa.OnConnecting(connection.Hostname)
}
// First run the Authentication App
pa.AuthApp.Init(connection)