impl cidr as password:CIDR:http://target

This commit is contained in:
bel
2025-11-20 08:28:25 -07:00
parent 9791f80b28
commit 2ff12869cd
6 changed files with 88 additions and 2 deletions

View File

@@ -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