From a6f833087a0220b1487cb5a4550f0b0d22ba55ec Mon Sep 17 00:00:00 2001 From: Runciter Date: Sun, 31 Mar 2024 19:52:10 +0800 Subject: Initial. A .gitignore A AUTHORS A COPYING A ChangeLog A HACKING A Makefile.am A NEWS A README A README.org A build-aux/test-driver.scm A configure.ac A doc/whispers.texi A guix.scm A hall.scm A pre-inst-env.in A scripts/whispers.in A whispers.scm A whispers/hconfig.scm --- whispers.scm | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 whispers.scm (limited to 'whispers.scm') diff --git a/whispers.scm b/whispers.scm new file mode 100644 index 0000000..a736784 --- /dev/null +++ b/whispers.scm @@ -0,0 +1,49 @@ +;;; Whispers --- Stealth VPN and ssh tunneler +;;; Copyright © 2024 Runciter +;;; +;;; This file is part of Whispers. +;;; +;;; Whispers is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; Whispers is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Whispers. If not, see . + +(define-module (whispers) + #:export (whispers)) + +(define herd-path "/run/current-system/profile/bin/herd") + +(define (strip-final-slash path) + "Strip the last character of the string PATH if it is a slash, and return +the resulting string." + (let ((lgth (string-length path))) + (if (equal? "/" (substring path (- lgth 1) lgth)) + (substring path 0 (- lgth 1)) + path))) + +(define* (whispers #:key + (lieutenant "/") + (act '("status"))) + "Call an herd sub-process to command the whispers lieutenant at the +whispers path LIEUTENANT to perform the shepherd action described by the +list of strings ACT of the form either (ACTION) or (ACTION SERVICE +. ARGS), in which ARGS is optionally the emtpy list." + (let ((lieut (strip-final-slash lieutenant))) + (apply system* + (append (list herd-path + "-s" + (string-append "/run/whispers" + lieut + "/unix-sockets/" + (basename (string-append "/whispers" + lieut)) + ".sock")) + act)))) -- cgit v1.2.3