net-proxy/redsocks: Ship man page, init files, etc
authorMatt Turner <mattst88@gentoo.org>
Wed, 14 Jun 2017 15:36:41 +0000 (08:36 -0700)
committerMatt Turner <mattst88@gentoo.org>
Wed, 14 Jun 2017 15:48:04 +0000 (08:48 -0700)
Also move config file to /etc/redsocks.conf (there's a single file, no
need for a directory) and add a redsocks user and group.

net-proxy/redsocks/files/redsocks.conf [new file with mode: 0644]
net-proxy/redsocks/files/redsocks.init [new file with mode: 0644]
net-proxy/redsocks/files/redsocks.service [new file with mode: 0644]
net-proxy/redsocks/metadata.xml
net-proxy/redsocks/redsocks-0.5.ebuild
net-proxy/redsocks/redsocks-9999.ebuild

diff --git a/net-proxy/redsocks/files/redsocks.conf b/net-proxy/redsocks/files/redsocks.conf
new file mode 100644 (file)
index 0000000..76b2c5f
--- /dev/null
@@ -0,0 +1,15 @@
+# Config file for /etc/init.d/redsocks
+
+# Path to the redsocks binary (needs to be absolute path).
+
+#REDSOCKS_BINARY="/usr/sbin/redsocks"
+
+# Path to the redsocks config (needs to be absolute path).
+
+#REDSOCKS_CONFIG="/etc/redsocks.conf"
+
+# Pid file to use (needs to be absolute path).
+
+#REDSOCKS_PIDFILE="/run/redsocks/redsocks.pid"
+
+rc_use="logger"
diff --git a/net-proxy/redsocks/files/redsocks.init b/net-proxy/redsocks/files/redsocks.init
new file mode 100644 (file)
index 0000000..853d9b5
--- /dev/null
@@ -0,0 +1,53 @@
+#!/sbin/openrc-run
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+: ${REDSOCKS_BINARY:=/usr/sbin/redsocks}
+: ${REDSOCKS_CONFIG:=/etc/redsocks.conf}
+: ${REDSOCKS_PIDFILE:=/run/redsocks/redsocks.pid}
+
+extra_commands="checkconfig"
+extra_started_commands="reload"
+
+depend() {
+       need localmount
+       use dns
+}
+
+checkconfig() {
+       if [ ! -f "${REDSOCKS_CONFIG}" ] ; then
+               eerror "No ${REDSOCKS_CONFIG} file exists!"
+               return 1
+       fi
+
+        "${REDSOCKS_BINARY}" -t -c ${REDSOCKS_CONFIG} || return 1
+}
+
+start() {
+        checkconfig || return 1
+
+        ebegin "Starting ${SVCNAME}"
+        start-stop-daemon --start --exec "${REDSOCKS_BINARY}" \
+            -p "${REDSOCKS_PIDFILE}" -c ${REDSOCKS_CONFIG}
+        eend $?
+}
+
+stop() {
+        if [ "${RC_CMD}" = "restart" ] ; then
+                checkconfig || return 1
+        fi
+
+        ebegin "Stopping ${SVCNAME}"
+        start-stop-daemon --stop --exec "${REDSOCKS_BINARY}" \
+            -p "${REDSOCKS_PIDFILE}" -c "${REDSOCKS_CONFIG}"
+        eend $?
+}
+
+reload() {
+        checkconfig || return 1
+
+        ebegin "Reloading ${SVCNAME}"
+        start-stop-daemon --signal HUP --exec "${REDSOCKS_BINARY}" \
+           -p "${REDSOCKS_PIDFILE}" -c "${REDSOCKS_CONFIG}"
+        eend $?
+}
diff --git a/net-proxy/redsocks/files/redsocks.service b/net-proxy/redsocks/files/redsocks.service
new file mode 100644 (file)
index 0000000..db0e9d6
--- /dev/null
@@ -0,0 +1,15 @@
+[Unit]
+Description=Transparent redirector of any TCP connection to proxy using your firewall
+
+[Service]
+Type=forking
+PIDFile=/run/redsocks/redsocks.pid
+User=redsocks
+ExecStartPre=/usr/sbin/redsocks -t -c /etc/redsocks.conf
+ExecStart=/usr/sbin/redsocks -c /etc/redsocks.conf \
+  -p /run/redsocks/redsocks.pid
+ExecStopPost=/bin/rm /run/redsocks/redsocks.pid
+Restart=on-abort
+
+[Install]
+WantedBy=multi-user.target
index bf35bd06d3833f2c14fad63e11ee3f9506dc5562..8f0d16e0c2201a6298dd3e77743bb509cd033c38 100644 (file)
@@ -5,6 +5,21 @@
                <email>mattst88@gentoo.org</email>
                <name>Matt Turner</name>
        </maintainer>
