Skip to content

Commit 8e6dc59

Browse files
committed
[tunnel] --skip-insecure-verify + --public-addr flags
1 parent 9df78e4 commit 8e6dc59

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

cmd/tunnelproxy/main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ var (
4848
jwksURLs = flag.String("jwks_urls", "", "Comma-separated URLs of the JWKS endpoints.")
4949

5050
tunnelNodeSelector = flag.String("label_selector", "", "Label selector for TunnelNode objects.")
51-
52-
extIPv6SubnetSize = flag.Int("ext_ipv6_subnet_size", 64, "IPv6 subnet size.")
53-
extIPv6Ifc = flag.String("ext_ipv6_ifc", "", "IPv6 interface name.")
54-
cksumRecalc = flag.Bool("cksum_recalc", false, "Recalculate checksum.")
51+
publicAddr = flag.String("public_addr", "", "Public address of the tunnel proxy.")
52+
extIPv6SubnetSize = flag.Int("ext_ipv6_subnet_size", 64, "IPv6 subnet size.")
53+
extIPv6Ifc = flag.String("ext_ipv6_ifc", "", "IPv6 interface name.")
54+
cksumRecalc = flag.Bool("cksum_recalc", false, "Recalculate checksum.")
5555
)
5656

5757
func main() {
@@ -136,6 +136,7 @@ func main() {
136136
r,
137137
tunnel.WithExternalIPv6Prefix(extIPv6Prefix),
138138
tunnel.WithLabelSelector(*tunnelNodeSelector),
139+
tunnel.WithPublicAddr(*publicAddr),
139140
)
140141
g.Go(func() error {
141142
log.Infof("Starting Tunnel Proxy server")

pkg/cmd/tunnel/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ func init() {
215215
updateCmd.Flags().StringVarP(&tunnelNodeFile, "file", "f", "", "Path to the TunnelNode file to update.")
216216
tunnelRunCmd.Flags().StringVarP(&tunnelNodePcapPath, "pcap", "p", "", "Path to the TunnelNode file to create.")
217217
tunnelRunCmd.Flags().StringVarP(&tunnelModeS, "mode", "m", "user", "Mode to run the TunnelNode in.")
218+
tunnelRunCmd.Flags().BoolVar(&insecureSkipVerify, "insecure-skip-verify", false, "Skip TLS certificate verification")
218219

219220
tunnelCmd.AddCommand(createCmd)
220221
tunnelCmd.AddCommand(getCmd)

pkg/cmd/tunnel/run.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ var (
4545
tunnelNodePcapPath string
4646
tunnelModeS string
4747
tunnelMode tunnel.TunnelClientMode
48+
insecureSkipVerify bool
4849
)
4950

5051
func init() {
@@ -229,7 +230,7 @@ func (t *tunnelNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request)
229230
cOpts = append(cOpts, tunnel.WithServerAddr(srvAddr))
230231
}
231232
}
232-
if t.cfg.IsLocalMode {
233+
if t.cfg.IsLocalMode || insecureSkipVerify {
233234
cOpts = append(cOpts, tunnel.WithInsecureSkipVerify(true))
234235
}
235236

pkg/tunnel/server.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"net"
1010
"net/http"
1111
"net/netip"
12+
"slices"
1213
"strings"
1314
"time"
1415

@@ -47,6 +48,7 @@ type TunnelServerOption func(*tunnelServerOptions)
4748

4849
type tunnelServerOptions struct {
4950
proxyAddr string
51+
publicAddr string
5052
ulaPrefix netip.Prefix
5153
certPath string
5254
keyPath string
@@ -58,6 +60,7 @@ type tunnelServerOptions struct {
5860
func defaultServerOptions() *tunnelServerOptions {
5961
return &tunnelServerOptions{
6062
proxyAddr: "0.0.0.0:9443",
63+
publicAddr: "",
6164
ulaPrefix: netip.MustParsePrefix("fd00::/64"),
6265
certPath: "/etc/apoxy/certs/tunnelproxy.crt",
6366
keyPath: "/etc/apoxy/certs/tunnelproxy.key",
@@ -74,6 +77,14 @@ func WithProxyAddr(addr string) TunnelServerOption {
7477
}
7578
}
7679

80+
// WithPublicAddr sets the address tunnel proxy is reachable at. This
81+
// address will be set on the TunnelNode objects that this proxy is serving.
82+
func WithPublicAddr(addr string) TunnelServerOption {
83+
return func(o *tunnelServerOptions) {
84+
o.publicAddr = addr
85+
}
86+
}
87+
7788
// WithULAPrefix sets the Unique Local Address prefix.
7889
func WithULAPrefix(prefix netip.Prefix) TunnelServerOption {
7990
return func(o *tunnelServerOptions) {
@@ -472,6 +483,19 @@ func (t *TunnelServer) reconcile(ctx context.Context, request reconcile.Request)
472483
return reconcile.Result{}, nil
473484
}
474485

486+
if t.options.publicAddr != "" {
487+
var updated bool
488+
if !slices.Contains(node.Status.Addresses, t.options.publicAddr) {
489+
node.Status.Addresses = append(node.Status.Addresses, t.options.publicAddr)
490+
updated = true
491+
}
492+
if updated {
493+
if err := t.Status().Update(ctx, node); err != nil {
494+
return reconcile.Result{}, fmt.Errorf("failed to update TunnelNode status: %w", err)
495+
}
496+
}
497+
}
498+
475499
t.AddTunnelNode(node)
476500

477501
return ctrl.Result{}, nil

0 commit comments

Comments
 (0)