chore: listeners support tun

This commit is contained in:
wwqgtxx
2022-12-05 17:43:50 +08:00
parent 5c410b8df4
commit fd9c4cbfa5
12 changed files with 260 additions and 50 deletions

View File

@ -58,6 +58,18 @@ func (p ListenPrefix) Build() netip.Prefix {
return netip.Prefix(p)
}
func StringSliceToListenPrefixSlice(ss []string) ([]ListenPrefix, error) {
lps := make([]ListenPrefix, 0, len(ss))
for _, s := range ss {
prefix, err := netip.ParsePrefix(s)
if err != nil {
return nil, err
}
lps = append(lps, ListenPrefix(prefix))
}
return lps, nil
}
type Tun struct {
Enable bool
Device string