MCPcopy Index your code
hub / github.com/tailscale/tailscale / Impl

Struct Impl

wgengine/netstack/netstack.go:160–284  ·  view source on GitHub ↗

Impl contains the state for the netstack implementation, and implements wgengine.FakeImpl to act as a userspace network stack when Tailscale is running in fake mode.

Source from the content-addressed store, hash-verified

158// and implements wgengine.FakeImpl to act as a userspace network
159// stack when Tailscale is running in fake mode.
160type Impl struct {
161 // GetTCPHandlerForFlow conditionally handles an incoming TCP flow for the
162 // provided (src/port, dst/port) 4-tuple.
163 //
164 // A nil value is equivalent to a func returning (nil, false).
165 //
166 // If func returns intercept=false, the default forwarding behavior (if
167 // ProcessLocalIPs and/or ProcesssSubnetIPs) takes place.
168 //
169 // When intercept=true, the behavior depends on whether the returned handler
170 // is non-nil: if nil, the connection is rejected. If non-nil, handler takes
171 // over the TCP conn.
172 GetTCPHandlerForFlow func(src, dst netip.AddrPort) (handler func(net.Conn), intercept bool)
173
174 // GetUDPHandlerForFlow conditionally handles an incoming UDP flow for the
175 // provided (src/port, dst/port) 4-tuple.
176 //
177 // A nil value is equivalent to a func returning (nil, false).
178 //
179 // If func returns intercept=false, the default forwarding behavior (if
180 // ProcessLocalIPs and/or ProcesssSubnetIPs) takes place.
181 //
182 // When intercept=true, the behavior depends on whether the returned handler
183 // is non-nil: if nil, the connection is rejected. If non-nil, handler takes
184 // over the UDP flow.
185 GetUDPHandlerForFlow func(src, dst netip.AddrPort) (handler func(nettype.ConnPacketConn), intercept bool)
186
187 // CheckLocalTransportEndpoints, if true, causes netstack to check if gVisor
188 // has a registered endpoint for incoming packets to local IPs. This is used
189 // by tsnet to intercept packets for registered listeners and outbound
190 // connections when ProcessLocalIPs is false (i.e., when using a TUN).
191 // It can only be set before calling Start.
192 // TODO(raggi): refactor the way we handle both CheckLocalTransportEndpoints
193 // and the earlier netstack registrations for serve, funnel, peerAPI and so
194 // on. Currently this optimizes away cost for tailscaled in TUN mode, while
195 // enabling extension support when using tsnet in TUN mode. See #18423.
196 CheckLocalTransportEndpoints bool
197
198 // ProcessLocalIPs is whether netstack should handle incoming
199 // traffic directed at the Node.Addresses (local IPs).
200 // It can only be set before calling Start.
201 ProcessLocalIPs bool
202
203 // ProcessSubnets is whether netstack should handle incoming
204 // traffic destined to non-local IPs (i.e. whether it should
205 // be a subnet router).
206 // It can only be set before calling Start.
207 ProcessSubnets bool
208
209 ipstack *stack.Stack
210 linkEP *linkEndpoint
211 tundev *tstun.Wrapper
212 e wgengine.Engine
213 pm *proxymap.Mapper
214 mc *magicsock.Conn
215 logf logger.Logf
216 dialer *tsdial.Dialer
217 ctx context.Context // alive until Close

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected