2018-07-15 22:23:20 +08:00
|
|
|
package hub
|
|
|
|
|
|
|
|
import (
|
2018-07-26 00:04:59 +08:00
|
|
|
"github.com/Dreamacro/clash/config"
|
2018-07-15 22:23:20 +08:00
|
|
|
"github.com/Dreamacro/clash/proxy"
|
|
|
|
T "github.com/Dreamacro/clash/tunnel"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2018-07-26 00:04:59 +08:00
|
|
|
tunnel = T.Instance()
|
|
|
|
cfg = config.Instance()
|
2018-07-15 22:23:20 +08:00
|
|
|
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}
|
|
|
|
}
|