mirror of
https://github.com/apernet/hysteria.git
synced 2025-04-03 04:27:39 +03:00
feat(tun): allow omit pfxlen in full len pfx route
This commit is contained in:
parent
aab104ae2e
commit
6374ea11c4
1 changed files with 15 additions and 5 deletions
|
@ -727,12 +727,22 @@ func clientTUN(config tunConfig, c client.Client) error {
|
|||
server.AutoRoute = true
|
||||
server.StructRoute = config.Route.Strict
|
||||
|
||||
parsePrefixes := func(field string, s []string) ([]netip.Prefix, error) {
|
||||
parsePrefixes := func(field string, ss []string) ([]netip.Prefix, error) {
|
||||
var prefixes []netip.Prefix
|
||||
for i, s := range s {
|
||||
p, err := netip.ParsePrefix(s)
|
||||
if err != nil {
|
||||
return nil, configError{Field: fmt.Sprintf("%s[%d]", field, i), Err: err}
|
||||
for i, s := range ss {
|
||||
var p netip.Prefix
|
||||
if strings.Contains(s, "/") {
|
||||
var err error
|
||||
p, err = netip.ParsePrefix(s)
|
||||
if err != nil {
|
||||
return nil, configError{Field: fmt.Sprintf("%s[%d]", field, i), Err: err}
|
||||
}
|
||||
} else {
|
||||
pa, err := netip.ParseAddr(s)
|
||||
if err != nil {
|
||||
return nil, configError{Field: fmt.Sprintf("%s[%d]", field, i), Err: err}
|
||||
}
|
||||
p = netip.PrefixFrom(pa, pa.BitLen())
|
||||
}
|
||||
prefixes = append(prefixes, p)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue