Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/ingress/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ http {

location / {
default_type text/html;
return 200 "<h1><a href='https://www.bytetradelab.io/'>Bytetrade</a></h1>";
return 200 "<h1><a href='https://olares.xyz/'>Olares</a></h1>";
}

location /ping {
Expand Down
67 changes: 67 additions & 0 deletions pkg/apis/backend/v1/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ func (h *Handler) handleReDownloadCert(req *restful.Request, resp *restful.Respo
response.SuccessNoData(resp)
}

// Deprecated: use handleOlaresInfo instead
func (h *Handler) handleTerminusInfo(req *restful.Request, resp *restful.Response) {

userOp, err := operator.NewUserOperator()
Expand Down Expand Up @@ -383,6 +384,72 @@ func (h *Handler) handleTerminusInfo(req *restful.Request, resp *restful.Respons

}

func (h *Handler) handleOlaresInfo(req *restful.Request, resp *restful.Response) {

userOp, err := operator.NewUserOperator()
if err != nil {
response.HandleError(resp, errors.Errorf("olares info: new user operator err: %v", err))
return
}

user, err := userOp.GetUser("")
if err != nil {
response.HandleError(resp, errors.Errorf("olares info: get user err: %v", err))
return
}

tInfo := OlaresInfo{}
tInfo.OlaresName = userOp.GetTerminusName(user)

status := userOp.GetTerminusStatus(user)
if status == "" {
tInfo.WizardStatus = constants.WaitActivateVault
} else {
tInfo.WizardStatus = constants.WizardStatus(status)
}

selfhosted, terminusd, osVersion, err := userOp.SelfhostedAndOsVersion()
if err != nil {
response.HandleError(resp, errors.Errorf("olares info: get olares host type err: %v", err))
return
}

tInfo.Selfhosted = selfhosted
tInfo.OsVersion = osVersion

tInfo.Olaresd = "0"
if terminusd {
tInfo.Olaresd = "1"
}

terminusId, err := userOp.GetTerminusID()
if err != nil {
response.HandleError(resp, errors.Errorf("olares info: get olares id err: %v", err))
return
}

tInfo.OlaresID = terminusId

var denyAllAnno string = userOp.GetDenyAllPolicy(user)
if denyAllAnno == "" {
tInfo.TailScaleEnable = false
} else {
denyAll, _ := strconv.Atoi(denyAllAnno)
tInfo.TailScaleEnable = denyAll == 1
}

tInfo.LoginBackground = userOp.GetLoginBackground(user)
tInfo.Avatar = userOp.GetAvatar(user)
tInfo.UserDID = userOp.GetUserDID(user)

if reverseProxy := userOp.GetUserAnnotation(user, constants.UserAnnotationReverseProxyType); reverseProxy != "" {
tInfo.ReverseProxy = reverseProxy
}

response.Success(resp, tInfo)

}

func (h *Handler) myapps(req *restful.Request, resp *restful.Response) {
// provider api
var opt MyAppsProviderRequest
Expand Down
15 changes: 15 additions & 0 deletions pkg/apis/backend/v1/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type IPAddress struct {
MasterExternalIP string `json:"masterExternalIP"`
}

// Depreacted
type TerminusInfo struct {
TerminusName string `json:"terminusName"`
WizardStatus constants.WizardStatus `json:"wizardStatus"`
Expand All @@ -41,6 +42,20 @@ type TerminusInfo struct {
Terminusd string `json:"terminusd"`
}

type OlaresInfo struct {
OlaresName string `json:"olaresName"`
WizardStatus constants.WizardStatus `json:"wizardStatus"`
Selfhosted bool `json:"selfhosted"`
TailScaleEnable bool `json:"tailScaleEnable"`
OsVersion string `json:"osVersion"`
LoginBackground string `json:"loginBackground"`
Avatar string `json:"avatar"`
OlaresID string `json:"olaresId"`
UserDID string `json:"did"`
ReverseProxy string `json:"reverseProxy"`
Olaresd string `json:"olaresd"`
}

type MyAppsParam struct {
IsLocal bool `json:"isLocal"`
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/apis/backend/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ func AddContainer(c *restful.Container) error {
Metadata(restfulspec.KeyOpenAPITags, tags).
Returns(http.StatusOK, "", response.Response{}))

ws.Route(ws.GET("/olares-info").
To(handler.handleOlaresInfo).
Doc("olares information.").
Metadata(restfulspec.KeyOpenAPITags, tags).
Returns(http.StatusOK, "", response.Response{}))

ws.Route(ws.GET("/ip").
To(handler.handleGetIPAddress).
Doc("IP Address.").
Expand Down Expand Up @@ -87,6 +93,12 @@ func AddContainer(c *restful.Container) error {
Metadata(restfulspec.KeyOpenAPITags, tags).
Returns(http.StatusOK, "", response.Response{}))

wsWizard.Route(wsWizard.GET("/olares-info").
To(handler.handleOlaresInfo).
Doc("olares information.").
Metadata(restfulspec.KeyOpenAPITags, tags).
Returns(http.StatusOK, "", response.Response{}))

c.Add(wsWizard)
return nil
}