Skip to content

Commit

Permalink
update to Go 1.15 (and Go modules)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyke369 committed Sep 21, 2020
1 parent 3f0d66e commit e61db5c
Show file tree
Hide file tree
Showing 17 changed files with 132 additions and 93 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
tcpsplice
monitor.go
debian/tcpsplice
debian/*debhelper*
debian/*substvars*
debian/files
_*
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

23 changes: 10 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## 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")

`tcpsplice` is a simple TCP proxy/connection splicer written in Go.

## Requirements

`tcpsplice` only requires a recent Golang compiler (1.6+).
`tcpsplice` only requires a recent Golang compiler (1.15+).

## Build

Expand Down Expand Up @@ -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) ...
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
tcpsplice (1.1.0) stable; urgency=medium

* update to Go 1.15 (and Go modules)

-- Pierre-Yves Kerembellec <[email protected]> Mon, 21 Sep 2020 18:10:58 +0200

tcpsplice (1.0.2) stable; urgency=medium

* add arbitrary metadata scan (+ display on monitoring screen)
Expand Down
2 changes: 1 addition & 1 deletion debian/compat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5
9
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: tcpsplice
Section: net
Priority: optional
Maintainer: Pierre-Yves Kerembellec <[email protected]>
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
Expand Down
2 changes: 2 additions & 0 deletions debian/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tcpsplice usr/bin
tcpsplice.conf etc
38 changes: 7 additions & 31 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions debian/tcpsplice.default
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# tcpsplice base configuration
# base configuration

ENABLED=1
# CONFIGURATION="/etc/tcpsplice.conf"
CONFIGURATION="/etc/tcpsplice.conf"
52 changes: 52 additions & 0 deletions debian/tcpsplice.init
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions debian/tcpsplice.service
Original file line number Diff line number Diff line change
@@ -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
25 changes: 0 additions & 25 deletions debian/tcpsplice.upstart

This file was deleted.

5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module tcpsplice

go 1.15

require github.com/pyke369/golang-support v0.0.0-20200321184731-cd1ed731523d
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
2 changes: 1 addition & 1 deletion tcpsplice.go → main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 17 additions & 8 deletions tcpsplice.conf
Original file line number Diff line number Diff line change
@@ -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 = "["
}
}

0 comments on commit e61db5c

Please sign in to comment.