feat: add side to update checker

This commit is contained in:
Toby 2023-08-29 22:16:38 -07:00
parent 26fdba6049
commit 1ea7c515ae

View file

@ -21,6 +21,7 @@ type UpdateChecker struct {
Platform string Platform string
Architecture string Architecture string
Channel string Channel string
Side string
Client *http.Client Client *http.Client
} }
@ -30,6 +31,7 @@ func NewServerUpdateChecker(currentVersion, platform, architecture, channel stri
Platform: platform, Platform: platform,
Architecture: architecture, Architecture: architecture,
Channel: channel, Channel: channel,
Side: "server",
Client: &http.Client{ Client: &http.Client{
Timeout: updateCheckTimeout, Timeout: updateCheckTimeout,
}, },
@ -47,6 +49,7 @@ func NewClientUpdateChecker(currentVersion, platform, architecture, channel stri
Platform: platform, Platform: platform,
Architecture: architecture, Architecture: architecture,
Channel: channel, Channel: channel,
Side: "client",
Client: &http.Client{ Client: &http.Client{
Timeout: updateCheckTimeout, Timeout: updateCheckTimeout,
Transport: &http.Transport{ Transport: &http.Transport{
@ -67,12 +70,13 @@ type UpdateResponse struct {
} }
func (uc *UpdateChecker) Check() (*UpdateResponse, error) { func (uc *UpdateChecker) Check() (*UpdateResponse, error) {
url := fmt.Sprintf("%s?cver=%s&plat=%s&arch=%s&chan=%s", url := fmt.Sprintf("%s?cver=%s&plat=%s&arch=%s&chan=%s&side=%s",
updateCheckEndpoint, updateCheckEndpoint,
uc.CurrentVersion, uc.CurrentVersion,
uc.Platform, uc.Platform,
uc.Architecture, uc.Architecture,
uc.Channel, uc.Channel,
uc.Side,
) )
resp, err := uc.Client.Get(url) resp, err := uc.Client.Get(url)
if err != nil { if err != nil {