MCPcopy Create free account
hub / github.com/SamNet-dev/snix / TestRawSocketAvailable

Function TestRawSocketAvailable

platform/linux/nfqueue_integration_test.go:96–108  ·  view source on GitHub ↗

TestRawSocketAvailable verifies we can acquire a raw socket + IP_HDRINCL. If this fails, Inject() cannot work on this host (missing CAP_NET_RAW).

(t *testing.T)

Source from the content-addressed store, hash-verified

94// TestRawSocketAvailable verifies we can acquire a raw socket + IP_HDRINCL.
95// If this fails, Inject() cannot work on this host (missing CAP_NET_RAW).
96func TestRawSocketAvailable(t *testing.T) {
97 mustBeRoot(t)
98 b := New(Config{QueueNum: 4244})
99 if err := b.Open(context.Background(), safeScope()); err != nil {
100 t.Fatalf("Open: %v", err)
101 }
102 if b.rawSock < 0 {
103 t.Fatal("raw socket not opened")
104 }
105 if err := b.Close(); err != nil {
106 t.Fatalf("Close: %v", err)
107 }
108}
109
110var _ = net.Listen // keep net imported for future use
111var _ = time.Second

Callers

nothing calls this directly

Calls 5

mustBeRootFunction · 0.85
safeScopeFunction · 0.85
NewFunction · 0.70
OpenMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected