aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/service/ifaceconfig.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-05 20:40:14 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-05 20:40:14 +0100
commit16bf47444dfbefda4705a24585dc5b6c2953e665 (patch)
treee32cb1daee0864c71f7bbe0bdea217982837f730 /service/ifaceconfig.go
parentconf: expose base64 key parsing (diff)
downloadwireguard-windows-16bf47444dfbefda4705a24585dc5b6c2953e665.tar.xz
wireguard-windows-16bf47444dfbefda4705a24585dc5b6c2953e665.zip
ifaceconfig: more compact less function
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'service/ifaceconfig.go')
-rw-r--r--service/ifaceconfig.go17
1 files changed, 4 insertions, 13 deletions
diff --git a/service/ifaceconfig.go b/service/ifaceconfig.go
index b2f93b70..1bd5f690 100644
--- a/service/ifaceconfig.go
+++ b/service/ifaceconfig.go
@@ -206,19 +206,10 @@ func configureInterface(conf *conf.Config, guid *windows.GUID) error {
deduplicatedRoutes := make([]*winipcfg.RouteData, routeCount)
routeCount = 0
sort.Slice(routes, func(i, j int) bool {
- if routes[i].Metric < routes[j].Metric {
- return true
- }
- if bytes.Compare(routes[i].NextHop, routes[j].NextHop) == -1 {
- return true
- }
- if bytes.Compare(routes[i].Destination.IP, routes[j].Destination.IP) == -1 {
- return true
- }
- if bytes.Compare(routes[i].Destination.Mask, routes[j].Destination.Mask) == -1 {
- return true
- }
- return false
+ return routes[i].Metric < routes[j].Metric ||
+ bytes.Compare(routes[i].NextHop, routes[j].NextHop) == -1 ||
+ bytes.Compare(routes[i].Destination.IP, routes[j].Destination.IP) == -1 ||
+ bytes.Compare(routes[i].Destination.Mask, routes[j].Destination.Mask) == -1
})
for i := 0; i < len(routes); i++ {
if i > 0 && routes[i].Metric == routes[i-1].Metric &&