mirror of
https://github.com/fatedier/frp.git
synced 2025-07-27 07:35:07 +00:00
code optimization (#3625)
This commit is contained in:
@@ -45,38 +45,3 @@ func Major(v string) int64 {
|
||||
func Minor(v string) int64 {
|
||||
return getSubVersion(v, 2)
|
||||
}
|
||||
|
||||
// add every case there if server will not accept client's protocol and return false
|
||||
func Compat(client string) (ok bool, msg string) {
|
||||
if LessThan(client, "0.18.0") {
|
||||
return false, "Please upgrade your frpc version to at least 0.18.0"
|
||||
}
|
||||
return true, ""
|
||||
}
|
||||
|
||||
func LessThan(client string, server string) bool {
|
||||
vc := Proto(client)
|
||||
vs := Proto(server)
|
||||
if vc > vs {
|
||||
return false
|
||||
} else if vc < vs {
|
||||
return true
|
||||
}
|
||||
|
||||
vc = Major(client)
|
||||
vs = Major(server)
|
||||
if vc > vs {
|
||||
return false
|
||||
} else if vc < vs {
|
||||
return true
|
||||
}
|
||||
|
||||
vc = Minor(client)
|
||||
vs = Minor(server)
|
||||
if vc > vs {
|
||||
return false
|
||||
} else if vc < vs {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@@ -51,15 +51,3 @@ func TestVersion(t *testing.T) {
|
||||
version := Full()
|
||||
assert.Equal(parseVerion, version)
|
||||
}
|
||||
|
||||
func TestCompact(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
ok, _ := Compat("0.9.0")
|
||||
assert.False(ok)
|
||||
|
||||
ok, _ = Compat("10.0.0")
|
||||
assert.True(ok)
|
||||
|
||||
ok, _ = Compat("0.10.0")
|
||||
assert.False(ok)
|
||||
}
|
||||
|
Reference in New Issue
Block a user