Server invitation process functions
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
65f9ee2e07
commit
432f449558
@ -44,7 +44,8 @@ func CreateIdentity(nickname string) *Identity {
|
||||
return &id
|
||||
}
|
||||
|
||||
func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerIdxs []int) (*meowlib.ContactCard, error) {
|
||||
// Creates an invitation for a peer, returns the peer containing
|
||||
func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerIdxs []int) (*Peer, *meowlib.ContactCard, error) {
|
||||
var peer Peer
|
||||
var myContactCard meowlib.ContactCard
|
||||
peer.MyIdentity = meowlib.NewKeyPair()
|
||||
@ -53,11 +54,11 @@ func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerI
|
||||
peer.Name = ContactName
|
||||
peer.InvitationId = uuid.New().String()
|
||||
if id.MessageServers.Servers == nil {
|
||||
return nil, errors.New("no message servers defined in your identity")
|
||||
return nil, nil, errors.New("no message servers defined in your identity")
|
||||
}
|
||||
for _, i := range MessageServerIdxs {
|
||||
if i > len(id.MessageServers.Servers)-1 {
|
||||
return nil, errors.New("requested server out of range of defined message servers")
|
||||
return nil, nil, errors.New("requested server out of range of defined message servers")
|
||||
}
|
||||
}
|
||||
for _, i := range MessageServerIdxs {
|
||||
@ -71,7 +72,7 @@ func (id *Identity) InvitePeer(MyName string, ContactName string, MessageServerI
|
||||
myContactCard.InvitationId = peer.InvitationId
|
||||
id.Peers = append(id.Peers, peer)
|
||||
|
||||
return &myContactCard, nil
|
||||
return &peer, &myContactCard, nil
|
||||
}
|
||||
|
||||
func (id *Identity) CheckInvitation(ReceivedContact *meowlib.ContactCard) (isAnswer bool, proposedNick string, receivedNick string) {
|
||||
|
@ -100,6 +100,23 @@ func (p *Peer) BuildSingleFileMessage(filename string, message []byte) ([]meowli
|
||||
return msgs, nil
|
||||
}
|
||||
|
||||
// Builds an invitation answer user message.
|
||||
// it takes as input a contactcard generated by Identity.AnswerInvitation
|
||||
func (p *Peer) BuildInvitationAnswserMessage(myContactCard *meowlib.ContactCard) (*meowlib.UserMessage, error) {
|
||||
var msg meowlib.UserMessage
|
||||
var invitation meowlib.Invitation
|
||||
invitation.Step = 3
|
||||
out, err := proto.Marshal(myContactCard)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
invitation.Payload = out
|
||||
msg.Destination = p.Contact.LookupPublicKey
|
||||
msg.From = p.MyIdentity.Public
|
||||
msg.Type = "1"
|
||||
return &msg, nil
|
||||
}
|
||||
|
||||
//
|
||||
// Messages encryption and packaging
|
||||
//
|
||||
|
@ -97,6 +97,7 @@ func (ints *Server) BuildMessageRequestMessage(lookupKeys []string) ([]byte, err
|
||||
}
|
||||
|
||||
// BuildToServerMessageInvitation creates an invitation message to server and returns it as a meowlib.ToServerMessage
|
||||
// it takes as input a contactcard generated by Identity.InvitePeer
|
||||
func (ints *Server) BuildToServerMessageInvitationCreation(invitation *meowlib.ContactCard, password string, timeout int, invitationIdLen int) (*meowlib.ToServerMessage, error) {
|
||||
var msg meowlib.ToServerMessage
|
||||
var inv meowlib.Invitation
|
||||
@ -109,21 +110,21 @@ func (ints *Server) BuildToServerMessageInvitationCreation(invitation *meowlib.C
|
||||
inv.Step = 1
|
||||
inv.Password = password
|
||||
inv.Timeout = int32(timeout)
|
||||
inv.Idlen = int32(invitationIdLen)
|
||||
inv.ShortcodeLen = int32(invitationIdLen)
|
||||
inv.Payload = payload
|
||||
msg.Invitation = &inv
|
||||
return &msg, nil
|
||||
}
|
||||
|
||||
// BuildToServerMessageInvitationRequest requests invitation with provided id from server and returns it as a meowlib.ToServerMessage
|
||||
func (ints *Server) BuildToServerMessageInvitationRequest(invitationId string, password string) (*meowlib.ToServerMessage, error) {
|
||||
func (ints *Server) BuildToServerMessageInvitationRequest(shortcode string, password string) (*meowlib.ToServerMessage, error) {
|
||||
var msg meowlib.ToServerMessage
|
||||
var inv meowlib.Invitation
|
||||
msg.Type = "1"
|
||||
msg.From = ints.Me.Public
|
||||
inv.Step = 2
|
||||
inv.Password = password
|
||||
inv.Id = invitationId
|
||||
inv.Shortcode = shortcode
|
||||
msg.Invitation = &inv
|
||||
return &msg, nil
|
||||
}
|
||||
|
@ -30,20 +30,21 @@ func TestEndToEnd(t *testing.T) {
|
||||
// Create an invitation for a friend, I want him/her to know me as Bender //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
fmt.Println("Creating an invitation for the first friend...")
|
||||
invitation, err := Me.InvitePeer("Bender", "myfirstfriend", []int{1, 2})
|
||||
peer, myContactCard, err := Me.InvitePeer("Bender", "myfirstfriend", []int{1, 2})
|
||||
if err != nil {
|
||||
println(err)
|
||||
}
|
||||
println(peer.Name)
|
||||
// print my invitation
|
||||
a, _ := json.Marshal(invitation)
|
||||
a, _ := json.Marshal(myContactCard)
|
||||
fmt.Println(string(a))
|
||||
// TODO : Convert invitation to QR Code
|
||||
invitation.WritePng("invitation.png")
|
||||
data, err := invitation.Compress()
|
||||
myContactCard.WritePng("invitation.png")
|
||||
data, err := myContactCard.Compress()
|
||||
if err != nil {
|
||||
println(err)
|
||||
}
|
||||
invitation.WriteQr("qrcode.png")
|
||||
myContactCard.WriteQr("qrcode.png")
|
||||
println("Compressed contact card :", len(data))
|
||||
///////////////////////////////////////
|
||||
// Simulate peer invitation response //
|
||||
@ -59,7 +60,7 @@ func TestEndToEnd(t *testing.T) {
|
||||
ReceivedContact.ContactPublicKey = FirstFriendContactKp.Public
|
||||
ReceivedContact.EncryptionPublicKey = FirstFriendEncryptionKp.Public
|
||||
ReceivedContact.LookupPublicKey = FirstFriendLookupKp.Public
|
||||
ReceivedContact.InvitationId = invitation.InvitationId
|
||||
ReceivedContact.InvitationId = myContactCard.InvitationId
|
||||
FriendServer1KP := meowlib.NewKeyPair()
|
||||
FriendServer1 := meowlib.ServerCard{Name: "FriendServer1", Url: "http://myfriend.org/meow/", PublicKey: FriendServer1KP.Public, Description: "Fancy description", ConfidenceLevel: 1}
|
||||
ReceivedContact.PullServers = append(ReceivedContact.PullServers, &FriendServer1)
|
||||
|
@ -13,7 +13,7 @@ func (msg *UserMessage) AddFile(filename string, maxMessageSize int64) error {
|
||||
return err
|
||||
}
|
||||
if fi.Size() > maxMessageSize {
|
||||
return errors.New("cannot add file, file bigger than messge size")
|
||||
return errors.New("cannot add file, file bigger than message size")
|
||||
}
|
||||
var totalsize int64
|
||||
totalsize = 0
|
||||
|
113
messages.pb.go
113
messages.pb.go
@ -104,11 +104,12 @@ type Invitation struct {
|
||||
|
||||
Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` // invitation payload, encrypted after step 2
|
||||
Timeout int32 `protobuf:"varint,2,opt,name=timeout,proto3" json:"timeout,omitempty"` // how long do I want the invitation to remain available on the server
|
||||
Idlen int32 `protobuf:"varint,3,opt,name=idlen,proto3" json:"idlen,omitempty"` // len of the id you wish for short url transmission
|
||||
Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"` // password tou set for accessin invitation (optional)
|
||||
Id string `protobuf:"bytes,5,opt,name=id,proto3" json:"id,omitempty"` // id that the friend shall request to get teh invitation
|
||||
Expiry int64 `protobuf:"varint,6,opt,name=expiry,proto3" json:"expiry,omitempty"` // the server allowed expiry date, it may be samller than the requested timeout according to server policy
|
||||
Step int32 `protobuf:"varint,7,opt,name=step,proto3" json:"step,omitempty"` // progress in the inviattion process : 1=invite friend, 2=friend requests invitation, 3=friend's answer, 4=request answer
|
||||
ShortcodeLen int32 `protobuf:"varint,3,opt,name=shortcodeLen,proto3" json:"shortcodeLen,omitempty"` // len of the shortcode you wish for short url transmission
|
||||
Shortcode string `protobuf:"bytes,4,opt,name=shortcode,proto3" json:"shortcode,omitempty"` // shortcode that the friend shall request to get the invitation
|
||||
Password string `protobuf:"bytes,5,opt,name=password,proto3" json:"password,omitempty"` // password tou set for accessin invitation (optional)
|
||||
Uuid string `protobuf:"bytes,6,opt,name=uuid,proto3" json:"uuid,omitempty"` // id that the friend gave you, that you should include to your reply to get recognized
|
||||
Expiry int64 `protobuf:"varint,7,opt,name=expiry,proto3" json:"expiry,omitempty"` // the server allowed expiry date, it may be samller than the requested timeout according to server policy
|
||||
Step int32 `protobuf:"varint,8,opt,name=step,proto3" json:"step,omitempty"` // progress in the inviattion process : 1=invite friend, 2=friend requests invitation, 3=friend's answer
|
||||
}
|
||||
|
||||
func (x *Invitation) Reset() {
|
||||
@ -157,13 +158,20 @@ func (x *Invitation) GetTimeout() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Invitation) GetIdlen() int32 {
|
||||
func (x *Invitation) GetShortcodeLen() int32 {
|
||||
if x != nil {
|
||||
return x.Idlen
|
||||
return x.ShortcodeLen
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Invitation) GetShortcode() string {
|
||||
if x != nil {
|
||||
return x.Shortcode
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Invitation) GetPassword() string {
|
||||
if x != nil {
|
||||
return x.Password
|
||||
@ -171,9 +179,9 @@ func (x *Invitation) GetPassword() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Invitation) GetId() string {
|
||||
func (x *Invitation) GetUuid() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
return x.Uuid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -278,7 +286,7 @@ type ToServerMessage struct {
|
||||
KnownServers []*ServerCard `protobuf:"bytes,6,rep,name=knownServers,proto3" json:"knownServers,omitempty"`
|
||||
MatriochkaMessage *Matriochka `protobuf:"bytes,7,opt,name=matriochkaMessage,proto3" json:"matriochkaMessage,omitempty"`
|
||||
Uuid string `protobuf:"bytes,8,opt,name=uuid,proto3" json:"uuid,omitempty"`
|
||||
Invitation *Invitation `protobuf:"bytes,9,opt,name=invitation,proto3" json:"invitation,omitempty"`
|
||||
Invitation *Invitation `protobuf:"bytes,9,opt,name=invitation,proto3" json:"invitation,omitempty"` // invitation for the 2 first steps of a "through server" invitation process
|
||||
}
|
||||
|
||||
func (x *ToServerMessage) Reset() {
|
||||
@ -436,7 +444,7 @@ type FromServerMessage struct {
|
||||
ServerUuid string `protobuf:"bytes,5,opt,name=serverUuid,proto3" json:"serverUuid,omitempty"` // Provides the server uuid that replaced the client uuid
|
||||
Chat []*PackedUserMessage `protobuf:"bytes,6,rep,name=chat,proto3" json:"chat,omitempty"`
|
||||
KnownServers []*ServerCard `protobuf:"bytes,7,rep,name=knownServers,proto3" json:"knownServers,omitempty"`
|
||||
Invitation *Invitation `protobuf:"bytes,8,opt,name=invitation,proto3" json:"invitation,omitempty"`
|
||||
Invitation *Invitation `protobuf:"bytes,8,opt,name=invitation,proto3" json:"invitation,omitempty"` // invitation answer, for the third steps of any invitation
|
||||
}
|
||||
|
||||
func (x *FromServerMessage) Reset() {
|
||||
@ -1100,6 +1108,7 @@ type UserMessage struct {
|
||||
Files []*File `protobuf:"bytes,9,rep,name=files,proto3" json:"files,omitempty"`
|
||||
CurrentLocation *Location `protobuf:"bytes,10,opt,name=currentLocation,proto3" json:"currentLocation,omitempty"`
|
||||
Appdata []byte `protobuf:"bytes,11,opt,name=appdata,proto3" json:"appdata,omitempty"`
|
||||
Invitation *Invitation `protobuf:"bytes,12,opt,name=invitation,proto3" json:"invitation,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UserMessage) Reset() {
|
||||
@ -1211,15 +1220,22 @@ func (x *UserMessage) GetAppdata() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UserMessage) GetInvitation() *Invitation {
|
||||
if x != nil {
|
||||
return x.Invitation
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type File struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"`
|
||||
Size uint64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"`
|
||||
Chunk uint32 `protobuf:"varint,3,opt,name=chunk,proto3" json:"chunk,omitempty"`
|
||||
Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
|
||||
Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"` // the proposed filename
|
||||
Size uint64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` // the file size
|
||||
Chunk uint32 `protobuf:"varint,3,opt,name=chunk,proto3" json:"chunk,omitempty"` // the chunk counter if file is sent by chunks
|
||||
Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` // the file/chunk content
|
||||
}
|
||||
|
||||
func (x *File) Reset() {
|
||||
@ -1363,18 +1379,21 @@ var file_messages_proto_rawDesc = []byte{
|
||||
0x66, 0x72, 0x6f, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1c,
|
||||
0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
|
||||
0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xae, 0x01, 0x0a,
|
||||
0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0xde, 0x01, 0x0a,
|
||||
0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x70,
|
||||
0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61,
|
||||
0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12,
|
||||
0x14, 0x0a, 0x05, 0x69, 0x64, 0x6c, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05,
|
||||
0x69, 0x64, 0x6c, 0x65, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72,
|
||||
0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72,
|
||||
0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69,
|
||||
0x64, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28,
|
||||
0x22, 0x0a, 0x0c, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x6f, 0x64, 0x65, 0x4c, 0x65, 0x6e, 0x18,
|
||||
0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x6f, 0x64, 0x65,
|
||||
0x4c, 0x65, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x6f, 0x64, 0x65,
|
||||
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x63, 0x6f, 0x64,
|
||||
0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69,
|
||||
0x64, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x65,
|
||||
0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x65, 0x70, 0x22, 0xaf, 0x01,
|
||||
0x70, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x65, 0x70, 0x22, 0xaf, 0x01,
|
||||
0x0a, 0x13, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x4b,
|
||||
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6c, 0x6f, 0x6f, 0x6b, 0x75, 0x70,
|
||||
@ -1515,7 +1534,7 @@ var file_messages_proto_rawDesc = []byte{
|
||||
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x6d, 0x65, 0x6d,
|
||||
0x62, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6d, 0x65, 0x6f,
|
||||
0x77, 0x6c, 0x69, 0x62, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x43, 0x61, 0x72, 0x64,
|
||||
0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x22, 0xab, 0x03, 0x0a, 0x0b, 0x55, 0x73,
|
||||
0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x22, 0xe0, 0x03, 0x0a, 0x0b, 0x55, 0x73,
|
||||
0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73,
|
||||
0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b,
|
||||
0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x66,
|
||||
@ -1542,23 +1561,26 @@ var file_messages_proto_rawDesc = []byte{
|
||||
0x6c, 0x69, 0x62, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x63, 0x75,
|
||||
0x72, 0x72, 0x65, 0x6e, 0x74, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x61, 0x70, 0x70, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07,
|
||||
0x61, 0x70, 0x70, 0x64, 0x61, 0x74, 0x61, 0x22, 0x60, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12,
|
||||
0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73,
|
||||
0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12,
|
||||
0x14, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05,
|
||||
0x63, 0x68, 0x75, 0x6e, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x74, 0x0a, 0x08, 0x4c, 0x6f, 0x63,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x04, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x61, 0x74,
|
||||
0x69, 0x74, 0x75, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x02, 0x52, 0x08, 0x6c, 0x61, 0x74,
|
||||
0x69, 0x74, 0x75, 0x64, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x6e, 0x67, 0x69, 0x74, 0x75,
|
||||
0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x6c, 0x6f, 0x6e, 0x67, 0x69, 0x74,
|
||||
0x75, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x6c, 0x74, 0x69, 0x74, 0x75, 0x64, 0x65, 0x18,
|
||||
0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x6c, 0x74, 0x69, 0x74, 0x75, 0x64, 0x65, 0x42,
|
||||
0x21, 0x5a, 0x1f, 0x66, 0x6f, 0x72, 0x67, 0x65, 0x2e, 0x72, 0x65, 0x64, 0x72, 0x6f, 0x6f, 0x6d,
|
||||
0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x2f, 0x79, 0x76, 0x65, 0x73, 0x2f, 0x6d, 0x65, 0x6f, 0x77, 0x6c,
|
||||
0x69, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x61, 0x70, 0x70, 0x64, 0x61, 0x74, 0x61, 0x12, 0x33, 0x0a, 0x0a, 0x69, 0x6e, 0x76, 0x69, 0x74,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6d, 0x65,
|
||||
0x6f, 0x77, 0x6c, 0x69, 0x62, 0x2e, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x52, 0x0a, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x60, 0x0a, 0x04,
|
||||
0x46, 0x69, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04,
|
||||
0x73, 0x69, 0x7a, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x0d, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61,
|
||||
0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x74,
|
||||
0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x6c, 0x61, 0x74, 0x69, 0x74, 0x75, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x02,
|
||||
0x52, 0x08, 0x6c, 0x61, 0x74, 0x69, 0x74, 0x75, 0x64, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f,
|
||||
0x6e, 0x67, 0x69, 0x74, 0x75, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x6c,
|
||||
0x6f, 0x6e, 0x67, 0x69, 0x74, 0x75, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x6c, 0x74, 0x69,
|
||||
0x74, 0x75, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x61, 0x6c, 0x74, 0x69,
|
||||
0x74, 0x75, 0x64, 0x65, 0x42, 0x21, 0x5a, 0x1f, 0x66, 0x6f, 0x72, 0x67, 0x65, 0x2e, 0x72, 0x65,
|
||||
0x64, 0x72, 0x6f, 0x6f, 0x6d, 0x2e, 0x6c, 0x69, 0x6e, 0x6b, 0x2f, 0x79, 0x76, 0x65, 0x73, 0x2f,
|
||||
0x6d, 0x65, 0x6f, 0x77, 0x6c, 0x69, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -1612,11 +1634,12 @@ var file_messages_proto_depIdxs = []int32{
|
||||
12, // 16: meowlib.UserMessage.group:type_name -> meowlib.Group
|
||||
14, // 17: meowlib.UserMessage.files:type_name -> meowlib.File
|
||||
15, // 18: meowlib.UserMessage.currentLocation:type_name -> meowlib.Location
|
||||
19, // [19:19] is the sub-list for method output_type
|
||||
19, // [19:19] is the sub-list for method input_type
|
||||
19, // [19:19] is the sub-list for extension type_name
|
||||
19, // [19:19] is the sub-list for extension extendee
|
||||
0, // [0:19] is the sub-list for field type_name
|
||||
1, // 19: meowlib.UserMessage.invitation:type_name -> meowlib.Invitation
|
||||
20, // [20:20] is the sub-list for method output_type
|
||||
20, // [20:20] is the sub-list for method input_type
|
||||
20, // [20:20] is the sub-list for extension type_name
|
||||
20, // [20:20] is the sub-list for extension extendee
|
||||
0, // [0:20] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_messages_proto_init() }
|
||||
|
@ -24,11 +24,12 @@ message PackedServerMessage {
|
||||
message Invitation {
|
||||
bytes payload = 1; // invitation payload, encrypted after step 2
|
||||
int32 timeout = 2; // how long do I want the invitation to remain available on the server
|
||||
int32 idlen = 3; // len of the id you wish for short url transmission
|
||||
string password = 4; // password tou set for accessin invitation (optional)
|
||||
string id = 5; // id that the friend shall request to get teh invitation
|
||||
int64 expiry = 6; // the server allowed expiry date, it may be samller than the requested timeout according to server policy
|
||||
int32 step = 7; // progress in the inviattion process : 1=invite friend, 2=friend requests invitation, 3=friend's answer, 4=request answer
|
||||
int32 shortcodeLen = 3; // len of the shortcode you wish for short url transmission
|
||||
string shortcode = 4; // shortcode that the friend shall request to get the invitation
|
||||
string password = 5; // password tou set for accessin invitation (optional)
|
||||
string uuid = 6; // id that the friend gave you, that you should include to your reply to get recognized
|
||||
int64 expiry = 7; // the server allowed expiry date, it may be samller than the requested timeout according to server policy
|
||||
int32 step = 8; // progress in the inviattion process : 1=invite friend, 2=friend requests invitation, 3=friend's answer
|
||||
}
|
||||
|
||||
|
||||
@ -57,7 +58,7 @@ message ToServerMessage {
|
||||
|
||||
string uuid = 8;
|
||||
|
||||
Invitation invitation = 9;
|
||||
Invitation invitation = 9; // invitation for the 2 first steps of a "through server" invitation process
|
||||
|
||||
}
|
||||
|
||||
@ -77,7 +78,7 @@ message FromServerMessage {
|
||||
|
||||
repeated ServerCard knownServers = 7;
|
||||
|
||||
Invitation invitation = 8;
|
||||
Invitation invitation = 8; // invitation answer, for the third steps of any invitation
|
||||
|
||||
}
|
||||
|
||||
@ -160,13 +161,15 @@ message UserMessage {
|
||||
Location currentLocation = 10;
|
||||
|
||||
bytes appdata = 11;
|
||||
|
||||
Invitation invitation = 12;
|
||||
}
|
||||
|
||||
message File {
|
||||
string filename=1;
|
||||
uint64 size=2;
|
||||
uint32 chunk=3;
|
||||
bytes data=4;
|
||||
string filename=1; // the proposed filename
|
||||
uint64 size=2; // the file size
|
||||
uint32 chunk=3; // the chunk counter if file is sent by chunks
|
||||
bytes data=4; // the file/chunk content
|
||||
}
|
||||
|
||||
message Location {
|
||||
|
@ -93,11 +93,11 @@ func (r *RedisRouter) Route(msg *meowlib.ToServerMessage) (*meowlib.FromServerMe
|
||||
if msg.Invitation != nil {
|
||||
switch msg.Invitation.Step {
|
||||
case 1: // create invitation
|
||||
url, expiry := r.CreateInvitation(msg.Invitation.Payload, int(msg.Invitation.Timeout), msg.Invitation.Password, r.InvitationTimeout, int(msg.Invitation.Idlen))
|
||||
from_server.Invitation.Id = url
|
||||
url, expiry := r.CreateInvitation(msg.Invitation.Payload, int(msg.Invitation.Timeout), msg.Invitation.Password, r.InvitationTimeout, int(msg.Invitation.ShortcodeLen))
|
||||
from_server.Invitation.Shortcode = url
|
||||
from_server.Invitation.Expiry = expiry.UTC().Unix()
|
||||
case 2: // get invitation
|
||||
invitation, err := r.GetInvitation(msg.Invitation.Id, msg.Invitation.Password)
|
||||
invitation, err := r.GetInvitation(msg.Invitation.Shortcode, msg.Invitation.Password)
|
||||
if err != nil {
|
||||
if err.Error() == "auth failed" {
|
||||
from_server.Invitation.Payload = []byte("authentication failure")
|
||||
@ -107,6 +107,8 @@ func (r *RedisRouter) Route(msg *meowlib.ToServerMessage) (*meowlib.FromServerMe
|
||||
} else {
|
||||
from_server.Invitation.Payload = invitation
|
||||
}
|
||||
|
||||
/* should not happen
|
||||
case 3: // answer invitation
|
||||
expiry := r.AnswerInvitation(msg.Invitation.Id, int(msg.Invitation.Timeout), msg.Invitation.Payload, r.InvitationTimeout)
|
||||
from_server.Invitation.Expiry = expiry.UTC().Unix()
|
||||
@ -117,6 +119,7 @@ func (r *RedisRouter) Route(msg *meowlib.ToServerMessage) (*meowlib.FromServerMe
|
||||
} else {
|
||||
from_server.Invitation.Payload = answer
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user