forked from cwtch.im/cwtch
Merge pull request 'Split Peer and Server Connection Launching' (#326) from gating into master
Reviewed-on: cwtch.im/cwtch#326
This commit is contained in:
commit
8b176327a7
|
@ -93,6 +93,7 @@ type CwtchPeer interface {
|
|||
|
||||
Listen()
|
||||
StartPeersConnections()
|
||||
StartServerConnections()
|
||||
Shutdown()
|
||||
}
|
||||
|
||||
|
@ -480,13 +481,20 @@ func (cp *cwtchPeer) Listen() {
|
|||
cp.eventBus.Publish(event.NewEvent(event.ProtocolEngineStartListen, map[event.Field]string{event.Onion: cp.Profile.Onion}))
|
||||
}
|
||||
|
||||
// StartGroupConnections attempts to connect to all group servers (thus initiating reconnect attempts in the conectionsmanager)
|
||||
// StartPeersConnections attempts to connect to peer connections
|
||||
func (cp *cwtchPeer) StartPeersConnections() {
|
||||
for _, contact := range cp.GetContacts() {
|
||||
if cp.GetContact(contact).IsServer() == false {
|
||||
cp.PeerWithOnion(contact)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// StartServerConnections attempts to connect to all server connections
|
||||
func (cp *cwtchPeer) StartServerConnections() {
|
||||
for _, contact := range cp.GetContacts() {
|
||||
if cp.GetContact(contact).IsServer() {
|
||||
cp.JoinServer(contact)
|
||||
} else {
|
||||
cp.PeerWithOnion(contact)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,14 +118,14 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
|||
log.ExcludeFromPattern("event/eventmanager")
|
||||
log.ExcludeFromPattern("pipeBridge")
|
||||
log.ExcludeFromPattern("tapir")
|
||||
os.Mkdir("tordir",0700)
|
||||
os.Mkdir("tordir", 0700)
|
||||
dataDir := path.Join("tordir", "tor")
|
||||
os.MkdirAll(dataDir, 0700)
|
||||
|
||||
// we don't need real randomness for the port, just to avoid a possible conflict...
|
||||
mrand.Seed(int64(time.Now().Nanosecond()))
|
||||
socksPort := mrand.Intn(1000)+9051
|
||||
controlPort := mrand.Intn(1000)+9052
|
||||
socksPort := mrand.Intn(1000) + 9051
|
||||
controlPort := mrand.Intn(1000) + 9052
|
||||
|
||||
// generate a random password
|
||||
key := make([]byte, 64)
|
||||
|
@ -139,7 +139,7 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("Could not start Tor: %v", err)
|
||||
}
|
||||
pid,err := acn.GetPID()
|
||||
pid, err := acn.GetPID()
|
||||
t.Logf("Tor pid: %v", pid)
|
||||
|
||||
// ***** Cwtch Server management *****
|
||||
|
|
Loading…
Reference in New Issue