MCPcopy
hub / github.com/safing/portmaster / start

Function start

service/firewall/interception/module.go:60–92  ·  view source on GitHub ↗

Start starts the interception.

()

Source from the content-addressed store, hash-verified

58
59// Start starts the interception.
60func start() error {
61 if disableInterception {
62 log.Warning("interception: packet interception is disabled via flag - this breaks a lot of functionality")
63 return nil
64 }
65
66 if !isStarted.CompareAndSwap(false, true) {
67 return nil // already running
68 }
69
70 inputPackets := Packets
71 if packetMetricsDestination != "" {
72 go metrics.writeMetrics()
73 inputPackets = make(chan packet.Packet)
74 go func() {
75 for p := range inputPackets {
76 Packets <- tracePacket(p)
77 }
78 }()
79 }
80
81 err := startInterception(inputPackets)
82 if err != nil {
83 log.Errorf("interception: failed to start module: %q", err)
84 log.Debug("interception: cleaning up after failed start...")
85 metrics.stop()
86 if e := stopInterception(); e != nil {
87 log.Debugf("interception: error cleaning up after failed start: %q", e.Error())
88 }
89 isStarted.Store(false)
90 }
91 return err
92}
93
94// Stop starts the interception.
95func stop() error {

Callers 1

StartMethod · 0.70

Calls 10

WarningFunction · 0.92
ErrorfFunction · 0.92
DebugFunction · 0.92
DebugfFunction · 0.92
tracePacketFunction · 0.85
writeMetricsMethod · 0.80
startInterceptionFunction · 0.70
stopInterceptionFunction · 0.70
ErrorMethod · 0.65
stopMethod · 0.45

Tested by

no test coverage detected