mirror of
https://github.com/yhl452493373/frpc-panel.git
synced 2026-04-04 06:17:00 +08:00
support update proxies
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/vaughan0/go-ini"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
Success int = iota
|
||||
ParamError
|
||||
@@ -17,7 +11,7 @@ const (
|
||||
|
||||
const (
|
||||
NameKey = "name"
|
||||
OldNameKey = "_old_name"
|
||||
OriginalNameKey = "_original_name"
|
||||
SessionName = "GOSESSION"
|
||||
AuthName = "_PANEL_AUTH"
|
||||
LoginUrl = "/login"
|
||||
@@ -26,16 +20,6 @@ const (
|
||||
LogoutSuccessUrl = "/login"
|
||||
)
|
||||
|
||||
var (
|
||||
clientCommon ini.Section
|
||||
clientProxies map[string]ini.Section
|
||||
)
|
||||
|
||||
func init() {
|
||||
clientCommon = ini.Section{}
|
||||
clientProxies = make(map[string]ini.Section)
|
||||
}
|
||||
|
||||
type HTTPError struct {
|
||||
Code int
|
||||
Err error
|
||||
@@ -75,38 +59,3 @@ type ProxyResponse struct {
|
||||
OperationResponse
|
||||
Data any `json:"data"`
|
||||
}
|
||||
|
||||
type ClientProxies struct {
|
||||
Proxy ini.Section `json:"proxy"`
|
||||
}
|
||||
|
||||
type SectionInfo struct {
|
||||
Name string
|
||||
Section ini.Section
|
||||
}
|
||||
|
||||
type Sections struct {
|
||||
sections map[string]ini.Section
|
||||
}
|
||||
|
||||
func (s *Sections) sort() []SectionInfo {
|
||||
sectionInfos := make([]SectionInfo, 0)
|
||||
|
||||
for key, value := range s.sections {
|
||||
sectionInfos = append(sectionInfos, SectionInfo{Name: key, Section: value})
|
||||
}
|
||||
|
||||
sort.Slice(sectionInfos, func(i, j int) bool {
|
||||
typeCompare := strings.Compare(sectionInfos[i].Section["type"], sectionInfos[j].Section["type"])
|
||||
if typeCompare == -1 {
|
||||
return true
|
||||
} else if typeCompare == 0 {
|
||||
nameCompare := strings.Compare(sectionInfos[i].Name, sectionInfos[j].Name)
|
||||
return nameCompare == -1
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
return sectionInfos
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user