-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocal.go
More file actions
50 lines (44 loc) · 836 Bytes
/
local.go
File metadata and controls
50 lines (44 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"net"
"github.com/astaxie/beego/logs"
)
func ModeOptions() []string {
return []string{
"Full Local Proxy",
"Match Domain Proxy",
"Auto Connect Proxy",
"Full Remote Proxy",
}
}
func ModeOptionsIdx() int {
mode := ConfigGet().Mode
if int(mode) < len(ModeOptions()) {
return int(mode)
}
return 0
}
func ModeOptionsSet(idx int) {
ModeSave(ModeType(idx))
}
func IfaceOptions() []string {
output := []string{"0.0.0.0", "::"}
ifaces, err := net.Interfaces()
if err != nil {
logs.Error("get interfaces fail, %s", err.Error())
return output
}
for _, v := range ifaces {
if v.Flags&net.FlagUp == 0 {
continue
}
address, err := InterfaceAddsGet(&v)
if err != nil {
continue
}
for _, addr := range address {
output = append(output, addr.String())
}
}
return output
}