Update: add config route

This commit is contained in:
Dreamacro
2018-07-15 22:23:20 +08:00
parent 0eef9bbf5d
commit 3cacfb8a7f
12 changed files with 319 additions and 77 deletions

31
hub/common.go Normal file
View File

@ -0,0 +1,31 @@
package hub
import (
"github.com/Dreamacro/clash/proxy"
T "github.com/Dreamacro/clash/tunnel"
)
var (
tunnel = T.GetInstance()
listener = proxy.Instance()
)
type Error struct {
Error string `json:"error"`
}
type Errors struct {
Errors map[string]string `json:"errors"`
}
func formatErrors(errorsMap map[string]error) (bool, Errors) {
errors := make(map[string]string)
hasError := false
for key, err := range errorsMap {
if err != nil {
errors[key] = err.Error()
hasError = true
}
}
return hasError, Errors{Errors: errors}
}