From: Mark Wooding Date: Mon, 23 Apr 2012 17:11:11 +0000 (+0100) Subject: contrib/greet.in: Grotty script to send a TrIPE greeting packet. X-Git-Tag: 1.0.0pre11~14 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/tripe/commitdiff_plain/5d60949f7d6a88e88d4d962d093b0ae1a4df5096 contrib/greet.in: Grotty script to send a TrIPE greeting packet. Useful for testing. --- diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 8802b62a..a81e14a8 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -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 index 00000000..c84efdcb --- /dev/null +++ b/contrib/greet.in @@ -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) diff --git a/debian/rules b/debian/rules index 3738102a..ad785081 100755 --- a/debian/rules +++ b/debian/rules @@ -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