Skip to content

Commit 3f54572

Browse files
committed
IPN: Update ServeConfig to accept configuration for Services.
This commit updates ServeConfig to allow configuration to Services (VIPServices for now) via Serve. The scope of this commit is only adding the Services field to ServeConfig. The field doesn't actually allow packet flowing yet. The purpose of this commit is to unblock other work on k8s end. Updates #22953 Signed-off-by: KevinLiang10 <[email protected]>
1 parent 8d0c690 commit 3f54572

File tree

4 files changed

+144
-2
lines changed

4 files changed

+144
-2
lines changed

ipn/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
//go:generate go run tailscale.com/cmd/viewer -type=Prefs,ServeConfig,TCPPortHandler,HTTPHandler,WebServerConfig
4+
//go:generate go run tailscale.com/cmd/viewer -type=Prefs,ServeConfig,ServiceConfig,TCPPortHandler,HTTPHandler,WebServerConfig
55

66
// Package ipn implements the interactions between the Tailscale cloud
77
// control plane and the local network stack.

ipn/ipn_clone.go

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ipn/ipn_view.go

Lines changed: 73 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ipn/serve.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ func ServeConfigKey(profileID ProfileID) StateKey {
2424
return StateKey("_serve/" + profileID)
2525
}
2626

27+
// ServiceConfig contains the config information for a single service.
28+
// it contains a bool to indicate if the service is in Tun mode (L3 forwarding).
29+
// If the service is not in Tun mode, the service is configured by the L4 forwarding
30+
// (TCP ports) and/or the L7 forwarding (http handlers) information.
31+
type ServiceConfig struct {
32+
// TCP are the list of TCP port numbers that tailscaled should handle for
33+
// the Tailscale IP addresses. (not subnet routers, etc)
34+
TCP map[uint16]*TCPPortHandler `json:",omitempty"`
35+
36+
// Web maps from "$SNI_NAME:$PORT" to a set of HTTP handlers
37+
// keyed by mount point ("/", "/foo", etc)
38+
Web map[HostPort]*WebServerConfig `json:",omitempty"`
39+
40+
// Tun determines if the service should be using L3 forwarding (Tun mode).
41+
Tun bool `json:",omitempty"`
42+
}
43+
2744
// ServeConfig is the JSON type stored in the StateStore for
2845
// StateKey "_serve/$PROFILE_ID" as returned by ServeConfigKey.
2946
type ServeConfig struct {
@@ -35,6 +52,10 @@ type ServeConfig struct {
3552
// keyed by mount point ("/", "/foo", etc)
3653
Web map[HostPort]*WebServerConfig `json:",omitempty"`
3754

55+
// Services maps from service name to a ServiceConfig. Which describes the
56+
// L3, L4, and L7 forwarding information for the service.
57+
Services map[string]*ServiceConfig `json:",omitempty"`
58+
3859
// AllowFunnel is the set of SNI:port values for which funnel
3960
// traffic is allowed, from trusted ingress peers.
4061
AllowFunnel map[HostPort]bool `json:",omitempty"`

0 commit comments

Comments
 (0)