diff --git a/.gitignore b/.gitignore index cd22e82..a0f856f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ tcpsplice monitor.go +debian/tcpsplice +debian/*debhelper* +debian/*substvars* +debian/files +_* diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d4db5ae..0000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -sudo: required -dist: trusty -language: go -script: make -go: - - tip diff --git a/Makefile b/Makefile index 9a420c3..a22fa24 100755 --- a/Makefile +++ b/Makefile @@ -1,19 +1,16 @@ #!/bin/sh -tcpsplice: tcpsplice.go monitor.html +tcpsplice: *.go monitor.html @(echo -n "package main\nimport \"encoding/base64\"\nconst _monitorContent = \""; base64 -w 0 < monitor.html; echo "\"\nvar monitorContent []byte\nfunc init() { monitorContent, _ = base64.StdEncoding.DecodeString(_monitorContent) }") >monitor.go - @export GOPATH=`pwd`; export GIT_SSL_NO_VERIFY=true; export CGO_ENABLED=0; go get -v -d && go build tcpsplice.go monitor.go && strip tcpsplice - -run: tcpsplice - @./tcpsplice tcpsplice.conf - -deb: - @debuild -i -us -uc -b - + @export GOPATH=/tmp/go; export CGO_ENABLED=0; go build -trimpath -o tcpsplice && strip tcpsplice clean: - distclean: - @rm -rf tcpsplice monitor.go src - + @rm -rf tcpsplice monitor.go +deb: + @debuild -e GOROOT -e GOPATH -e PATH -i -us -uc -b debclean: - @debuild clean + @debuild -- clean + @rm -f ../tcpsplice_* + +run: tcpsplice + @./tcpsplice tcpsplice.conf diff --git a/README.md b/README.md index 49c3fbe..3269b7b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## tcpsplice [![Build Status](https://travis-ci.org/pyke369/tcpsplice.svg?branch=master)](https://travis-ci.org/pyke369/tcpsplice) +## tcpsplice ![Chain Of Gophers](/images/chain.jpg?raw=true "Chain Of Gophers") @@ -6,7 +6,7 @@ ## Requirements -`tcpsplice` only requires a recent Golang compiler (1.6+). +`tcpsplice` only requires a recent Golang compiler (1.15+). ## Build @@ -37,7 +37,7 @@ You may optionally build a Debian package by typing the following command at the The `tcpsplice` binary will be installed by the package in the `/usr/sbin` directory, with additional startup scripts and a default configuration file in `/etc/tcpsplice.conf`. - $ sudo dpkg -i tcpsplice_1.0.2_amd64.deb + $ sudo dpkg -i tcpsplice_1.1.0_amd64.deb Selecting previously unselected package tcpsplice. - Unpacking tcpsplice (from tcpsplice_1.0.2_amd64.deb) ... - Setting up tcpsplice (1.0.2) ... + Unpacking tcpsplice (from tcpsplice_1.1.0_amd64.deb) ... + Setting up tcpsplice (1.1.0) ... diff --git a/debian/changelog b/debian/changelog index 363b4c7..9c9978b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +tcpsplice (1.1.0) stable; urgency=medium + + * update to Go 1.15 (and Go modules) + + -- Pierre-Yves Kerembellec Mon, 21 Sep 2020 18:10:58 +0200 + tcpsplice (1.0.2) stable; urgency=medium * add arbitrary metadata scan (+ display on monitoring screen) diff --git a/debian/compat b/debian/compat index 7ed6ff8..ec63514 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -5 +9 diff --git a/debian/control b/debian/control index ba17e5e..b44eb35 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: tcpsplice Section: net Priority: optional Maintainer: Pierre-Yves Kerembellec -Build-Depends: debhelper (>= 5), git-core, golang-go (>= 1.6), make +Build-Depends: debhelper (>= 5), golang-1.15 Standards-Version: 3.7.2 Package: tcpsplice diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..41807d1 --- /dev/null +++ b/debian/install @@ -0,0 +1,2 @@ +tcpsplice usr/bin +tcpsplice.conf etc diff --git a/debian/rules b/debian/rules index 05357e2..2a8f1ce 100755 --- a/debian/rules +++ b/debian/rules @@ -1,36 +1,12 @@ #!/usr/bin/make -f -build: build-stamp +DPKG_EXPORT_BUILDFLAGS=1 +include /usr/share/dpkg/default.mk +DEB_BUILD_OPTIONS=nostrip -build-stamp: - dh_testdir - $(MAKE) - touch build-stamp +override_dh_strip: -clean: - dh_testdir - dh_testroot - rm -f build-stamp - $(MAKE) clean - dh_clean +override_dh_strip_nondeterminism: -install: build - dh_testdir - dh_prep - dh_install tcpsplice /usr/sbin - dh_install tcpsplice.conf /etc - -binary-indep: build install - -binary-arch: build install - dh_testdir - dh_testroot - dh_installinit - dh_fixperms - dh_installdeb - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install +%: + dh $@ --with systemd diff --git a/debian/tcpsplice.default b/debian/tcpsplice.default index b60c539..3ba50eb 100644 --- a/debian/tcpsplice.default +++ b/debian/tcpsplice.default @@ -1,4 +1,4 @@ -# tcpsplice base configuration +# base configuration ENABLED=1 -# CONFIGURATION="/etc/tcpsplice.conf" +CONFIGURATION="/etc/tcpsplice.conf" diff --git a/debian/tcpsplice.init b/debian/tcpsplice.init new file mode 100755 index 0000000..c5da0e2 --- /dev/null +++ b/debian/tcpsplice.init @@ -0,0 +1,52 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: tcpsplice +# Required-Start: $local_fs $network +# Required-Stop: $local_fs $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: tcpsplice +# Description: tcpsplice +### END INIT INFO# + +set -e + +ENABLED=0 +NAME=tcpsplice +BINARY=/usr/bin/tcpsplice +PIDFILE=/var/run/tcpsplice.pid +CONFIGURATION=/etc/tcpsplice.conf + +[ -r /etc/default/$NAME ] && . /etc/default/$NAME +[ "$ENABLED" -eq 0 ] && exit 0 +[ ! -x "$BINARY" ] && exit 0 +[ ! -f "$CONFIGURATION" ] && exit 0 + +. /lib/lsb/init-functions + +case "$1" in + start) + log_daemon_msg "Starting $NAME" + ulimit -n 65536 + start-stop-daemon --start --oknodo --quiet --background --exec "$BINARY" --make-pidfile --pidfile "$PIDFILE" -- "$CONFIGURATION" + log_end_msg $? + ;; + stop) + log_daemon_msg "Stopping $NAME" + start-stop-daemon --stop --oknodo --quiet --pidfile "$PIDFILE" --retry 3 + log_end_msg $? + ;; + restart) + $0 stop + $0 start + ;; + status) + status_of_proc "$BINARY" "$NAME" && exit 0 || exit $? + ;; + *) + echo "Usage: /etc/init.d/$NAME {start|stop|restart|status}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/debian/tcpsplice.service b/debian/tcpsplice.service new file mode 100644 index 0000000..874feee --- /dev/null +++ b/debian/tcpsplice.service @@ -0,0 +1,16 @@ +[Unit] +Description=tcpsplice +After=network.target + +[Service] +EnvironmentFile=/etc/default/tcpsplice +StandardOutput=null +StandardError=journal +LimitNOFILE=65536 +ExecStart=/usr/bin/tcpsplice ${CONFIGURATION} +ExecReload=/bin/kill -HUP $MAINPID +Restart=always +RestartSec=3 + +[Install] +WantedBy=multi-user.target diff --git a/debian/tcpsplice.upstart b/debian/tcpsplice.upstart deleted file mode 100644 index d50031e..0000000 --- a/debian/tcpsplice.upstart +++ /dev/null @@ -1,25 +0,0 @@ -description "tcpsplice server" - -start on runlevel [2345] -stop on runlevel [!2345] - -console none -respawn -umask 022 -limit nofile 16384 16384 -limit core unlimited unlimited - -env ENABLED=0 -env DAEMON=tcpsplice -env BINARY=/usr/sbin/tcpsplice -env CONFIGURATION=/etc/tcpsplice.conf - -pre-start script - [ -f /etc/default/$DAEMON ] && . /etc/default/$DAEMON - [ -z "$ENABLED" ] && { stop; exit 0; } - [ ! -f "$CONFIGURATION" ] && { stop; exit 0; } - [ ! -x "$BINARY" ] && { stop; exit 0; } - exit 0 -end script - -exec $BINARY $CONFIGURATION diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..d09e4e3 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module tcpsplice + +go 1.15 + +require github.com/pyke369/golang-support v0.0.0-20200321184731-cd1ed731523d diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..6289dec --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/pyke369/golang-support v0.0.0-20200321184731-cd1ed731523d h1:bssjYWDUaYbjtBc7gZ6BI3YBerIg5EAn+kAM5hMQf2s= +github.com/pyke369/golang-support v0.0.0-20200321184731-cd1ed731523d/go.mod h1:0XGrzgrEp0fa/+JSV8XZePUwyjnU6C3bMc7Xz2bHHKI= diff --git a/tcpsplice.go b/main.go similarity index 99% rename from tcpsplice.go rename to main.go index 23b2568..3efec30 100644 --- a/tcpsplice.go +++ b/main.go @@ -19,7 +19,7 @@ import ( ) const progname = "tcpsplice" -const version = "1.0.2" +const version = "1.1.0" type Session struct { id, service, source, target, meta string diff --git a/tcpsplice.conf b/tcpsplice.conf index 1c7b2a1..f1b6c9e 100644 --- a/tcpsplice.conf +++ b/tcpsplice.conf @@ -1,23 +1,32 @@ server { - log = "console()" + // log = "console()" } monitor { listen = "*:8000" - acl - { - allow = [ "127.0.0.1" ] - auth = [ "tcpsplice:monitor" ] - } + // acl + // { + // allow = [ "127.0.0.1" ] + // auth = [ "tcpsplice:monitor" ] + // } } services { example { - local = [ "*:12345" ] - remote = [ "my.origin.net:12345" ] + local = [ "*:12345" ] + remote = [ "my.origin.net:12345" ] + // connect_timeout = 10 + // write_timeout = 10 + // idle_timeout = 60 + // incoming_buffer_size = 64k + // outgoing_buffer_size = 64k + // log_minimum_size = 1k + // session_minimum_size = 1k + // meta_size = 16k + // meta_scan = "[" } }