+       <longdescription lang="en">
+               Redirect any TCP connection to a SOCKS or HTTPS proxy server Redsocks
+               is a daemon running on the local system, that will transparently tunnel
+               any TCP connection via a remote SOCKS4, SOCKS5 or HTTP proxy server. It
+               uses the system firewall's redirection facility to intercept TCP
+               connections, thus the redirection is system-wide, with fine-grained
+               control, and does not depend on LD_PRELOAD libraries.
+
+               Redsocks supports tunneling TCP connections and UDP packets. It has
+               authentication support for both, SOCKS and HTTP proxies.
+
+               Also included is a small DNS server returning answers with the
+               "truncated" flag set for any UDP query, forcing the resolver to use
+               TCP.
+       </longdescription>
        <upstream>
                <remote-id type="github">darkk/redsocks</remote-id>
        </upstream>
index 609aff1f957111d7fb16c995b1eedc127086e0fe..984f5b196d5c9d1ea71b3534596548149f9b89d1 100644 (file)
@@ -11,7 +11,7 @@ else
        EGIT_REPO_URI="git://github.com/darkk/${PN}.git"
 fi
 
-inherit toolchain-funcs ${GIT_ECLASS}
+inherit systemd toolchain-funcs user ${GIT_ECLASS}
 
 DESCRIPTION="Transparent redirector of any TCP connection to proxy"
 HOMEPAGE="http://darkk.net.ru/redsocks/"
@@ -25,13 +25,24 @@ RDEPEND="${DEPEND}
 
 [[ ${PV} != *9999 ]] && S="${WORKDIR}"/"${PN}"-release-"${PV}"
 
+pkg_setup() {
+       enewgroup redsocks
+       enewuser redsocks -1 -1 /run/redsocks redsocks
+}
+
 src_compile() {
        CC="$(tc-getCC)" emake || die "emake failed"
 }
 
 src_install() {
-       dobin redsocks
+       dosbin redsocks
+       doman debian/redsocks.8
        use doc && dodoc README doc/*
-       insinto /etc/redsocks
-       newins redsocks.conf.example redsocks.conf
+       insinto /etc
+       newins debian/redsocks.conf redsocks.conf
+
+       newinitd "${FILESDIR}"/redsocks.init redsocks
+       newconfd "${FILESDIR}"/redsocks.conf redsocks
+
+       systemd_dounit "${FILESDIR}"/redsocks.service
 }
index 609aff1f957111d7fb16c995b1eedc127086e0fe..984f5b196d5c9d1ea71b3534596548149f9b89d1 100644 (file)
@@ -11,7 +11,7 @@ else
        EGIT_REPO_URI="git://github.com/darkk/${PN}.git"
 fi
 
-inherit toolchain-funcs ${GIT_ECLASS}
+inherit systemd toolchain-funcs user ${GIT_ECLASS}
 
 DESCRIPTION="Transparent redirector of any TCP connection to proxy"
 HOMEPAGE="http://darkk.net.ru/redsocks/"
@@ -25,13 +25,24 @@ RDEPEND="${DEPEND}
 
 [[ ${PV} != *9999 ]] && S="${WORKDIR}"/"${PN}"-release-"${PV}"
 
+pkg_setup() {
+       enewgroup redsocks
+       enewuser redsocks -1 -1 /run/redsocks redsocks
+}
+
 src_compile() {
        CC="$(tc-getCC)" emake || die "emake failed"
 }
 
 src_install() {
-       dobin redsocks
+       dosbin redsocks
+       doman debian/redsocks.8
        use doc && dodoc README doc/*
-       insinto /etc/redsocks
-       newins redsocks.conf.example redsocks.conf
+       insinto /etc
+       newins debian/redsocks.conf redsocks.conf
+
+       newinitd "${FILESDIR}"/redsocks.init redsocks
+       newconfd "${FILESDIR}"/redsocks.conf redsocks
+
+       systemd_dounit "${FILESDIR}"/redsocks.service
 }