mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-26 11:35:35 +00:00
d488678fdc
For #707 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
37 lines
820 B
Go
37 lines
820 B
Go
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package netstack
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
"tailscale.com/wgengine"
|
|
"tailscale.com/wgengine/router"
|
|
)
|
|
|
|
func init() {
|
|
wgengine.NetstackRouterType = reflect.TypeOf(&subnetRouter{})
|
|
}
|
|
|
|
type subnetRouter struct {
|
|
router.Router
|
|
}
|
|
|
|
// NewSubnetRouterWrapper returns a Router wrapper that prevents the
|
|
// underlying Router r from seeing any advertised subnet routes, as
|
|
// netstack will handle them instead.
|
|
func NewSubnetRouterWrapper(r router.Router) router.Router {
|
|
return &subnetRouter{
|
|
Router: r,
|
|
}
|
|
}
|
|
|
|
func (r *subnetRouter) Set(c *router.Config) error {
|
|
if c != nil {
|
|
c.SubnetRoutes = nil // netstack will handle
|
|
}
|
|
return r.Router.Set(c)
|
|
}
|