1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-03 07:56:42 -05:00

Merge pull request #1293 from Quasilyte/quasilyte/ifElseChain

app/router: rewrite if-else chain to switch
This commit is contained in:
Victoria Raymond 2018-10-01 11:39:37 +02:00 committed by GitHub
commit 504eff5fe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,14 +36,15 @@ func cidrToCondition(cidr []*CIDR, source bool) (Condition, error) {
}
}
if !ipv4Net.IsEmpty() && hasIpv6 {
switch {
case !ipv4Net.IsEmpty() && hasIpv6:
cond := NewAnyCondition()
cond.Add(NewIPv4Matcher(ipv4Net, source))
cond.Add(ipv6Cond)
return cond, nil
} else if !ipv4Net.IsEmpty() {
case !ipv4Net.IsEmpty():
return NewIPv4Matcher(ipv4Net, source), nil
} else {
default:
return ipv6Cond, nil
}
}