unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Joshua Branson via Guix-patches via <guix-patches@gnu.org>
To: 39136@debbugs.gnu.org
Cc: "Nicolò Balzarotti" <nicolo@nixo.xyz>
Subject: [bug#39136] [PATCH 1/2] services: Add endlessh service.
Date: Mon, 15 Mar 2021 12:29:48 -0400	[thread overview]
Message-ID: <20210315162949.17092-1-jbranso@dismail.de> (raw)
In-Reply-To: <874kwx91k6.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me>

From: Nicolò Balzarotti <nicolo@nixo.xyz>

* gnu/services/ssh.scm: Add endlessh service
(<endlessh-configuration>): New record type.
(endlessh-config->conf, endlessh-shepherd-service, endlessh-service-type): New procedures.
---
 gnu/services/ssh.scm | 73 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm
index 1891db0487..aad9bbc754 100644
--- a/gnu/services/ssh.scm
+++ b/gnu/services/ssh.scm
@@ -54,6 +54,10 @@
             autossh-configuration?
             autossh-service-type
 
+            endlessh-configuration
+            endlessh-configuration?
+            endlessh-service-type
+
             webssh-configuration
             webssh-configuration?
             webssh-service-type
@@ -739,6 +743,75 @@ object."
                              autossh-service-activation)))
    (default-value (autossh-configuration))))
 
+\f
+;;;
+;;; Endlessh.
+;;;
+
+(define-record-type* <endlessh-configuration>
+  endlessh-configuration make-endlessh-configuration
+  endlessh-configuration?
+  ;; list of two symbols, allowed values are ipv4, ipv6 or both
+  (bind-family endlessh-configuration-bind-family (default '(ipv4 ipv6)))
+  ;; integer
+  (delay endlessh-configuration-delay (default 10000))
+  ;; integer
+  ;; Must be in the range
+  (length endlessh-configuration-length (default 32))
+  ;; integer
+  (max-clients endlessh-configuration-max-clients (default 4096))
+  ;; integer
+  (port-number endlessh-configuration-port-number (default 2222))
+  ;; integer
+  ;; Allowed values are 0, 1 and 2
+  (log-level endlessh-configuration-log-level (default 0)))
+
+(define (endlessh-config->conf config)
+  "Convert the CONFIG of type <endlessh-config> to a config file."
+  (let* ((family (endlessh-configuration-bind-family config))
+	 (ipv4 (member 'ipv4 family))
+	 (ipv6 (member 'ipv6 family))
+	 (port (endlessh-configuration-port-number config))
+	 (delay (endlessh-configuration-delay config))
+	 (length (endlessh-configuration-length config))
+	 (log-level (endlessh-configuration-log-level config))
+	 (max-clients (endlessh-configuration-max-clients config))
+	 (bind
+	  ;; check if both are true (0), or only one of them is present
+	  (if (not (and (equal? ipv4 ipv6) ipv4))
+	      (if ipv4 4
+		  (if ipv6 6
+		      (throw 'endlessh-error
+			     "bind-family must contain at least one value")))
+	      0)))
+    (mixed-text-file "endlessh.conf"
+		     "# Generated by 'endlessh-config'.\n\n"
+		     "Port " (number->string port) "\n"
+		     "Delay " (number->string delay) "\n"
+		     "MaxLineLength " (number->string length) "\n"
+		     "MaxClients " (number->string max-clients) "\n"
+		     "LogLevel " (number->string log-level) "\n"
+		     "BindFamily " (number->string bind) "\n")))
+
+(define (endlessh-shepherd-service config)
+  (shepherd-service
+   (documentation "Run endlessh tarpit server.")
+   (provision '(endlessh))
+   (start #~(make-forkexec-constructor
+	     (list #$(file-append endlessh "/bin/endlessh")
+		   "-f" #$(endlessh-config->conf config))))
+   (stop  #~(make-kill-destructor))))
+
+(define endlessh-service-type
+  (service-type
+   (name 'endlessh)
+   (description "Run endlessh tarpit server.")
+   (extensions
+    (list (service-extension shepherd-root-service-type
+                             (compose list endlessh-shepherd-service))))
+   (default-value (endlessh-configuration))))
+
+
 \f
 ;;;
 ;;; WebSSH
-- 
2.30.0





  parent reply	other threads:[~2021-03-15 16:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-14 21:21 [bug#39136] [PATCH] gnu: services: Add endlessh Nicolò Balzarotti
2020-07-25 20:08 ` Oleg Pykhalov
2021-03-15 16:29 ` Joshua Branson via Guix-patches via [this message]
2021-03-15 16:29   ` [bug#39136] [PATCH 2/2] services: containerized endlessh Joshua Branson via Guix-patches via
2022-08-31 10:49     ` [bug#39136] [PATCH] gnu: services: Add endlessh Ludovic Courtès
2022-08-31 23:34     ` jbranso--- via Guix-patches via
2021-03-16 15:32 ` [bug#39136] My endlessh patch series Joshua Branson via Guix-patches via
2021-03-19 16:22   ` [bug#39136] [PATCH] gnu: services: Add endlessh Joshua Branson via Guix-patches via
2021-03-22 18:45     ` Oleg Pykhalov
2021-04-04 13:31       ` Joshua Branson via Guix-patches via
2023-09-01  2:37         ` Maxim Cournoyer
2023-09-01 18:42         ` jbranso--- via Guix-patches via
2023-09-02 18:10           ` Maxim Cournoyer
2022-09-30 17:03 ` [bug#39136] [PATCH] * gnu: endlessh: new service Joshua Branson via Guix-patches via
2022-09-30 17:08 ` Joshua Branson via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210315162949.17092-1-jbranso@dismail.de \
    --to=guix-patches@gnu.org \
    --cc=39136@debbugs.gnu.org \
    --cc=jbranso@dismail.de \
    --cc=nicolo@nixo.xyz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).