diff --git a/client/storage/liststorage.go b/client/storage/liststorage.go index 40d46e38..ea6fb886 100644 --- a/client/storage/liststorage.go +++ b/client/storage/liststorage.go @@ -37,7 +37,7 @@ func newListStorage(spaceId string, db *badger.DB, txn *badger.Txn) (ls storage. ls = &listStorage{ db: db, - keys: keys, + keys: newACLKeys(spaceId), id: stringId, root: rootWithId, } @@ -70,14 +70,14 @@ func createListStorage(spaceId string, db *badger.DB, txn *badger.Txn, root *acl ls = &listStorage{ db: db, - keys: keys, + keys: newACLKeys(spaceId), id: root.Id, root: root, } return } -func (l *listStorage) ID() string { +func (l *listStorage) Id() string { return l.id } diff --git a/client/storage/spacestorage.go b/client/storage/spacestorage.go index 58f43482..8d41b298 100644 --- a/client/storage/spacestorage.go +++ b/client/storage/spacestorage.go @@ -3,7 +3,7 @@ package storage import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" spacestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage" - storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" + storage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" "github.com/dgraph-io/badger/v3" "sync" ) @@ -12,7 +12,7 @@ type spaceStorage struct { spaceId string objDb *badger.DB keys spaceKeys - aclStorage storage2.ListStorage + aclStorage storage.ListStorage header *spacesyncproto.RawSpaceHeaderWithId mx sync.Mutex } @@ -77,15 +77,15 @@ func createSpaceStorage(db *badger.DB, payload spacestorage.SpaceStorageCreatePa return } -func (s *spaceStorage) ID() string { +func (s *spaceStorage) Id() string { return s.spaceId } -func (s *spaceStorage) TreeStorage(id string) (storage2.TreeStorage, error) { +func (s *spaceStorage) TreeStorage(id string) (storage.TreeStorage, error) { return newTreeStorage(s.objDb, s.spaceId, id) } -func (s *spaceStorage) CreateTreeStorage(payload storage2.TreeStorageCreatePayload) (ts storage2.TreeStorage, err error) { +func (s *spaceStorage) CreateTreeStorage(payload storage.TreeStorageCreatePayload) (ts storage.TreeStorage, err error) { // we have mutex here, so we prevent overwriting the heads of a tree on concurrent creation s.mx.Lock() defer s.mx.Unlock() @@ -93,7 +93,7 @@ func (s *spaceStorage) CreateTreeStorage(payload storage2.TreeStorageCreatePaylo return createTreeStorage(s.objDb, s.spaceId, payload) } -func (s *spaceStorage) ACLStorage() (storage2.ListStorage, error) { +func (s *spaceStorage) ACLStorage() (storage.ListStorage, error) { return s.aclStorage, nil } diff --git a/client/storage/treestorage.go b/client/storage/treestorage.go index 25c49192..8c11f003 100644 --- a/client/storage/treestorage.go +++ b/client/storage/treestorage.go @@ -2,7 +2,7 @@ package storage import ( "context" - storage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto" "github.com/dgraph-io/badger/v3" ) @@ -40,14 +40,11 @@ func newTreeStorage(db *badger.DB, spaceId, treeId string) (ts storage.TreeStora } return nil }) - if err == badger.ErrKeyNotFound { - err = storage.ErrUnknownTreeId - } return } func createTreeStorage(db *badger.DB, spaceId string, payload storage.TreeStorageCreatePayload) (ts storage.TreeStorage, err error) { - keys := newTreeKeys(spaceId, payload.RootRawChange.Id) + keys := newTreeKeys(spaceId, payload.TreeId) if hasDB(db, keys.RootIdKey()) { err = storage.ErrTreeExists return @@ -88,7 +85,7 @@ func createTreeStorage(db *badger.DB, spaceId string, payload storage.TreeStorag return } -func (t *treeStorage) ID() string { +func (t *treeStorage) Id() string { return t.id } diff --git a/common/commonspace/service.go b/common/commonspace/service.go index c5e94298..19c4bd40 100644 --- a/common/commonspace/service.go +++ b/common/commonspace/service.go @@ -6,15 +6,12 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/diffservice" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/treegetter" - config2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/config" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto" ) const CName = "common.commonspace" @@ -29,12 +26,11 @@ type Service interface { DeriveSpace(ctx context.Context, payload SpaceDerivePayload) (string, error) CreateSpace(ctx context.Context, payload SpaceCreatePayload) (string, error) GetSpace(ctx context.Context, id string) (sp Space, err error) - AddSpace(ctx context.Context, spaceDescription SpaceDescription) (err error) app.Component } type service struct { - config config2.Space + config config.Space account account.Service configurationService nodeconf.Service storageProvider storage.SpaceStorageProvider @@ -43,7 +39,7 @@ type service struct { } func (s *service) Init(a *app.App) (err error) { - s.config = a.MustComponent(config2.CName).(*config2.Config).Space + s.config = a.MustComponent(config.CName).(*config.Config).Space s.account = a.MustComponent(account.CName).(account.Service) s.storageProvider = a.MustComponent(storage.CName).(storage.SpaceStorageProvider) s.configurationService = a.MustComponent(nodeconf.CName).(nodeconf.Service) @@ -56,9 +52,7 @@ func (s *service) Name() (name string) { return CName } -func (s *service) CreateSpace( - ctx context.Context, - payload SpaceCreatePayload) (id string, err error) { +func (s *service) CreateSpace(ctx context.Context, payload SpaceCreatePayload) (id string, err error) { storageCreate, err := storagePayloadForSpaceCreate(payload) if err != nil { return @@ -68,12 +62,10 @@ func (s *service) CreateSpace( return } - return store.ID(), nil + return store.Id(), nil } -func (s *service) DeriveSpace( - ctx context.Context, - payload SpaceDerivePayload) (id string, err error) { +func (s *service) DeriveSpace(ctx context.Context, payload SpaceDerivePayload) (id string, err error) { storageCreate, err := storagePayloadForSpaceDerive(payload) if err != nil { return @@ -83,51 +75,13 @@ func (s *service) DeriveSpace( return } - return store.ID(), nil -} - -func (s *service) AddSpace(ctx context.Context, spaceDescription SpaceDescription) (err error) { - _, err = s.storageProvider.SpaceStorage(spaceDescription.SpaceHeader.Id) - if err == nil { - err = spacesyncproto.ErrSpaceExists - return - } - if err != storage.ErrSpaceStorageMissing { - err = spacesyncproto.ErrUnexpected - return - } - - payload := storage.SpaceStorageCreatePayload{ - RecWithId: &aclrecordproto.RawACLRecordWithId{ - Payload: spaceDescription.AclPayload, - Id: spaceDescription.AclId, - }, - SpaceHeaderWithId: spaceDescription.SpaceHeader, - } - st, err := s.storageProvider.CreateSpaceStorage(payload) - if err != nil { - err = spacesyncproto.ErrUnexpected - if err == storage.ErrSpaceStorageExists { - err = spacesyncproto.ErrSpaceExists - } - return - } - err = st.Close() - return + return store.Id(), nil } func (s *service) GetSpace(ctx context.Context, id string) (Space, error) { st, err := s.storageProvider.SpaceStorage(id) if err != nil { - if err != spacesyncproto.ErrSpaceMissing { - return nil, err - } - - st, err = s.getSpaceStorageFromRemote(ctx, id) - if err != nil { - err = storage.ErrSpaceStorageMissing - return nil, err - } + return nil, err } lastConfiguration := s.configurationService.GetLast() @@ -148,38 +102,3 @@ func (s *service) GetSpace(ctx context.Context, id string) (Space, error) { } return sp, nil } - -func (s *service) getSpaceStorageFromRemote(ctx context.Context, id string) (st storage.SpaceStorage, err error) { - var p peer.Peer - peerId, err := syncservice.GetPeerIdFromStreamContext(ctx) - if err == nil { - p, err = s.pool.Dial(ctx, peerId) - if err != nil { - return - } - } else { - lastConfiguration := s.configurationService.GetLast() - // for nodes we always get remote space only if we have id in the context - if lastConfiguration.IsResponsible(id) { - err = spacesyncproto.ErrSpaceMissing - return - } - p, err = s.pool.DialOneOf(ctx, lastConfiguration.NodeIds(id)) - if err != nil { - return - } - } - cl := spacesyncproto.NewDRPCSpaceClient(p) - res, err := cl.PullSpace(ctx, &spacesyncproto.PullSpaceRequest{Id: id}) - if err != nil { - return - } - st, err = s.storageProvider.CreateSpaceStorage(storage.SpaceStorageCreatePayload{ - RecWithId: &aclrecordproto.RawACLRecordWithId{ - Payload: res.AclPayload, - Id: res.AclPayloadId, - }, - SpaceHeaderWithId: res.SpaceHeader, - }) - return -} diff --git a/common/commonspace/storage/mock_storage/mock_storage.go b/common/commonspace/storage/mock_storage/mock_storage.go index fb76ad05..419c61fa 100644 --- a/common/commonspace/storage/mock_storage/mock_storage.go +++ b/common/commonspace/storage/mock_storage/mock_storage.go @@ -162,18 +162,18 @@ func (mr *MockSpaceStorageMockRecorder) CreateTreeStorage(arg0 interface{}) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTreeStorage", reflect.TypeOf((*MockSpaceStorage)(nil).CreateTreeStorage), arg0) } -// ID mocks base method. -func (m *MockSpaceStorage) ID() string { +// Id mocks base method. +func (m *MockSpaceStorage) Id() string { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ID") + ret := m.ctrl.Call(m, "Id") ret0, _ := ret[0].(string) return ret0 } -// ID indicates an expected call of ID. -func (mr *MockSpaceStorageMockRecorder) ID() *gomock.Call { +// Id indicates an expected call of Id. +func (mr *MockSpaceStorageMockRecorder) Id() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ID", reflect.TypeOf((*MockSpaceStorage)(nil).ID)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Id", reflect.TypeOf((*MockSpaceStorage)(nil).Id)) } // SpaceHeader mocks base method. diff --git a/common/commonspace/storage/storage.go b/common/commonspace/storage/storage.go index a469a4b1..a18b9c16 100644 --- a/common/commonspace/storage/storage.go +++ b/common/commonspace/storage/storage.go @@ -6,7 +6,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto" - storage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" ) const CName = "commonspace.storage" @@ -16,7 +16,7 @@ var ErrSpaceStorageMissing = errors.New("space storage missing") type SpaceStorage interface { storage.Provider - ID() string + Id() string ACLStorage() (storage.ListStorage, error) SpaceHeader() (*spacesyncproto.RawSpaceHeaderWithId, error) StoredIds() ([]string, error) diff --git a/common/pkg/acl/aclrecordproto/aclrecord.pb.go b/common/pkg/acl/aclrecordproto/aclrecord.pb.go index bca4e5d8..d0e583fa 100644 --- a/common/pkg/acl/aclrecordproto/aclrecord.pb.go +++ b/common/pkg/acl/aclrecordproto/aclrecord.pb.go @@ -103,8 +103,10 @@ func (m *RawACLRecord) GetSignature() []byte { } type RawACLRecordWithId struct { - Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` - Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + AcceptorIdentity []byte `protobuf:"bytes,3,opt,name=acceptorIdentity,proto3" json:"acceptorIdentity,omitempty"` + AcceptorSignature []byte `protobuf:"bytes,4,opt,name=acceptorSignature,proto3" json:"acceptorSignature,omitempty"` } func (m *RawACLRecordWithId) Reset() { *m = RawACLRecordWithId{} } @@ -154,6 +156,20 @@ func (m *RawACLRecordWithId) GetId() string { return "" } +func (m *RawACLRecordWithId) GetAcceptorIdentity() []byte { + if m != nil { + return m.AcceptorIdentity + } + return nil +} + +func (m *RawACLRecordWithId) GetAcceptorSignature() []byte { + if m != nil { + return m.AcceptorSignature + } + return nil +} + type ACLRecord struct { PrevId string `protobuf:"bytes,1,opt,name=prevId,proto3" json:"prevId,omitempty"` Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` @@ -680,10 +696,13 @@ func (m *ACLUserAdd) GetPermissions() ACLUserPermissions { } type ACLUserInvite struct { - AcceptPublicKey []byte `protobuf:"bytes,1,opt,name=acceptPublicKey,proto3" json:"acceptPublicKey,omitempty"` - EncryptSymKeyHash uint64 `protobuf:"varint,2,opt,name=encryptSymKeyHash,proto3" json:"encryptSymKeyHash,omitempty"` + AcceptPublicKey []byte `protobuf:"bytes,1,opt,name=acceptPublicKey,proto3" json:"acceptPublicKey,omitempty"` + // TODO: change to read key + EncryptPublicKey []byte `protobuf:"bytes,2,opt,name=encryptPublicKey,proto3" json:"encryptPublicKey,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=aclrecord.ACLUserPermissions" json:"permissions,omitempty"` + // TODO: either derive inviteId from pub keys or think if it is possible to just use ACL record id + InviteId string `protobuf:"bytes,5,opt,name=inviteId,proto3" json:"inviteId,omitempty"` } func (m *ACLUserInvite) Reset() { *m = ACLUserInvite{} } @@ -726,11 +745,11 @@ func (m *ACLUserInvite) GetAcceptPublicKey() []byte { return nil } -func (m *ACLUserInvite) GetEncryptSymKeyHash() uint64 { +func (m *ACLUserInvite) GetEncryptPublicKey() []byte { if m != nil { - return m.EncryptSymKeyHash + return m.EncryptPublicKey } - return 0 + return nil } func (m *ACLUserInvite) GetEncryptedReadKeys() [][]byte { @@ -747,11 +766,18 @@ func (m *ACLUserInvite) GetPermissions() ACLUserPermissions { return ACLUserPermissions_Admin } +func (m *ACLUserInvite) GetInviteId() string { + if m != nil { + return m.InviteId + } + return "" +} + type ACLUserJoin struct { Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` AcceptSignature []byte `protobuf:"bytes,3,opt,name=acceptSignature,proto3" json:"acceptSignature,omitempty"` - AcceptPubKey []byte `protobuf:"bytes,4,opt,name=acceptPubKey,proto3" json:"acceptPubKey,omitempty"` + InviteId string `protobuf:"bytes,4,opt,name=inviteId,proto3" json:"inviteId,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,5,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` } @@ -809,11 +835,11 @@ func (m *ACLUserJoin) GetAcceptSignature() []byte { return nil } -func (m *ACLUserJoin) GetAcceptPubKey() []byte { +func (m *ACLUserJoin) GetInviteId() string { if m != nil { - return m.AcceptPubKey + return m.InviteId } - return nil + return "" } func (m *ACLUserJoin) GetEncryptedReadKeys() [][]byte { @@ -825,7 +851,7 @@ func (m *ACLUserJoin) GetEncryptedReadKeys() [][]byte { type ACLUserRemove struct { Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - ReadKeyReplaces []*ACLReadKeyReplace `protobuf:"bytes,2,rep,name=readKeyReplaces,proto3" json:"readKeyReplaces,omitempty"` + ReadKeyReplaces []*ACLReadKeyReplace `protobuf:"bytes,3,rep,name=readKeyReplaces,proto3" json:"readKeyReplaces,omitempty"` } func (m *ACLUserRemove) Reset() { *m = ACLUserRemove{} } @@ -987,6 +1013,168 @@ func (m *ACLUserPermissionChange) GetPermissions() ACLUserPermissions { return ACLUserPermissions_Admin } +type ACLSyncMessage struct { + Content *ACLSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` +} + +func (m *ACLSyncMessage) Reset() { *m = ACLSyncMessage{} } +func (m *ACLSyncMessage) String() string { return proto.CompactTextString(m) } +func (*ACLSyncMessage) ProtoMessage() {} +func (*ACLSyncMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_14abe0d1b4206d54, []int{14} +} +func (m *ACLSyncMessage) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ACLSyncMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ACLSyncMessage.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ACLSyncMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLSyncMessage.Merge(m, src) +} +func (m *ACLSyncMessage) XXX_Size() int { + return m.Size() +} +func (m *ACLSyncMessage) XXX_DiscardUnknown() { + xxx_messageInfo_ACLSyncMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_ACLSyncMessage proto.InternalMessageInfo + +func (m *ACLSyncMessage) GetContent() *ACLSyncContentValue { + if m != nil { + return m.Content + } + return nil +} + +// ACLSyncContentValue provides different types for acl sync +type ACLSyncContentValue struct { + // Types that are valid to be assigned to Value: + // + // *ACLSyncContentValue_AddRecords + Value isACLSyncContentValue_Value `protobuf_oneof:"value"` +} + +func (m *ACLSyncContentValue) Reset() { *m = ACLSyncContentValue{} } +func (m *ACLSyncContentValue) String() string { return proto.CompactTextString(m) } +func (*ACLSyncContentValue) ProtoMessage() {} +func (*ACLSyncContentValue) Descriptor() ([]byte, []int) { + return fileDescriptor_14abe0d1b4206d54, []int{15} +} +func (m *ACLSyncContentValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ACLSyncContentValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ACLSyncContentValue.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ACLSyncContentValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLSyncContentValue.Merge(m, src) +} +func (m *ACLSyncContentValue) XXX_Size() int { + return m.Size() +} +func (m *ACLSyncContentValue) XXX_DiscardUnknown() { + xxx_messageInfo_ACLSyncContentValue.DiscardUnknown(m) +} + +var xxx_messageInfo_ACLSyncContentValue proto.InternalMessageInfo + +type isACLSyncContentValue_Value interface { + isACLSyncContentValue_Value() + MarshalTo([]byte) (int, error) + Size() int +} + +type ACLSyncContentValue_AddRecords struct { + AddRecords *ACLAddRecords `protobuf:"bytes,1,opt,name=addRecords,proto3,oneof" json:"addRecords,omitempty"` +} + +func (*ACLSyncContentValue_AddRecords) isACLSyncContentValue_Value() {} + +func (m *ACLSyncContentValue) GetValue() isACLSyncContentValue_Value { + if m != nil { + return m.Value + } + return nil +} + +func (m *ACLSyncContentValue) GetAddRecords() *ACLAddRecords { + if x, ok := m.GetValue().(*ACLSyncContentValue_AddRecords); ok { + return x.AddRecords + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*ACLSyncContentValue) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*ACLSyncContentValue_AddRecords)(nil), + } +} + +type ACLAddRecords struct { + Records []*RawACLRecordWithId `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"` +} + +func (m *ACLAddRecords) Reset() { *m = ACLAddRecords{} } +func (m *ACLAddRecords) String() string { return proto.CompactTextString(m) } +func (*ACLAddRecords) ProtoMessage() {} +func (*ACLAddRecords) Descriptor() ([]byte, []int) { + return fileDescriptor_14abe0d1b4206d54, []int{16} +} +func (m *ACLAddRecords) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ACLAddRecords) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ACLAddRecords.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ACLAddRecords) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLAddRecords.Merge(m, src) +} +func (m *ACLAddRecords) XXX_Size() int { + return m.Size() +} +func (m *ACLAddRecords) XXX_DiscardUnknown() { + xxx_messageInfo_ACLAddRecords.DiscardUnknown(m) +} + +var xxx_messageInfo_ACLAddRecords proto.InternalMessageInfo + +func (m *ACLAddRecords) GetRecords() []*RawACLRecordWithId { + if m != nil { + return m.Records + } + return nil +} + func init() { proto.RegisterEnum("aclrecord.ACLUserPermissions", ACLUserPermissions_name, ACLUserPermissions_value) proto.RegisterType((*RawACLRecord)(nil), "aclrecord.RawACLRecord") @@ -1004,6 +1192,9 @@ func init() { proto.RegisterType((*ACLUserRemove)(nil), "aclrecord.ACLUserRemove") proto.RegisterType((*ACLReadKeyReplace)(nil), "aclrecord.ACLReadKeyReplace") proto.RegisterType((*ACLUserPermissionChange)(nil), "aclrecord.ACLUserPermissionChange") + proto.RegisterType((*ACLSyncMessage)(nil), "aclrecord.ACLSyncMessage") + proto.RegisterType((*ACLSyncContentValue)(nil), "aclrecord.ACLSyncContentValue") + proto.RegisterType((*ACLAddRecords)(nil), "aclrecord.ACLAddRecords") } func init() { @@ -1011,61 +1202,67 @@ func init() { } var fileDescriptor_14abe0d1b4206d54 = []byte{ - // 854 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xdf, 0x59, 0x3b, 0x71, 0xf6, 0xd9, 0x6d, 0xdc, 0x11, 0xa4, 0xab, 0xa8, 0x58, 0xd6, 0x8a, - 0x83, 0x55, 0x81, 0x0b, 0x06, 0xa9, 0x28, 0x07, 0x90, 0x6b, 0x5a, 0x39, 0x24, 0x87, 0x6a, 0x02, - 0x14, 0x71, 0x9b, 0xee, 0x8e, 0xe2, 0x51, 0xed, 0xdd, 0xd5, 0xec, 0xd8, 0xc8, 0x47, 0xce, 0x5c, - 0xe0, 0x23, 0xf0, 0x41, 0xb8, 0x23, 0x71, 0xe9, 0x05, 0xc4, 0x11, 0x25, 0x1f, 0x83, 0x0b, 0x9a, - 0xd9, 0xff, 0xbb, 0xb6, 0x45, 0x25, 0xab, 0x87, 0xc4, 0xf3, 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xf4, 0xf3, 0x6d, 0xcf, 0x78, 0x7d, 0xdb, 0x33, 0xfe, 0xbe, 0xed, 0x19, 0xdf, 0x9f, 0x6c, - 0xfe, 0x3d, 0xf7, 0xf2, 0x50, 0x7f, 0x7c, 0xf2, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0xdf, - 0xf6, 0x6c, 0xf0, 0x09, 0x00, 0x00, + // 959 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0xac, 0x9d, 0x38, 0x7e, 0x76, 0x13, 0x67, 0x80, 0xd4, 0x8a, 0x8a, 0x15, 0xad, 0x38, + 0x44, 0x55, 0x71, 0xc1, 0x20, 0xa5, 0xca, 0x05, 0xb9, 0xa6, 0x95, 0xdd, 0x04, 0xa9, 0x9a, 0x00, + 0x45, 0xbd, 0x4d, 0x77, 0x47, 0xc9, 0xa8, 0xf6, 0xee, 0x6a, 0x66, 0x6c, 0xe4, 0x23, 0x67, 0x2e, + 0x70, 0xe3, 0xca, 0x1f, 0xc2, 0x89, 0x0b, 0xc7, 0x5e, 0x90, 0x38, 0xa2, 0xe4, 0x1f, 0xe0, 0xce, + 0x05, 0xcd, 0xcc, 0xfe, 0x5e, 0x27, 0xa2, 0x52, 0xd4, 0x43, 0xe2, 0x9d, 0xf7, 0xbe, 0x79, 0xfb, + 0xbd, 0xef, 0xbd, 0x79, 0xb3, 0xf0, 0x71, 0xf4, 0xfa, 0xfc, 0x21, 0xf5, 0x66, 0xfa, 0x4f, 0x30, + 0x2f, 0x14, 0x7e, 0x24, 0x42, 0x15, 0x3e, 0x34, 0xff, 0x65, 0x66, 0x1d, 0x18, 0x03, 0x6e, 0xa5, + 0x06, 0xf7, 0x29, 0x74, 0x08, 0xfd, 0x7e, 0x34, 0x3e, 0x25, 0x66, 0x8d, 0x7b, 0xd0, 0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 0x25, 0x99, 0x94, 0xcd, 0xb9, 0x91, 0x96, 0x41, 0x9d, 0xc2, 0x48, 0xcb, 0xb0, 0xef, + 0x36, 0x2d, 0x53, 0x07, 0x93, 0xce, 0xd4, 0x8f, 0x27, 0x67, 0xba, 0x76, 0x7f, 0x47, 0xd0, 0xce, + 0x1d, 0xd8, 0x5b, 0xa8, 0x59, 0x2a, 0x59, 0x76, 0x27, 0xd6, 0xf3, 0x92, 0xa5, 0xe6, 0x02, 0xaf, + 0x46, 0x91, 0xd7, 0x7a, 0x89, 0x36, 0xae, 0x91, 0xc8, 0x95, 0x69, 0xdd, 0xe2, 0xb9, 0x79, 0x53, + 0x1a, 0x4f, 0x61, 0x27, 0x9e, 0x0a, 0x84, 0x45, 0x33, 0xea, 0xa5, 0x67, 0xfa, 0x5e, 0x51, 0x53, + 0x52, 0x00, 0x91, 0xf2, 0x26, 0xf7, 0x07, 0x04, 0xbb, 0x15, 0xd8, 0x2d, 0x08, 0xb8, 0xee, 0x72, + 0xac, 0xaf, 0xbf, 0x1c, 0xdd, 0x25, 0xdc, 0xbd, 0x66, 0xf0, 0xdf, 0x48, 0xa4, 0xd4, 0x52, 0xce, + 0x5b, 0x9f, 0x94, 0x67, 0xb0, 0xad, 0xa7, 0xde, 0x2a, 0xf0, 0xbe, 0x62, 0x52, 0xd2, 0x73, 0x86, + 0x1f, 0x41, 0xd3, 0x8b, 0xc7, 0xb8, 0x9d, 0x62, 0xfd, 0xd2, 0x84, 0x5c, 0x05, 0x5e, 0x61, 0x94, + 0x27, 0x70, 0xf7, 0x25, 0xbc, 0xb7, 0xc6, 0x6f, 0xae, 0x06, 0xdf, 0xb7, 0x9f, 0x4b, 0x32, 0xbe, + 0x6c, 0x4b, 0x93, 0x71, 0x94, 0xfa, 0xf5, 0x05, 0x95, 0xa1, 0xb3, 0xab, 0x66, 0x62, 0x1a, 0x23, + 0xc3, 0xe1, 0x23, 0x68, 0x8a, 0x34, 0xa4, 0x2e, 0x7a, 0x3e, 0xeb, 0xea, 0x97, 0x23, 0x49, 0xd0, + 0xf7, 0x8f, 0x00, 0x57, 0x45, 0xc1, 0x2d, 0xd8, 0x18, 0xf9, 0x73, 0x1e, 0x74, 0x6b, 0x18, 0x60, + 0xf3, 0x85, 0xe0, 0x8a, 0x89, 0x2e, 0xd2, 0xcf, 0xba, 0x42, 0x4c, 0x74, 0x9d, 0xc7, 0x9f, 0xfc, + 0x71, 0xd9, 0x47, 0x6f, 0x2e, 0xfb, 0xe8, 0xef, 0xcb, 0x3e, 0xfa, 0xe9, 0xaa, 0x5f, 0x7b, 0x73, + 0xd5, 0xaf, 0xfd, 0x75, 0xd5, 0xaf, 0xbd, 0xdc, 0x5b, 0xff, 0xb9, 0xfc, 0x6a, 0xd3, 0xfc, 0x7c, + 0xf6, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x04, 0x6d, 0x2c, 0x1d, 0x4f, 0x0b, 0x00, 0x00, } func (m *RawACLRecord) Marshal() (dAtA []byte, err error) { @@ -1125,6 +1322,20 @@ func (m *RawACLRecordWithId) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AcceptorSignature) > 0 { + i -= len(m.AcceptorSignature) + copy(dAtA[i:], m.AcceptorSignature) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.AcceptorSignature))) + i-- + dAtA[i] = 0x22 + } + if len(m.AcceptorIdentity) > 0 { + i -= len(m.AcceptorIdentity) + copy(dAtA[i:], m.AcceptorIdentity) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.AcceptorIdentity))) + i-- + dAtA[i] = 0x1a + } if len(m.Id) > 0 { i -= len(m.Id) copy(dAtA[i:], m.Id) @@ -1632,6 +1843,13 @@ func (m *ACLUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.InviteId) > 0 { + i -= len(m.InviteId) + copy(dAtA[i:], m.InviteId) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.InviteId))) + i-- + dAtA[i] = 0x2a + } if m.Permissions != 0 { i = encodeVarintAclrecord(dAtA, i, uint64(m.Permissions)) i-- @@ -1646,10 +1864,12 @@ func (m *ACLUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x1a } } - if m.EncryptSymKeyHash != 0 { - i = encodeVarintAclrecord(dAtA, i, uint64(m.EncryptSymKeyHash)) + if len(m.EncryptPublicKey) > 0 { + i -= len(m.EncryptPublicKey) + copy(dAtA[i:], m.EncryptPublicKey) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptPublicKey))) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x12 } if len(m.AcceptPublicKey) > 0 { i -= len(m.AcceptPublicKey) @@ -1690,10 +1910,10 @@ func (m *ACLUserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x2a } } - if len(m.AcceptPubKey) > 0 { - i -= len(m.AcceptPubKey) - copy(dAtA[i:], m.AcceptPubKey) - i = encodeVarintAclrecord(dAtA, i, uint64(len(m.AcceptPubKey))) + if len(m.InviteId) > 0 { + i -= len(m.InviteId) + copy(dAtA[i:], m.InviteId) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.InviteId))) i-- dAtA[i] = 0x22 } @@ -1752,7 +1972,7 @@ func (m *ACLUserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } } if len(m.Identity) > 0 { @@ -1844,6 +2064,131 @@ func (m *ACLUserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *ACLSyncMessage) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ACLSyncMessage) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ACLSyncMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Content != nil { + { + size, err := m.Content.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAclrecord(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} + +func (m *ACLSyncContentValue) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ACLSyncContentValue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ACLSyncContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != nil { + { + size := m.Value.Size() + i -= size + if _, err := m.Value.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *ACLSyncContentValue_AddRecords) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ACLSyncContentValue_AddRecords) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.AddRecords != nil { + { + size, err := m.AddRecords.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAclrecord(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *ACLAddRecords) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ACLAddRecords) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ACLAddRecords) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Records) > 0 { + for iNdEx := len(m.Records) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Records[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAclrecord(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintAclrecord(dAtA []byte, offset int, v uint64) int { offset -= sovAclrecord(v) base := offset @@ -1886,6 +2231,14 @@ func (m *RawACLRecordWithId) Size() (n int) { if l > 0 { n += 1 + l + sovAclrecord(uint64(l)) } + l = len(m.AcceptorIdentity) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.AcceptorSignature) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } return n } @@ -2129,8 +2482,9 @@ func (m *ACLUserInvite) Size() (n int) { if l > 0 { n += 1 + l + sovAclrecord(uint64(l)) } - if m.EncryptSymKeyHash != 0 { - n += 1 + sovAclrecord(uint64(m.EncryptSymKeyHash)) + l = len(m.EncryptPublicKey) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) } if len(m.EncryptedReadKeys) > 0 { for _, b := range m.EncryptedReadKeys { @@ -2141,6 +2495,10 @@ func (m *ACLUserInvite) Size() (n int) { if m.Permissions != 0 { n += 1 + sovAclrecord(uint64(m.Permissions)) } + l = len(m.InviteId) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } return n } @@ -2162,7 +2520,7 @@ func (m *ACLUserJoin) Size() (n int) { if l > 0 { n += 1 + l + sovAclrecord(uint64(l)) } - l = len(m.AcceptPubKey) + l = len(m.InviteId) if l > 0 { n += 1 + l + sovAclrecord(uint64(l)) } @@ -2231,6 +2589,58 @@ func (m *ACLUserPermissionChange) Size() (n int) { return n } +func (m *ACLSyncMessage) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Content != nil { + l = m.Content.Size() + n += 1 + l + sovAclrecord(uint64(l)) + } + return n +} + +func (m *ACLSyncContentValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != nil { + n += m.Value.Size() + } + return n +} + +func (m *ACLSyncContentValue_AddRecords) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AddRecords != nil { + l = m.AddRecords.Size() + n += 1 + l + sovAclrecord(uint64(l)) + } + return n +} +func (m *ACLAddRecords) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Records) > 0 { + for _, e := range m.Records { + l = e.Size() + n += 1 + l + sovAclrecord(uint64(l)) + } + } + return n +} + func sovAclrecord(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2450,6 +2860,74 @@ func (m *RawACLRecordWithId) Unmarshal(dAtA []byte) error { } m.Id = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AcceptorIdentity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AcceptorIdentity = append(m.AcceptorIdentity[:0], dAtA[iNdEx:postIndex]...) + if m.AcceptorIdentity == nil { + m.AcceptorIdentity = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AcceptorSignature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AcceptorSignature = append(m.AcceptorSignature[:0], dAtA[iNdEx:postIndex]...) + if m.AcceptorSignature == nil { + m.AcceptorSignature = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAclrecord(dAtA[iNdEx:]) @@ -3881,10 +4359,10 @@ func (m *ACLUserInvite) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptSymKeyHash", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptPublicKey", wireType) } - m.EncryptSymKeyHash = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclrecord @@ -3894,11 +4372,26 @@ func (m *ACLUserInvite) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.EncryptSymKeyHash |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptPublicKey = append(m.EncryptPublicKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptPublicKey == nil { + m.EncryptPublicKey = []byte{} + } + iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) @@ -3950,6 +4443,38 @@ func (m *ACLUserInvite) Unmarshal(dAtA []byte) error { break } } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InviteId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InviteId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAclrecord(dAtA[iNdEx:]) @@ -4104,9 +4629,9 @@ func (m *ACLUserJoin) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AcceptPubKey", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field InviteId", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclrecord @@ -4116,25 +4641,23 @@ func (m *ACLUserJoin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAclrecord } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF } - m.AcceptPubKey = append(m.AcceptPubKey[:0], dAtA[iNdEx:postIndex]...) - if m.AcceptPubKey == nil { - m.AcceptPubKey = []byte{} - } + m.InviteId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: if wireType != 2 { @@ -4252,7 +4775,7 @@ func (m *ACLUserRemove) Unmarshal(dAtA []byte) error { m.Identity = []byte{} } iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ReadKeyReplaces", wireType) } @@ -4562,6 +5085,261 @@ func (m *ACLUserPermissionChange) Unmarshal(dAtA []byte) error { } return nil } +func (m *ACLSyncMessage) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ACLSyncMessage: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLSyncMessage: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Content == nil { + m.Content = &ACLSyncContentValue{} + } + if err := m.Content.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLSyncContentValue) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ACLSyncContentValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLSyncContentValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AddRecords", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ACLAddRecords{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ACLSyncContentValue_AddRecords{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLAddRecords) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ACLAddRecords: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLAddRecords: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Records = append(m.Records, &RawACLRecordWithId{}) + if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipAclrecord(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/common/pkg/acl/aclrecordproto/protos/aclrecord.proto b/common/pkg/acl/aclrecordproto/protos/aclrecord.proto index bca03cd6..cf0afcfa 100644 --- a/common/pkg/acl/aclrecordproto/protos/aclrecord.proto +++ b/common/pkg/acl/aclrecordproto/protos/aclrecord.proto @@ -3,99 +3,124 @@ package aclrecord; option go_package = "pkg/acl/aclrecordproto"; message RawACLRecord { - bytes payload = 1; - bytes signature = 2; + bytes payload = 1; + bytes signature = 2; } message RawACLRecordWithId { - bytes payload = 1; - string id = 2; + bytes payload = 1; + string id = 2; + bytes acceptorIdentity = 3; + bytes acceptorSignature = 4; } message ACLRecord { - string prevId = 1; - bytes identity = 2; - bytes data = 3; - uint64 currentReadKeyHash = 4; - int64 timestamp = 5; + string prevId = 1; + bytes identity = 2; + bytes data = 3; + uint64 currentReadKeyHash = 4; + int64 timestamp = 5; } message ACLRoot { - bytes identity = 1; - bytes encryptionKey = 2; - string spaceId = 3; - bytes encryptedReadKey = 4; - string derivationScheme = 5; - uint64 currentReadKeyHash = 6; - int64 timestamp = 7; + bytes identity = 1; + bytes encryptionKey = 2; + string spaceId = 3; + bytes encryptedReadKey = 4; + string derivationScheme = 5; + uint64 currentReadKeyHash = 6; + int64 timestamp = 7; } message ACLContentValue { - oneof value { - ACLUserAdd userAdd = 1; - ACLUserRemove userRemove = 2; - ACLUserPermissionChange userPermissionChange = 3; - ACLUserInvite userInvite = 4; - ACLUserJoin userJoin = 5; - } + oneof value { + ACLUserAdd userAdd = 1; + ACLUserRemove userRemove = 2; + ACLUserPermissionChange userPermissionChange = 3; + ACLUserInvite userInvite = 4; + ACLUserJoin userJoin = 5; + } } message ACLData { - repeated ACLContentValue aclContent = 1; + repeated ACLContentValue aclContent = 1; } message ACLState { - repeated uint64 readKeyHashes = 1; - repeated ACLUserState userStates = 2; - map invites = 3; + repeated uint64 readKeyHashes = 1; + repeated ACLUserState userStates = 2; + map invites = 3; } message ACLUserState { - bytes identity = 1; - bytes encryptionKey = 2; - ACLUserPermissions permissions = 3; + bytes identity = 1; + bytes encryptionKey = 2; + ACLUserPermissions permissions = 3; } message ACLUserAdd { - bytes identity = 1; - bytes encryptionKey = 2; - repeated bytes encryptedReadKeys = 3; - ACLUserPermissions permissions = 4; + bytes identity = 1; + bytes encryptionKey = 2; + repeated bytes encryptedReadKeys = 3; + ACLUserPermissions permissions = 4; } +// accept key, encrypt key, invite id +// GetSpace(id) -> ... (space header + acl root) -> diff +// Join(ACLJoinRecord) -> Ok + message ACLUserInvite { - bytes acceptPublicKey = 1; - uint64 encryptSymKeyHash = 2; - repeated bytes encryptedReadKeys = 3; - ACLUserPermissions permissions = 4; + bytes acceptPublicKey = 1; + // TODO: change to read key + bytes encryptPublicKey = 2; + repeated bytes encryptedReadKeys = 3; + ACLUserPermissions permissions = 4; + // TODO: either derive inviteId from pub keys or think if it is possible to just use ACL record id + string inviteId = 5; } message ACLUserJoin { - bytes identity = 1; - bytes encryptionKey = 2; - bytes acceptSignature = 3; - bytes acceptPubKey = 4; - repeated bytes encryptedReadKeys = 5; + bytes identity = 1; + bytes encryptionKey = 2; + bytes acceptSignature = 3; + string inviteId = 4; + repeated bytes encryptedReadKeys = 5; } message ACLUserRemove { - bytes identity = 1; - repeated ACLReadKeyReplace readKeyReplaces = 2; + bytes identity = 1; + repeated ACLReadKeyReplace readKeyReplaces = 3; } message ACLReadKeyReplace { - bytes identity = 1; - bytes encryptionKey = 2; - bytes encryptedReadKey = 3; + bytes identity = 1; + bytes encryptionKey = 2; + bytes encryptedReadKey = 3; } message ACLUserPermissionChange { - bytes identity = 1; - ACLUserPermissions permissions = 2; + bytes identity = 1; + ACLUserPermissions permissions = 2; } enum ACLUserPermissions { - Admin = 0; - Writer = 1; - Reader = 2; + Admin = 0; + Writer = 1; + Reader = 2; } + + +message ACLSyncMessage { + ACLSyncContentValue content = 2; +} + +// ACLSyncContentValue provides different types for acl sync +message ACLSyncContentValue { + oneof value { + ACLAddRecords addRecords = 1; + } +} + +message ACLAddRecords { + repeated RawACLRecordWithId records = 1; +} \ No newline at end of file diff --git a/common/pkg/acl/list/list.go b/common/pkg/acl/list/list.go index 6045fec4..3c91bd33 100644 --- a/common/pkg/acl/list/list.go +++ b/common/pkg/acl/list/list.go @@ -25,11 +25,10 @@ type RWLocker interface { type ACLList interface { RWLocker ID() string - Root() *aclrecordproto.RawACLRecordWithId + Root() *aclrecordproto.ACLRoot Records() []*ACLRecord ACLState() *ACLState IsAfter(first string, second string) (bool, error) - AddRawRecords(ctx context.Context, rec []*aclrecordproto.RawACLRecordWithId) (err error) Head() *ACLRecord Get(id string) (*ACLRecord, error) Iterate(iterFunc IterFunc) @@ -38,32 +37,38 @@ type ACLList interface { } type aclList struct { - root *aclrecordproto.RawACLRecordWithId + root *aclrecordproto.ACLRoot records []*ACLRecord indexes map[string]int id string - stateBuilder *aclStateBuilder - recordBuilder ACLRecordBuilder - aclState *ACLState - keychain *common.Keychain - storage storage.ListStorage + builder *aclStateBuilder + aclState *ACLState + keychain *common.Keychain sync.RWMutex } func BuildACLListWithIdentity(acc *account.AccountData, storage storage.ListStorage) (ACLList, error) { - id := storage.ID() builder := newACLStateBuilderWithIdentity(acc) - return build(id, builder, newACLRecordBuilder(id, common.NewKeychain()), storage) + return build(storage.Id(), builder, newACLRecordBuilder(storage.Id(), common.NewKeychain()), storage) } func BuildACLList(storage storage.ListStorage) (ACLList, error) { - id := storage.ID() - return build(id, newACLStateBuilder(), newACLRecordBuilder(id, common.NewKeychain()), storage) + return build(storage.Id(), newACLStateBuilder(), newACLRecordBuilder(storage.Id(), common.NewKeychain()), storage) } func build(id string, stateBuilder *aclStateBuilder, recBuilder ACLRecordBuilder, storage storage.ListStorage) (list ACLList, err error) { + // TODO: need to add context here + rootWithId, err := storage.Root() + if err != nil { + return + } + aclRecRoot, err := recBuilder.ConvertFromRaw(rootWithId) + if err != nil { + return + } + head, err := storage.Head() if err != nil { return @@ -80,7 +85,7 @@ func build(id string, stateBuilder *aclStateBuilder, recBuilder ACLRecordBuilder } records := []*ACLRecord{record} - for record.PrevId != "" { + for record.PrevId != "" && record.PrevId != id { rawRecordWithId, err = storage.GetRawRecord(context.Background(), record.PrevId) if err != nil { return @@ -92,6 +97,8 @@ func build(id string, stateBuilder *aclStateBuilder, recBuilder ACLRecordBuilder } records = append(records, record) } + // adding root in the end, because we already parsed it + records = append(records, aclRecRoot) indexes := make(map[string]int) for i, j := 0, len(records)-1; i < j; i, j = i+1, j-1 { @@ -110,21 +117,14 @@ func build(id string, stateBuilder *aclStateBuilder, recBuilder ACLRecordBuilder return } - rootWithId, err := storage.Root() - if err != nil { - return - } - list = &aclList{ - root: rootWithId, - records: records, - indexes: indexes, - stateBuilder: stateBuilder, - recordBuilder: recBuilder, - aclState: state, - storage: storage, - id: id, - RWMutex: sync.RWMutex{}, + root: aclRecRoot.Model.(*aclrecordproto.ACLRoot), + records: records, + indexes: indexes, + builder: stateBuilder, + aclState: state, + id: id, + RWMutex: sync.RWMutex{}, } return } @@ -137,44 +137,10 @@ func (a *aclList) ID() string { return a.id } -func (a *aclList) Root() *aclrecordproto.RawACLRecordWithId { +func (a *aclList) Root() *aclrecordproto.ACLRoot { return a.root } -func (a *aclList) AddRawRecords(ctx context.Context, records []*aclrecordproto.RawACLRecordWithId) (err error) { - if len(records) == 0 { - return - } - // converting and verifying - var aclRecords []*ACLRecord - for _, rec := range records { - var record *ACLRecord - record, err = a.recordBuilder.ConvertFromRaw(rec) - if err != nil { - return - } - aclRecords = append(aclRecords, record) - } - - // trying to append them to state - err = a.stateBuilder.Append(a.aclState, aclRecords) - if err != nil { - return - } - - // saving to storage - for _, rec := range records { - err = a.storage.AddRawRecord(ctx, rec) - if err != nil { - return - } - } - - // setting new head - err = a.storage.SetHead(records[len(records)-1].Id) - return -} - func (a *aclList) ACLState() *ACLState { return a.aclState } diff --git a/common/pkg/acl/storage/inmemory.go b/common/pkg/acl/storage/inmemory.go index d3d42b1e..e9834f9a 100644 --- a/common/pkg/acl/storage/inmemory.go +++ b/common/pkg/acl/storage/inmemory.go @@ -9,10 +9,8 @@ import ( ) type inMemoryACLListStorage struct { + records []*aclrecordproto.RawACLRecordWithId id string - root *aclrecordproto.RawACLRecordWithId - head string - records map[string]*aclrecordproto.RawACLRecordWithId sync.RWMutex } @@ -20,63 +18,48 @@ type inMemoryACLListStorage struct { func NewInMemoryACLListStorage( id string, records []*aclrecordproto.RawACLRecordWithId) (ListStorage, error) { - - allRecords := make(map[string]*aclrecordproto.RawACLRecordWithId) - for _, ch := range records { - allRecords[ch.Id] = ch - } - root := records[0] - head := records[len(records)-1] - return &inMemoryACLListStorage{ - id: root.Id, - root: root, - head: head.Id, - records: allRecords, + id: id, + records: records, RWMutex: sync.RWMutex{}, }, nil } -func (t *inMemoryACLListStorage) ID() string { - t.RLock() - defer t.RUnlock() - return t.id +func (i *inMemoryACLListStorage) Root() (*aclrecordproto.RawACLRecordWithId, error) { + i.RLock() + defer i.RUnlock() + return i.records[0], nil } -func (t *inMemoryACLListStorage) Root() (*aclrecordproto.RawACLRecordWithId, error) { - t.RLock() - defer t.RUnlock() - return t.root, nil +func (i *inMemoryACLListStorage) SetHead(headId string) error { + panic("implement me") } -func (t *inMemoryACLListStorage) Head() (string, error) { - t.RLock() - defer t.RUnlock() - return t.head, nil +func (i *inMemoryACLListStorage) Head() (string, error) { + i.RLock() + defer i.RUnlock() + return i.records[len(i.records)-1].Id, nil } -func (t *inMemoryACLListStorage) SetHead(head string) error { - t.Lock() - defer t.Unlock() - t.head = head - return nil -} - -func (t *inMemoryACLListStorage) AddRawRecord(ctx context.Context, record *aclrecordproto.RawACLRecordWithId) error { - t.Lock() - defer t.Unlock() - // TODO: better to do deep copy - t.records[record.Id] = record - return nil -} - -func (t *inMemoryACLListStorage) GetRawRecord(ctx context.Context, recordId string) (*aclrecordproto.RawACLRecordWithId, error) { - t.RLock() - defer t.RUnlock() - if res, exists := t.records[recordId]; exists { - return res, nil +func (i *inMemoryACLListStorage) GetRawRecord(ctx context.Context, id string) (*aclrecordproto.RawACLRecordWithId, error) { + i.RLock() + defer i.RUnlock() + for _, rec := range i.records { + if rec.Id == id { + return rec, nil + } } - return nil, fmt.Errorf("could not get record with id: %s", recordId) + return nil, fmt.Errorf("no such record") +} + +func (i *inMemoryACLListStorage) AddRawRecord(ctx context.Context, rec *aclrecordproto.RawACLRecordWithId) error { + panic("implement me") +} + +func (i *inMemoryACLListStorage) Id() string { + i.RLock() + defer i.RUnlock() + return i.id } type inMemoryTreeStorage struct { @@ -89,6 +72,7 @@ type inMemoryTreeStorage struct { } func NewInMemoryTreeStorage( + treeId string, root *treechangeproto.RawTreeChangeWithId, heads []string, changes []*treechangeproto.RawTreeChangeWithId) (TreeStorage, error) { @@ -96,10 +80,10 @@ func NewInMemoryTreeStorage( for _, ch := range changes { allChanges[ch.Id] = ch } - allChanges[root.Id] = root + allChanges[treeId] = root return &inMemoryTreeStorage{ - id: root.Id, + id: treeId, root: root, heads: heads, changes: allChanges, @@ -112,7 +96,7 @@ func (t *inMemoryTreeStorage) HasChange(ctx context.Context, id string) (bool, e return exists, nil } -func (t *inMemoryTreeStorage) ID() string { +func (t *inMemoryTreeStorage) Id() string { t.RLock() defer t.RUnlock() return t.id @@ -175,12 +159,12 @@ func (i *inMemoryStorageProvider) TreeStorage(id string) (TreeStorage, error) { func (i *inMemoryStorageProvider) CreateTreeStorage(payload TreeStorageCreatePayload) (TreeStorage, error) { i.Lock() defer i.Unlock() - res, err := NewInMemoryTreeStorage(payload.RootRawChange, payload.Heads, payload.Changes) + res, err := NewInMemoryTreeStorage(payload.TreeId, payload.RootRawChange, payload.Heads, payload.Changes) if err != nil { return nil, err } - i.objects[payload.RootRawChange.Id] = res + i.objects[payload.TreeId] = res return res, nil } diff --git a/common/pkg/acl/storage/liststorage.go b/common/pkg/acl/storage/liststorage.go index 81bb43cc..bfe47ab9 100644 --- a/common/pkg/acl/storage/liststorage.go +++ b/common/pkg/acl/storage/liststorage.go @@ -12,7 +12,7 @@ var ErrACLExists = errors.New("acl already exists") var ErrUnknownRecord = errors.New("record doesn't exist") type ListStorage interface { - ID() string + Id() string Root() (*aclrecordproto.RawACLRecordWithId, error) Head() (string, error) SetHead(headId string) error diff --git a/common/pkg/acl/storage/mock_storage/mock_storage.go b/common/pkg/acl/storage/mock_storage/mock_storage.go index 38f8a2b2..751184a7 100644 --- a/common/pkg/acl/storage/mock_storage/mock_storage.go +++ b/common/pkg/acl/storage/mock_storage/mock_storage.go @@ -80,18 +80,18 @@ func (mr *MockListStorageMockRecorder) Head() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Head", reflect.TypeOf((*MockListStorage)(nil).Head)) } -// ID mocks base method. -func (m *MockListStorage) ID() string { +// Id mocks base method. +func (m *MockListStorage) Id() string { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ID") + ret := m.ctrl.Call(m, "Id") ret0, _ := ret[0].(string) return ret0 } -// ID indicates an expected call of ID. -func (mr *MockListStorageMockRecorder) ID() *gomock.Call { +// Id indicates an expected call of Id. +func (mr *MockListStorageMockRecorder) Id() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ID", reflect.TypeOf((*MockListStorage)(nil).ID)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Id", reflect.TypeOf((*MockListStorage)(nil).Id)) } // Root mocks base method. @@ -205,18 +205,18 @@ func (mr *MockTreeStorageMockRecorder) Heads() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Heads", reflect.TypeOf((*MockTreeStorage)(nil).Heads)) } -// ID mocks base method. -func (m *MockTreeStorage) ID() string { +// Id mocks base method. +func (m *MockTreeStorage) Id() string { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ID") + ret := m.ctrl.Call(m, "Id") ret0, _ := ret[0].(string) return ret0 } -// ID indicates an expected call of ID. -func (mr *MockTreeStorageMockRecorder) ID() *gomock.Call { +// Id indicates an expected call of Id. +func (mr *MockTreeStorageMockRecorder) Id() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ID", reflect.TypeOf((*MockTreeStorage)(nil).ID)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Id", reflect.TypeOf((*MockTreeStorage)(nil).Id)) } // Root mocks base method. diff --git a/common/pkg/acl/storage/treestorage.go b/common/pkg/acl/storage/treestorage.go index 751dd1d9..549e872a 100644 --- a/common/pkg/acl/storage/treestorage.go +++ b/common/pkg/acl/storage/treestorage.go @@ -6,7 +6,7 @@ import ( ) type TreeStorage interface { - ID() string + Id() string Root() (*treechangeproto.RawTreeChangeWithId, error) Heads() ([]string, error) SetHeads(heads []string) error diff --git a/common/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go b/common/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go index a1309073..33703a9b 100644 --- a/common/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go +++ b/common/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go @@ -3,13 +3,13 @@ package acllistbuilder import ( "context" "fmt" - aclrecordproto "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto" + aclrecordproto2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/testutils/yamltests" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/cid" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/symmetric" + "hash/fnv" "io/ioutil" "path" "time" @@ -19,12 +19,20 @@ import ( ) type ACLListStorageBuilder struct { - storage.ListStorage - keychain *YAMLKeychain + aclList string + records []*aclrecordproto2.ACLRecord + rawRecords []*aclrecordproto2.RawACLRecordWithId + indexes map[string]int + keychain *YAMLKeychain + rawRoot *aclrecordproto2.RawACLRecordWithId + root *aclrecordproto2.ACLRoot + id string } func NewACLListStorageBuilder(keychain *YAMLKeychain) *ACLListStorageBuilder { return &ACLListStorageBuilder{ + records: make([]*aclrecordproto2.ACLRecord, 0), + indexes: make(map[string]int), keychain: keychain, } } @@ -52,7 +60,7 @@ func NewACLListStorageBuilderFromFile(file string) (*ACLListStorageBuilder, erro return tb, nil } -func (t *ACLListStorageBuilder) createRaw(rec proto.Marshaler, identity []byte) *aclrecordproto.RawACLRecordWithId { +func (t *ACLListStorageBuilder) createRaw(rec proto.Marshaler, identity []byte) *aclrecordproto2.RawACLRecordWithId { protoMarshalled, err := rec.Marshal() if err != nil { panic("should be able to marshal final acl message!") @@ -63,7 +71,7 @@ func (t *ACLListStorageBuilder) createRaw(rec proto.Marshaler, identity []byte) panic("should be able to sign final acl message!") } - rawRec := &aclrecordproto.RawACLRecord{ + rawRec := &aclrecordproto2.RawACLRecord{ Payload: protoMarshalled, Signature: signature, } @@ -75,62 +83,94 @@ func (t *ACLListStorageBuilder) createRaw(rec proto.Marshaler, identity []byte) id, _ := cid.NewCIDFromBytes(rawMarshalled) - return &aclrecordproto.RawACLRecordWithId{ + return &aclrecordproto2.RawACLRecordWithId{ Payload: rawMarshalled, Id: id, } } +func (t *ACLListStorageBuilder) Head() (string, error) { + l := len(t.records) + if l > 0 { + return t.rawRecords[l-1].Id, nil + } + return t.rawRoot.Id, nil +} + +func (t *ACLListStorageBuilder) SetHead(headId string) error { + panic("SetHead is not implemented") +} + +func (t *ACLListStorageBuilder) Root() (*aclrecordproto2.RawACLRecordWithId, error) { + return t.rawRoot, nil +} + +func (t *ACLListStorageBuilder) GetRawRecord(ctx context.Context, id string) (*aclrecordproto2.RawACLRecordWithId, error) { + recIdx, ok := t.indexes[id] + if !ok { + if id == t.rawRoot.Id { + return t.rawRoot, nil + } + return nil, fmt.Errorf("no such record") + } + return t.rawRecords[recIdx], nil +} + +func (t *ACLListStorageBuilder) AddRawRecord(ctx context.Context, rec *aclrecordproto2.RawACLRecordWithId) error { + panic("implement me") +} + +func (t *ACLListStorageBuilder) Id() string { + return t.id +} + +func (t *ACLListStorageBuilder) GetRawRecords() []*aclrecordproto2.RawACLRecordWithId { + return t.rawRecords +} + func (t *ACLListStorageBuilder) GetKeychain() *YAMLKeychain { return t.keychain } -func (t *ACLListStorageBuilder) Parse(l *YMLList) { +func (t *ACLListStorageBuilder) Parse(tree *YMLList) { // Just to clarify - we are generating new identities for the ones that // are specified in the yml file, because our identities should be Ed25519 // the same thing is happening for the encryption keys - t.keychain.ParseKeys(&l.Keys) - rawRoot := t.parseRoot(l.Root) - var err error - t.ListStorage, err = storage.NewInMemoryACLListStorage(rawRoot.Id, []*aclrecordproto.RawACLRecordWithId{rawRoot}) - if err != nil { - panic(err) - } - prevId := rawRoot.Id - for _, rec := range l.Records { + t.keychain.ParseKeys(&tree.Keys) + t.parseRoot(tree.Root) + prevId := t.id + for idx, rec := range tree.Records { newRecord := t.parseRecord(rec, prevId) rawRecord := t.createRaw(newRecord, newRecord.Identity) - err = t.AddRawRecord(context.Background(), rawRecord) - if err != nil { - panic(err) - } + t.records = append(t.records, newRecord) + t.rawRecords = append(t.rawRecords, rawRecord) + t.indexes[rawRecord.Id] = idx prevId = rawRecord.Id } - t.SetHead(prevId) } -func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclrecordproto.ACLRecord { +func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclrecordproto2.ACLRecord { k := t.keychain.GetKey(rec.ReadKey).(*SymKey) - var aclChangeContents []*aclrecordproto.ACLContentValue + var aclChangeContents []*aclrecordproto2.ACLContentValue for _, ch := range rec.AclChanges { aclChangeContent := t.parseACLChange(ch) aclChangeContents = append(aclChangeContents, aclChangeContent) } - data := &aclrecordproto.ACLData{ + data := &aclrecordproto2.ACLData{ AclContent: aclChangeContents, } bytes, _ := data.Marshal() - return &aclrecordproto.ACLRecord{ + return &aclrecordproto2.ACLRecord{ PrevId: prevId, Identity: []byte(t.keychain.GetIdentity(rec.Identity)), Data: bytes, CurrentReadKeyHash: k.Hash, - Timestamp: time.Now().UnixNano(), + Timestamp: time.Now().Unix(), } } -func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecordproto.ACLContentValue) { +func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecordproto2.ACLContentValue) { switch { case ch.UserAdd != nil: add := ch.UserAdd @@ -138,12 +178,12 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecord encKey := t.keychain.GetKey(add.EncryptionKey).(encryptionkey.PrivKey) rawKey, _ := encKey.GetPublic().Raw() - convCh = &aclrecordproto.ACLContentValue{ - Value: &aclrecordproto.ACLContentValue_UserAdd{ - UserAdd: &aclrecordproto.ACLUserAdd{ + convCh = &aclrecordproto2.ACLContentValue{ + Value: &aclrecordproto2.ACLContentValue_UserAdd{ + UserAdd: &aclrecordproto2.ACLUserAdd{ Identity: []byte(t.keychain.GetIdentity(add.Identity)), EncryptionKey: rawKey, - EncryptedReadKeys: t.encryptReadKeysWithPubKey(add.EncryptedReadKeys, encKey), + EncryptedReadKeys: t.encryptReadKeys(add.EncryptedReadKeys, encKey), Permissions: t.convertPermission(add.Permission), }, }, @@ -151,50 +191,52 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecord case ch.UserJoin != nil: join := ch.UserJoin - encKey := t.keychain.GetKey(join.EncryptionKey).(encryptionkey.PrivKey) + encKey := t.keychain. + GetKey(join.EncryptionKey).(encryptionkey.PrivKey) rawKey, _ := encKey.GetPublic().Raw() - idKey, _ := t.keychain.SigningKeysByYAMLName[join.Identity].GetPublic().Raw() - signKey := t.keychain.GetKey(join.AcceptKey).(signingkey.PrivKey) + idKey, _ := t.keychain.SigningKeysByYAMLIdentity[join.Identity].GetPublic().Raw() + signKey := t.keychain.GetKey(join.AcceptSignature).(signingkey.PrivKey) signature, err := signKey.Sign(idKey) if err != nil { panic(err) } - acceptPubKey, _ := signKey.GetPublic().Raw() - convCh = &aclrecordproto.ACLContentValue{ - Value: &aclrecordproto.ACLContentValue_UserJoin{ - UserJoin: &aclrecordproto.ACLUserJoin{ + convCh = &aclrecordproto2.ACLContentValue{ + Value: &aclrecordproto2.ACLContentValue_UserJoin{ + UserJoin: &aclrecordproto2.ACLUserJoin{ Identity: []byte(t.keychain.GetIdentity(join.Identity)), EncryptionKey: rawKey, AcceptSignature: signature, - AcceptPubKey: acceptPubKey, - EncryptedReadKeys: t.encryptReadKeysWithPubKey(join.EncryptedReadKeys, encKey), + InviteId: join.InviteId, + EncryptedReadKeys: t.encryptReadKeys(join.EncryptedReadKeys, encKey), }, }, } case ch.UserInvite != nil: invite := ch.UserInvite rawAcceptKey, _ := t.keychain.GetKey(invite.AcceptKey).(signingkey.PrivKey).GetPublic().Raw() - hash := t.keychain.GetKey(invite.EncryptionKey).(*SymKey).Hash - encKey := t.keychain.ReadKeysByHash[hash] + encKey := t.keychain. + GetKey(invite.EncryptionKey).(encryptionkey.PrivKey) + rawEncKey, _ := encKey.GetPublic().Raw() - convCh = &aclrecordproto.ACLContentValue{ - Value: &aclrecordproto.ACLContentValue_UserInvite{ - UserInvite: &aclrecordproto.ACLUserInvite{ + convCh = &aclrecordproto2.ACLContentValue{ + Value: &aclrecordproto2.ACLContentValue_UserInvite{ + UserInvite: &aclrecordproto2.ACLUserInvite{ AcceptPublicKey: rawAcceptKey, - EncryptSymKeyHash: hash, - EncryptedReadKeys: t.encryptReadKeysWithSymKey(invite.EncryptedReadKeys, encKey.Key), + EncryptPublicKey: rawEncKey, + EncryptedReadKeys: t.encryptReadKeys(invite.EncryptedReadKeys, encKey), Permissions: t.convertPermission(invite.Permissions), + InviteId: invite.InviteId, }, }, } case ch.UserPermissionChange != nil: permissionChange := ch.UserPermissionChange - convCh = &aclrecordproto.ACLContentValue{ - Value: &aclrecordproto.ACLContentValue_UserPermissionChange{ - UserPermissionChange: &aclrecordproto.ACLUserPermissionChange{ + convCh = &aclrecordproto2.ACLContentValue{ + Value: &aclrecordproto2.ACLContentValue_UserPermissionChange{ + UserPermissionChange: &aclrecordproto2.ACLUserPermissionChange{ Identity: []byte(t.keychain.GetIdentity(permissionChange.Identity)), Permissions: t.convertPermission(permissionChange.Permission), }, @@ -205,24 +247,24 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecord newReadKey := t.keychain.GetKey(remove.NewReadKey).(*SymKey) - var replaces []*aclrecordproto.ACLReadKeyReplace + var replaces []*aclrecordproto2.ACLReadKeyReplace for _, id := range remove.IdentitiesLeft { - encKey := t.keychain.EncryptionKeysByYAMLName[id] + encKey := t.keychain.EncryptionKeysByYAMLIdentity[id] rawEncKey, _ := encKey.GetPublic().Raw() encReadKey, err := encKey.GetPublic().Encrypt(newReadKey.Key.Bytes()) if err != nil { panic(err) } - replaces = append(replaces, &aclrecordproto.ACLReadKeyReplace{ + replaces = append(replaces, &aclrecordproto2.ACLReadKeyReplace{ Identity: []byte(t.keychain.GetIdentity(id)), EncryptionKey: rawEncKey, EncryptedReadKey: encReadKey, }) } - convCh = &aclrecordproto.ACLContentValue{ - Value: &aclrecordproto.ACLContentValue_UserRemove{ - UserRemove: &aclrecordproto.ACLUserRemove{ + convCh = &aclrecordproto2.ACLContentValue{ + Value: &aclrecordproto2.ACLContentValue_UserRemove{ + UserRemove: &aclrecordproto2.ACLUserRemove{ Identity: []byte(t.keychain.GetIdentity(remove.RemovedIdentity)), ReadKeyReplaces: replaces, }, @@ -236,7 +278,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecord return convCh } -func (t *ACLListStorageBuilder) encryptReadKeysWithPubKey(keys []string, encKey encryptionkey.PrivKey) (enc [][]byte) { +func (t *ACLListStorageBuilder) encryptReadKeys(keys []string, encKey encryptionkey.PrivKey) (enc [][]byte) { for _, k := range keys { realKey := t.keychain.GetKey(k).(*SymKey).Key.Bytes() res, err := encKey.GetPublic().Encrypt(realKey) @@ -249,47 +291,43 @@ func (t *ACLListStorageBuilder) encryptReadKeysWithPubKey(keys []string, encKey return } -func (t *ACLListStorageBuilder) encryptReadKeysWithSymKey(keys []string, key *symmetric.Key) (enc [][]byte) { - for _, k := range keys { - realKey := t.keychain.GetKey(k).(*SymKey).Key.Bytes() - res, err := key.Encrypt(realKey) - if err != nil { - panic(err) - } - - enc = append(enc, res) - } - return -} - -func (t *ACLListStorageBuilder) convertPermission(perm string) aclrecordproto.ACLUserPermissions { +func (t *ACLListStorageBuilder) convertPermission(perm string) aclrecordproto2.ACLUserPermissions { switch perm { case "admin": - return aclrecordproto.ACLUserPermissions_Admin + return aclrecordproto2.ACLUserPermissions_Admin case "writer": - return aclrecordproto.ACLUserPermissions_Writer + return aclrecordproto2.ACLUserPermissions_Writer case "reader": - return aclrecordproto.ACLUserPermissions_Reader + return aclrecordproto2.ACLUserPermissions_Reader default: panic(fmt.Sprintf("incorrect permission: %s", perm)) } } -func (t *ACLListStorageBuilder) traverseFromHead(f func(rec *aclrecordproto.ACLRecord, id string) error) (err error) { - panic("this was removed, add if needed") +func (t *ACLListStorageBuilder) traverseFromHead(f func(rec *aclrecordproto2.ACLRecord, id string) error) (err error) { + for i := len(t.records) - 1; i >= 0; i-- { + err = f(t.records[i], t.rawRecords[i].Id) + if err != nil { + return err + } + } + return nil } -func (t *ACLListStorageBuilder) parseRoot(root *Root) (rawRoot *aclrecordproto.RawACLRecordWithId) { - rawSignKey, _ := t.keychain.SigningKeysByYAMLName[root.Identity].GetPublic().Raw() - rawEncKey, _ := t.keychain.EncryptionKeysByYAMLName[root.Identity].GetPublic().Raw() - readKey := t.keychain.ReadKeysByYAMLName[root.Identity] - aclRoot := &aclrecordproto.ACLRoot{ +func (t *ACLListStorageBuilder) parseRoot(root *Root) { + rawSignKey, _ := t.keychain.SigningKeysByYAMLIdentity[root.Identity].GetPublic().Raw() + rawEncKey, _ := t.keychain.EncryptionKeysByYAMLIdentity[root.Identity].GetPublic().Raw() + readKey, _ := aclrecordproto2.ACLReadKeyDerive(rawSignKey, rawEncKey) + hasher := fnv.New64() + hasher.Write(readKey.Bytes()) + t.root = &aclrecordproto2.ACLRoot{ Identity: rawSignKey, EncryptionKey: rawEncKey, SpaceId: root.SpaceId, EncryptedReadKey: nil, DerivationScheme: "scheme", - CurrentReadKeyHash: readKey.Hash, + CurrentReadKeyHash: hasher.Sum64(), } - return t.createRaw(aclRoot, rawSignKey) + t.rawRoot = t.createRaw(t.root, rawSignKey) + t.id = t.rawRoot.Id } diff --git a/common/pkg/acl/tree/objecttreefactory.go b/common/pkg/acl/tree/objecttreefactory.go index ca097505..c148d930 100644 --- a/common/pkg/acl/tree/objecttreefactory.go +++ b/common/pkg/acl/tree/objecttreefactory.go @@ -3,7 +3,7 @@ package tree import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/common" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/list" - storage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" + storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/asymmetric/signingkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/keys/symmetric" @@ -20,7 +20,7 @@ type ObjectTreeCreatePayload struct { Identity []byte } -func BuildObjectTree(treeStorage storage.TreeStorage, aclList list.ACLList) (ObjectTree, error) { +func BuildObjectTree(treeStorage storage2.TreeStorage, aclList list.ACLList) (ObjectTree, error) { rootChange, err := treeStorage.Root() if err != nil { return nil, err @@ -32,14 +32,14 @@ func BuildObjectTree(treeStorage storage.TreeStorage, aclList list.ACLList) (Obj func CreateDerivedObjectTree( payload ObjectTreeCreatePayload, aclList list.ACLList, - createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { + createStorage storage2.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { return createObjectTree(payload, 0, nil, aclList, createStorage) } func CreateObjectTree( payload ObjectTreeCreatePayload, aclList list.ACLList, - createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { + createStorage storage2.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { bytes := make([]byte, 32) _, err = rand.Read(bytes) if err != nil { @@ -53,7 +53,7 @@ func createObjectTree( timestamp int64, seed []byte, aclList list.ACLList, - createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { + createStorage storage2.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { aclList.RLock() aclHeadId := aclList.Head().Id aclList.RUnlock() @@ -77,7 +77,8 @@ func createObjectTree( } // create storage - st, err := createStorage(storage.TreeStorageCreatePayload{ + st, err := createStorage(storage2.TreeStorageCreatePayload{ + TreeId: raw.Id, RootRawChange: raw, Changes: []*treechangeproto.RawTreeChangeWithId{raw}, Heads: []string{raw.Id}, @@ -126,7 +127,8 @@ func buildObjectTree(deps objectTreeDeps) (ObjectTree, error) { } } - objTree.id = objTree.treeStorage.ID() + objTree.id = objTree.treeStorage.Id() + objTree.root, err = objTree.treeStorage.Root() if err != nil { return nil, err diff --git a/node/acl/service.go b/node/acl/service.go new file mode 100644 index 00000000..c6099cb9 --- /dev/null +++ b/node/acl/service.go @@ -0,0 +1,111 @@ +package acl + +import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/app" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice/synchandler" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/consensus/consensusclient" + "github.com/anytypeio/go-anytype-infrastructure-experiments/consensus/consensusproto" + "time" +) + +const CName = "node.acl" + +var log = logger.NewNamed(CName) + +type Service interface { + app.Component +} + +type service struct { + consService consensusclient.Service + account account.Service +} + +func (s *service) Init(a *app.App) (err error) { + s.consService = a.MustComponent(consensusclient.CName).(consensusclient.Service) + s.account = a.MustComponent(account.CName).(account.Service) + return +} + +func (s *service) Name() (name string) { + return CName +} + +func (s *service) CreateLog(ctx context.Context, aclId string, rec *aclrecordproto.RawACLRecordWithId) (err error) { + logId, err := cidToByte(aclId) + if err != nil { + return + } + recId, err := cidToByte(rec.Id) + if err != nil { + return + } + acc := s.account.Account() + rec.AcceptorIdentity = acc.Identity + if rec.AcceptorSignature, err = acc.SignKey.Sign(rec.Payload); err != nil { + return + } + recPayload, err := rec.Marshal() + if err != nil { + return + } + return s.consService.AddLog(ctx, &consensusproto.Log{ + Id: logId, + Records: []*consensusproto.Record{ + { + Id: recId, + Payload: recPayload, + CreatedUnix: uint64(time.Now().Unix()), + }, + }, + }) +} + +func (s *service) AddRecord(ctx context.Context, aclId string, rec *aclrecordproto.RawACLRecordWithId) (err error) { + logId, err := cidToByte(aclId) + if err != nil { + return + } + recId, err := cidToByte(rec.Id) + if err != nil { + return + } + acc := s.account.Account() + rec.AcceptorIdentity = acc.Identity + if rec.AcceptorSignature, err = acc.SignKey.Sign(rec.Payload); err != nil { + return + } + recPayload, err := rec.Marshal() + if err != nil { + return + } + return s.consService.AddRecord(ctx, logId, &consensusproto.Record{ + Id: recId, + PrevId: nil, //TODO: + Payload: recPayload, + CreatedUnix: uint64(time.Now().Unix()), + }) +} + +func (s *service) Watch(ctx context.Context, spaceId, aclId string, h synchandler.SyncHandler) (err error) { + w, err := newWatcher(spaceId, aclId, h) + if err != nil { + return + } + if err = s.consService.Watch(w.logId, w); err != nil { + return err + } + return w.Ready(ctx) +} + +func (s *service) UnWatch(aclId string) (err error) { + logId, err := cidToByte(aclId) + if err != nil { + return + } + return s.consService.UnWatch(logId) +} diff --git a/node/acl/util.go b/node/acl/util.go new file mode 100644 index 00000000..c6784a33 --- /dev/null +++ b/node/acl/util.go @@ -0,0 +1,19 @@ +package acl + +import "github.com/ipfs/go-cid" + +func cidToString(b []byte) (s string, err error) { + rcid, err := cid.Cast(b) + if err != nil { + return + } + return rcid.String(), nil +} + +func cidToByte(s string) (b []byte, err error) { + rcid, err := cid.Decode(s) + if err != nil { + return + } + return rcid.Bytes(), nil +} diff --git a/node/acl/util_test.go b/node/acl/util_test.go new file mode 100644 index 00000000..1ebe5fcb --- /dev/null +++ b/node/acl/util_test.go @@ -0,0 +1,16 @@ +package acl + +import ( + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/util/cid" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestCIDLen(t *testing.T) { + s, _ := cid.NewCIDFromBytes([]byte("some data")) + t.Log(s, len(s)) + b, _ := cidToByte(s) + t.Log(b, len(b)) + s2, _ := cidToString(b) + assert.Equal(t, s, s2) +} diff --git a/node/acl/watcher.go b/node/acl/watcher.go new file mode 100644 index 00000000..6a88cb0e --- /dev/null +++ b/node/acl/watcher.go @@ -0,0 +1,93 @@ +package acl + +import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice/synchandler" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/consensus/consensusproto" + "go.uber.org/zap" + "sync" +) + +func newWatcher(spaceId, aclId string, h synchandler.SyncHandler) (w *watcher, err error) { + w = &watcher{ + aclId: aclId, + spaceId: spaceId, + handler: h, + ready: make(chan struct{}), + } + if w.logId, err = cidToByte(aclId); err != nil { + return nil, err + } + return +} + +type watcher struct { + spaceId string + aclId string + logId []byte + handler synchandler.SyncHandler + ready chan struct{} + isReady sync.Once + err error +} + +func (w *watcher) AddConsensusRecords(recs []*consensusproto.Record) { + w.isReady.Do(func() { + close(w.ready) + }) + records := make([]*aclrecordproto.RawACLRecordWithId, 0, len(recs)) + + for _, rec := range recs { + recId, err := cidToString(rec.Id) + if err != nil { + log.Error("received invalid id from consensus node", zap.Error(err)) + continue + } + records = append(records, &aclrecordproto.RawACLRecordWithId{ + Payload: rec.Payload, + Id: recId, + }) + } + + aclReq := &aclrecordproto.ACLSyncMessage{ + Content: &aclrecordproto.ACLSyncContentValue{ + Value: &aclrecordproto.ACLSyncContentValue_AddRecords{ + AddRecords: &aclrecordproto.ACLAddRecords{ + Records: records, + }, + }, + }, + } + payload, err := aclReq.Marshal() + if err != nil { + log.Error("acl payload marshal error", zap.Error(err)) + return + } + req := &spacesyncproto.ObjectSyncMessage{ + SpaceId: w.spaceId, + Payload: payload, + ObjectId: w.aclId, + } + + if err = w.handler.HandleMessage(context.TODO(), "", req); err != nil { + log.Warn("handle message error", zap.Error(err)) + } +} + +func (w *watcher) AddConsensusError(err error) { + w.isReady.Do(func() { + w.err = err + close(w.ready) + }) +} + +func (w *watcher) Ready(ctx context.Context) (err error) { + select { + case <-w.ready: + return w.err + case <-ctx.Done(): + return ctx.Err() + } +} diff --git a/node/storage/liststorage.go b/node/storage/liststorage.go index 1247b2e8..e7fa3aba 100644 --- a/node/storage/liststorage.go +++ b/node/storage/liststorage.go @@ -82,7 +82,7 @@ func createListStorage(db *pogreb.DB, root *aclrecordproto.RawACLRecordWithId) ( return } -func (l *listStorage) ID() string { +func (l *listStorage) Id() string { return l.id } diff --git a/node/storage/spacestorage.go b/node/storage/spacestorage.go index eed05609..b15e1a4d 100644 --- a/node/storage/spacestorage.go +++ b/node/storage/spacestorage.go @@ -5,7 +5,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" spacestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage" - storage2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" + storage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" "go.uber.org/zap" "path" "sync" @@ -22,7 +22,7 @@ type spaceStorage struct { spaceId string objDb *pogreb.DB keys spaceKeys - aclStorage storage2.ListStorage + aclStorage storage.ListStorage header *spacesyncproto.RawSpaceHeaderWithId mx sync.Mutex } @@ -88,8 +88,8 @@ func createSpaceStorage(rootPath string, payload spacestorage.SpaceStorageCreate } defer func() { + log.With(zap.String("id", payload.SpaceHeaderWithId.Id), zap.Error(err)).Warn("failed to create storage") if err != nil { - log.With(zap.String("id", payload.SpaceHeaderWithId.Id), zap.Error(err)).Warn("failed to create storage") db.Close() } }() @@ -129,15 +129,15 @@ func createSpaceStorage(rootPath string, payload spacestorage.SpaceStorageCreate return } -func (s *spaceStorage) ID() string { +func (s *spaceStorage) Id() string { return s.spaceId } -func (s *spaceStorage) TreeStorage(id string) (storage2.TreeStorage, error) { +func (s *spaceStorage) TreeStorage(id string) (storage.TreeStorage, error) { return newTreeStorage(s.objDb, id) } -func (s *spaceStorage) CreateTreeStorage(payload storage2.TreeStorageCreatePayload) (ts storage2.TreeStorage, err error) { +func (s *spaceStorage) CreateTreeStorage(payload storage.TreeStorageCreatePayload) (ts storage.TreeStorage, err error) { // we have mutex here, so we prevent overwriting the heads of a tree on concurrent creation s.mx.Lock() defer s.mx.Unlock() @@ -145,7 +145,7 @@ func (s *spaceStorage) CreateTreeStorage(payload storage2.TreeStorageCreatePaylo return createTreeStorage(s.objDb, payload) } -func (s *spaceStorage) ACLStorage() (storage2.ListStorage, error) { +func (s *spaceStorage) ACLStorage() (storage.ListStorage, error) { return s.aclStorage, nil } @@ -156,13 +156,13 @@ func (s *spaceStorage) SpaceHeader() (header *spacesyncproto.RawSpaceHeaderWithI func (s *spaceStorage) StoredIds() (ids []string, err error) { index := s.objDb.Items() - key, _, err := index.Next() + key, val, err := index.Next() for err == nil { strKey := string(key) if isRootIdKey(strKey) { - ids = append(ids, getRootId(strKey)) + ids = append(ids, string(val)) } - key, _, err = index.Next() + key, val, err = index.Next() } if err != pogreb.ErrIterationDone { diff --git a/node/storage/treestorage.go b/node/storage/treestorage.go index 9b92379d..f35872ec 100644 --- a/node/storage/treestorage.go +++ b/node/storage/treestorage.go @@ -3,7 +3,7 @@ package storage import ( "context" "github.com/akrylysov/pogreb" - storage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto" ) @@ -48,7 +48,7 @@ func newTreeStorage(db *pogreb.DB, treeId string) (ts storage.TreeStorage, err e } func createTreeStorage(db *pogreb.DB, payload storage.TreeStorageCreatePayload) (ts storage.TreeStorage, err error) { - keys := newTreeKeys(payload.RootRawChange.Id) + keys := newTreeKeys(payload.TreeId) has, err := db.Has(keys.HeadsKey()) if err != nil { return @@ -86,7 +86,7 @@ func createTreeStorage(db *pogreb.DB, payload storage.TreeStorageCreatePayload) return } -func (t *treeStorage) ID() string { +func (t *treeStorage) Id() string { return t.id }