Merge missing bugfixes... #31
5
go.sum
5
go.sum
|
@ -14,6 +14,7 @@ github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uM
|
|||
github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o=
|
||||
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
|
@ -21,6 +22,7 @@ github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG
|
|||
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
|
@ -41,9 +43,12 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 h1:Bli41pIlzTzf3KEY06n+xnzK/BESIg2ze4Pgfh/aI8c=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e h1:FDhOuMEY4JVRztM/gsbk+IKUQ8kj74bxZrgw87eMMVc=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
|
|
|
@ -21,9 +21,11 @@ type BaseOnionService struct {
|
|||
privateKey ed25519.PrivateKey
|
||||
ls connectivity.ListenService
|
||||
lock sync.Mutex
|
||||
port int
|
||||
}
|
||||
|
||||
// Metrics provide metrics for services
|
||||
// Metrics provides a report of useful information about the status of the service e.g. the number of active
|
||||
// connections
|
||||
func (s *BaseOnionService) Metrics() tapir.ServiceMetrics {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
@ -50,6 +52,12 @@ func (s *BaseOnionService) Init(acn connectivity.ACN, sk ed25519.PrivateKey, id
|
|||
s.acn = acn
|
||||
s.id = id
|
||||
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
|
||||
|
@ -145,7 +153,7 @@ func (s *BaseOnionService) Listen(app tapir.Application) error {
|
|||
// accepts a new connection
|
||||
// spins off to a connection struct
|
||||
s.lock.Lock()
|
||||
ls, err := s.acn.Listen(s.privateKey, 9878)
|
||||
ls, err := s.acn.Listen(s.privateKey, s.port)
|
||||
s.ls = ls
|
||||
log.Debugf("Starting a service on %v ", ls.AddressFull())
|
||||
s.lock.Unlock()
|
||||
|
@ -171,7 +179,9 @@ func (s *BaseOnionService) Listen(app tapir.Application) error {
|
|||
func (s *BaseOnionService) Shutdown() {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
s.ls.Close()
|
||||
if s.ls != nil {
|
||||
s.ls.Close()
|
||||
}
|
||||
s.connections.Range(func(key, value interface{}) bool {
|
||||
connection := value.(tapir.Connection)
|
||||
connection.Close()
|
||||
|
|
|
@ -72,7 +72,8 @@ func (t *Token) unblindSignedToken(token SignedToken) {
|
|||
func (t *Token) SpendToken(data []byte) SpentToken {
|
||||
key := sha3.Sum256(append(t.t, t.W.Encode(nil)...))
|
||||
mac := hmac.New(sha3.New512, key[:])
|
||||
return SpentToken{t.t, mac.Sum(data)}
|
||||
mac.Write(data)
|
||||
return SpentToken{t.t, mac.Sum(nil)}
|
||||
}
|
||||
|
||||
// GenerateBlindedTokenBatch generates a batch of blinded tokens (and their unblinded equivalents)
|
||||
|
|
|
@ -136,7 +136,8 @@ func (ts *TokenServer) SpendToken(token SpentToken, data []byte) error {
|
|||
W := new(ristretto.Element).ScalarMult(ts.k, T)
|
||||
key := sha3.Sum256(append(token.T, W.Encode(nil)...))
|
||||
mac := hmac.New(sha3.New512, key[:])
|
||||
computedMAC := mac.Sum(data)
|
||||
mac.Write(data)
|
||||
computedMAC := mac.Sum(nil)
|
||||
result := hmac.Equal(token.MAC, computedMAC)
|
||||
if result == true {
|
||||
if ts.persistanceService == nil {
|
||||
|
|
|
@ -12,7 +12,8 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
// ServiceMetrics are metrics for servers...
|
||||
|
||||
// ServiceMetrics outlines higher level information about the service e.g. counts of connections
|
||||
type ServiceMetrics struct {
|
||||
ConnectionCount int
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue