mirror of
https://github.com/kubenetworks/kubevpn.git
synced 2025-10-08 08:40:30 +08:00
feat: add option extra-cidr
This commit is contained in:
@@ -47,9 +47,11 @@ import (
|
||||
)
|
||||
|
||||
type ConnectOptions struct {
|
||||
Namespace string
|
||||
Headers map[string]string
|
||||
Workloads []string
|
||||
Namespace string
|
||||
Headers map[string]string
|
||||
Workloads []string
|
||||
ExtraCIDR []string
|
||||
|
||||
clientset *kubernetes.Clientset
|
||||
restclient *rest.RESTClient
|
||||
config *rest.Config
|
||||
@@ -255,6 +257,14 @@ func (c *ConnectOptions) startLocalTunServe(ctx context.Context, forwardAddress
|
||||
for _, ipNet := range c.cidrs {
|
||||
list.Insert(ipNet.String())
|
||||
}
|
||||
// add extra-cidr
|
||||
for _, s := range c.ExtraCIDR {
|
||||
_, _, err = net.ParseCIDR(s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid extra-cidr %s, err: %v", s, err)
|
||||
}
|
||||
list.Insert(s)
|
||||
}
|
||||
r := core.Route{
|
||||
ServeNodes: []string{
|
||||
fmt.Sprintf("tun:/127.0.0.1:8422?net=%s&route=%s", c.localTunIP.String(), strings.Join(list.UnsortedList(), ",")),
|
||||
|
Reference in New Issue
Block a user