| 369 | } |
| 370 | |
| 371 | func doCleanup(queue, repeatQueue *netfilter.Queue) { |
| 372 | log.Info("Cleaning up ...") |
| 373 | firewall.Stop() |
| 374 | monitor.End() |
| 375 | uiClient.Close() |
| 376 | if resolvMonitor != nil { |
| 377 | resolvMonitor.Close() |
| 378 | } |
| 379 | |
| 380 | if cpuProfile != "" { |
| 381 | pprof.StopCPUProfile() |
| 382 | } |
| 383 | |
| 384 | if memProfile != "" { |
| 385 | runtime.GC() // get up-to-date statistics |
| 386 | if err := pprof.WriteHeapProfile(memFile); err != nil { |
| 387 | log.Error("Could not write memory profile: %s", err) |
| 388 | } |
| 389 | log.Info("Writing mem profile to %s", memProfile) |
| 390 | memFile.Close() |
| 391 | } |
| 392 | if traceFile != "" { |
| 393 | trace.Stop() |
| 394 | } |
| 395 | |
| 396 | repeatQueue.Close() |
| 397 | queue.Close() |
| 398 | } |
| 399 | |
| 400 | func onPacket(packet netfilter.Packet) { |
| 401 | // DNS response, just parse, track and accept. |