mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-06 07:37:21 +02:00

+ Added support for multiple upstreams + Added load balancer + Added upstream abstraction in endpoint + Added load balancer structure + Added breaking change auto-updater + Added uptime monitor proxy type definitions + Added upstream editor UI + Fixed charset bug in many snippets HTML files
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package update
|
|
|
|
/*
|
|
Update.go
|
|
|
|
This module handle cross version updates that contains breaking changes
|
|
update command should always exit after the update is completed
|
|
*/
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
|
|
v308 "imuslab.com/zoraxy/mod/update/v308"
|
|
)
|
|
|
|
// Run config update. Version numbers are int. For example
|
|
// to update 3.0.7 to 3.0.8, use RunConfigUpdate(307, 308)
|
|
// This function support cross versions updates (e.g. 307 -> 310)
|
|
func RunConfigUpdate(fromVersion int, toVersion int) {
|
|
for i := fromVersion; i < toVersion; i++ {
|
|
oldVersion := fromVersion
|
|
newVersion := fromVersion + 1
|
|
fmt.Println("Updating from v", oldVersion, " to v", newVersion)
|
|
runUpdateRoutineWithVersion(oldVersion, newVersion)
|
|
}
|
|
fmt.Println("Update completed")
|
|
}
|
|
|
|
func GetVersionIntFromVersionNumber(version string) int {
|
|
versionNumberOnly := strings.ReplaceAll(version, ".", "")
|
|
versionInt, _ := strconv.Atoi(versionNumberOnly)
|
|
return versionInt
|
|
}
|
|
|
|
func runUpdateRoutineWithVersion(fromVersion int, toVersion int) {
|
|
if fromVersion == 307 && toVersion == 308 {
|
|
err := v308.UpdateFrom307To308()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
}
|