-
-
Notifications
You must be signed in to change notification settings - Fork 12.6k
/
Copy pathfastnetmon.rb
98 lines (82 loc) · 3.44 KB
/
fastnetmon.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
class Fastnetmon < Formula
desc "DDoS detection tool with sFlow, Netflow, IPFIX and port mirror support"
homepage "https://github.com/pavel-odintsov/fastnetmon/"
url "https://github.com/pavel-odintsov/fastnetmon/archive/refs/tags/v1.2.6.tar.gz"
sha256 "b6a7d1e9ba98c1c042d774bff82ea3e8bbf03085e0be43a2676e41d590f668cf"
license "GPL-2.0-only"
revision 9
bottle do
sha256 cellar: :any, arm64_sonoma: "d5756c39a491cd984f93fbeeb557bd0805beefffee2a7f91e0fca0ba4cf6b3c0"
sha256 cellar: :any, arm64_ventura: "16db61342bf43c20c0f4967c5098c0d0d58076307ab178278162fc4dc06ad328"
sha256 cellar: :any, arm64_monterey: "d3223d632cfd595f9a2ee7d5dd436111434688fcde9ea58afedc2d5c00110b3d"
sha256 cellar: :any, sonoma: "6d5ef084103a327bfdd887da8c3c136ec18ab62a773a6fee12fb32e7df5f6ff5"
sha256 cellar: :any, ventura: "dddd0d0189fe3890b941db38741f933124ff6f082b58f9fe9ac55461799f52ca"
sha256 cellar: :any, monterey: "4bf576e058feeb213ebe5666bd9441b4f7fac3e843e590e81d6f5af8a625e5a5"
sha256 cellar: :any_skip_relocation, x86_64_linux: "15595b13025fe7bcfcb7415e0cb76c74f127ed43fbfd0b1c6af9c3c9ef00199c"
end
depends_on "cmake" => :build
depends_on "abseil"
depends_on "boost"
depends_on "capnp"
depends_on "grpc"
depends_on "hiredis"
depends_on "log4cpp"
depends_on macos: :big_sur # We need C++ 20 available for build which is available from Big Sur
depends_on "mongo-c-driver"
depends_on "openssl@3"
depends_on "protobuf"
uses_from_macos "ncurses"
on_linux do
depends_on "elfutils"
depends_on "libbpf"
depends_on "libpcap"
end
fails_with gcc: "5"
# Fix build with newer `protobuf` using open PR.
# PR ref: https://github.com/pavel-odintsov/fastnetmon/pull/997
patch do
url "https://github.com/pavel-odintsov/fastnetmon/commit/fad8757b8986226024d549a6dfb40abbab01643e.patch?full_index=1"
sha256 "2da8dbdf9dc63df9f17067aef20d198123ce1338559d394f29461761e6b85f85"
end
def install
system "cmake", "-S", "src", "-B", "build",
"-DLINK_WITH_ABSL=TRUE",
"-DSET_ABSOLUTE_INSTALL_PATH=OFF",
*std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
service do
run [
opt_sbin/"fastnetmon",
"--configuration_file",
etc/"fastnetmon.conf",
"--log_to_console",
"--disable_pid_logic",
]
keep_alive false
working_dir HOMEBREW_PREFIX
log_path var/"log/fastnetmon.log"
error_log_path var/"log/fastnetmon.log"
end
test do
cp etc/"fastnetmon.conf", testpath
inreplace testpath/"fastnetmon.conf", "/tmp/fastnetmon.dat", (testpath/"fastnetmon.dat").to_s
inreplace testpath/"fastnetmon.conf", "/tmp/fastnetmon_ipv6.dat", (testpath/"fastnetmon_ipv6.dat").to_s
fastnetmon_pid = fork do
exec opt_sbin/"fastnetmon",
"--configuration_file",
testpath/"fastnetmon.conf",
"--log_to_console"
end
sleep 15
assert_path_exists testpath/"fastnetmon.dat"
ipv4_stats_output = (testpath/"fastnetmon.dat").read
assert_match("Incoming traffic", ipv4_stats_output)
assert_path_exists testpath/"fastnetmon_ipv6.dat"
ipv6_stats_output = (testpath/"fastnetmon_ipv6.dat").read
assert_match("Incoming traffic", ipv6_stats_output)
ensure
Process.kill "SIGTERM", fastnetmon_pid
end
end