MCPcopy Create free account
hub / github.com/tailscale/tailscale / TestClientSideJailing

Function TestClientSideJailing

tstest/integration/integration_test.go:1198–1306  ·  view source on GitHub ↗

TestClientSideJailing tests that when one node is jailed for another, the jailed node cannot initiate connections to the other node however the other node can initiate connections to the jailed node.

(t *testing.T)

Source from the content-addressed store, hash-verified

1196// jailed node cannot initiate connections to the other node however the other
1197// node can initiate connections to the jailed node.
1198func TestClientSideJailing(t *testing.T) {
1199 flakytest.Mark(t, "https://github.com/tailscale/tailscale/issues/17419")
1200 tstest.Parallel(t)
1201 env := NewTestEnv(t)
1202 registerNode := func() (*TestNode, key.NodePublic) {
1203 n := NewTestNode(t, env)
1204 n.StartDaemon()
1205 n.AwaitListening()
1206 n.MustUp()
1207 n.AwaitRunning()
1208 k := n.MustStatus().Self.PublicKey
1209 return n, k
1210 }
1211 n1, k1 := registerNode()
1212 n2, k2 := registerNode()
1213
1214 ln, err := net.Listen("tcp", "localhost:0")
1215 if err != nil {
1216 t.Fatal(err)
1217 }
1218 defer ln.Close()
1219 port := uint16(ln.Addr().(*net.TCPAddr).Port)
1220
1221 lc1 := &local.Client{
1222 Socket: n1.sockFile,
1223 UseSocketOnly: true,
1224 }
1225 lc2 := &local.Client{
1226 Socket: n2.sockFile,
1227 UseSocketOnly: true,
1228 }
1229
1230 ip1 := n1.AwaitIP4()
1231 ip2 := n2.AwaitIP4()
1232
1233 tests := []struct {
1234 name string
1235 n1JailedForN2 bool
1236 n2JailedForN1 bool
1237 }{
1238 {
1239 name: "not_jailed",
1240 n1JailedForN2: false,
1241 n2JailedForN1: false,
1242 },
1243 {
1244 name: "uni_jailed",
1245 n1JailedForN2: true,
1246 n2JailedForN1: false,
1247 },
1248 {
1249 name: "bi_jailed", // useless config?
1250 n1JailedForN2: true,
1251 n2JailedForN1: true,
1252 },
1253 }
1254
1255 testDial := func(t *testing.T, lc *local.Client, ip netip.Addr, port uint16, shouldFail bool) {

Callers

nothing calls this directly

Calls 15

StartDaemonMethod · 0.95
AwaitListeningMethod · 0.95
MustUpMethod · 0.95
AwaitRunningMethod · 0.95
MustStatusMethod · 0.95
WatchIPNBusMethod · 0.95
MarkFunction · 0.92
ParallelFunction · 0.92
NewTestEnvFunction · 0.85
NewTestNodeFunction · 0.85
fetchNetMapForTestFunction · 0.85
AwaitIP4Method · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…