Skip to content

Commit

Permalink
Remove unnecceasy subscription. It was a bad idea.
Browse files Browse the repository at this point in the history
  • Loading branch information
bahner committed Feb 11, 2024
1 parent 9e074e2 commit 9c40a94
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 60 deletions.
7 changes: 1 addition & 6 deletions entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ type Entity struct {
DID *did.DID
Doc *doc.Document

Topic *p2ppubsub.Topic
Subscription *Subscription
Topic *p2ppubsub.Topic

// Only keyset maybe nil
Keyset *set.Keyset
Expand Down Expand Up @@ -75,10 +74,6 @@ func New(d *did.DID, k *set.Keyset, nick string) (*Entity, error) {

// Cache the entity
cache(e)
e.Subscription, err = e.Subscribe()
if err != nil {
return nil, fmt.Errorf("entity/new: failed to subscribe to topic: %w", err)
}

return e, nil
}
Expand Down
53 changes: 0 additions & 53 deletions entity/subscription.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.18.2
golang.org/x/crypto v0.18.0
gopkg.in/yaml.v2 v2.4.0
)

Expand Down Expand Up @@ -155,7 +156,6 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d h1:t5Wuyh53qYyg9eqn4BbnlIT+vmhyww0TatL+zT3uWgI=
github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
github.com/matoous/go-nanoid v1.5.0 h1:VRorl6uCngneC4oUQqOYtO3S0H5QKFtKuKycFG3euek=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
12 changes: 12 additions & 0 deletions ui/envelopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/bahner/go-ma/msg"
p2ppubsub "github.com/libp2p/go-libp2p-pubsub"
log "github.com/sirupsen/logrus"
"golang.org/x/crypto/curve25519"
)

// Handle incoming envelopes to an entity. The actor
Expand All @@ -22,6 +23,17 @@ func (ui *ChatUI) handleIncomingEnvelopes(a *entity.Entity) {
}
log.Debugf("Received actor envelope: %v", envelope)

if a.Keyset == nil {
log.Errorf("Actor %s has no keyset, cannot open envelope", a.DID)
continue
}

// Check if privkey is a non-zero byte array.
if a.Keyset.EncryptionKey.PrivKey != [curve25519.ScalarSize]byte{} {
log.Errorf("Actor %s has zero-byte privkey. Unable to decrypt envelope.", a.DID)
continue
}

// Process the envelope and send a pong response
m, err := envelope.Open(a.Keyset.EncryptionKey.PrivKey[:])
if err != nil {
Expand Down

0 comments on commit 9c40a94

Please sign in to comment.