impl cidr as password:CIDR:http://target
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
type Proxy struct {
|
||||
Auth string
|
||||
From string
|
||||
To string
|
||||
}
|
||||
|
||||
@@ -60,14 +61,15 @@ func GetRoutes() map[string]Proxy {
|
||||
s := conf.Get("proxy2").GetString()
|
||||
var dict map[string]string
|
||||
if err := yaml.Unmarshal([]byte(s), &dict); err == nil && len(s) > 0 {
|
||||
pattern := regexp.MustCompile(`(([^:]*):)?([a-z0-9]*:.*)`)
|
||||
pattern := regexp.MustCompile(`(([^:]*):)?(([^:]*):)?([a-z0-9]*:.*)`)
|
||||
result := map[string]Proxy{}
|
||||
for k, v := range dict {
|
||||
submatches := pattern.FindAllStringSubmatch(v, -1)
|
||||
log.Printf("%+v", submatches)
|
||||
result[k] = Proxy{
|
||||
Auth: submatches[0][2],
|
||||
To: submatches[0][3],
|
||||
From: submatches[0][4],
|
||||
To: submatches[0][5],
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user