From b4ace4f839e37a0019582962be48f9b75a50db94 Mon Sep 17 00:00:00 2001 From: Sense T Date: Sat, 1 Mar 2025 17:25:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BD=90=E6=B2=BB=E3=80=81h3c=20=E5=A0=A1?= =?UTF-8?q?=E5=9E=92=E6=9C=BA=E7=99=BB=E5=BD=95=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.nix | 1 + qzsec/access-client/access-client | 19 +++++++++++++ qzsec/access-client/access-client.desktop | 13 +++++++++ qzsec/access-client/package.nix | 33 +++++++++++++++++++++++ qzsec/default.nix | 4 +++ 5 files changed, 70 insertions(+) create mode 100644 qzsec/access-client/access-client create mode 100644 qzsec/access-client/access-client.desktop create mode 100644 qzsec/access-client/package.nix create mode 100644 qzsec/default.nix diff --git a/flake.nix b/flake.nix index 767ed1b..94505cf 100644 --- a/flake.nix +++ b/flake.nix @@ -28,6 +28,7 @@ packages."${system}" = { h3c = import ./h3c { inherit pkgs; }; + qzsec = import ./qzsec { inherit pkgs; }; }; nixosModules = diff --git a/qzsec/access-client/access-client b/qzsec/access-client/access-client new file mode 100644 index 0000000..2bed3d6 --- /dev/null +++ b/qzsec/access-client/access-client @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +URL="$1" + +ARGS=$(echo $URL | sed 's|accessclient://||' | base64 -d | minideflate -d ) + +APP=$(echo $ARGS | jq -r.app) +if [ "$APP" != "putty" ]; then + echo "Unsupported app, should be putty." + sleep 5 + exit 1 +fi + +HOSTNAME=$(echo $ARGS | jq -r .hn) +PORT_NUM=$(echo $ARGS | jq -r .pn) +USERNAME=$(echo $ARGS | jq -r .un) +PASSWORD=$(echo $ARGS | jq -r .pw) + +passh -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o HostKeyAlgorithms=+ssh-rsa -p $PORT_NUM $USERNAME@$HOSTNAME \ No newline at end of file diff --git a/qzsec/access-client/access-client.desktop b/qzsec/access-client/access-client.desktop new file mode 100644 index 0000000..3ef33c7 --- /dev/null +++ b/qzsec/access-client/access-client.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Type=Application +Version=@VERSION +Name=Access Client +GenericName=Access Client +Comment=Resource monitor that shows usage and stats for processor, memory, disks, network and processes +Comment[zh_CN]=齐治、H3C 运维审计系统连接代理 +Terminal=true +Categories=System;ConsoleOnly; +Keywords=system;h3c; +NoDisplay=true +Exec=@EXEC +MimeType=x-scheme-handler/accessclient \ No newline at end of file diff --git a/qzsec/access-client/package.nix b/qzsec/access-client/package.nix new file mode 100644 index 0000000..fa222ad --- /dev/null +++ b/qzsec/access-client/package.nix @@ -0,0 +1,33 @@ +{ + stdenv, + + jq, + zlib-ng, + passh, + ... +}: +let + bin = ./access-client; + desktop = ./access-client.desktop; +in +stdenv.mkDerivation rec { + pname = "access-client"; + version = "1.0.0"; + + buildInputs = [ + jq + zlib-ng + passh + ]; + + phases = [ "installPhase" ]; + + installPhase = '' + mkdir -p $out/bin + cp -rv "${bin}" $out/bin + chmod +x $out/bin/* + + mkdir -p $out/share/applications + cp -rv "${desktop}" $out/share/applications + ''; +} diff --git a/qzsec/default.nix b/qzsec/default.nix new file mode 100644 index 0000000..ce342b5 --- /dev/null +++ b/qzsec/default.nix @@ -0,0 +1,4 @@ +{ pkgs }: +{ + access-client = pkgs.callPackage ./access-client/package.nix { }; +}