Fixups from merging AddServer PR
This commit is contained in:
parent
c1428762f8
commit
cb8960f893
|
@ -18,8 +18,6 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"cwtch.im/cwtch/model/constants"
|
||||
|
||||
"cwtch.im/cwtch/event"
|
||||
"cwtch.im/cwtch/model"
|
||||
"cwtch.im/cwtch/model/attr"
|
||||
|
@ -599,7 +597,7 @@ func (cp *cwtchPeer) StartGroup(name string, server string) (int, error) {
|
|||
// Returns the onion of the new server if added
|
||||
// TODO in the future this function should also integrate with a trust provider to validate the key bundle.
|
||||
// Status: Ready for 1.5
|
||||
func (cp *cwtchPeer) AddServer(serverSpecification string) error {
|
||||
func (cp *cwtchPeer) AddServer(serverSpecification string) (string, error) {
|
||||
// This confirms that the server did at least sign the bundle
|
||||
keyBundle, err := model.DeserializeAndVerify([]byte(serverSpecification))
|
||||
if err != nil {
|
||||
|
@ -623,7 +621,7 @@ func (cp *cwtchPeer) AddServer(serverSpecification string) error {
|
|||
if conversationInfo == nil {
|
||||
_, err := cp.NewContactConversation(onion, model.DefaultP2PAccessControl(), true)
|
||||
if err != nil {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -635,7 +633,7 @@ func (cp *cwtchPeer) AddServer(serverSpecification string) error {
|
|||
if exists {
|
||||
if val != v {
|
||||
// this is inconsistent!
|
||||
return model.InconsistentKeyBundleError
|
||||
return "", model.InconsistentKeyBundleError
|
||||
}
|
||||
}
|
||||
// we haven't seen this key associated with the server before
|
||||
|
@ -647,13 +645,12 @@ func (cp *cwtchPeer) AddServer(serverSpecification string) error {
|
|||
cp.SetConversationAttribute(conversationInfo.ID, attr.PublicScope.ConstructScopedZonedPath(attr.ServerKeyZone.ConstructZonedPath(k)), v)
|
||||
}
|
||||
cp.SetConversationAttribute(conversationInfo.ID, attr.PublicScope.ConstructScopedZonedPath(attr.ServerKeyZone.ConstructZonedPath(string(model.BundleType))), serverSpecification)
|
||||
|
||||
return onion, err
|
||||
} else {
|
||||
return err
|
||||
return "", err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
return "", model.InconsistentKeyBundleError
|
||||
}
|
||||
|
||||
// GetServers returns an unordered list of servers
|
||||
|
@ -795,7 +792,7 @@ func (cp *cwtchPeer) ImportBundle(importString string) error {
|
|||
// Server Key Bundles are prefixed with
|
||||
bundle, err := base64.StdEncoding.DecodeString(importString[len(serverPrefix):])
|
||||
if err == nil {
|
||||
if err = cp.AddServer(string(bundle)); err != nil {
|
||||
if _, err = cp.AddServer(string(bundle)); err != nil {
|
||||
return ConstructResponse(importBundlePrefix, err.Error())
|
||||
}
|
||||
return ConstructResponse(importBundlePrefix, "success")
|
||||
|
|
|
@ -40,7 +40,7 @@ type ModifyGroups interface {
|
|||
|
||||
// ModifyServers provides write-only access to servers
|
||||
type ModifyServers interface {
|
||||
AddServer(string) error
|
||||
AddServer(string) (string, error)
|
||||
ResyncServer(onion string) error
|
||||
}
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
|||
|
||||
// Simulate Alice Creating a Group
|
||||
fmt.Println("Alice joining server...")
|
||||
if err := alice.AddServer(string(serverKeyBundle)); err != nil {
|
||||
if _, err := alice.AddServer(string(serverKeyBundle)); err != nil {
|
||||
t.Fatalf("Failed to Add Server Bundle %v", err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue