From f7c15dd0b0a3d54452cb50d04ba889a1b9c389e9 Mon Sep 17 00:00:00 2001 From: Sonia Appasamy Date: Thu, 22 Sep 2022 13:36:08 -0400 Subject: [PATCH] types/view: add ContainsNonExitSubnetRoutes func Signed-off-by: Sonia Appasamy (cherry picked from commit 5363a902725ad8464e5618dcecc284b0224c3d8a) --- types/views/views.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/types/views/views.go b/types/views/views.go index bfefbef4d..fe3fe8031 100644 --- a/types/views/views.go +++ b/types/views/views.go @@ -216,6 +216,17 @@ func (v IPPrefixSlice) ContainsExitRoutes() bool { return tsaddr.ContainsExitRoutes(v.ж.ж) } +// ContainsNonExitSubnetRoutes reports whether v contains Subnet +// Routes other than ExitNode Routes. +func (v IPPrefixSlice) ContainsNonExitSubnetRoutes() bool { + for i := 0; i < v.Len(); i++ { + if v.At(i).Bits() != 0 { + return true + } + } + return false +} + // MarshalJSON implements json.Marshaler. func (v IPPrefixSlice) MarshalJSON() ([]byte, error) { return v.ж.MarshalJSON()