Add Broadcast #23

Merged
dan merged 4 commits from broadcast into master 2020-07-14 22:05:54 +00:00
4 changed files with 4 additions and 4 deletions
Showing only changes of commit 8eeea02997 - Show all commits

View File

@ -106,7 +106,7 @@ func (s *BaseOnionService) Connect(hostname string, app tapir.Application) (bool
}
log.Debugf("Connected to %v [%v]", hostname, connectionID)
s.connections.Store(connectionID, tapir.NewConnection(s.id, hostname, true, conn, app.NewInstance(), s))
s.connections.Store(connectionID, tapir.NewConnection(s, s.id, hostname, true, conn, app.NewInstance()))
return true, nil
}
log.Debugf("Error connecting to %v %v", hostname, err)
@ -137,7 +137,7 @@ func (s *BaseOnionService) Listen(app tapir.Application) error {
if err == nil {
tempHostname := s.getNewConnectionID()
log.Debugf("Accepted connection from %v", tempHostname)
s.connections.Store(tempHostname, tapir.NewConnection(s.id, tempHostname, false, conn, app.NewInstance(), s))
s.connections.Store(tempHostname, tapir.NewConnection(s, s.id, tempHostname, false, conn, app.NewInstance()))
} else {
log.Debugf("Error accepting connection %v", err)
return err

BIN
persistence/test.dbgi Normal file

Binary file not shown.

View File

@ -58,7 +58,7 @@ type connection struct {
}
// NewConnection creates a new Connection
func NewConnection(id *primitives.Identity, hostname string, outbound bool, conn io.ReadWriteCloser, app Application, service Service) Connection {
func NewConnection(service Service, id *primitives.Identity, hostname string, outbound bool, conn io.ReadWriteCloser, app Application) Connection {
Outdated
Review

can we change the sig to

NewConnection(service Service, hostname string, outbound bool, conn io.ReadWriteCloser, app Application)

and either not need to store .identity or just pull it from service.id or service.getNewConnectionID() (we seem to use the former in connect and the latter in listen)

can we change the sig to ```NewConnection(service Service, hostname string, outbound bool, conn io.ReadWriteCloser, app Application)``` and either not need to store .identity or just pull it from service.id or service.getNewConnectionID() (we seem to use the former in connect and the latter in listen)
Review

Fixed the signature, can't get rid of id yet (see: #20)

Fixed the signature, can't get rid of id yet (see: https://git.openprivacy.ca/cwtch.im/tapir/issues/20)
connection := new(connection)
connection.hostname = hostname
connection.conn = conn

View File

@ -64,7 +64,7 @@ func TestTapirMaliciousRemote(t *testing.T) {
log.Infof("closing ACN...")
acn.Close()
sg.Wait()
time.Sleep(time.Second * 2)
time.Sleep(time.Second * 5) // wait for goroutines to finish...
log.Infof("Number of goroutines open at close: %d", runtime.NumGoroutine())
if numRoutinesStart != runtime.NumGoroutine() {
t.Errorf("Potential goroutine leak: Num Start:%v NumEnd: %v", numRoutinesStart, runtime.NumGoroutine())