CreateProfile takes attributes
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
667fc15294
commit
32a02b68dc
13
app/app.go
13
app/app.go
|
@ -34,6 +34,8 @@ type application struct {
|
||||||
// Application is a full cwtch peer application. It allows management, usage and storage of multiple peers
|
// Application is a full cwtch peer application. It allows management, usage and storage of multiple peers
|
||||||
type Application interface {
|
type Application interface {
|
||||||
LoadProfiles(password string)
|
LoadProfiles(password string)
|
||||||
|
CreatePeer(name string, password string, attributes map[attr.ZonedPath]string)
|
||||||
|
// Deprecated in 1.10
|
||||||
CreateTaggedPeer(name string, password string, tag string)
|
CreateTaggedPeer(name string, password string, tag string)
|
||||||
ImportProfile(exportedCwtchFile string, password string) (peer.CwtchPeer, error)
|
ImportProfile(exportedCwtchFile string, password string) (peer.CwtchPeer, error)
|
||||||
DeletePeer(onion string, currentPassword string)
|
DeletePeer(onion string, currentPassword string)
|
||||||
|
@ -122,7 +124,12 @@ func (ap *application) AddPlugin(peerid string, id plugins.PluginID, bus event.M
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated in 1.10
|
||||||
func (app *application) CreateTaggedPeer(name string, password string, tag string) {
|
func (app *application) CreateTaggedPeer(name string, password string, tag string) {
|
||||||
|
app.CreatePeer(name, password, map[attr.ZonedPath]string{attr.ProfileZone.ConstructZonedPath(constants.Tag): tag})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (app *application) CreatePeer(name string, password string, attributes map[attr.ZonedPath]string) {
|
||||||
app.appmutex.Lock()
|
app.appmutex.Lock()
|
||||||
defer app.appmutex.Unlock()
|
defer app.appmutex.Unlock()
|
||||||
|
|
||||||
|
@ -140,9 +147,11 @@ func (app *application) CreateTaggedPeer(name string, password string, tag strin
|
||||||
profile.Init(app.eventBuses[profile.GetOnion()])
|
profile.Init(app.eventBuses[profile.GetOnion()])
|
||||||
app.peers[profile.GetOnion()] = profile
|
app.peers[profile.GetOnion()] = profile
|
||||||
|
|
||||||
if tag != "" {
|
for zp, val := range attributes {
|
||||||
profile.SetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants.Tag, tag)
|
zone, key := attr.ParseZone(zp.ToString())
|
||||||
|
profile.SetScopedZonedAttribute(attr.LocalScope, zone, key, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
app.AddPeerPlugin(profile.GetOnion(), plugins.CONNECTIONRETRY) // Now Mandatory
|
app.AddPeerPlugin(profile.GetOnion(), plugins.CONNECTIONRETRY) // Now Mandatory
|
||||||
app.appBus.Publish(event.NewEvent(event.NewPeer, map[event.Field]string{event.Identity: profile.GetOnion(), event.Created: event.True}))
|
app.appBus.Publish(event.NewEvent(event.NewPeer, map[event.Field]string{event.Identity: profile.GetOnion(), event.Created: event.True}))
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,10 @@ func (zone Zone) ConstructZonedPath(path string) ZonedPath {
|
||||||
return ZonedPath(string(zone) + Separator + path)
|
return ZonedPath(string(zone) + Separator + path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (zp ZonedPath) ToString() string {
|
||||||
|
return string(zp)
|
||||||
|
}
|
||||||
|
|
||||||
// ParseZone takes in an untyped string and returns an explicit Zone along with the rest of the untyped path
|
// ParseZone takes in an untyped string and returns an explicit Zone along with the rest of the untyped path
|
||||||
func ParseZone(path string) (Zone, string) {
|
func ParseZone(path string) (Zone, string) {
|
||||||
parts := strings.SplitN(path, Separator, 2)
|
parts := strings.SplitN(path, Separator, 2)
|
||||||
|
|
Loading…
Reference in New Issue