You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmd/agent/app/options/options.go
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,9 @@ import (
5
5
"fmt"
6
6
"net"
7
7
"os"
8
+
"regexp"
8
9
"strconv"
10
+
"strings"
9
11
10
12
"github.com/spf13/pflag"
11
13
v1 "k8s.io/api/core/v1"
@@ -35,6 +37,7 @@ const (
35
37
DefaultTunnelMetricsPort=10265
36
38
DefaultProxyMetricsPort=10266
37
39
DefaultHealthyProbeAddr=10275
40
+
DefaultMACPrefix="aa:0f"
38
41
)
39
42
40
43
// AgentOptions has the information that required by the raven agent
@@ -52,6 +55,7 @@ type TunnelOptions struct {
52
55
VPNDriverstring
53
56
VPNPortstring
54
57
RouteDriverstring
58
+
MACPrefixstring
55
59
ForwardNodeIPbool
56
60
NATTraversalbool
57
61
KeepAliveIntervalint
@@ -77,6 +81,15 @@ func (o *AgentOptions) Validate() error {
77
81
returnerrors.New("currently only supports libreswan and wireguard VPN drivers")
78
82
}
79
83
}
84
+
ifo.MACPrefix!="" {
85
+
reg:=regexp.MustCompile(`^[0-9a-fA-F]+$`)
86
+
strs:=strings.Split(o.MACPrefix, ":")
87
+
fori:=rangestrs {
88
+
if!reg.MatchString(strings.ToLower(strs[i])) {
89
+
returnfmt.Errorf("mac prefix %s is nonstandard", o.MACPrefix)
90
+
}
91
+
}
92
+
}
80
93
returnnil
81
94
}
82
95
@@ -95,6 +108,7 @@ func (o *AgentOptions) AddFlags(fs *pflag.FlagSet) {
95
108
fs.BoolVar(&o.ForwardNodeIP, "forward-node-ip", o.ForwardNodeIP, `Forward node IP or not. (default "false")`)
96
109
fs.IntVar(&o.KeepAliveInterval, "keep-alive-interval", o.KeepAliveInterval, `Interval for sending keepalive packets in the VPN tunnel, (default "0", closed)`)
97
110
fs.IntVar(&o.KeepAliveTimeout, "keep-alive-timeout", o.KeepAliveTimeout, `Timeout for sending keepalive packets in the VPN tunnel, (default "0", closed)`)
111
+
fs.StringVar(&o.MACPrefix, "customized-mac-prefix", o.MACPrefix, `Customized MAC address prefix for vxlan link, (default "aa:0f")`)
98
112
99
113
fs.StringVar(&o.ProxyMetricsAddress, "proxy-metric-bind-addr", o.ProxyMetricsAddress, `Binding address of proxy metrics. (default ":10266")`)
0 commit comments