clash/config/utils.go

30 lines
443 B
Go
Raw Normal View History

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"
)
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
func genAddr(port int, allowLan bool) string {
if allowLan {
return fmt.Sprintf(":%d", port)
}
return fmt.Sprintf("127.0.0.1:%d", port)
}
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]
}