Unverified Commit b59f175f authored by Nico Felbinger's avatar Nico Felbinger
Browse files

netcap: init at 0.6.11

parent bc2d7512
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
{
  ndpi,
  fetchFromGitHub,
  lib,
  stdenv,
  autoreconfHook,
  autoconf,
  automake,
  fixDarwinDylibNames,
}:

ndpi.overrideAttrs (
  finalAttrs: prevAttrs: {
    version = "4.0";

    src = fetchFromGitHub {
      inherit (prevAttrs.src) owner repo;
      tag = finalAttrs.version;
      hash = "sha256-vWx6IVyxPJBgOkXpHdnvstvDGJbAtndFPtowpjLd32o=";
    };

    configureScript = "./autogen.sh";

    nativeBuildInputs =
      lib.remove autoreconfHook prevAttrs.nativeBuildInputs
      ++ [
        autoconf
        automake
      ]
      ++ lib.optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ];
  }
)
+92 −0
Original line number Diff line number Diff line
{
  lib,
  callPackage,
  buildGoModule,
  fetchFromGitHub,
  withDpi ? true,
  libpcap,
  libprotoident,
  libflowmanager,
  libtrace,
  versionCheckHook,
  nix-update-script,
}:
let
  ndpi = callPackage ./ndpi_4_0.nix { };
in
buildGoModule (finalAttrs: {
  pname = "netcap";
  version = "0.6.11";

  src = fetchFromGitHub {
    owner = "dreadl0ck";
    repo = "netcap";
    tag = "v${finalAttrs.version}";
    hash = "sha256-SCBKOIC/s+rfrVWmryp9EBp7ARpZZcxymsnZWtEHrhk=";
  };

  vendorHash = "sha256-MvHrJLhcFA0fEgK+YT0rwI6wIwTGMcLWQt6AYkx1eZM=";

  subPackages = [ "cmd" ];

  buildInputs =
    [
      libpcap
    ]
    ++ lib.optionals withDpi [
      ndpi
      libprotoident
      libflowmanager
      libtrace
    ];

  ldflags = [
    "-s -w"
  ];

  tags = lib.optionals (!withDpi) [
    "nodpi"
  ];

  CGO_LDFLAGS = lib.optionalString withDpi ''
    -L${ndpi}/lib -lndpi
    -L${libprotoident}/lib -lndpi
  '';

  CGO_CFLAGS = lib.optionalString withDpi ''
    -I${ndpi}/include
    -I${libprotoident}/include
  '';

  postInstall = ''
    mv $out/bin/cmd $out/bin/net
  '';

  checkFlags =
    let
      skippedTests = [
        # couldn't open packet socket: operation not permitted
        "TestCaptureLive"
        # requires local test data
        "TestCapturePCAP"
      ];
    in
    [ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];

  nativeInstallCheckInputs = [ versionCheckHook ];
  versionCheckProgram = "${placeholder "out"}/bin/net";
  versionCheckProgramArg = "--version";
  doInstallCheck = true;

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Framework for secure and scalable network traffic analysis";
    homepage = "https://netcap.io";
    downloadPage = "https://github.com/dreadl0ck/netcap";
    changelog = "https://github.com/dreadl0ck/netcap/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [ felbinger ];
    mainProgram = "net";
  };
})
+4 −0
Original line number Diff line number Diff line
@@ -3826,6 +3826,10 @@ with pkgs;
  # Not in aliases because it wouldn't get picked up by callPackage
  netbox = netbox_4_2;
  netcap-nodpi = callPackage ../by-name/ne/netcap/package.nix {
    withDpi = false;
  };
  netcat = libressl.nc.overrideAttrs (old: {
    meta = old.meta // {
      description = "Utility which reads and writes data across network connections — LibreSSL implementation";