|
|
|
@ -199,7 +199,7 @@ func initChain() (*gost.Chain, error) { |
|
|
|
timeout, _ := strconv.Atoi(node.Values.Get("timeout")) |
|
|
|
node.DialOptions = append(node.DialOptions, |
|
|
|
gost.TimeoutDialOption(time.Duration(timeout)*time.Second), |
|
|
|
gost.IPDialOption(strings.Split(node.Values.Get("ip"), ",")...), |
|
|
|
gost.IPDialOption(parseIP(node.Values.Get("ip"))...), |
|
|
|
) |
|
|
|
|
|
|
|
interval, _ := strconv.Atoi(node.Values.Get("ping")) |
|
|
|
@ -478,3 +478,25 @@ func parseUsers(authFile string) (users []*url.Userinfo, err error) { |
|
|
|
err = scanner.Err() |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func parseIP(s string) (ips []string) { |
|
|
|
if s == "" { |
|
|
|
return nil |
|
|
|
} |
|
|
|
file, err := os.Open(s) |
|
|
|
if err != nil { |
|
|
|
return strings.Split(s, ",") |
|
|
|
} |
|
|
|
|
|
|
|
scanner := bufio.NewScanner(file) |
|
|
|
for scanner.Scan() { |
|
|
|
line := strings.TrimSpace(scanner.Text()) |
|
|
|
if line == "" || strings.HasPrefix(line, "#") { |
|
|
|
continue |
|
|
|
} |
|
|
|
if ip := net.ParseIP(line); ip != nil { |
|
|
|
ips = append(ips, line) |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|