Merge missing bugfixes... #31
|
@ -21,6 +21,7 @@ type BaseOnionService struct {
|
||||||
privateKey ed25519.PrivateKey
|
privateKey ed25519.PrivateKey
|
||||||
ls connectivity.ListenService
|
ls connectivity.ListenService
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
|
port int
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metrics provides a report of useful information about the status of the service e.g. the number of active
|
// Metrics provides a report of useful information about the status of the service e.g. the number of active
|
||||||
|
@ -51,6 +52,12 @@ func (s *BaseOnionService) Init(acn connectivity.ACN, sk ed25519.PrivateKey, id
|
||||||
s.acn = acn
|
s.acn = acn
|
||||||
s.id = id
|
s.id = id
|
||||||
s.privateKey = sk
|
s.privateKey = sk
|
||||||
|
s.port = 9878
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPort configures the port that the service uses.
|
||||||
|
func (s *BaseOnionService) SetPort(port int) {
|
||||||
|
s.port = port
|
||||||
}
|
}
|
||||||
|
|
||||||
// WaitForCapabilityOrClose blocks until the connection has the given capability or the underlying connection is closed
|
// WaitForCapabilityOrClose blocks until the connection has the given capability or the underlying connection is closed
|
||||||
|
@ -146,7 +153,7 @@ func (s *BaseOnionService) Listen(app tapir.Application) error {
|
||||||
// accepts a new connection
|
// accepts a new connection
|
||||||
// spins off to a connection struct
|
// spins off to a connection struct
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
ls, err := s.acn.Listen(s.privateKey, 9878)
|
ls, err := s.acn.Listen(s.privateKey, s.port)
|
||||||
s.ls = ls
|
s.ls = ls
|
||||||
log.Debugf("Starting a service on %v ", ls.AddressFull())
|
log.Debugf("Starting a service on %v ", ls.AddressFull())
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
|
@ -172,7 +179,9 @@ func (s *BaseOnionService) Listen(app tapir.Application) error {
|
||||||
func (s *BaseOnionService) Shutdown() {
|
func (s *BaseOnionService) Shutdown() {
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
|
if s.ls != nil {
|
||||||
s.ls.Close()
|
s.ls.Close()
|
||||||
|
}
|
||||||
s.connections.Range(func(key, value interface{}) bool {
|
s.connections.Range(func(key, value interface{}) bool {
|
||||||
connection := value.(tapir.Connection)
|
connection := value.(tapir.Connection)
|
||||||
connection.Close()
|
connection.Close()
|
||||||
|
|
Loading…
Reference in New Issue