meowurls
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc 2024-03-26 14:57:33 +01:00
parent 53145f1c5e
commit 12ad5ced49

View File

@ -53,6 +53,21 @@ func CreateServerFromUid(uid string) *Server {
return &is 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 // GetServerCard returns a server card from a server
func (ints *Server) GetServerCard() *meowlib.ServerCard { func (ints *Server) GetServerCard() *meowlib.ServerCard {
var sc meowlib.ServerCard var sc meowlib.ServerCard
@ -72,6 +87,13 @@ func (sc *Server) GetUid() string {
return sc.Url 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 // Create a server from a server card
func CreateServerFromServerCard(server *meowlib.ServerCard) *Server { func CreateServerFromServerCard(server *meowlib.ServerCard) *Server {
var is Server var is Server