diff --git a/MODULE.bazel b/MODULE.bazel index fc23fde..396d0cb 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -29,6 +29,7 @@ bazel_dep(name = "aspect_bazel_lib", version = "2.9.0") bazel_dep(name = "hermetic_cc_toolchain", version = "3.1.0") bazel_dep(name = "toolchains_protoc", version = "0.3.3") bazel_dep(name = "rules_multirun", version = "0.9.0") +bazel_dep(name = "protobuf", version = "29.2") toolchains = use_extension("@hermetic_cc_toolchain//toolchain:ext.bzl", "toolchains") use_repo(toolchains, "zig_sdk") @@ -54,13 +55,12 @@ use_repo( "com_github_gopacket_gopacket", "com_github_huandu_go_sqlbuilder", "com_github_netsampler_goflow2", - "com_github_netsampler_goflow2_v2", "com_github_osrg_gobgp", "com_github_pressly_goose_v3", "com_github_sirupsen_logrus", "com_github_vishvananda_netlink", - "io_k8s_klog_v2", "org_cuelang_go", + "org_golang_google_protobuf", ) oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") @@ -111,5 +111,26 @@ grafana_plugin( grafana_plugin( name = "grafana-clickhouse-datasource", plugin_name = "grafana-clickhouse-datasource", - version = "4.5.0", + version = "4.5.1", ) + +grafana = use_repo_rule("//third_party/grafana:defs.bzl", "grafana") + +grafana( + name = "grafana_bin", +) + +clickhouse = use_repo_rule("//third_party/clickhouse:defs.bzl", "clickhouse") + +clickhouse( + name = "clickhouse_bin", +) + +#http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") + +#http_file( +# name = "clickhouse", +# downloaded_file_path = "clickhouse", +# executable = True, +# url = "https://builds.clickhouse.com/master/macos-aarch64/clickhouse", +#) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 0a2d1a9..e2a5b31 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -4,7 +4,12 @@ "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/MODULE.bazel": "70390338f7a5106231d20620712f7cccb659cd0e9d073d1991c038eb9fc57589", - "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/source.json": "7e3a9adf473e9af076ae485ed649d5641ad50ec5c11718103f34de03170d94ad", + "https://bcr.bazel.build/modules/abseil-cpp/20230125.1/MODULE.bazel": "89047429cb0207707b2dface14ba7f8df85273d484c2572755be4bab7ce9c3a0", + "https://bcr.bazel.build/modules/abseil-cpp/20230802.0.bcr.1/MODULE.bazel": "1c8cec495288dccd14fdae6e3f95f772c1c91857047a098fad772034264cc8cb", + "https://bcr.bazel.build/modules/abseil-cpp/20230802.0/MODULE.bazel": "d253ae36a8bd9ee3c5955384096ccb6baf16a1b1e93e858370da0a3b94f77c16", + "https://bcr.bazel.build/modules/abseil-cpp/20230802.1/MODULE.bazel": "fa92e2eb41a04df73cdabeec37107316f7e5272650f81d6cc096418fe647b915", + "https://bcr.bazel.build/modules/abseil-cpp/20240116.1/MODULE.bazel": "37bcdb4440fbb61df6a1c296ae01b327f19e9bb521f9b8e26ec854b6f97309ed", + "https://bcr.bazel.build/modules/abseil-cpp/20240116.1/source.json": "9be551b8d4e3ef76875c0d744b5d6a504a27e3ae67bc6b28f46415fd2d2957da", "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", "https://bcr.bazel.build/modules/apple_support/1.5.0/source.json": "eb98a7627c0bc486b57f598ad8da50f6625d974c8f723e9ea71bd39f709c9862", "https://bcr.bazel.build/modules/aspect_bazel_lib/2.7.2/MODULE.bazel": "780d1a6522b28f5edb7ea09630748720721dfe27690d65a2d33aa7509de77e07", @@ -13,12 +18,16 @@ "https://bcr.bazel.build/modules/bazel_features/1.1.1/MODULE.bazel": "27b8c79ef57efe08efccbd9dd6ef70d61b4798320b8d3c134fd571f78963dbcd", "https://bcr.bazel.build/modules/bazel_features/1.10.0/MODULE.bazel": "f75e8807570484a99be90abcd52b5e1f390362c258bcb73106f4544957a48101", "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", + "https://bcr.bazel.build/modules/bazel_features/1.15.0/MODULE.bazel": "d38ff6e517149dc509406aca0db3ad1efdd890a85e049585b7234d04238e2a4d", + "https://bcr.bazel.build/modules/bazel_features/1.17.0/MODULE.bazel": "039de32d21b816b47bd42c778e0454217e9c9caac4a3cf8e15c7231ee3ddee4d", "https://bcr.bazel.build/modules/bazel_features/1.18.0/MODULE.bazel": "1be0ae2557ab3a72a57aeb31b29be347bcdc5d2b1eb1e70f39e3851a7e97041a", - "https://bcr.bazel.build/modules/bazel_features/1.18.0/source.json": "cde886d88c8164b50b9b97dba7c0a64ca24d257b72ca3a2fcb06bee1fdb47ee4", + "https://bcr.bazel.build/modules/bazel_features/1.19.0/MODULE.bazel": "59adcdf28230d220f0067b1f435b8537dd033bfff8db21335ef9217919c7fb58", + "https://bcr.bazel.build/modules/bazel_features/1.19.0/source.json": "d7bf14517c1b25b9d9c580b0f8795fceeae08a7590f507b76aace528e941375d", "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", "https://bcr.bazel.build/modules/bazel_features/1.9.0/MODULE.bazel": "885151d58d90d8d9c811eb75e3288c11f850e1d6b481a8c9f766adee4712358b", "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", + "https://bcr.bazel.build/modules/bazel_skylib/1.1.1/MODULE.bazel": "1add3e7d93ff2e6998f9e118022c84d163917d912f5afafb3058e3d2f1545b5e", "https://bcr.bazel.build/modules/bazel_skylib/1.2.0/MODULE.bazel": "44fe84260e454ed94ad326352a698422dbe372b21a1ac9f3eab76eb531223686", "https://bcr.bazel.build/modules/bazel_skylib/1.2.1/MODULE.bazel": "f35baf9da0efe45fa3da1696ae906eea3d615ad41e2e3def4aeb4e8bc0ef9a7a", "https://bcr.bazel.build/modules/bazel_skylib/1.3.0/MODULE.bazel": "20228b92868bf5cfc41bda7afc8a8ba2a543201851de39d990ec957b513579c5", @@ -26,15 +35,23 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.4.2/MODULE.bazel": "3bd40978e7a1fac911d5989e6b09d8f64921865a45822d8b09e815eaa726a651", "https://bcr.bazel.build/modules/bazel_skylib/1.5.0/MODULE.bazel": "32880f5e2945ce6a03d1fbd588e9198c0a959bb42297b2cfaf1685b7bc32e138", "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", - "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/source.json": "082ed5f9837901fada8c68c2f3ddc958bb22b6d654f71dd73f3df30d45d4b749", + "https://bcr.bazel.build/modules/bazel_skylib/1.7.0/MODULE.bazel": "0db596f4563de7938de764cc8deeabec291f55e8ec15299718b93c4423e9796d", + "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/MODULE.bazel": "3120d80c5861aa616222ec015332e5f8d3171e062e3e804a2a0253e1be26e59b", + "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/source.json": "f121b43eeefc7c29efbd51b83d08631e2347297c95aac9764a701f2a6a2bb953", "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", "https://bcr.bazel.build/modules/gazelle/0.40.0/MODULE.bazel": "42ba5378ebe845fca43989a53186ab436d956db498acde790685fe0e8f9c6146", "https://bcr.bazel.build/modules/gazelle/0.40.0/source.json": "1e5ef6e4d8b9b6836d93273c781e78ff829ea2e077afef7a57298040fa4f010a", + "https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb", "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", - "https://bcr.bazel.build/modules/googletest/1.11.0/source.json": "c73d9ef4268c91bd0c1cd88f1f9dfa08e814b1dbe89b5f594a9f08ba0244d206", + "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6", + "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/source.json": "41e9e129f80d8c8bf103a7acc337b76e54fad1214ac0a7084bf24f4cd924b8b4", + "https://bcr.bazel.build/modules/googletest/1.14.0/MODULE.bazel": "cfbcbf3e6eac06ef9d85900f64424708cc08687d1b527f0ef65aa7517af8118f", "https://bcr.bazel.build/modules/hermetic_cc_toolchain/3.1.0/MODULE.bazel": "ea4b3a25a9417a7db57a8a2f9ebdee91d679823c6274b482b817ed128d81c594", "https://bcr.bazel.build/modules/hermetic_cc_toolchain/3.1.0/source.json": "9d1df0459caefdf41052d360469922a73e219f67c8ce4da0628cc604469822b9", + "https://bcr.bazel.build/modules/jsoncpp/1.9.5/MODULE.bazel": "31271aedc59e815656f5736f282bb7509a97c7ecb43e927ac1a37966e0578075", + "https://bcr.bazel.build/modules/jsoncpp/1.9.5/source.json": "4108ee5085dd2885a341c7fab149429db457b3169b86eb081fa245eadf69169d", + "https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902", "https://bcr.bazel.build/modules/platforms/0.0.10/MODULE.bazel": "8cb8efaf200bdeb2150d93e162c40f388529a25852b332cec879373771e48ed5", "https://bcr.bazel.build/modules/platforms/0.0.10/source.json": "f22828ff4cf021a6b577f1bf6341cb9dcd7965092a439f64fc1bb3b7a5ae4bd5", "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", @@ -44,25 +61,48 @@ "https://bcr.bazel.build/modules/platforms/0.0.8/MODULE.bazel": "9f142c03e348f6d263719f5074b21ef3adf0b139ee4c5133e2aa35664da9eb2d", "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", - "https://bcr.bazel.build/modules/protobuf/21.7/source.json": "bbe500720421e582ff2d18b0802464205138c06056f443184de39fbb8187b09b", + "https://bcr.bazel.build/modules/protobuf/27.0/MODULE.bazel": "7873b60be88844a0a1d8f80b9d5d20cfbd8495a689b8763e76c6372998d3f64c", + "https://bcr.bazel.build/modules/protobuf/29.2/MODULE.bazel": "5435497c190d86f79b0568698c45044df7c8d97692886cda9fe9cf9053aea712", + "https://bcr.bazel.build/modules/protobuf/29.2/source.json": "fe7090cc34072609b26d9beafb122916dabc1d47ba61b242c26c4b06c51384ab", "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", "https://bcr.bazel.build/modules/protobuf/3.19.2/MODULE.bazel": "532ffe5f2186b69fdde039efe6df13ba726ff338c6bc82275ad433013fa10573", "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", + "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1/MODULE.bazel": "88af1c246226d87e65be78ed49ecd1e6f5e98648558c14ce99176da041dc378e", + "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1/source.json": "be4789e951dd5301282729fe3d4938995dc4c1a81c2ff150afc9f1b0504c6022", + "https://bcr.bazel.build/modules/re2/2023-09-01/MODULE.bazel": "cb3d511531b16cfc78a225a9e2136007a48cf8a677e4264baeab57fe78a80206", + "https://bcr.bazel.build/modules/re2/2023-09-01/source.json": "e044ce89c2883cd957a2969a43e79f7752f9656f6b20050b62f90ede21ec6eb4", + "https://bcr.bazel.build/modules/rules_android/0.1.1/MODULE.bazel": "48809ab0091b07ad0182defb787c4c5328bd3a278938415c00a7b69b50c4d3a8", + "https://bcr.bazel.build/modules/rules_android/0.1.1/source.json": "e6986b41626ee10bdc864937ffb6d6bf275bb5b9c65120e6137d56e6331f089e", "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", + "https://bcr.bazel.build/modules/rules_cc/0.0.10/MODULE.bazel": "ec1705118f7eaedd6e118508d3d26deba2a4e76476ada7e0e3965211be012002", + "https://bcr.bazel.build/modules/rules_cc/0.0.16/MODULE.bazel": "7661303b8fc1b4d7f532e54e9d6565771fea666fbdf839e0a86affcd02defe87", + "https://bcr.bazel.build/modules/rules_cc/0.0.16/source.json": "227e83737046aa4f50015da48e98e0d8ab42fd0ec74d8d653b6cc9f9a357f200", "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", + "https://bcr.bazel.build/modules/rules_cc/0.0.6/MODULE.bazel": "abf360251023dfe3efcef65ab9d56beefa8394d4176dd29529750e1c57eaa33f", "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", - "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", + "https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6", + "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8", + "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/source.json": "c8b1e2c717646f1702290959a3302a178fb639d987ab61d548105019f11e527e", "https://bcr.bazel.build/modules/rules_go/0.50.1/MODULE.bazel": "b91a308dc5782bb0a8021ad4330c81fea5bda77f96b9e4c117b9b9c8f6665ee0", "https://bcr.bazel.build/modules/rules_go/0.50.1/source.json": "205765fd30216c70321f84c9a967267684bdc74350af3f3c46c857d9f80a4fa2", "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", "https://bcr.bazel.build/modules/rules_java/5.3.5/MODULE.bazel": "a4ec4f2db570171e3e5eb753276ee4b389bae16b96207e9d3230895c99644b86", "https://bcr.bazel.build/modules/rules_java/6.3.0/MODULE.bazel": "a97c7678c19f236a956ad260d59c86e10a463badb7eb2eda787490f4c969b963", + "https://bcr.bazel.build/modules/rules_java/6.5.2/MODULE.bazel": "1d440d262d0e08453fa0c4d8f699ba81609ed0e9a9a0f02cd10b3e7942e61e31", + "https://bcr.bazel.build/modules/rules_java/7.10.0/MODULE.bazel": "530c3beb3067e870561739f1144329a21c851ff771cd752a49e06e3dc9c2e71a", + "https://bcr.bazel.build/modules/rules_java/7.12.2/MODULE.bazel": "579c505165ee757a4280ef83cda0150eea193eed3bef50b1004ba88b99da6de6", + "https://bcr.bazel.build/modules/rules_java/7.12.2/source.json": "b0890f9cda8ff1b8e691a3ac6037b5c14b7fd4134765a3946b89f31ea02e5884", + "https://bcr.bazel.build/modules/rules_java/7.2.0/MODULE.bazel": "06c0334c9be61e6cef2c8c84a7800cef502063269a5af25ceb100b192453d4ab", + "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", - "https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d", "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", + "https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909", "https://bcr.bazel.build/modules/rules_jvm_external/5.2/MODULE.bazel": "d9351ba35217ad0de03816ef3ed63f89d411349353077348a45348b096615036", - "https://bcr.bazel.build/modules/rules_jvm_external/5.2/source.json": "10572111995bc349ce31c78f74b3c147f6b3233975c7fa5eff9211f6db0d34d9", + "https://bcr.bazel.build/modules/rules_jvm_external/6.3/MODULE.bazel": "c998e060b85f71e00de5ec552019347c8bca255062c990ac02d051bb80a38df0", + "https://bcr.bazel.build/modules/rules_jvm_external/6.3/source.json": "6f5f5a5a4419ae4e37c35a5bb0a6ae657ed40b7abc5a5189111b47fcebe43197", + "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/MODULE.bazel": "d269a01a18ee74d0335450b10f62c9ed81f2321d7958a2934e44272fe82dcef3", + "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/source.json": "2faa4794364282db7c06600b7e5e34867a564ae91bda7cae7c29c64e9466b7d5", "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", "https://bcr.bazel.build/modules/rules_license/1.0.0/MODULE.bazel": "a7fda60eefdf3d8c827262ba499957e4df06f659330bbe6cdbdb975b768bb65c", @@ -77,10 +117,14 @@ "https://bcr.bazel.build/modules/rules_proto/4.0.0/MODULE.bazel": "a7a7b6ce9bee418c1a760b3d84f83a299ad6952f9903c67f19e4edd964894e06", "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/MODULE.bazel": "e8dff86b0971688790ae75528fe1813f71809b5afd57facb44dad9e8eca631b7", "https://bcr.bazel.build/modules/rules_proto/6.0.0/MODULE.bazel": "b531d7f09f58dce456cd61b4579ce8c86b38544da75184eadaf0a7cb7966453f", - "https://bcr.bazel.build/modules/rules_proto/6.0.0/source.json": "de77e10ff0ab16acbf54e6b46eecd37a99c5b290468ea1aee6e95eb1affdaed7", + "https://bcr.bazel.build/modules/rules_proto/6.0.2/MODULE.bazel": "ce916b775a62b90b61888052a416ccdda405212b6aaeb39522f7dc53431a5e73", + "https://bcr.bazel.build/modules/rules_proto/6.0.2/source.json": "17a2e195f56cb28d6bbf763e49973d13890487c6945311ed141e196fb660426d", "https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f", "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel": "26114f0c0b5e93018c0c066d6673f1a2c3737c7e90af95eff30cfee38d0bbac7", + "https://bcr.bazel.build/modules/rules_python/0.23.1/MODULE.bazel": "49ffccf0511cb8414de28321f5fcf2a31312b47c40cc21577144b7447f2bf300", + "https://bcr.bazel.build/modules/rules_python/0.25.0/MODULE.bazel": "72f1506841c920a1afec76975b35312410eea3aa7b63267436bfb1dd91d2d382", "https://bcr.bazel.build/modules/rules_python/0.27.1/MODULE.bazel": "65dc875cc1a06c30d5bbdba7ab021fd9e551a6579e408a3943a61303e2228a53", + "https://bcr.bazel.build/modules/rules_python/0.28.0/MODULE.bazel": "cba2573d870babc976664a912539b320cbaa7114cd3e8f053c720171cde331ed", "https://bcr.bazel.build/modules/rules_python/0.31.0/MODULE.bazel": "93a43dc47ee570e6ec9f5779b2e64c1476a6ce921c48cc9a1678a91dd5f8fd58", "https://bcr.bazel.build/modules/rules_python/0.31.0/source.json": "a41c836d4065888eef4377f2f27b6eea0fedb9b5adb1bab1970437373fe90dc7", "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", @@ -90,15 +134,16 @@ "https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c", "https://bcr.bazel.build/modules/stardoc/0.5.4/MODULE.bazel": "6569966df04610b8520957cb8e97cf2e9faac2c0309657c537ab51c16c18a2a4", "https://bcr.bazel.build/modules/stardoc/0.6.2/MODULE.bazel": "7060193196395f5dd668eda046ccbeacebfd98efc77fed418dbe2b82ffaa39fd", - "https://bcr.bazel.build/modules/stardoc/0.6.2/source.json": "d2ff8063b63b4a85e65fe595c4290f99717434fa9f95b4748a79a7d04dfed349", + "https://bcr.bazel.build/modules/stardoc/0.7.0/MODULE.bazel": "05e3d6d30c099b6770e97da986c53bd31844d7f13d41412480ea265ac9e8079c", + "https://bcr.bazel.build/modules/stardoc/0.7.0/source.json": "e3c524bf2ef20992539ce2bc4a2243f4853130209ee831689983e28d05769099", "https://bcr.bazel.build/modules/toolchains_protoc/0.3.3/MODULE.bazel": "88dcce64b6d21454710d3f69006e57d29317e1637ccd04b75c7618c37cf1fc08", "https://bcr.bazel.build/modules/toolchains_protoc/0.3.3/source.json": "162b584e472041273e3d83c5bedfe68e97f9a4cc6e52859e1bf87c4899f019e6", "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", - "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/source.json": "f1ef7d3f9e0e26d4b23d1c39b5f5de71f584dd7d1b4ef83d9bbba6ec7a6a6459", "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", - "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d" + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d", + "https://bcr.bazel.build/modules/zlib/1.3.1/MODULE.bazel": "751c9940dcfe869f5f7274e1295422a34623555916eb98c174c1e945594bf198" }, "selectedYankedVersions": {}, "moduleExtensions": { @@ -663,9 +708,78 @@ "recordedRepoMappingEntries": [] } }, + "@@rules_kotlin~//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { + "general": { + "bzlTransitiveDigest": "fus14IFJ/1LGWWGKPH/U18VnJCoMjfDt1ckahqCnM0A=", + "usagesDigest": "aJF6fLy82rR95Ff5CZPAqxNoFgOMLMN5ImfBS0nhnkg=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "com_github_jetbrains_kotlin_git": { + "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:compiler.bzl", + "ruleClassName": "kotlin_compiler_git_repository", + "attributes": { + "urls": [ + "https://github.com/JetBrains/kotlin/releases/download/v1.9.23/kotlin-compiler-1.9.23.zip" + ], + "sha256": "93137d3aab9afa9b27cb06a824c2324195c6b6f6179d8a8653f440f5bd58be88" + } + }, + "com_github_jetbrains_kotlin": { + "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:compiler.bzl", + "ruleClassName": "kotlin_capabilities_repository", + "attributes": { + "git_repository_name": "com_github_jetbrains_kotlin_git", + "compiler_version": "1.9.23" + } + }, + "com_github_google_ksp": { + "bzlFile": "@@rules_kotlin~//src/main/starlark/core/repositories:ksp.bzl", + "ruleClassName": "ksp_compiler_plugin_repository", + "attributes": { + "urls": [ + "https://github.com/google/ksp/releases/download/1.9.23-1.0.20/artifacts.zip" + ], + "sha256": "ee0618755913ef7fd6511288a232e8fad24838b9af6ea73972a76e81053c8c2d", + "strip_version": "1.9.23-1.0.20" + } + }, + "com_github_pinterest_ktlint": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "sha256": "01b2e0ef893383a50dbeb13970fe7fa3be36ca3e83259e01649945b09d736985", + "urls": [ + "https://github.com/pinterest/ktlint/releases/download/1.3.0/ktlint" + ], + "executable": true + } + }, + "rules_android": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806", + "strip_prefix": "rules_android-0.1.1", + "urls": [ + "https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip" + ] + } + } + }, + "recordedRepoMappingEntries": [ + [ + "rules_kotlin~", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, "@@rules_oci~//oci:extensions.bzl%oci": { "general": { - "bzlTransitiveDigest": "ZatOnHz+LuHzDmGYO7EWajB9hHtbyblPP+OTbJ9lSzw=", + "bzlTransitiveDigest": "nqpWhi7h/GA7WhjwXS/D1koGhTmQmGXbJdQA93J9VD4=", "usagesDigest": "fhbWw+S64RhafQKHpWqNP9l+k8tL/g8oIajuByoZtH4=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, @@ -823,7 +937,8 @@ "ruleClassName": "globals_repo", "attributes": { "globals": { - "CcSharedLibraryInfo": "7.0.0", + "CcSharedLibraryInfo": "6.0.0-pre.20220630.1", + "CcSharedLibraryHintInfo": "7.0.0-pre.20230316.2", "PackageSpecificationInfo": "6.4.0", "RunEnvironmentInfo": "5.3.0", "DefaultInfo": "0.0.1", @@ -1255,13 +1370,453 @@ "@@rules_python~//python/extensions:python.bzl%python": { "general": { "bzlTransitiveDigest": "8vDKUdCc6qEk2/YsFiPsFO1Jqgl+XPFRklapOxMAbE8=", - "usagesDigest": "abUgYqI1bdv/jc3Xu7C2SbT7mmtxAziRT/kUCFERO+A=", + "usagesDigest": "iyLU4ZsGf5QO0xQFTBK8V2mnxzNstMJoeH78R2QAkOE=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": { "RULES_PYTHON_BZLMOD_DEBUG": null }, "generatedRepoSpecs": { + "python_3_8_aarch64-apple-darwin": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "1825b1f7220bc93ff143f2e70b5c6a79c6469e0eeb40824e07a7277f59aabfda", + "patches": [], + "platform": "aarch64-apple-darwin", + "python_version": "3.8.18", + "release_filename": "20231002/cpython-3.8.18+20231002-aarch64-apple-darwin-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.8.18+20231002-aarch64-apple-darwin-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_8_aarch64-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "236a300f386ead02ca98dbddbc026ff4ef4de6701a394106e291ff8b75445ee1", + "patches": [], + "platform": "aarch64-unknown-linux-gnu", + "python_version": "3.8.18", + "release_filename": "20231002/cpython-3.8.18+20231002-aarch64-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.8.18+20231002-aarch64-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_8_x86_64-apple-darwin": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "fcf04532e644644213977242cd724fe5e84c0a5ac92ae038e07f1b01b474fca3", + "patches": [], + "platform": "x86_64-apple-darwin", + "python_version": "3.8.18", + "release_filename": "20231002/cpython-3.8.18+20231002-x86_64-apple-darwin-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.8.18+20231002-x86_64-apple-darwin-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_8_x86_64-pc-windows-msvc": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "a9d203e78caed94de368d154e841610cef6f6b484738573f4ae9059d37e898a5", + "patches": [], + "platform": "x86_64-pc-windows-msvc", + "python_version": "3.8.18", + "release_filename": "20231002/cpython-3.8.18+20231002-x86_64-pc-windows-msvc-shared-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.8.18+20231002-x86_64-pc-windows-msvc-shared-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_8_x86_64-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "1e8a3babd1500111359b0f5675d770984bcbcb2cc8890b117394f0ed342fb9ec", + "patches": [], + "platform": "x86_64-unknown-linux-gnu", + "python_version": "3.8.18", + "release_filename": "20231002/cpython-3.8.18+20231002-x86_64-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.8.18+20231002-x86_64-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_8_host": { + "bzlFile": "@@rules_python~//python/private:toolchains_repo.bzl", + "ruleClassName": "host_toolchain", + "attributes": { + "python_version": "3.8.18", + "user_repository_name": "python_3_8", + "platforms": [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu" + ] + } + }, + "python_3_8": { + "bzlFile": "@@rules_python~//python/private:toolchains_repo.bzl", + "ruleClassName": "toolchain_aliases", + "attributes": { + "python_version": "3.8.18", + "user_repository_name": "python_3_8", + "platforms": [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu" + ] + } + }, + "python_3_9_aarch64-apple-darwin": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "fdc4054837e37b69798c2ef796222a480bc1f80e8ad3a01a95d0168d8282a007", + "patches": [], + "platform": "aarch64-apple-darwin", + "python_version": "3.9.18", + "release_filename": "20231002/cpython-3.9.18+20231002-aarch64-apple-darwin-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.9.18+20231002-aarch64-apple-darwin-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_9_aarch64-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "1e0a3e8ce8e58901a259748c0ab640d2b8294713782d14229e882c6898b2fb36", + "patches": [], + "platform": "aarch64-unknown-linux-gnu", + "python_version": "3.9.18", + "release_filename": "20231002/cpython-3.9.18+20231002-aarch64-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.9.18+20231002-aarch64-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_9_ppc64le-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "101c38b22fb2f5a0945156da4259c8e9efa0c08de9d7f59afa51e7ce6e22a1cc", + "patches": [], + "platform": "ppc64le-unknown-linux-gnu", + "python_version": "3.9.18", + "release_filename": "20231002/cpython-3.9.18+20231002-ppc64le-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.9.18+20231002-ppc64le-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_9_s390x-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "eee31e55ffbc1f460d7b17f05dd89e45a2636f374a6f8dc29ea13d0497f7f586", + "patches": [], + "platform": "s390x-unknown-linux-gnu", + "python_version": "3.9.18", + "release_filename": "20231002/cpython-3.9.18+20231002-s390x-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.9.18+20231002-s390x-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_9_x86_64-apple-darwin": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "82231cb77d4a5c8081a1a1d5b8ae440abe6993514eb77a926c826e9a69a94fb1", + "patches": [], + "platform": "x86_64-apple-darwin", + "python_version": "3.9.18", + "release_filename": "20231002/cpython-3.9.18+20231002-x86_64-apple-darwin-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.9.18+20231002-x86_64-apple-darwin-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_9_x86_64-pc-windows-msvc": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "02ea7bb64524886bd2b05d6b6be4401035e4ba4319146f274f0bcd992822cd75", + "patches": [], + "platform": "x86_64-pc-windows-msvc", + "python_version": "3.9.18", + "release_filename": "20231002/cpython-3.9.18+20231002-x86_64-pc-windows-msvc-shared-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.9.18+20231002-x86_64-pc-windows-msvc-shared-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_9_x86_64-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "f3ff38b1ccae7dcebd8bbf2e533c9a984fac881de0ffd1636fbb61842bd924de", + "patches": [], + "platform": "x86_64-unknown-linux-gnu", + "python_version": "3.9.18", + "release_filename": "20231002/cpython-3.9.18+20231002-x86_64-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.9.18+20231002-x86_64-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_9_host": { + "bzlFile": "@@rules_python~//python/private:toolchains_repo.bzl", + "ruleClassName": "host_toolchain", + "attributes": { + "python_version": "3.9.18", + "user_repository_name": "python_3_9", + "platforms": [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "ppc64le-unknown-linux-gnu", + "s390x-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu" + ] + } + }, + "python_3_9": { + "bzlFile": "@@rules_python~//python/private:toolchains_repo.bzl", + "ruleClassName": "toolchain_aliases", + "attributes": { + "python_version": "3.9.18", + "user_repository_name": "python_3_9", + "platforms": [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "ppc64le-unknown-linux-gnu", + "s390x-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu" + ] + } + }, + "python_3_10_aarch64-apple-darwin": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "fd027b1dedf1ea034cdaa272e91771bdf75ddef4c8653b05d224a0645aa2ca3c", + "patches": [], + "platform": "aarch64-apple-darwin", + "python_version": "3.10.13", + "release_filename": "20231002/cpython-3.10.13+20231002-aarch64-apple-darwin-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.10.13+20231002-aarch64-apple-darwin-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_10_aarch64-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "8675915ff454ed2f1597e27794bc7df44f5933c26b94aa06af510fe91b58bb97", + "patches": [], + "platform": "aarch64-unknown-linux-gnu", + "python_version": "3.10.13", + "release_filename": "20231002/cpython-3.10.13+20231002-aarch64-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.10.13+20231002-aarch64-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_10_ppc64le-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "f3f9c43eec1a0c3f72845d0b705da17a336d3906b7df212d2640b8f47e8ff375", + "patches": [], + "platform": "ppc64le-unknown-linux-gnu", + "python_version": "3.10.13", + "release_filename": "20231002/cpython-3.10.13+20231002-ppc64le-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.10.13+20231002-ppc64le-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_10_s390x-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "859f6cfe9aedb6e8858892fdc124037e83ab05f28d42a7acd314c6a16d6bd66c", + "patches": [], + "platform": "s390x-unknown-linux-gnu", + "python_version": "3.10.13", + "release_filename": "20231002/cpython-3.10.13+20231002-s390x-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.10.13+20231002-s390x-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_10_x86_64-apple-darwin": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "be0b19b6af1f7d8c667e5abef5505ad06cf72e5a11bb5844970c395a7e5b1275", + "patches": [], + "platform": "x86_64-apple-darwin", + "python_version": "3.10.13", + "release_filename": "20231002/cpython-3.10.13+20231002-x86_64-apple-darwin-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.10.13+20231002-x86_64-apple-darwin-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_10_x86_64-pc-windows-msvc": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "b8d930ce0d04bda83037ad3653d7450f8907c88e24bb8255a29b8dab8930d6f1", + "patches": [], + "platform": "x86_64-pc-windows-msvc", + "python_version": "3.10.13", + "release_filename": "20231002/cpython-3.10.13+20231002-x86_64-pc-windows-msvc-shared-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.10.13+20231002-x86_64-pc-windows-msvc-shared-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_10_x86_64-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "5d0429c67c992da19ba3eb58b3acd0b35ec5e915b8cae9a4aa8ca565c423847a", + "patches": [], + "platform": "x86_64-unknown-linux-gnu", + "python_version": "3.10.13", + "release_filename": "20231002/cpython-3.10.13+20231002-x86_64-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.10.13+20231002-x86_64-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_10_host": { + "bzlFile": "@@rules_python~//python/private:toolchains_repo.bzl", + "ruleClassName": "host_toolchain", + "attributes": { + "python_version": "3.10.13", + "user_repository_name": "python_3_10", + "platforms": [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "ppc64le-unknown-linux-gnu", + "s390x-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu" + ] + } + }, + "python_3_10": { + "bzlFile": "@@rules_python~//python/private:toolchains_repo.bzl", + "ruleClassName": "toolchain_aliases", + "attributes": { + "python_version": "3.10.13", + "user_repository_name": "python_3_10", + "platforms": [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "ppc64le-unknown-linux-gnu", + "s390x-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu" + ] + } + }, "python_3_11_aarch64-apple-darwin": { "bzlFile": "@@rules_python~//python:repositories.bzl", "ruleClassName": "python_repository", @@ -1422,21 +1977,197 @@ ] } }, + "python_3_12_aarch64-apple-darwin": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "f93f8375ca6ac0a35d58ff007043cbd3a88d9609113f1cb59cf7c8d215f064af", + "patches": [], + "platform": "aarch64-apple-darwin", + "python_version": "3.12.1", + "release_filename": "20240107/cpython-3.12.1+20240107-aarch64-apple-darwin-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.12.1+20240107-aarch64-apple-darwin-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_12_aarch64-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "236533ef20e665007a111c2f36efb59c87ae195ad7dca223b6dc03fb07064f0b", + "patches": [], + "platform": "aarch64-unknown-linux-gnu", + "python_version": "3.12.1", + "release_filename": "20240107/cpython-3.12.1+20240107-aarch64-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.12.1+20240107-aarch64-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_12_ppc64le-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "78051f0d1411ee62bc2af5edfccf6e8400ac4ef82887a2affc19a7ace6a05267", + "patches": [], + "platform": "ppc64le-unknown-linux-gnu", + "python_version": "3.12.1", + "release_filename": "20240107/cpython-3.12.1+20240107-ppc64le-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.12.1+20240107-ppc64le-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_12_s390x-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "60631211c701f8d2c56e5dd7b154e68868128a019b9db1d53a264f56c0d4aee2", + "patches": [], + "platform": "s390x-unknown-linux-gnu", + "python_version": "3.12.1", + "release_filename": "20240107/cpython-3.12.1+20240107-s390x-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.12.1+20240107-s390x-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_12_x86_64-apple-darwin": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "eca96158c1568dedd9a0b3425375637a83764d1fa74446438293089a8bfac1f8", + "patches": [], + "platform": "x86_64-apple-darwin", + "python_version": "3.12.1", + "release_filename": "20240107/cpython-3.12.1+20240107-x86_64-apple-darwin-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.12.1+20240107-x86_64-apple-darwin-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_12_x86_64-pc-windows-msvc": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "fd5a9e0f41959d0341246d3643f2b8794f638adc0cec8dd5e1b6465198eae08a", + "patches": [], + "platform": "x86_64-pc-windows-msvc", + "python_version": "3.12.1", + "release_filename": "20240107/cpython-3.12.1+20240107-x86_64-pc-windows-msvc-shared-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.12.1+20240107-x86_64-pc-windows-msvc-shared-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_12_x86_64-unknown-linux-gnu": { + "bzlFile": "@@rules_python~//python:repositories.bzl", + "ruleClassName": "python_repository", + "attributes": { + "sha256": "74e330b8212ca22fd4d9a2003b9eec14892155566738febc8e5e572f267b9472", + "patches": [], + "platform": "x86_64-unknown-linux-gnu", + "python_version": "3.12.1", + "release_filename": "20240107/cpython-3.12.1+20240107-x86_64-unknown-linux-gnu-install_only.tar.gz", + "urls": [ + "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.12.1+20240107-x86_64-unknown-linux-gnu-install_only.tar.gz" + ], + "distutils_content": "", + "strip_prefix": "python", + "coverage_tool": "", + "ignore_root_user_error": false + } + }, + "python_3_12_host": { + "bzlFile": "@@rules_python~//python/private:toolchains_repo.bzl", + "ruleClassName": "host_toolchain", + "attributes": { + "python_version": "3.12.1", + "user_repository_name": "python_3_12", + "platforms": [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "ppc64le-unknown-linux-gnu", + "s390x-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu" + ] + } + }, + "python_3_12": { + "bzlFile": "@@rules_python~//python/private:toolchains_repo.bzl", + "ruleClassName": "toolchain_aliases", + "attributes": { + "python_version": "3.12.1", + "user_repository_name": "python_3_12", + "platforms": [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "ppc64le-unknown-linux-gnu", + "s390x-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu" + ] + } + }, "pythons_hub": { "bzlFile": "@@rules_python~//python/private/bzlmod:pythons_hub.bzl", "ruleClassName": "hub_repo", "attributes": { "default_python_version": "3.11", "toolchain_prefixes": [ - "_0000_python_3_11_" + "_0000_python_3_8_", + "_0001_python_3_9_", + "_0002_python_3_10_", + "_0003_python_3_12_", + "_0004_python_3_11_" ], "toolchain_python_versions": [ + "3.8", + "3.9", + "3.10", + "3.12", "3.11" ], "toolchain_set_python_version_constraints": [ + "True", + "True", + "True", + "True", "False" ], "toolchain_user_repository_names": [ + "python_3_8", + "python_3_9", + "python_3_10", + "python_3_12", "python_3_11" ] } @@ -1446,7 +2177,11 @@ "ruleClassName": "multi_toolchain_aliases", "attributes": { "python_versions": { - "3.11": "python_3_11" + "3.8": "python_3_8", + "3.9": "python_3_9", + "3.10": "python_3_10", + "3.11": "python_3_11", + "3.12": "python_3_12" } } } diff --git a/build/cue/def.bzl b/build/cue/def.bzl index 6488aa0..f3fdefb 100644 --- a/build/cue/def.bzl +++ b/build/cue/def.bzl @@ -12,8 +12,8 @@ def _cue_export(ctx): for arg in ctx.attr.args: arguments.add(ctx.expand_location(arg)) - output = ctx.actions.declare_file(ctx.attr.outfile) - arguments.add_all(["--outfile", output]) + output = ctx.actions.declare_file(ctx.attr.output) + arguments.add_all(["--output", output]) ctx.actions.run( outputs = [output], @@ -38,7 +38,7 @@ cue_export = rule( "args": attr.string_list(), "srcs": attr.label_list( ), - "outfile": attr.string( + "output": attr.string( mandatory = True, ), "_cue": attr.label( diff --git a/cmd/pcap/BUILD.bazel b/cmd/pcap/BUILD.bazel new file mode 100644 index 0000000..2d4ed2f --- /dev/null +++ b/cmd/pcap/BUILD.bazel @@ -0,0 +1,62 @@ +load("@rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "pcap_lib", + srcs = [ + "bla.go", + "frame.go", + "main.go", + "quote.go", + "visitor.go", + ], + data = [ + ":google_protos", + "//cmd/risinfo", + "//deploy:all_files", + "@clickhouse_bin//:clickhouse", + "@grafana-clickhouse-datasource//:files", + "@grafana_bin//:bin/grafana-server", + "@netsage-sankey-panel//:files", + ], + importpath = "github.com/monogon-dev/netmeta/cmd/pcap", + visibility = ["//visibility:private"], + x_defs = { + "xClickhousePath": "$(rlocationpath @clickhouse_bin//:clickhouse)", + "xGrafanaPath": "$(rlocationpath @grafana_bin//:bin/grafana-server)", + "xProtobufPaths": "$(rlocationpaths :google_protos)", + "xRisInfoPath": "$(rlocationpath //cmd/risinfo)", + "xNetsageSankeyPanel": "$(rlocationpaths @netsage-sankey-panel//:files)", + "xGrafanaClickhouseDatasource": "$(rlocationpaths @grafana-clickhouse-datasource//:files)", + }, + deps = [ + "@com_github_clickhouse_clickhouse_go_v2//:clickhouse-go", + "@com_github_clickhouse_clickhouse_go_v2//lib/driver", + "@com_github_emicklei_proto//:proto", + "@com_github_gopacket_gopacket//:gopacket", + "@com_github_gopacket_gopacket//layers", + "@com_github_gopacket_gopacket//pcapgo", + "@com_github_huandu_go_sqlbuilder//:go-sqlbuilder", + "@com_github_netsampler_goflow2//pb", + "@org_cuelang_go//cue", + "@org_cuelang_go//cue/cuecontext", + "@org_cuelang_go//cue/errors", + "@org_cuelang_go//cue/interpreter/embed", + "@org_cuelang_go//cue/load", + "@org_golang_google_protobuf//encoding/protodelim", + "@rules_go//go/runfiles", + ], +) + +filegroup( + name = "google_protos", + srcs = [ + "@protobuf//:descriptor_proto_srcs", + "@protobuf//:well_known_type_protos", + ], +) + +go_binary( + name = "pcap", + embed = [":pcap_lib"], + visibility = ["//visibility:public"], +) diff --git a/cmd/pcap/bla.go b/cmd/pcap/bla.go new file mode 100644 index 0000000..1d89153 --- /dev/null +++ b/cmd/pcap/bla.go @@ -0,0 +1,834 @@ +package main + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "flag" + "fmt" + "io" + "log" + "net" + "net/http" + "net/url" + "os" + "os/exec" + "os/signal" + "path/filepath" + "runtime" + "strings" + "sync" + "syscall" + "time" + + "cuelang.org/go/cue" + "cuelang.org/go/cue/cuecontext" + cEmbed "cuelang.org/go/cue/interpreter/embed" + "cuelang.org/go/cue/load" + "github.com/ClickHouse/clickhouse-go/v2" + "github.com/ClickHouse/clickhouse-go/v2/lib/driver" + "github.com/bazelbuild/rules_go/go/runfiles" + "github.com/gopacket/gopacket" + "github.com/gopacket/gopacket/layers" + "github.com/gopacket/gopacket/pcapgo" + flowpb "github.com/netsampler/goflow2/pb" + "google.golang.org/protobuf/encoding/protodelim" +) + +var ( + cueContext = cuecontext.New(cuecontext.Interpreter(cEmbed.New())) + + xClickhousePath string + xRisInfoPath string + xGrafanaPath string + + xProtobufPaths string + xNetsageSankeyPanel string + xGrafanaClickhouseDatasource string +) + +func init() { + var err error + for _, path := range []*string{ + &xClickhousePath, &xRisInfoPath, &xGrafanaPath, + } { + *path, err = runfiles.Rlocation(*path) + if err != nil { + panic(err) + } + } + + for _, pathStr := range []*string{ + &xProtobufPaths, &xNetsageSankeyPanel, + &xGrafanaClickhouseDatasource, + } { + paths := strings.Split(*pathStr, " ") + for i, path := range paths { + paths[i], err = runfiles.Rlocation(path) + if err != nil { + panic(err) + } + } + + baseComponents := strings.Split(paths[0], string(filepath.Separator)) + for _, path := range paths { + pathComponents := strings.Split(path, string(filepath.Separator)) + // Find the common prefix components. + for i := range baseComponents { + if i >= len(pathComponents) || baseComponents[i] != pathComponents[i] { + baseComponents = baseComponents[:i] + break + } + } + } + + *pathStr = strings.Join(baseComponents, string(filepath.Separator)) + } +} + +const minimalDefaultUserXML = ` + + + + + + + + ::/0 + + default + default + 1 + + + + + +` + +var setup = []string{ + ` +CREATE TABLE IF NOT EXISTS flows_raw +( + Date Date, + FlowType Enum8( + 'FLOWUNKNOWN' = 0, + 'SFLOW_5' = 1, + 'NETFLOW_V5' = 2, + 'NETFLOW_V9' = 3, + 'IPFIX' = 4 +), + + SequenceNum UInt64, + + TimeReceived UInt64, + SamplingRate UInt64, + + FlowDirection UInt8, + + SamplerAddress IPv6, + + TimeFlowStart UInt64, + TimeFlowEnd UInt64, + + Bytes UInt64, + Packets UInt64, + + SrcAddr IPv6, + DstAddr IPv6, + + EType UInt16, + + Proto UInt8, + + SrcPort UInt32, + DstPort UInt32, + + InIf UInt32, + OutIf UInt32, + + SrcMac UInt64, + DstMac UInt64, + + SrcVlan UInt32, + DstVlan UInt32, + VlanId UInt32, + + IngressVrfId UInt32, + EgressVrfId UInt32, + + IPTos UInt8, + ForwardingStatus UInt8, + IPTTL UInt8, + TCPFlags UInt8, + IcmpType UInt8, + IcmpCode UInt8, + IPv6FlowLabel UInt32, + + FragmentId UInt32, + FragmentOffset UInt32, + + BiFlowDirection UInt8, + + SrcAS UInt32, + DstAS UInt32, + + NextHop IPv6, + NextHopAS UInt32, + + SrcNet UInt8, + DstNet UInt8 + ) ENGINE = MergeTree() + PARTITION BY Date + ORDER BY (TimeReceived, FlowDirection, SamplerAddress, SrcAS, DstAS, SrcAddr, DstAddr); +`, + `CREATE DATABASE IF NOT EXISTS dictionaries Engine=Dictionary;`, +} + +func main() { + flag.Parse() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) + go func() { + <-sigs + log.Println("Received shutdown signal") + cancel() + }() + + baseDir, err := os.MkdirTemp("", "netmeta-in-a-box-*") + if err != nil { + log.Fatal(err) + } + defer func() { + log.Printf("Deleting temporary directory %v...", err) + if err := os.RemoveAll(baseDir); err != nil { + log.Printf("Error removing temporary directory: %v", err) + return + } + }() + + chCfg, err := buildClickhouseConfig(baseDir) + if err != nil { + log.Println(err) + cancel() + return + } + + var wg sync.WaitGroup + risInfoAddr, err := setupRisInfo(ctx, &wg) + if err != nil { + log.Println(err) + cancel() + wg.Wait() + return + } + + if err := setupClickhouse(ctx, &wg, risInfoAddr, chCfg); err != nil { + log.Println(err) + cancel() + wg.Wait() + return + } + + for _, arg := range flag.Args() { + if err := importPcap(chCfg, arg); err != nil { + log.Println(err) + cancel() + wg.Wait() + return + } + } + + if err := setupGrafana(ctx, &wg, chCfg, baseDir); err != nil { + log.Println(err) + cancel() + wg.Wait() + return + } + + wg.Wait() + log.Println("bye...") +} + +func setupGrafana(ctx context.Context, wg *sync.WaitGroup, chCfg *ClickhouseConfig, baseDir string) error { + baseDir = filepath.Join(baseDir, "grafana") + + //TODO: remove hardcoded path + val, err := buildCUE("deploy/dashboards") + if err != nil { + return err + } + + dashboardFiles := make(map[string]json.RawMessage) + if err := val. + Unify(cueContext.CompileString("#Config: minInterval: null")). + LookupPath(cue.MakePath(cue.Str("dashboards"))).Decode(&dashboardFiles); err != nil { + return err + } + + provisionFolder := filepath.Join(baseDir, "provisioning") + os.MkdirAll(provisionFolder, 0755) + dashboardFolder := filepath.Join(provisionFolder, "dashboards") + os.MkdirAll(dashboardFolder, 0755) + datasourceFolder := filepath.Join(provisionFolder, "datasources") + os.MkdirAll(datasourceFolder, 0755) + + dashboardProvider := fmt.Sprintf(` +apiVersion: 1 +providers: + - name: Dashboards + ordId: 1 + type: file + disableDeletion: true + allowUiUpdates: true + updateIntervalSeconds: 1 + options: + path: %q + foldersFromFilesStructure: true +`, dashboardFolder) + if err := writeStringFile(filepath.Join(dashboardFolder, "dashboards.yaml"), dashboardProvider); err != nil { + return err + } + + datasourcesProvider := fmt.Sprintf(` +apiVersion: 1 +datasources: + - isDefault: true + name: ClickHouse + type: grafana-clickhouse-datasource + access: proxy + jsonData: + defaultDatabase: default + port: %d + host: %q + username: default + protocol: http +`, *chCfg.HTTPPort.int, chCfg.ListenHost[0]) + if err := writeStringFile(filepath.Join(datasourceFolder, "datasources.yaml"), datasourcesProvider); err != nil { + return err + } + + for name, data := range dashboardFiles { + fileName := strings.ToLower(strings.Replace(name, " ", "_", -1)) + ".json" + err := writeStringFile(filepath.Join(dashboardFolder, fileName), string(data)) + if err != nil { + return err + } + } + + pluginsFolder := filepath.Join(baseDir, "plugins") + os.MkdirAll(pluginsFolder, 0755) + + grafanaPort, err := getUnusedPort() + if err != nil { + return err + } + + if err := os.CopyFS(baseDir+"/plugins/grafana-clickhouse-datasource", os.DirFS(xGrafanaClickhouseDatasource+"/grafana-clickhouse-datasource")); err != nil { + return err + } + if err := os.CopyFS(baseDir+"/plugins/netsage-sankey-panel", os.DirFS(xNetsageSankeyPanel+"/netsage-sankey-panel")); err != nil { + return err + } + + grafanaConfig := strings.Join([]string{ + "cfg:default.paths.data=" + baseDir, + "cfg:default.paths.log=/dev/null", + "cfg:default.paths.plugins=" + baseDir + "/plugins", + "cfg:default.paths.provisioning=" + baseDir + "/provisioning", + "cfg:default.dashboards.default_home_dashboard_path=" + dashboardFolder + "/home.json", + "cfg:default.server.http_port=" + fmt.Sprintf("%d", grafanaPort), + "cfg:default.server.http_addr=127.0.0.1", + "cfg:default.auth.anonymous.enabled=true", + "cfg:default.auth.anonymous.org_role=Admin", + }, " ") + + cmd, err := runSubprocess(xGrafanaPath, + "--homepath", filepath.Join(xGrafanaPath, "../../"), + "--configOverrides", grafanaConfig, + ) + if err != nil { + return err + } + + for { + if ctx.Err() != nil { + return ctx.Err() + } + + log.Print("Waiting for grafana...") + if _, err := http.Get(fmt.Sprintf("http://127.0.0.1:%d", grafanaPort)); err != nil { + log.Printf("Testing for grafana failed: %v", err) + time.Sleep(1 * time.Second) + continue + } + + log.Println("Grafana connection successful...") + break + } + + grafanaURL := fmt.Sprintf("http://127.0.0.1:%d", grafanaPort) + if err := openBrowser(grafanaURL); err != nil { + log.Printf("Error opening grafana in browser: %v", err) + } + + wg.Add(1) + go func() { + defer wg.Done() + <-ctx.Done() + cmd.Process.Signal(os.Interrupt) + cmd.Wait() + }() + + return nil +} + +func openBrowser(url string) error { + switch runtime.GOOS { + case "linux": + return exec.Command("xdg-open", url).Start() + case "windows": + return exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() + case "darwin": + return exec.Command("open", url).Start() + default: + return fmt.Errorf("unsupported platform") + } +} + +func setupRisInfo(ctx context.Context, wg *sync.WaitGroup) (string, error) { + risInfoPort, err := getUnusedPort() + if err != nil { + return "", err + } + + risInfoAddr := fmt.Sprintf("127.0.0.1:%d", risInfoPort) + cmd, err := runSubprocess(xRisInfoPath, "--addr", risInfoAddr) + if err != nil { + return "", err + } + risInfoAddr = "http://" + risInfoAddr + + wg.Add(1) + go func() { + defer wg.Done() + <-ctx.Done() + cmd.Process.Signal(os.Interrupt) + cmd.Wait() + }() + + for { + if ctx.Err() != nil { + return "", ctx.Err() + } + + log.Print("Waiting for risinfo...") + if _, err := http.Get(risInfoAddr + "/"); err != nil { + log.Printf("Testing for risinfo failed: %v", err) + time.Sleep(1 * time.Second) + continue + } + + log.Println("Risinfo connection successful...") + break + } + + ribResp, err := http.Get(risInfoAddr + "/rib.tsv") + if err != nil { + return "", err + } + io.Copy(io.Discard, ribResp.Body) + + autnumsResp, err := http.Get(risInfoAddr + "/autnums.tsv") + if err != nil { + return "", err + } + io.Copy(io.Discard, autnumsResp.Body) + + return risInfoAddr, nil +} + +func setupClickhouse(ctx context.Context, wg *sync.WaitGroup, risInfoAddr string, chCfg *ClickhouseConfig) error { + if err := writeClickhouseConfig(chCfg); err != nil { + return err + } + + if err := writeStringFile(chCfg.UsersConfig, minimalDefaultUserXML); err != nil { + return err + } + + if err := deployDictionaries(chCfg, risInfoAddr); err != nil { + return err + } + + cmd, err := runSubprocess(xClickhousePath, "server", "--config-file", filepath.Join(chCfg.Path, "config.xml")) + if err != nil { + return err + } + + wg.Add(1) + go func() { + defer wg.Done() + <-ctx.Done() + cmd.Process.Signal(os.Interrupt) + cmd.Wait() + }() + + conn, err := clickhouse.Open(&clickhouse.Options{ + Addr: []string{fmt.Sprintf("%s:%d", chCfg.ListenHost[0], *chCfg.TCPPort.int)}, + Auth: clickhouse.Auth{ + Database: "default", + }, + }) + if err != nil { + return err + } + + for { + if ctx.Err() != nil { + return ctx.Err() + } + + log.Print("Testing clickhouse connection...") + if err := conn.Ping(context.Background()); err != nil { + log.Printf("Testing clickhouse connection failed: %v", err) + time.Sleep(1 * time.Second) + continue + } + + log.Println("Clickhouse connection successful...") + log.Printf("Clickhouse UI available at http://%s:%d/play", chCfg.ListenHost[0], *chCfg.HTTPPort.int) + break + } + + if err := deploySchema(chCfg, conn); err != nil { + return err + } + + return nil +} + +func writeClickhouseConfig(chCfg *ClickhouseConfig) error { + os.MkdirAll(chCfg.Path, 0755) + chCfgFile, err := os.Create(filepath.Join(chCfg.Path, "config.xml")) + if err != nil { + return err + } + defer chCfgFile.Close() + return encodeXML(chCfgFile, chCfg) +} + +func deploySchema(chCfg *ClickhouseConfig, conn driver.Conn) error { + //TODO: remove hardcoded path + val, err := buildCUE("deploy/single-node/schema") + if err != nil { + return err + } + + type schema struct { + Function map[string]Function + View map[string]MaterializedView + Table map[string]Table + File map[string]string + } + var s schema + + if err := val.Decode(&s); err != nil { + return err + } + + os.MkdirAll(chCfg.FormatSchemasPath, 0755) + for fileName, content := range s.File { + if err := writeStringFile(filepath.Join(chCfg.FormatSchemasPath, fileName), content); err != nil { + return err + } + } + + for fnName, fn := range s.Function { + if err := conn.Exec(context.Background(), fn.CreateQuery()); err != nil { + return fmt.Errorf("creating function %s: %w", fnName, err) + } + } + + //TODO: remove setup array + for _, query := range setup { + if err := conn.Exec(context.Background(), query); err != nil { + return err + } + } + + flowsRawNull := s.Table["flows_queue"] + flowsRawNull.Engine = "Null" + flowsRawNull.Name = "flows_raw_null" + flowsRawNull.Settings = nil + flowsRawNullCreate, err := flowsRawNull.CreateQuery("default") + if err != nil { + return fmt.Errorf("formatting %s: %w", flowsRawNull.Name, err) + } + + if err := conn.Exec(context.Background(), flowsRawNullCreate); err != nil { + return fmt.Errorf("creating %s: %w", flowsRawNull.Name, err) + } + + flowsRawView := s.View["flows_raw_view"] + flowsRawView.From = "flows_raw_null" + if err := conn.Exec(context.Background(), flowsRawView.CreateQuery("default")); err != nil { + return fmt.Errorf("creating %s: %w", flowsRawView.Name, err) + } + + return nil +} + +func deployDictionaries(cfg *ClickhouseConfig, risInfoAddr string) error { + const configTpl = `#Config: { + dataPath: "%s" + risinfoURL: "%s" +}` + + //TODO: remove hardcoded path + val, err := buildCUE("deploy/base/clickhouse") + if err != nil { + return err + } + + dictionariesPath := filepath.Join(cfg.Path, "dictionaries") + configVal := cueContext.CompileString( + fmt.Sprintf(configTpl, dictionariesPath, risInfoAddr), + ) + + files := make(map[string]string) + err = val.Unify(configVal).LookupPath(cue.MakePath(cue.Str("files"))).Decode(&files) + if err != nil { + return err + } + + os.MkdirAll(dictionariesPath, 0755) + for fileName, content := range files { + if err := writeStringFile(filepath.Join(dictionariesPath, fileName), content); err != nil { + return err + } + } + + return nil +} + +func buildClickhouseConfig(baseDir string) (*ClickhouseConfig, error) { + tcpPort, err := getUnusedPort() + if err != nil { + return nil, err + } + + httpPort, err := getUnusedPort() + if err != nil { + return nil, err + } + + baseDir = filepath.Join(baseDir, "clickhouse") + cfg := ClickhouseConfig{ + Path: baseDir, + TemporaryPath: filepath.Join(baseDir, "tmp"), + UserFilesPath: filepath.Join(baseDir, "user_files"), + UserScriptsPath: filepath.Join(baseDir, "user_scripts"), + FilesystemCachesPath: filepath.Join(baseDir, "cache"), + FormatSchemasPath: filepath.Join(baseDir, "format_schemas"), + DictionariesConfig: filepath.Join(baseDir, "dictionaries", "*.conf"), + GoogleProtosPath: strings.TrimSuffix(xProtobufPaths, "google/protobuf"), + MySQLPort: PortConfig{ + Remove: PtrTo(true), + }, + PostgreSQLPort: PortConfig{ + Remove: PtrTo(true), + }, + HTTPPort: PortConfig{ + int: &httpPort, + }, + TCPPort: PortConfig{ + int: &tcpPort, + }, + UsersConfig: "user.xml", + ListenHost: []string{"127.0.0.1"}, + } + + return &cfg, nil +} + +func encodeXML(w io.Writer, v any) error { + e := xml.NewEncoder(w) + e.Indent("", " ") + return e.Encode(v) +} + +func writeStringFile(filename string, content string) error { + user, err := os.Create(filename) + if err != nil { + return err + } + if _, err := user.WriteString(content); err != nil { + return err + } + return user.Close() +} + +func buildCUE(dir string) (cue.Value, error) { + insts := load.Instances(nil, &load.Config{ + Dir: dir, + }) + + inst := insts[0] + if err := inst.Err; err != nil { + return cue.Value{}, err + } + + val := cueContext.BuildInstance(inst) + return val, val.Err() +} + +func importPcap(cfg *ClickhouseConfig, pcapPath string) error { + f, err := os.Open(pcapPath) + if err != nil { + return fmt.Errorf("could not open pcap file: %v", err) + } + defer f.Close() + + h, err := pcapgo.NewReader(f) + if err != nil { + return fmt.Errorf("failed creating pcap reader: %w", err) + } + + var buf bytes.Buffer + var i int + for ; true; i++ { + data, ci, err := h.ZeroCopyReadPacketData() + if err != nil { + if err == io.EOF { + break + } + + return fmt.Errorf("failed reading packet: %w", err) + } + + info := readFrameInfo(gopacket.NewPacket(data, layers.LayerTypeEthernet, gopacket.Default)) + msg := &flowpb.FlowMessage{ + SamplerAddress: net.IPv4(127, 0, 0, 1), + Type: flowpb.FlowMessage_SFLOW_5, + TimeReceived: uint64(ci.Timestamp.Unix()), + SequenceNum: info.SeqNum, + SamplingRate: 1, + TimeFlowStart: uint64(ci.Timestamp.Unix()), + TimeFlowEnd: uint64(ci.Timestamp.Unix()), + Bytes: uint64(ci.Length), + Packets: 1, + SrcAddr: info.SrcIP, + DstAddr: info.DstIP, + Etype: info.EthernetType, + Proto: info.Protocol, + SrcPort: info.SrcPort, + DstPort: info.DstPort, + SrcMac: macToUint64(info.SrcMAC), + DstMac: macToUint64(info.DstMAC), + IpTos: uint32(info.IPTOS), + IpTtl: uint32(info.IPTTL), + TcpFlags: info.TCPFlags, + Ipv6FlowLabel: info.FlowLabel, + } + + if _, err := protodelim.MarshalTo(&buf, msg); err != nil { + return err + } + + if buf.Len() > 10_000_000 { // every 10mb push data + log.Printf("Importing %q: Packets done %d", f.Name(), i) + if err := pushProtoData(cfg, &buf); err != nil { + return err + } + buf.Reset() + } + i++ + } + if err := pushProtoData(cfg, &buf); err != nil { + return err + } + log.Printf("Done pushing %d packets", i) + + return nil +} + +func pushProtoData(cfg *ClickhouseConfig, r io.Reader) error { + req, err := http.NewRequest( + "POST", + fmt.Sprintf( + "http://127.0.0.1:%d/?%s", + *cfg.HTTPPort.int, + url.Values{ + "query": []string{ + "INSERT INTO flows_raw_null SETTINGS format_schema = 'FlowMessage.proto:FlowMessage' FORMAT Protobuf", + }, + }.Encode(), + ), + r, + ) + if err != nil { + return err + } + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return err + } + + if resp.StatusCode != 200 { + return fmt.Errorf("unexpected status code: %d", resp.StatusCode) + } + + return nil +} + +func runSubprocess(name string, args ...string) (*exec.Cmd, error) { + cmd := exec.Command(name, args...) + //cmd.Stdout = os.Stdout + //cmd.Stderr = os.Stderr + + return cmd, cmd.Start() +} + +func getUnusedPort() (int, error) { + listen, err := net.Listen("tcp4", "127.0.0.1:0") + if err != nil { + return 0, fmt.Errorf("could not create listener for 127.0.0.1: %w", err) + } + defer listen.Close() + + return listen.Addr().(*net.TCPAddr).Port, nil +} + +type ClickhouseConfig struct { + XMLName xml.Name `xml:"clickhouse"` + Path string `xml:"path"` + TemporaryPath string `xml:"tmp_path"` + UserFilesPath string `xml:"user_files_path"` + UserScriptsPath string `xml:"user_scripts_path"` + FilesystemCachesPath string `xml:"filesystem_caches_path"` + FormatSchemasPath string `xml:"format_schema_path"` + UsersConfig string `xml:"users_config"` + GoogleProtosPath string `xml:"google_protos_path"` + DictionariesConfig string `xml:"dictionaries_config"` + + MySQLPort PortConfig `xml:"mysql_port"` + PostgreSQLPort PortConfig `xml:"postgresql_port"` + HTTPPort PortConfig `xml:"http_port"` + TCPPort PortConfig `xml:"tcp_port"` + ListenHost []string `xml:"listen_host"` +} + +type PortConfig struct { + *int `xml:",chardata"` + Remove *bool `xml:"remove,attr"` +} + +func PtrTo[T any](v T) *T { + return &v +} diff --git a/cmd/pcap/frame.go b/cmd/pcap/frame.go new file mode 100644 index 0000000..797f050 --- /dev/null +++ b/cmd/pcap/frame.go @@ -0,0 +1,66 @@ +package main + +import ( + "net" + + "github.com/gopacket/gopacket" + "github.com/gopacket/gopacket/layers" +) + +func macToUint64(mac net.HardwareAddr) (u uint64) { + return uint64(mac[0])<<40 | uint64(mac[1])<<32 | (uint64(mac[2])<<24 | uint64(mac[3])<<16 | uint64(mac[4])<<8 | uint64(mac[5])) +} + +type frameInfo struct { + EthernetType uint32 + SrcMAC net.HardwareAddr + DstMAC net.HardwareAddr + + Protocol uint32 + SrcIP net.IP + DstIP net.IP + IPTOS uint8 + IPTTL uint8 + FlowLabel uint32 + + TCPFlags uint32 + SrcPort uint32 + DstPort uint32 + SeqNum uint32 +} + +func readFrameInfo(packet gopacket.Packet) (info frameInfo) { + for _, layer := range packet.Layers() { + switch layer.(type) { + case *layers.Ethernet: + info.EthernetType = uint32(layer.(*layers.Ethernet).EthernetType) + info.SrcMAC = layer.(*layers.Ethernet).SrcMAC + info.DstMAC = layer.(*layers.Ethernet).DstMAC + + case *layers.IPv4: + info.Protocol = uint32(layer.(*layers.IPv4).Protocol) + info.SrcIP = layer.(*layers.IPv4).SrcIP + info.DstIP = layer.(*layers.IPv4).DstIP + info.IPTOS = layer.(*layers.IPv4).TOS + info.IPTTL = layer.(*layers.IPv4).TTL + + case *layers.IPv6: + info.Protocol = uint32(layer.(*layers.IPv6).NextHeader) + info.SrcIP = layer.(*layers.IPv6).SrcIP + info.DstIP = layer.(*layers.IPv6).DstIP + info.FlowLabel = layer.(*layers.IPv6).FlowLabel + + case *layers.TCP: + info.SrcPort = uint32(layer.(*layers.TCP).SrcPort) + info.DstPort = uint32(layer.(*layers.TCP).DstPort) + info.TCPFlags = uint32(layer.(*layers.TCP).Contents[13]) + info.SeqNum = layer.(*layers.TCP).Seq + + case *layers.UDP: + info.SrcPort = uint32(layer.(*layers.UDP).SrcPort) + info.DstPort = uint32(layer.(*layers.UDP).DstPort) + } + } + + return +} diff --git a/cmd/pcap/main.go b/cmd/pcap/main.go new file mode 100644 index 0000000..bb05662 --- /dev/null +++ b/cmd/pcap/main.go @@ -0,0 +1,147 @@ +package main + +import ( + _ "embed" + "fmt" + "os" + "sort" + "strings" + + "github.com/emicklei/proto" + "github.com/huandu/go-sqlbuilder" +) + +type Function struct { + Name string `json:"name"` + Arguments []string `json:"arguments"` + Query string `json:"query"` +} + +func (f *Function) CreateQuery() string { + return fmt.Sprintf("CREATE FUNCTION %s AS (%s) -> %s", f.Name, strings.Join(f.Arguments, ", "), f.Query) +} + +func (f *Function) CreateOrReplaceQuery() string { + return fmt.Sprintf("CREATE OR REPLACE FUNCTION %s AS (%s) -> %s", f.Name, strings.Join(f.Arguments, ", "), f.Query) +} + +// MaterializedView contains all information to create a MaterializedView inside Clickhouse +// It also allows to benchmark the select statement inside the MV +type MaterializedView struct { + Name string `json:"name"` + To string `json:"to"` + From string `json:"from"` + Query string `json:"query"` +} + +func (mv MaterializedView) DropQuery(database string) string { + return fmt.Sprintf("DROP VIEW %s.%s", database, mv.Name) +} + +func (mv MaterializedView) SelectQuery(database string) string { + return strings.Replace(mv.Query, "%%from%%", database+"."+mv.From, 1) +} + +func (mv MaterializedView) CreateQuery(database string) string { + s := fmt.Sprintf("CREATE MATERIALIZED VIEW %s TO %s AS %s", mv.Name, mv.To, mv.Query) + s = strings.Replace(s, "%%from%%", database+"."+mv.From, 1) + return s +} + +type Settings map[string]any + +func (s Settings) String() string { + var settings []string + for k, v := range s { + switch v.(type) { + case int: + settings = append(settings, fmt.Sprintf("%s = %d", k, v)) + case float64: + settings = append(settings, fmt.Sprintf("%s = %.0f", k, v)) + case string: + settings = append(settings, fmt.Sprintf("%s = %s", k, QuoteSingleQuote(v.(string)))) + default: + settings = append(settings, fmt.Sprintf("%s = %s", k, v)) + } + } + + // clickhouse sorts the settings internally + sort.Strings(settings) + + return strings.Join(settings, ", ") +} + +// Table contains the Name, the Type, additional Settings and +// a reference to a Message inside the Protobuf file +type Table struct { + Name string `json:"name"` + Schema string `json:"schema"` + Engine string `json:"engine"` + Settings Settings `json:"settings"` +} + +func (t Table) CreateQuery(database string) (string, error) { + builder := sqlbuilder. + CreateTable(database + "." + t.Name) + + if err := loadTableSchema(t.Schema, builder); err != nil { + return "", err + } + + builder.SQL("ENGINE = " + t.Engine) + + if len(t.Settings) != 0 { + builder.SQL("SETTINGS " + t.Settings.String()) + } + + return builder.String(), nil +} + +func (t Table) DropQuery(database string) string { + return fmt.Sprintf("DROP TABLE %s.%s", database, t.Name) +} + +func loadTableSchema(schema string, builder *sqlbuilder.CreateTableBuilder) error { + n := strings.SplitN(schema, ":", 2) + if len(n) != 2 { + return fmt.Errorf("invalid source table schema: %v", schema) + } + + path, msgName := n[0], n[1] + f, err := os.Open("/Users/fionera/src/github.com/monogon-dev/NetMeta/deploy/single-node/schema/" + path) + if err != nil { + return err + } + defer f.Close() + + parser := proto.NewParser(f) + definition, err := parser.Parse() + if err != nil { + return err + } + + cv := &clickhouseVisitor{ + enumTypes: make(map[string]map[string]int), + builder: builder, + } + + var msg *proto.Message + proto.Walk(definition, + proto.WithEnum(func(e *proto.Enum) { + e.Accept(cv) + }), + proto.WithMessage(func(message *proto.Message) { + if message.Name == msgName { + msg = message + } + })) + if msg == nil { + return fmt.Errorf("can't find message inside %q: %v", path, msgName) + } + + // we have to evaluate the message after the proto.Walk + // else it's not guaranteed that all enums are discovered + msg.Accept(cv) + + return nil +} diff --git a/cmd/pcap/quote.go b/cmd/pcap/quote.go new file mode 100644 index 0000000..5b7d92e --- /dev/null +++ b/cmd/pcap/quote.go @@ -0,0 +1,97 @@ +package main + +import ( + "strconv" + "unicode/utf8" +) + +// QuoteSingleQuote has the same functionality as strconv.Quote but uses single quotes +func QuoteSingleQuote(s string) string { + return quoteWith(s, '\'') +} + +// The code followed below this comment is copied from strconv/quote.go +// and slightly modified by removing unused features in our usage. + +const ( + lowerhex = "0123456789abcdef" +) + +func quoteWith(s string, quote byte) string { + return string(appendQuotedWith(make([]byte, 0, 3*len(s)/2), s, quote)) +} + +func appendQuotedWith(buf []byte, s string, quote byte) []byte { + // Often called with big strings, so preallocate. If there's quoting, + // this is conservative but still helps a lot. + if cap(buf)-len(buf) < len(s) { + nBuf := make([]byte, len(buf), len(buf)+1+len(s)+1) + copy(nBuf, buf) + buf = nBuf + } + buf = append(buf, quote) + for width := 0; len(s) > 0; s = s[width:] { + r := rune(s[0]) + width = 1 + if r >= utf8.RuneSelf { + r, width = utf8.DecodeRuneInString(s) + } + if width == 1 && r == utf8.RuneError { + buf = append(buf, `\x`...) + buf = append(buf, lowerhex[s[0]>>4]) + buf = append(buf, lowerhex[s[0]&0xF]) + continue + } + buf = appendEscapedRune(buf, r, quote) + } + buf = append(buf, quote) + return buf +} + +func appendEscapedRune(buf []byte, r rune, quote byte) []byte { + if r == rune(quote) || r == '\\' { // always backslashed + buf = append(buf, '\\') + buf = append(buf, byte(r)) + return buf + } + if strconv.IsPrint(r) { + return utf8.AppendRune(buf, r) + } + switch r { + case '\a': + buf = append(buf, `\a`...) + case '\b': + buf = append(buf, `\b`...) + case '\f': + buf = append(buf, `\f`...) + case '\n': + buf = append(buf, `\n`...) + case '\r': + buf = append(buf, `\r`...) + case '\t': + buf = append(buf, `\t`...) + case '\v': + buf = append(buf, `\v`...) + default: + switch { + case r < ' ' || r == 0x7f: + buf = append(buf, `\x`...) + buf = append(buf, lowerhex[byte(r)>>4]) + buf = append(buf, lowerhex[byte(r)&0xF]) + case !utf8.ValidRune(r): + r = 0xFFFD + fallthrough + case r < 0x10000: + buf = append(buf, `\u`...) + for s := 12; s >= 0; s -= 4 { + buf = append(buf, lowerhex[r>>uint(s)&0xF]) + } + default: + buf = append(buf, `\U`...) + for s := 28; s >= 0; s -= 4 { + buf = append(buf, lowerhex[r>>uint(s)&0xF]) + } + } + } + return buf +} diff --git a/cmd/pcap/visitor.go b/cmd/pcap/visitor.go new file mode 100644 index 0000000..42acce9 --- /dev/null +++ b/cmd/pcap/visitor.go @@ -0,0 +1,124 @@ +package main + +import ( + "fmt" + "log" + "math" + "sort" + "strings" + + "github.com/emicklei/proto" + "github.com/huandu/go-sqlbuilder" +) + +type clickhouseVisitor struct { + proto.NoopVisitor + enumTypes map[string]map[string]int + builder *sqlbuilder.CreateTableBuilder +} + +func (c *clickhouseVisitor) VisitMessage(m *proto.Message) { + for _, v := range m.Elements { + v.Accept(c) + } +} + +func (c *clickhouseVisitor) VisitNormalField(i *proto.NormalField) { + columnName := i.Name + columnType := c.ToColumnType(i.Type) + + for _, option := range i.Options { + switch option.Name { + case "(column_type)": + columnType = option.Constant.Source + case "(column_name)": + columnName = option.Constant.Source + case "(column_skip)": + // just exit the visitor and ignore the rest of the logic + return + default: + log.Printf("unknown option %q on %q! Skipping!", option.Name, i.Name) + } + } + + c.builder.Define(columnName, columnType) +} + +func (c *clickhouseVisitor) VisitEnumField(i *proto.EnumField) { + c.enumTypes[i.Parent.(*proto.Enum).Name][i.Name] = i.Integer +} + +func (c *clickhouseVisitor) VisitEnum(e *proto.Enum) { + c.enumTypes[e.Name] = make(map[string]int) + for _, v := range e.Elements { + v.Accept(c) + } +} + +type enumOption struct { + value int + name string +} + +func (e enumOption) String() string { + return fmt.Sprintf("%s = %d", QuoteSingleQuote(e.name), e.value) +} + +func (c *clickhouseVisitor) ToColumnType(t string) string { + if enum, found := c.enumTypes[t]; found { + var enumOptions []enumOption + + for s, i := range enum { + enumOptions = append(enumOptions, enumOption{ + value: i, + name: s, + }) + } + + size := int(math.Log2(float64(len(enumOptions)))) + switch { + case size <= 8: + size = 8 + case size <= 16: + size = 16 + default: + size = 0 + } + + t := fmt.Sprintf("Enum%d", size) + if size == 0 { + t = "Enum" + } + + // Enums are sorted inside clickhouse + sort.SliceStable(enumOptions, func(i, j int) bool { + return enumOptions[i].value < enumOptions[j].value + }) + + var enumOptionStrings []string + for _, option := range enumOptions { + enumOptionStrings = append(enumOptionStrings, option.String()) + } + + return fmt.Sprintf("%s(%s)", t, strings.Join(enumOptionStrings, ", ")) + } + + switch t { + case "int32": + return "Int32" + case "uint32": + return "UInt32" + case "int64": + return "Int64" + case "uint64": + return "UInt64" + case "bytes": + return "String" + case "bool": + return "Bool" + case "string": + return "String" + default: + panic("type not implemented: " + t) + } +} diff --git a/cmd/reconciler/BUILD.bazel b/cmd/reconciler/BUILD.bazel index a6db165..4a7befa 100644 --- a/cmd/reconciler/BUILD.bazel +++ b/cmd/reconciler/BUILD.bazel @@ -7,7 +7,6 @@ go_library( srcs = [ "config.go", "main.go", - "placeholder.s", "quote.go", "reconciler.go", "visitor.go", diff --git a/cmd/reconciler/placeholder.s b/cmd/reconciler/placeholder.s deleted file mode 100644 index 15ecf27..0000000 --- a/cmd/reconciler/placeholder.s +++ /dev/null @@ -1 +0,0 @@ -// To allow the use of go:linkname a placeholder asm file is required \ No newline at end of file diff --git a/cmd/reconciler/quote.go b/cmd/reconciler/quote.go index 7ec2e1e..5b7d92e 100644 --- a/cmd/reconciler/quote.go +++ b/cmd/reconciler/quote.go @@ -3,7 +3,6 @@ package main import ( "strconv" "unicode/utf8" - _ "unsafe" ) // QuoteSingleQuote has the same functionality as strconv.Quote but uses single quotes diff --git a/cmd/risinfo/BUILD.bazel b/cmd/risinfo/BUILD.bazel index dd6be07..c00db89 100644 --- a/cmd/risinfo/BUILD.bazel +++ b/cmd/risinfo/BUILD.bazel @@ -10,7 +10,6 @@ go_library( deps = [ "@com_github_osrg_gobgp//pkg/packet/bgp", "@com_github_osrg_gobgp//pkg/packet/mrt", - "@io_k8s_klog_v2//:klog", ], ) diff --git a/cmd/risinfo/risinfo.go b/cmd/risinfo/risinfo.go index b1e9717..9f423fe 100644 --- a/cmd/risinfo/risinfo.go +++ b/cmd/risinfo/risinfo.go @@ -12,22 +12,22 @@ import ( "flag" "fmt" "io" + "log" "net/http" "os" "path" + "path/filepath" "regexp" "sync" "time" "github.com/osrg/gobgp/pkg/packet/bgp" "github.com/osrg/gobgp/pkg/packet/mrt" - - "k8s.io/klog/v2" ) var ( addr = flag.String("addr", ":8080", "Listening address [:8080]") - cacheDir = flag.String("cacheDir", "/tmp/risinfo-cache", "Caching directory") + cacheDir = flag.String("cacheDir", filepath.Join(os.TempDir(), "risinfo-cache"), "Caching directory") maxCacheAge = flag.Duration("maxCacheAge", 8*time.Hour, "Local RIB cache timeout") // Global cache write lock @@ -51,10 +51,6 @@ const ( autnumURI = "https://netmeta-cache.leoluk.de/v1/autnums.html" ) -func init() { - klog.InitFlags(nil) -} - // serveAutnums requests and parses autnums.html and writes its contents as tab-separated (asnum, asname, country) // lines to an io.Writer. func serveAutnums(ctx context.Context, w io.Writer) error { @@ -106,7 +102,7 @@ func fetchLatestRIB(ctx context.Context) (io.ReadCloser, error) { f := t.Format("rib.20060102.1500") + ".bz2" u := fmt.Sprintf("%s/%s/RIBS/%s", ribDumpURI, d, f) - klog.Infof("trying %s", u) + log.Printf("trying %s", u) req, err := http.NewRequestWithContext(ctx, "GET", u, nil) if err != nil { @@ -120,7 +116,7 @@ func fetchLatestRIB(ctx context.Context) (io.ReadCloser, error) { } if resp.StatusCode == 200 { - klog.Info("downloading latest RIB from NetMeta's routeviews.org cache: ", u) + log.Println("downloading latest RIB from NetMeta's routeviews.org cache: ", u) return resp.Body, nil } } @@ -140,7 +136,7 @@ func parseMRT(r io.Reader) (map[string]uint32, error) { count++ if count%10000 == 0 { - klog.V(1).Infof("progress: %d", count) + log.Printf("progress: %d", count) } hdr := &mrt.MRTHeader{} @@ -170,14 +166,14 @@ func parseMRT(r io.Reader) (map[string]uint32, error) { // IPv6 "subnets" for truncated IPv6-mapped IPv4 p := body.Prefix.(*bgp.IPAddrPrefix) if p.Length == 0 { - klog.V(1).Infof("ignoring IPv4 default route: %+v", body) + log.Printf("ignoring IPv4 default route: %+v", body) continue } prefix = fmt.Sprintf("::ffff:%s/%d", p.Prefix.String(), p.Length+96) case mrt.RIB_IPV6_UNICAST: p := body.Prefix.(*bgp.IPv6AddrPrefix) if p.Length == 0 { - klog.V(1).Infof("ignoring IPv6 default route: %+v", body) + log.Printf("ignoring IPv6 default route: %+v", body) continue } prefix = body.Prefix.String() @@ -206,12 +202,12 @@ func parseMRT(r io.Reader) (map[string]uint32, error) { return nil, fmt.Errorf("failed to scan input: %w", err) } - klog.Infof("parsed %d routes", count) + log.Printf("parsed %d routes", count) return result, nil } func handleRIB(w http.ResponseWriter, r *http.Request) { - klog.Infof("%v %s %s", r.RemoteAddr, r.Method, r.URL) + log.Printf("%v %s %s", r.RemoteAddr, r.Method, r.URL) // Check if we can serve the RIB from local cache. mu.RLock() @@ -219,26 +215,26 @@ func handleRIB(w http.ResponseWriter, r *http.Request) { fi, err := os.Stat(cacheFile) if err != nil { if os.IsNotExist(err) { - klog.Info("empty local cache") + log.Println("empty local cache") } else { - klog.Fatalf("error accessing cache file %s: %v", cacheFile, err) + log.Fatalf("error accessing cache file %s: %v", cacheFile, err) } } else { expiration := time.Now().Add(-*maxCacheAge) - klog.V(1).Infof("oldest cache accepted: %s, ours: %s", expiration, fi.ModTime()) + log.Printf("oldest cache accepted: %s, ours: %s", expiration, fi.ModTime()) if fi.ModTime().Before(expiration) { - klog.Info("cache has expired") + log.Println("cache has expired") } else { - klog.Info("cache is valid, serving request from cache") + log.Println("cache is valid, serving request from cache") cf, err := os.Open(cacheFile) if err != nil { - klog.Fatalf("error accessing cache file %s: %v", cacheFile, err) + log.Fatalf("error accessing cache file %s: %v", cacheFile, err) } if n, err := io.Copy(w, cf); err != nil { - klog.Errorf("failed to write cached response: %v", err) + log.Printf("failed to write cached response: %v", err) } else { - klog.Infof("%v sent %d bytes (cache hit)", r.RemoteAddr, n) + log.Printf("%v sent %d bytes (cache hit)", r.RemoteAddr, n) } mu.RUnlock() @@ -254,7 +250,7 @@ func handleRIB(w http.ResponseWriter, r *http.Request) { cf, err := os.CreateTemp(*cacheDir, "rib.*.tsv") if err != nil { - klog.Fatalf("failed to open cache file %s: %v", cacheFile, err) + log.Fatalf("failed to open cache file %s: %v", cacheFile, err) } defer os.Remove(cf.Name()) @@ -262,7 +258,7 @@ func handleRIB(w http.ResponseWriter, r *http.Request) { // Request latest RIB resp, err := fetchLatestRIB(r.Context()) if err != nil { - klog.Errorf("failed to fetch RIB: %v", err) + log.Printf("failed to fetch RIB: %v", err) w.WriteHeader(500) return } @@ -270,7 +266,7 @@ func handleRIB(w http.ResponseWriter, r *http.Request) { res, err := parseMRT(bzip2.NewReader(resp)) if err != nil { - klog.Errorf("failed to parse RIB: %v", err) + log.Printf("failed to parse RIB: %v", err) w.WriteHeader(500) return } @@ -282,26 +278,26 @@ func handleRIB(w http.ResponseWriter, r *http.Request) { n, err := fmt.Fprintf(cw, "%s\t%d\n", p, asn) written += n if err != nil { - klog.Errorf("failed to write response or cache: %v", err) + log.Printf("failed to write response or cache: %v", err) return } } // Response written successfully - commit cache. if err := os.Rename(cf.Name(), cacheFile); err != nil { - klog.Fatalf("failed to rename cachecommit cache: %v", err) + log.Fatalf("failed to rename cachecommit cache: %v", err) } - klog.Infof("%v sent %d bytes (cache miss)", r.RemoteAddr, written) + log.Printf("%v sent %d bytes (cache miss)", r.RemoteAddr, written) } func handleAutnums(w http.ResponseWriter, r *http.Request) { - klog.Infof("%v %s %s", r.RemoteAddr, r.Method, r.URL) + log.Printf("%v %s %s", r.RemoteAddr, r.Method, r.URL) // This is a cheap request - we do not cache it locally. if err := serveAutnums(r.Context(), w); err != nil { - klog.Errorf("failed to parse autnums.html: %v", err) + log.Printf("failed to parse autnums.html: %v", err) w.WriteHeader(500) return } @@ -310,11 +306,11 @@ func handleAutnums(w http.ResponseWriter, r *http.Request) { func main() { flag.Parse() if err := os.MkdirAll(*cacheDir, 0750); err != nil { - klog.Fatal(err) + log.Fatal(err) } http.HandleFunc("/rib.tsv", handleRIB) http.HandleFunc("/autnums.tsv", handleAutnums) - klog.Fatal(http.ListenAndServe(*addr, nil)) + log.Fatal(http.ListenAndServe(*addr, nil)) } diff --git a/deploy/base/clickhouse/clickhouse.cue b/deploy/base/clickhouse/clickhouse.cue index 3661ec6..0bf8325 100644 --- a/deploy/base/clickhouse/clickhouse.cue +++ b/deploy/base/clickhouse/clickhouse.cue @@ -1,7 +1,6 @@ package clickhouse import ( - schema "github.com/monogon-dev/NetMeta/deploy/single-node/schema" "netmeta.monogon.tech/xml" ) @@ -41,11 +40,6 @@ import ( } files: { - // Iterate over our required files from schema, e.g. the protobuf files - for k, v in schema.file { - "\(k)": v - } - // Iterate over all defined files in _files and generate the config files for clickhouse for k, v in _files { "\(k).conf": (xml.#Marshal & {in: v._cfg}).out diff --git a/deploy/base/clickhouse/static_files.cue b/deploy/base/clickhouse/static_files.cue index efbdcaa..b5aee5a 100644 --- a/deploy/base/clickhouse/static_files.cue +++ b/deploy/base/clickhouse/static_files.cue @@ -1,9 +1,5 @@ package clickhouse -import ( - schema "github.com/monogon-dev/netmeta/deploy/single-node/schema" -) - // curl -s https://www.iana.org/assignments/protocol-numbers/protocol-numbers-1.csv | awk -F ',' '{ print $1 "\t" $2 }' // plus some manual post-processing. Most of them are never seen on the wire, but doesn't hurt to have the full list. _files: IPProtocols: cfg: { diff --git a/deploy/dashboards/types.cue b/deploy/dashboards/types.cue index 822b379..0a1b201 100644 --- a/deploy/dashboards/types.cue +++ b/deploy/dashboards/types.cue @@ -31,6 +31,7 @@ import "strings" options: [] skipUrlSync: bool | *false type: "textbox" + query: "" } #AdHocVariable: { @@ -93,7 +94,7 @@ import "strings" #CustomVariable: V={ current: { - _option: [ for _, v in V.options if v.selected {v}, {text: "", value: ""}][0] + _option: [for _, v in V.options if v.selected {v}, {text: "", value: ""}][0] selected: false text: _option.text value: _option.value @@ -108,7 +109,7 @@ import "strings" text: string value: string }] - query: strings.Join([ for _, v in V.options {"\(v.text) : \(v.value)"}], ",") + query: strings.Join([for _, v in V.options {"\(v.text) : \(v.value)"}], ",") queryValue: "" skipUrlSync: false type: "custom" diff --git a/deploy/nix/defs.cue b/deploy/nix/defs.cue index 489ec37..7135415 100644 --- a/deploy/nix/defs.cue +++ b/deploy/nix/defs.cue @@ -2,10 +2,10 @@ package nix import ( // Dashboards - grafana_dashboards "github.com/monogon-dev/NetMeta/deploy/dashboards" - schema "github.com/monogon-dev/NetMeta/deploy/single-node/schema" - clickhouse "github.com/monogon-dev/NetMeta/deploy/base/clickhouse" - reconciler "github.com/monogon-dev/NetMeta/reconciler:main" + grafana_dashboards "github.com/monogon-dev/netmeta/deploy/dashboards" + schema "github.com/monogon-dev/netmeta/deploy/single-node/schema" + clickhouse "github.com/monogon-dev/netmeta/deploy/base/clickhouse" + reconciler "github.com/monogon-dev/netmeta/reconciler:main" "encoding/json" ) diff --git a/deploy/single-node/BUILD.bazel b/deploy/single-node/BUILD.bazel index 62d2be4..947002e 100644 --- a/deploy/single-node/BUILD.bazel +++ b/deploy/single-node/BUILD.bazel @@ -37,7 +37,7 @@ cue_export( "$(location :local_images)", ], expression = "all_objects_yaml", - outfile = "netmeta.yaml", + output = "netmeta.yaml", ) # TODO: add generator for initial config_local diff --git a/deploy/single-node/k8s/clickhouse/clickhouse.cue b/deploy/single-node/k8s/clickhouse/clickhouse.cue index d81e368..edea5c9 100644 --- a/deploy/single-node/k8s/clickhouse/clickhouse.cue +++ b/deploy/single-node/k8s/clickhouse/clickhouse.cue @@ -3,7 +3,7 @@ package clickhouse import ( "crypto/sha256" "encoding/hex" - chBase "github.com/monogon-dev/NetMeta/deploy/base/clickhouse" + chBase "github.com/monogon-dev/netmeta/deploy/base/clickhouse" ) #Config: { diff --git a/deploy/single-node/schema/DBManager.proto b/deploy/single-node/schema/DBManager.proto deleted file mode 100644 index fba069d..0000000 --- a/deploy/single-node/schema/DBManager.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto3"; -package netmeta; - -import "google/protobuf/descriptor.proto"; - -extend google.protobuf.FieldOptions { - optional string column_type = 50000; - optional string column_name = 50001; - optional bool column_skip = 50002; -} \ No newline at end of file diff --git a/deploy/single-node/schema/FlowMessage.proto b/deploy/single-node/schema/FlowMessage.proto index b6ba60b..3b11bc3 100644 --- a/deploy/single-node/schema/FlowMessage.proto +++ b/deploy/single-node/schema/FlowMessage.proto @@ -1,8 +1,15 @@ syntax = "proto3"; package netmeta; -// Adapter from/compatible with cloudflare/goflow. +import "google/protobuf/descriptor.proto"; + +extend google.protobuf.FieldOptions { + optional string column_type = 50000; + optional string column_name = 50001; + optional bool column_skip = 50002; +} +// Adapter from/compatible with cloudflare/goflow. message FlowMessage { enum FlowType { FLOWUNKNOWN = 0; @@ -119,4 +126,4 @@ message FlowMessage { // Custom fields: start after ID 1000: // uint32 MyCustomField = 1000; -} +} \ No newline at end of file diff --git a/deploy/single-node/schema/files.cue b/deploy/single-node/schema/files.cue index 81bdb2e..589ecd6 100644 --- a/deploy/single-node/schema/files.cue +++ b/deploy/single-node/schema/files.cue @@ -2,8 +2,6 @@ package schema -file: "DBManager.proto": _ @embed(file=DBManager.proto,type=text) - file: "FlowMessage.proto": _ @embed(file=FlowMessage.proto,type=text) // FastNetMon traffic format diff --git a/go.mod b/go.mod index 2c1a1a6..d140a57 100644 --- a/go.mod +++ b/go.mod @@ -5,16 +5,16 @@ go 1.22.0 require ( cuelang.org/go v0.11.1 github.com/ClickHouse/clickhouse-go/v2 v2.30.0 + github.com/bazelbuild/rules_go v0.50.1 github.com/emicklei/proto v1.13.2 github.com/gopacket/gopacket v1.3.1 github.com/huandu/go-sqlbuilder v1.20.0 - github.com/netsampler/goflow2 v1.1.1 - github.com/netsampler/goflow2/v2 v2.2.1 + github.com/netsampler/goflow2 v1.3.7 github.com/osrg/gobgp v2.0.0+incompatible github.com/pressly/goose/v3 v3.24.0 github.com/sirupsen/logrus v1.9.3 github.com/vishvananda/netlink v1.2.1-beta.2 - k8s.io/klog/v2 v2.90.1 + google.golang.org/protobuf v1.34.2 ) require ( @@ -37,7 +37,6 @@ require ( github.com/elastic/go-windows v1.0.1 // indirect github.com/go-faster/city v1.0.1 // indirect github.com/go-faster/errors v0.7.1 // indirect - github.com/go-logr/logr v1.4.1 // indirect github.com/go-sql-driver/mysql v1.8.1 // indirect github.com/golang-jwt/jwt/v4 v4.5.1 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect @@ -115,7 +114,6 @@ require ( golang.org/x/tools v0.26.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect google.golang.org/grpc v1.62.1 // indirect - google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect howett.net/plist v1.0.0 // indirect diff --git a/go.sum b/go.sum index bbe026e..7840c6f 100644 --- a/go.sum +++ b/go.sum @@ -34,6 +34,8 @@ github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOL github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= +github.com/bazelbuild/rules_go v0.50.1 h1:/BUvuaB8MEiUA2oLPPCGtuw5V+doAYyiGTFyoSWlkrw= +github.com/bazelbuild/rules_go v0.50.1/go.mod h1:Dhcz716Kqg1RHNWos+N6MlXNkjNP2EwZQ0LukRKJfMs= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -94,7 +96,6 @@ github.com/go-faster/city v1.0.1 h1:4WAxSZ3V2Ws4QRDrscLEDcibJY8uf41H6AhXDrNDcGw= github.com/go-faster/city v1.0.1/go.mod h1:jKcUJId49qdW3L1qKHH/3wPeUstCVpVSXTM6vO3VcTw= github.com/go-faster/errors v0.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg= github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -236,10 +237,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= -github.com/netsampler/goflow2 v1.1.1 h1:GpVlvPq4yRbyzoiz0Vp3XilNr5js/0UhHcQI7Ol/MDk= -github.com/netsampler/goflow2 v1.1.1/go.mod h1:oNIeGj67SjwrRSTEukErjNT1zZ02W9+8M5mSgQCkZC8= -github.com/netsampler/goflow2/v2 v2.2.1 h1:QzrtWS/meXsqCLv68hdouL+09NfuLKrCoVDJ1xfmuoE= -github.com/netsampler/goflow2/v2 v2.2.1/go.mod h1:057wOc/Xp7c+hUwRDB7wRqrx55m0r3vc7J0k4NrlFbM= +github.com/netsampler/goflow2 v1.3.7 h1:XZaTy8kkMnGXpJ9hS3KbO1McyrFTpVNhVFEx9rNhMmc= +github.com/netsampler/goflow2 v1.3.7/go.mod h1:4UZsVGVAs//iMCptUHn3WNScztJeUhZH7kDW2+/vDdQ= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= @@ -501,8 +500,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM= howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= -k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= -k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= modernc.org/cc/v4 v4.21.4 h1:3Be/Rdo1fpr8GrQ7IVw9OHtplU4gWbb+wNgeoBMmGLQ= modernc.org/cc/v4 v4.21.4/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ= modernc.org/ccgo/v4 v4.19.2 h1:lwQZgvboKD0jBwdaeVCTouxhxAyN6iawF3STraAal8Y= diff --git a/third_party/clickhouse/BUILD.bazel b/third_party/clickhouse/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/third_party/clickhouse/defs.bzl b/third_party/clickhouse/defs.bzl new file mode 100644 index 0000000..ea1fb70 --- /dev/null +++ b/third_party/clickhouse/defs.bzl @@ -0,0 +1,59 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") + +def _clickhouse_folder(ctx): + arch = ctx.os.arch + os_name = ctx.os.name + + if (os_name == "linux"): + cpu_info = ctx.read("/proc/cpuinfo") + + if (arch == "x86_64" or arch == "amd64"): + # Always return the statically linked build. + # It requires SSE 4.2 but we are talking about up to date hardware. + return "amd64musl" + elif (arch == "aarch64" or arch == "arm64"): + # Dispatch between standard and compatibility builds, see cmake/cpu_features.cmake for details. Unfortunately, (1) the ARM ISA level + # cannot be read directly, we need to guess from the "features" in /proc/cpuinfo, and (2) the flags in /proc/cpuinfo are named + # differently than the flags passed to the compiler in cpu_features.cmake. + hasArmV82 = ( + "asimd" in cpu_info and + "sha1" in cpu_info and + "aes" in cpu_info and + "atomics" in cpu_info and + "lrcpc" in cpu_info + ) + + if (hasArmV82): + return "aarch64" + else: + return "aarch64v80compat" + elif (arch == "powerpc64le" or arch == "ppc64le"): + return "powerpc64le" + elif (arch == "riscv64"): + return "riscv64" + elif (arch == "s390x"): + return "s390x" + + elif (os_name == "freebsd"): + if (arch == "x86_64" or arch == "amd64"): + return "freebsd" + + elif (os_name == "mac os x"): + if (arch == "x86_64" or arch == "amd64"): + return "macos" + elif (arch == "aarch64" or arch == "arm64"): + return "macos-aarch64" + + fail("unsupported os and arch: " + os_name + " - " + arch) + +def _clickhouse_impl(ctx): + ctx.download( + url = "https://builds.clickhouse.com/master/{DIR}/clickhouse".format(DIR = _clickhouse_folder(ctx)), + output = "clickhouse", + executable = True, + ) + ctx.file("BUILD.bazel", 'exports_files(["clickhouse"])') + +clickhouse = repository_rule( + implementation = _clickhouse_impl, +) diff --git a/third_party/goflow/readd-flowdirection.patch b/third_party/goflow/readd-flowdirection.patch new file mode 100644 index 0000000..43fd1a8 --- /dev/null +++ b/third_party/goflow/readd-flowdirection.patch @@ -0,0 +1,12 @@ +diff --git a/pb/flow.proto b/pb/flow.proto +@@ -16,9 +16,9 @@ + uint64 time_received_ns = 110; + uint32 sequence_num = 4; + uint64 sampling_rate = 3; + +- //uint32 flow_direction = 42; ++ uint32 flow_direction = 42; + + // Sampler information + bytes sampler_address = 11; + diff --git a/tools.go b/tools.go index 595c532..19fe65c 100644 --- a/tools.go +++ b/tools.go @@ -6,6 +6,6 @@ package NetMeta import ( _ "cuelang.org/go/cmd/cue" - _ "github.com/netsampler/goflow2/v2/cmd/goflow2" + _ "github.com/netsampler/goflow2/cmd/goflow2" _ "github.com/pressly/goose/v3/cmd/goose" )