Issue a PeerAuth event when attempting to peer to an existing authed connection
This commit is contained in:
parent
5aaa228691
commit
4a08331675
|
@ -4,6 +4,7 @@ import (
|
||||||
"cwtch.im/cwtch/event"
|
"cwtch.im/cwtch/event"
|
||||||
"cwtch.im/cwtch/protocol"
|
"cwtch.im/cwtch/protocol"
|
||||||
"cwtch.im/tapir"
|
"cwtch.im/tapir"
|
||||||
|
"cwtch.im/tapir/applications"
|
||||||
"cwtch.im/tapir/networks/tor"
|
"cwtch.im/tapir/networks/tor"
|
||||||
"errors"
|
"errors"
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/connectivity"
|
"git.openprivacy.ca/openprivacy/libricochet-go/connectivity"
|
||||||
|
@ -175,6 +176,19 @@ func (e *engine) peerWithOnion(onion string) {
|
||||||
if !blocked {
|
if !blocked {
|
||||||
e.ignoreOnShutdown(e.peerConnecting)(onion)
|
e.ignoreOnShutdown(e.peerConnecting)(onion)
|
||||||
connected, err := e.service.Connect(onion, e.createPeerTemplate())
|
connected, err := e.service.Connect(onion, e.createPeerTemplate())
|
||||||
|
|
||||||
|
// If we are already connected...check if we are authed and issue an auth event
|
||||||
|
// (This allows the ui to be stateless)
|
||||||
|
if connected && err != nil {
|
||||||
|
conn, err := e.service.GetConnection(onion)
|
||||||
|
if err == nil {
|
||||||
|
if conn.HasCapability(applications.AuthCapability) {
|
||||||
|
e.ignoreOnShutdown(e.peerAuthed)(onion)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Only issue a disconnected error if we are disconnected (Connect will fail if a connection already exists)
|
// Only issue a disconnected error if we are disconnected (Connect will fail if a connection already exists)
|
||||||
if !connected && err != nil {
|
if !connected && err != nil {
|
||||||
e.ignoreOnShutdown(e.peerDisconnected)(onion)
|
e.ignoreOnShutdown(e.peerDisconnected)(onion)
|
||||||
|
|
Loading…
Reference in New Issue