slowlorust: refactor (#361412)

This commit is contained in:
Fabian Affolter 2024-12-03 23:38:05 +01:00 committed by GitHub
commit aedc37d8a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 45 additions and 36 deletions

View File

@ -0,0 +1,45 @@
{
lib,
stdenv,
darwin,
fetchFromGitHub,
rustPlatform,
versionCheckHook,
}:
rustPlatform.buildRustPackage rec {
pname = "slowlorust";
version = "0.1.1";
src = fetchFromGitHub {
owner = "MJVL";
repo = "slowlorust";
rev = "refs/tags/${version}";
hash = "sha256-c4NWkQ/QvlUo1YoV2s7rWB6wQskAP5Qp1WVM23wvV3c=";
};
cargoHash = "sha256-Wu1mm+yJw2SddddxC5NfnMWLr+dplnRxH3AJ1/mTAKM=";
postPatch = ''
# https://github.com/MJVL/slowlorust/issues/2
substituteInPlace src/main.rs \
--replace-fail 'version = "1.0"' 'version = "${version}"'
'';
buildInputs = lib.optional stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.Security ];
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;
versionCheckProgramArg = [ "--version" ];
meta = with lib; {
description = "Lightweight slowloris (HTTP DoS) tool";
homepage = "https://github.com/MJVL/slowlorust";
changelog = "https://github.com/MJVL/slowlorust/releases/tag/${version}";
license = licenses.mit;
maintainers = with maintainers; [ fab ];
mainProgram = "slowlorust";
};
}

View File

@ -1,32 +0,0 @@
{ lib
, stdenv
, fetchFromGitHub
, rustPlatform
, Security
}:
rustPlatform.buildRustPackage rec {
pname = "slowlorust";
version = "0.1.1";
src = fetchFromGitHub {
owner = "MJVL";
repo = pname;
rev = version;
hash = "sha256-c4NWkQ/QvlUo1YoV2s7rWB6wQskAP5Qp1WVM23wvV3c=";
};
cargoHash = "sha256-Wu1mm+yJw2SddddxC5NfnMWLr+dplnRxH3AJ1/mTAKM=";
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
Security
];
meta = with lib; {
description = "Lightweight slowloris (HTTP DoS) tool";
homepage = "https://github.com/MJVL/slowlorust";
license = licenses.mit;
maintainers = with maintainers; [ fab ];
mainProgram = "slowlorust";
};
}

View File

@ -5230,10 +5230,6 @@ with pkgs;
ocamlPackages = ocaml-ng.ocamlPackages_4_12;
};
slowlorust = callPackage ../tools/networking/slowlorust {
inherit (darwin.apple_sdk.frameworks) Security;
};
slstatus = callPackage ../applications/misc/slstatus {
conf = config.slstatus.conf or null;
};