chiark / gitweb /
contrib/greet.in: Grotty script to send a TrIPE greeting packet.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 23 Apr 2012 17:11:11 +0000 (18:11 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 23 Apr 2012 17:40:39 +0000 (18:40 +0100)
Useful for testing.

contrib/Makefile.am
contrib/greet.in [new file with mode: 0644]
debian/rules

index 8802b62af1287e9c4c993451a848e1f39cee26b1..a81e14a8de9fe045eb6308c19f041d0c5b794ac9 100644 (file)
@@ -26,6 +26,7 @@
 include $(top_srcdir)/vars.am
 
 noinst_DATA             =
+noinst_SCRIPTS          =
 
 ###--------------------------------------------------------------------------
 ### Contributions.
@@ -52,4 +53,15 @@ tripe-upstart: tripe-upstart.in Makefile
        $(SUBST) $(srcdir)/tripe-upstart.in >$@.new $(SUBSTITUTIONS) && \
                mv $@.new $@
 
+## `greet' utility for stimulating passive connections.
+if HAVE_PYTHON
+noinst_SCRIPTS         += greet
+EXTRA_DIST             += greet.in
+CLEANFILES             += greet
+
+greet: greet.in Makefile
+       $(SUBST) $(srcdir)/greet.in >$@.new $(SUBSTITUTIONS) && \
+               chmod +x $@.new && mv $@.new $@
+endif
+
 ###----- That's all, folks --------------------------------------------------
diff --git a/contrib/greet.in b/contrib/greet.in
new file mode 100644 (file)
index 0000000..c84efdc
--- /dev/null
@@ -0,0 +1,17 @@
+#! @PYTHON@
+### greet HOST PORT CHALLENGE
+### Sends a TrIPE greeting packet to the server listening on HOST and PORT.
+### The payload is the base64-encoded CHALLENGE.
+
+import socket as S
+from sys import argv
+
+def db64(s):
+  return (s + '='*((-len(s))%4)).decode('base64')
+
+addr, chal = (lambda _, h, p, c: ((h, int(p)), db64(c)))(*argv)
+sk = S.socket(S.AF_INET, S.SOCK_DGRAM)
+sk.connect(addr)
+
+pkt = '\x25' + chal
+sk.send(pkt)
index 3738102a2f818c41e4e3feea11c79709a96118af..ad785081c79158edd1c83c01822fe6d570777dff 100755 (executable)
@@ -41,7 +41,7 @@ install/tripe::
        sed 's/^#\(user\|group\)/\1/' \
                $(DEB_SRCDIR)/init/tripe.conf >debian/tripe.default
        mkdir -p debian/tripe/usr/share/doc/tripe/examples
-       for i in tripe-ipif ipif-peers tripe-upstart; do \
+       for i in tripe-ipif ipif-peers tripe-upstart greet; do \
          cp $(DEB_BUILDDIR)/contrib/$$i \
                debian/tripe/usr/share/doc/tripe/examples; \
        done