This commit is contained in:
parent
53145f1c5e
commit
12ad5ced49
@ -53,6 +53,21 @@ func CreateServerFromUid(uid string) *Server {
|
||||
return &is
|
||||
}
|
||||
|
||||
// CreateServerFromMeowUrl creates a server from a meow url, ex : meow://mylogin:mypassword@https://my.meowserver.example:8443/meow/
|
||||
func CreateServerFromMeowUrl(meowurl string) *Server {
|
||||
uid := strings.Split(meowurl, "://")[1]
|
||||
return CreateServerFromUid(uid)
|
||||
}
|
||||
|
||||
// CreateServerFromInvitationLink creates a server from a meow url, ex : meow://mylogin:mypassword@https://my.meowserver.example:8443/meow/invitationCode
|
||||
func CreateServerFromInvitationLink(meowurl string) *Server {
|
||||
// remove the invitation code, last token after a /
|
||||
meowurlTable := strings.Split(meowurl, "/")
|
||||
// join all elements with / except the last one
|
||||
uid := strings.Join(meowurlTable[:len(meowurlTable)-1], "/")
|
||||
return CreateServerFromUid(uid)
|
||||
}
|
||||
|
||||
// GetServerCard returns a server card from a server
|
||||
func (ints *Server) GetServerCard() *meowlib.ServerCard {
|
||||
var sc meowlib.ServerCard
|
||||
@ -72,6 +87,13 @@ func (sc *Server) GetUid() string {
|
||||
return sc.Url
|
||||
}
|
||||
|
||||
func (sc *Server) GetMeowUrl() string {
|
||||
if len(sc.Login) > 0 || len(sc.Password) > 0 {
|
||||
return sc.Login + ":" + sc.Password + "@" + sc.Url
|
||||
}
|
||||
return "meow://" + sc.Url
|
||||
}
|
||||
|
||||
// Create a server from a server card
|
||||
func CreateServerFromServerCard(server *meowlib.ServerCard) *Server {
|
||||
var is Server
|
||||
|
Loading…
Reference in New Issue
Block a user