Skip to content

Commit db1053f

Browse files
committed
Add listen_port option to Tailscale endpoint
1 parent d4029f4 commit db1053f

5 files changed

Lines changed: 27 additions & 0 deletions

File tree

docs/configuration/endpoint/tailscale.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ icon: material/new-box
44

55
!!! quote "Changes in sing-box 1.14.0"
66

7+
:material-plus: [listen_port](#listen_port)
78
:material-plus: [ssh_server](#ssh_server)
89

910
!!! quote "Changes in sing-box 1.13.0"
@@ -34,6 +35,7 @@ icon: material/new-box
3435
"advertise_routes": [],
3536
"advertise_exit_node": false,
3637
"advertise_tags": [],
38+
"listen_port": 0,
3739
"relay_server_port": 0,
3840
"relay_server_static_endpoints": [],
3941
"system_interface": false,
@@ -121,6 +123,14 @@ Tags to advertise for this node, for ACL enforcement purposes.
121123

122124
Example: `["tag:server"]`
123125

126+
#### listen_port
127+
128+
!!! question "Since sing-box 1.14.0"
129+
130+
The UDP port to listen on for WireGuard and peer-to-peer traffic.
131+
132+
A port is automatically selected by default.
133+
124134
#### relay_server_port
125135

126136
!!! question "Since sing-box 1.13.0"

docs/configuration/endpoint/tailscale.zh.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ icon: material/new-box
44

55
!!! quote "sing-box 1.14.0 中的更改"
66

7+
:material-plus: [listen_port](#listen_port)
78
:material-plus: [ssh_server](#ssh_server)
89

910
!!! quote "sing-box 1.13.0 中的更改"
@@ -34,6 +35,7 @@ icon: material/new-box
3435
"advertise_routes": [],
3536
"advertise_exit_node": false,
3637
"advertise_tags": [],
38+
"listen_port": 0,
3739
"relay_server_port": 0,
3840
"relay_server_static_endpoints": [],
3941
"system_interface": false,
@@ -120,6 +122,14 @@ icon: material/new-box
120122

121123
示例:`["tag:server"]`
122124

125+
#### listen_port
126+
127+
!!! question "自 sing-box 1.14.0 起"
128+
129+
监听 WireGuard 和点对点流量的 UDP 端口。
130+
131+
默认自动选择端口。
132+
123133
#### relay_server_port
124134

125135
!!! question "自 sing-box 1.13.0 起"

docs/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4534,6 +4534,11 @@
45344534
}
45354535
]
45364536
},
4537+
"listen_port": {
4538+
"type": "integer",
4539+
"minimum": 0,
4540+
"maximum": 65535
4541+
},
45374542
"relay_server_port": {
45384543
"type": "integer",
45394544
"minimum": 0,

option/tailscale.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type TailscaleEndpointOptions struct {
2525
AdvertiseRoutes []netip.Prefix `json:"advertise_routes,omitempty"`
2626
AdvertiseExitNode bool `json:"advertise_exit_node,omitempty"`
2727
AdvertiseTags badoption.Listable[string] `json:"advertise_tags,omitempty"`
28+
ListenPort uint16 `json:"listen_port,omitempty"`
2829
RelayServerPort *uint16 `json:"relay_server_port,omitempty"`
2930
RelayServerStaticEndpoints []netip.AddrPort `json:"relay_server_static_endpoints,omitempty"`
3031
SystemInterface bool `json:"system_interface,omitempty"`

protocol/tailscale/endpoint.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ func NewEndpoint(ctx context.Context, router adapter.Router, logger log.ContextL
202202
Ephemeral: options.Ephemeral,
203203
AuthKey: options.AuthKey,
204204
ControlURL: options.ControlURL,
205+
Port: options.ListenPort,
205206
AdvertiseTags: options.AdvertiseTags,
206207
Dialer: &endpointDialer{Dialer: outboundDialer, logger: logger},
207208
LookupHook: func(ctx context.Context, host string) ([]netip.Addr, error) {

0 commit comments

Comments
 (0)