2018-07-26 00:04:59 +08:00
|
|
|
package config
|
2018-06-10 22:50:03 +08:00
|
|
|
|
|
|
|
import (
|
2018-08-12 02:23:46 +08:00
|
|
|
"fmt"
|
2018-06-10 22:50:03 +08:00
|
|
|
"strings"
|
2018-10-18 23:24:04 +08:00
|
|
|
|
|
|
|
C "github.com/Dreamacro/clash/constant"
|
2018-06-10 22:50:03 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func trimArr(arr []string) (r []string) {
|
|
|
|
for _, e := range arr {
|
|
|
|
r = append(r, strings.Trim(e, " "))
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
2018-08-12 02:23:46 +08:00
|
|
|
|
2018-10-18 23:24:04 +08:00
|
|
|
func getProxies(mapping map[string]C.Proxy, list []string) ([]C.Proxy, error) {
|
|
|
|
var ps []C.Proxy
|
|
|
|
for _, name := range list {
|
|
|
|
p, ok := mapping[name]
|
|
|
|
if !ok {
|
|
|
|
return nil, fmt.Errorf("'%s' not found", name)
|
|
|
|
}
|
|
|
|
ps = append(ps, p)
|
|
|
|
}
|
|
|
|
return ps, nil
|
|
|
|
}
|
|
|
|
|
2018-08-26 22:43:38 +08:00
|
|
|
func or(pointers ...*int) *int {
|
|
|
|
for _, p := range pointers {
|
|
|
|
if p != nil {
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pointers[len(pointers)-1]
|
|
|
|
}
|