Subject: [PATCH v5 09/25] gnu: Add go-github-com-operatorfoundation-obfs4.

From: Raghav Gururajan <[email-masked]>
Date: Fri, 18 Jun 2021 02:44:03 -0400

* gnu/packages/golang.scm (go-github-com-operatorfoundation-obfs4): New variable.
---
 gnu/packages/golang.scm | 152 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 152 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index fa181c49cc..968132c695 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -69,6 +69,158 @@
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1))
 
+(define-public go-github-com-operatorfoundation-obfs4
+  (package
+    (name "go-github-com-operatorfoundation-obfs4")
+    (version "1.0.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri
+        (git-reference
+         (url "https://github.com/OperatorFoundation/obfs4")
+         (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0s730xagdxs66wfh65hb5v9a5h01q5ncic3pyij0a043scagizgr"))))
+    (build-system go-build-system)
+    (arguments
+     `(#:unpack-path "github.com/OperatorFoundation/obfs4"
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch
+           (lambda _
+             (substitute* (find-files "." "\\.go$")
+               ;; To drop '.git' suffix in import path of goptlib.
+               (("goptlib\\.git") "goptlib"))))
+         (replace 'build
+           (lambda* (#:key source system outputs search-paths build-flags
+                     unpack-path inputs #:allow-other-keys)
+             (for-each
+              (lambda (directory)
+                ((assoc-ref %standard-phases 'build)
+                 #:source source
+                 #:system system
+                 #:outputs outputs
+                 #:search-paths search-paths
+                 #:build-flags build-flags
+                 #:unpack-path unpack-path
+                 #:inputs inputs
+                 #:import-path directory))
+              (list
+               "github.com/OperatorFoundation/obfs4/common/csrand"
+               "github.com/OperatorFoundation/obfs4/common/drbg"
+               "github.com/OperatorFoundation/obfs4/common/log"
+               "github.com/OperatorFoundation/obfs4/common/ntor"
+               "github.com/OperatorFoundation/obfs4/common/probdist"
+               "github.com/OperatorFoundation/obfs4/common/pt_extras"
+               "github.com/OperatorFoundation/obfs4/common/replayfilter"
+               "github.com/OperatorFoundation/obfs4/common/socks5"
+               "github.com/OperatorFoundation/obfs4/common/termmon"
+               "github.com/OperatorFoundation/obfs4/common/uniformdh"
+               "github.com/OperatorFoundation/obfs4/modes/pt_socks5"
+               "github.com/OperatorFoundation/obfs4/modes/stun_udp"
+               "github.com/OperatorFoundation/obfs4/modes/transparent_tcp"
+               "github.com/OperatorFoundation/obfs4/modes/transparent_udp"
+               "github.com/OperatorFoundation/obfs4/obfs4proxy"
+               "github.com/OperatorFoundation/obfs4/proxy_dialers/proxy_http"
+               "github.com/OperatorFoundation/obfs4/proxy_dialers/proxy_socks4"
+               "github.com/OperatorFoundation/obfs4/transports"))))
+         (replace 'check
+           (lambda* (#:key source system outputs search-paths tests? unpack-path
+                     inputs #:allow-other-keys)
+             (for-each
+              (lambda (directory)
+                ((assoc-ref %standard-phases 'check)
+                 #:source source
+                 #:system system
+                 #:outputs outputs
+                 #:search-paths search-paths
+                 #:tests? tests?
+                 #:unpack-path unpack-path
+                 #:inputs inputs
+                 #:import-path directory))
+              (list
+               "github.com/OperatorFoundation/obfs4/common/csrand"
+               "github.com/OperatorFoundation/obfs4/common/drbg"
+               "github.com/OperatorFoundation/obfs4/common/log"
+               "github.com/OperatorFoundation/obfs4/common/ntor"
+               "github.com/OperatorFoundation/obfs4/common/probdist"
+               "github.com/OperatorFoundation/obfs4/common/pt_extras"
+               "github.com/OperatorFoundation/obfs4/common/replayfilter"
+               "github.com/OperatorFoundation/obfs4/common/socks5"
+               "github.com/OperatorFoundation/obfs4/common/termmon"
+               "github.com/OperatorFoundation/obfs4/common/uniformdh"
+               ;; ERROR: Println arg dialFn is a func value, not called.
+               ;;"github.com/OperatorFoundation/obfs4/modes/pt_socks5"
+               ;; ERROR: Infof format %s has arg ln of wrong type *net.UDPConn.
+               ;;"github.com/OperatorFoundation/obfs4/modes/stun_udp"
+               "github.com/OperatorFoundation/obfs4/modes/transparent_tcp"
+               ;; ERROR: Infof format %s has arg ln of wrong type *net.UDPConn
+               ;;"github.com/OperatorFoundation/obfs4/modes/transparent_udp"
+               ;; ERROR: Println call has possible formatting directive %s.
+               ;;"github.com/OperatorFoundation/obfs4/obfs4proxy"
+               "github.com/OperatorFoundation/obfs4/proxy_dialers/proxy_http"
+               "github.com/OperatorFoundation/obfs4/proxy_dialers/proxy_socks4"
+               "github.com/OperatorFoundation/obfs4/transports"))))
+         (replace 'install
+           (lambda* (#:key source system outputs search-paths install-source?
+                     unpack-path inputs #:allow-other-keys)
+             (for-each
+              (lambda (directory)
+                ((assoc-ref %standard-phases 'install)
+                 #:source source
+                 #:system system
+                 #:outputs outputs
+                 #:search-paths search-paths
+                 #:install-source? install-source?
+                 #:unpack-path unpack-path
+                 #:inputs inputs
+                 #:import-path directory))
+              (list
+               "github.com/OperatorFoundation/obfs4/common/csrand"
+               "github.com/OperatorFoundation/obfs4/common/drbg"
+               "github.com/OperatorFoundation/obfs4/common/log"
+               "github.com/OperatorFoundation/obfs4/common/ntor"
+               "github.com/OperatorFoundation/obfs4/common/probdist"
+               "github.com/OperatorFoundation/obfs4/common/pt_extras"
+               "github.com/OperatorFoundation/obfs4/common/replayfilter"
+               "github.com/OperatorFoundation/obfs4/common/socks5"
+               "github.com/OperatorFoundation/obfs4/common/termmon"
+               "github.com/OperatorFoundation/obfs4/common/uniformdh"
+               "github.com/OperatorFoundation/obfs4/modes/pt_socks5"
+               "github.com/OperatorFoundation/obfs4/modes/stun_udp"
+               "github.com/OperatorFoundation/obfs4/modes/transparent_tcp"
+               "github.com/OperatorFoundation/obfs4/modes/transparent_udp"
+               "github.com/OperatorFoundation/obfs4/obfs4proxy"
+               "github.com/OperatorFoundation/obfs4/proxy_dialers/proxy_http"
+               "github.com/OperatorFoundation/obfs4/proxy_dialers/proxy_socks4"
+               "github.com/OperatorFoundation/obfs4/transports")))))))
+    (propagated-inputs
+     `(("go-github-com-dchest-siphash"
+        ,go-github-com-dchest-siphash)
+       ("go-github-com-operatorfoundation-ed25519"
+        ,go-github-com-operatorfoundation-ed25519)
+       ("go-github-com-willscott-goturn"
+        ,go-github-com-willscott-goturn)
+       ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)
+       ("go-golang-org-x-net" ,go-golang-org-x-net)
+       ("go-torproject-org-pluggable-transports-goptlib"
+        ,go-torproject-org-pluggable-transports-goptlib)))
+    (home-page "https://github.com/OperatorFoundation/obfs4")
+    (synopsis "Network Obfourscator")
+    (description "Obfs4 is a look-like nothing obfuscation protocol that
+incorporates ideas and concepts from Philipp Winter's ScrambleSuit protocol.
+The notable differences between ScrambleSuit and obfs4 are:
+@itemize
+@item The handshake always does a full key exchange (no such thing as a Session
+Ticket Handshake).
+@item The handshake uses the Tor Project's ntor handshake with public keys
+obfuscated via the Elligator 2 mapping.
+@item The link layer encryption uses NaCl secret boxes (Poly1305/XSalsa20).
+@end itemize")
+    (license license:bsd-2)))
+
 (define-public go-github-com-willscott-goturn
   (let ((commit "19f41278d0c9251d64e0ee29f37d51e87a24a97b")
         (revision "68"))
-- 
2.32.0