Skip to content

Commit

Permalink
zapret: init as 0-unstable-2024-07-16 (#327675)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishimara authored Jul 16, 2024
1 parent f10c38b commit 034f3ee
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
5 changes: 5 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14527,6 +14527,11 @@
github = "dev-nis";
githubId = 132921300;
};
nishimara = {
name = "nishimara";
github = "Nishimara";
githubId = 59232119;
};
nitsky = {
name = "nitsky";
github = "nitsky";
Expand Down
81 changes: 81 additions & 0 deletions pkgs/by-name/za/zapret/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
lib,
stdenv,
fetchFromGitHub,

libcap,
zlib,
libnetfilter_queue,
libnfnetlink,

iptables,
nftables,
gawk
}:

stdenv.mkDerivation {
pname = "zapret";
version = "0-unstable-2024-07-16";

src = fetchFromGitHub {
owner = "bol-van";
repo = "zapret";
rev = "9fcd8f830ebde2491719a5c698e22d1d5210e0fb";
sha256 = "sha256-8cqKCNYLLkZXlwrybKUPG6fLd7gmf8zV9tjWoTxAwIY=";
};

buildInputs = [ libcap zlib libnetfilter_queue libnfnetlink ];
nativeBuildInputs = [ iptables nftables gawk ];

buildPhase = ''
mkdir -p $out/bin
make TGT=$out/bin
'';

installPhase = ''
mkdir -p $out/usr/share/zapret/init.d/sysv
mkdir -p $out/usr/share/docs
cp $src/blockcheck.sh $out/bin/blockcheck
substituteInPlace $out/bin/blockcheck \
--replace "ZAPRET_BASE=\"\$EXEDIR\"" "ZAPRET_BASE=$out/usr/share/zapret"
cp $src/init.d/sysv/functions $out/usr/share/zapret/init.d/sysv/functions
cp $src/init.d/sysv/zapret $out/usr/share/zapret/init.d/sysv/init.d
substituteInPlace $out/usr/share/zapret/init.d/sysv/functions \
--replace "ZAPRET_BASE=\$(readlink -f \"\$EXEDIR/../..\")" "ZAPRET_BASE=$out/usr/share/zapret" \
--replace ". \"\$ZAPRET_BASE/config\"" ""
cp -r $src/docs/* $out/usr/share/docs
mkdir -p $out/usr/share/zapret/{common,ipset}
cp $src/common/* $out/usr/share/zapret/common
cp $src/ipset/* $out/usr/share/zapret/ipset
mkdir -p $out/usr/share/zapret/nfq
ln -s ../../../../bin/nfqws $out/usr/share/zapret/nfq/nfqws
for i in ip2net mdig tpws
do
mkdir -p $out/usr/share/zapret/$i
ln -s ../../../../bin/$i $out/usr/share/zapret/$i/$i
done
ln -s ../usr/share/zapret/init.d/sysv/init.d $out/bin/zapret
'';

meta = with lib; {
description = "DPI bypass multi platform";
homepage = "https://github.com/bol-van/zapret";
license = licenses.mit;
maintainers = with maintainers; [ nishimara ];
mainProgram = "zapret";

# probably gonna work on darwin, but untested
broken = stdenv.isDarwin;
};
}

0 comments on commit 034f3ee

Please sign in to comment.