network/redir: Added (Redirect TCP connections).

Signed-off-by: Matteo Bernardini <ponce@slackbuilds.org>
This commit is contained in:
Matteo Bernardini 2013-07-25 12:23:52 +02:00 committed by Willy Sudiarto Raharjo
parent 15498860e5
commit 9f0af0e072
17 changed files with 919 additions and 0 deletions

3
network/redir/README Normal file
View file

@ -0,0 +1,3 @@
redir is all you need to redirect traffic across firewalls.
The functionality of inetd/tcpd and "redir" will allow you to
do everything you need without screwy telnet/ftp etc gateways.

View file

@ -0,0 +1,61 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 01_fix_max_bandwidth_docs.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix docs and --help to show --max_bandwidth instead of --maxbandwidth
@DPATCH@
diff -urNad redir-2.2.1~/redir.c redir-2.2.1/redir.c
--- redir-2.2.1~/redir.c 1999-12-26 15:50:06.000000000 -0500
+++ redir-2.2.1/redir.c 2005-10-22 21:21:56.849499952 -0400
@@ -233,7 +233,7 @@
#ifndef NO_SHAPER
/* options for bandwidth */
fprintf(stderr, "\t\t--bufsize=<octets>\tsize of the buffer\n");
- fprintf(stderr, "\t\t--maxbandwidth=<bit-per-sec>\tlimit the bandwidth\n");
+ fprintf(stderr, "\t\t--max_bandwidth=<bit-per-sec>\tlimit the bandwidth\n");
fprintf(stderr, "\t\t--random_wait=<millisec>\twait before each packet\n");
fprintf(stderr, "\t\t--wait_in_out=<flag>\t1 wait for in, 2 out, 3 in&out\n");
/* end options for bandwidth */
diff -urNad redir-2.2.1~/redir.man redir-2.2.1/redir.man
--- redir-2.2.1~/redir.man 1999-12-26 15:52:24.000000000 -0500
+++ redir-2.2.1/redir.man 2005-10-22 21:22:28.882630176 -0400
@@ -18,7 +18,7 @@
.I --lport=port
.I --cport=port
.RB [ \--bufsize=n ]
-.RB [ \--maxbandwidth=n ]
+.RB [ \--max_bandwidth=n ]
.RB [ \--random_wait=n ]
.RB [ \--wait_in_out=n ]
.ll -8
@@ -35,7 +35,7 @@
.RB [ \--connect=host:port ]
.I --cport=port
.RB [ \--bufsize=n ]
-.RB [ \--maxbandwidth=n ]
+.RB [ \--max_bandwidth=n ]
.RB [ \--random_wait=n ]
.RB [ \--wait_in_out=n ]
.ll -8
@@ -102,9 +102,9 @@
.TP
.B \--bufsize n
Set the bufsize (defaut 4096) in bytes. Can be used combined with
---maxbandwidth or --random_wait to simulate a slow connection.
+--max_bandwidth or --random_wait to simulate a slow connection.
.TP
-.B \--maxbandwidth n
+.B \--max_bandwidth n
Reduce the bandwidth to be no more than n bits/sec. The algorithme is
basic, the goal is to simulate a slow connection, so there is no pic
acceptance.
@@ -115,7 +115,7 @@
than the bufsize (see also --bufsize).
.TP
.B \--wait_in_out n
-Apply --maxbandwidth and --random_wait for input if n=1, output if n=2 and
+Apply --max_bandwidth and --random_wait for input if n=1, output if n=2 and
both if n=3.
.SH "SEE ALSO"
inetd(1)

View file

@ -0,0 +1,50 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 02_use_ntohs.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: use ntohs() to generate comprehensible debug()s and syslog()s.
@DPATCH@
diff -urNad redir-2.2.1~/redir.c redir-2.2.1/redir.c
--- redir-2.2.1~/redir.c 1999-12-26 15:50:06.000000000 -0500
+++ redir-2.2.1/redir.c 2005-10-22 21:29:55.491735272 -0400
@@ -745,7 +745,7 @@
}
debug1("peer IP is %s\n", inet_ntoa(client.sin_addr));
- debug1("peer socket is %d\n", client.sin_port);
+ debug1("peer socket is %d\n", ntohs(client.sin_port));
/*
* Double fork here so we don't have to wait later
@@ -871,8 +871,8 @@
strcpy(tmp2, inet_ntoa(target->sin_addr));
syslog(LOG_NOTICE, "connecting %s/%d to %s/%d",
- tmp1, client.sin_port,
- tmp2, target->sin_port);
+ tmp1, ntohs(client.sin_port),
+ tmp2, ntohs(target->sin_port));
}
/* do proxy stuff */
@@ -1066,7 +1066,7 @@
if (!getpeername(0, (struct sockaddr *) &client, &client_size)) {
debug1("peer IP is %s\n", inet_ntoa(client.sin_addr));
- debug1("peer socket is %d\n", client.sin_port);
+ debug1("peer socket is %d\n", ntohs(client.sin_port));
}
if ((targetsock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
perror("target: socket");
@@ -1109,8 +1109,8 @@
if (dosyslog) {
syslog(LOG_NOTICE, "connecting %s/%d to %s/%d",
- inet_ntoa(client.sin_addr), client.sin_port,
- target_ip, target.sin_port);
+ inet_ntoa(client.sin_addr), ntohs(client.sin_port),
+ target_ip, ntohs(target.sin_port));
}
/* Just start copying - one side of the loop is stdin - 0 */

View file

@ -0,0 +1,32 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 03_fix_tcp_wrappers.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: fix calls to tcp wrappers
@DPATCH@
diff -urNad redir-2.2.1~/redir.c redir-2.2.1/redir.c
--- redir-2.2.1~/redir.c 2005-10-22 22:10:11.439455392 -0400
+++ redir-2.2.1/redir.c 2005-10-22 22:10:51.625346208 -0400
@@ -802,8 +802,8 @@
#ifdef USE_TCP_WRAPPERS
request_init(&request, RQ_DAEMON, ident, RQ_FILE, clisock, 0);
sock_host(&request);
- sock_hostname(&request);
- sock_hostaddr(&request);
+ sock_hostname(request.client);
+ sock_hostaddr(request.client);
if (!hosts_access(&request)) {
refuse(&request);
@@ -1057,8 +1057,8 @@
#ifdef USE_TCP_WRAPPERS
request_init(&request, RQ_DAEMON, ident, RQ_FILE, 0, 0);
sock_host(&request);
- sock_hostname(&request);
- sock_hostaddr(&request);
+ sock_hostname(request.client);
+ sock_hostaddr(request.client);
if (!hosts_access(&request))
refuse(&request);

View file

@ -0,0 +1,45 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 04_fix_timeouts.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Apply a close approximation of Robert de Bath's patch for bug #142382
@DPATCH@
diff -urNad redir-2.2.1~/redir.c redir-2.2.1/redir.c
--- redir-2.2.1~/redir.c 2005-10-22 22:44:39.504061784 -0400
+++ redir-2.2.1/redir.c 2005-10-22 22:47:14.746461352 -0400
@@ -598,10 +598,6 @@
/* Record start time */
start_time = (unsigned int) time(NULL);
- /* Set up timeout */
- timeout.tv_sec = timeout_secs;
- timeout.tv_usec = 0;
-
/* file descriptor bits */
FD_ZERO(&iofds);
FD_SET(insock, &iofds);
@@ -618,14 +614,21 @@
while(1) {
(void) memcpy(&c_iofds, &iofds, sizeof(iofds));
+ /* Set up timeout, Linux returns seconds left in this structure
+ * so we have to reset it before each select(). */
+ timeout.tv_sec = timeout_secs;
+ timeout.tv_usec = 0;
+
if (select(max_fd + 1,
&c_iofds,
(fd_set *)0,
(fd_set *)0,
(timeout_secs ? &timeout : NULL)) <= 0) {
- /* syslog(LLEV,"connection timeout: %d sec",timeout.tv_sec);*/
- break;
+ if (dosyslog) {
+ syslog(LOG_NOTICE,"connection timeout: %d sec",timeout_secs);
+ }
+ break;
}
if(FD_ISSET(insock, &c_iofds)) {

View file

@ -0,0 +1,183 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 05_pedantic.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: changes to make clean up compilation
@DPATCH@
diff -urNad redir-2.2.1~/Makefile redir-2.2.1/Makefile
--- redir-2.2.1~/Makefile 2005-10-22 23:11:41.000000000 -0400
+++ redir-2.2.1/Makefile 2005-10-22 23:11:48.818368360 -0400
@@ -32,7 +32,7 @@
# if your system lacks getopt_long, remove the comment from this line
OBJS = redir.o $(GETOPT_OBJS)
-CFLAGS = -O2 -Wall $(STR_CFLAGS) $(WRAP_CFLAGS) $(EXTRA_CFLAGS)
+CFLAGS = -O2 -Wall --pedantic $(STR_CFLAGS) $(WRAP_CFLAGS) $(EXTRA_CFLAGS)
LDFLAGS = -s
# solaris, and others, may also need these libraries to link
diff -urNad redir-2.2.1~/redir.c redir-2.2.1/redir.c
--- redir-2.2.1~/redir.c 2005-10-22 23:11:48.282449832 -0400
+++ redir-2.2.1/redir.c 2005-10-22 23:12:23.201141384 -0400
@@ -73,6 +73,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
+#include <time.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -460,7 +461,7 @@
int lport, rport;
int remip[4];
int localsock;
- int socksize = sizeof(struct sockaddr_in);
+ size_t socksize = sizeof(struct sockaddr_in);
struct sockaddr_in newsession;
struct sockaddr_in sockname;
@@ -509,7 +510,7 @@
if(getsockname(localsock, (struct sockaddr *)&sockname, &socksize) < 0) {
perror("getsockname");
if (dosyslog)
- syslog(LOG_ERR, "getsockname failed: %m");
+ syslog(LOG_ERR, "getsockname failed: %s",strerror(errno));
exit(1);
}
@@ -562,7 +563,7 @@
switch(fork())
{
case -1: /* Error */
- syslog(LOG_ERR, "Couldn't fork: %m");
+ syslog(LOG_ERR, "Couldn't fork: %s",strerror(errno));
_exit(1);
case 0: /* Child */
{
@@ -723,7 +724,7 @@
int clisock;
int targetsock;
struct sockaddr_in client;
- int clientlen = sizeof(client);
+ size_t clientlen = sizeof(client);
int accept_errno;
debug("top of accept loop\n");
@@ -734,7 +735,7 @@
perror("server: accept");
if (dosyslog)
- syslog(LOG_ERR, "accept failed: %m");
+ syslog(LOG_ERR, "accept failed: %s",strerror(errno));
/* determine if this error is fatal */
switch(accept_errno) {
@@ -768,7 +769,7 @@
perror("(server) fork");
if (dosyslog)
- syslog(LOG_ERR, "(server) fork failed: %m");
+ syslog(LOG_ERR, "(server) fork failed: %s",strerror(errno));
_exit(1);
case 0: /* Child */
@@ -795,7 +796,7 @@
perror("(child) fork");
if (dosyslog)
- syslog(LOG_ERR, "(child) fork failed: %m");
+ syslog(LOG_ERR, "(child) fork failed: %s",strerror(errno));
_exit(1);
case 0: /* Child */
@@ -826,7 +827,7 @@
perror("target: socket");
if (dosyslog)
- syslog(LOG_ERR, "socket failed: %m");
+ syslog(LOG_ERR, "socket failed: %s",strerror(errno));
_exit(1);
}
@@ -850,7 +851,7 @@
only be different if the input value is 0 (let the system pick a
port) */
if (dosyslog)
- syslog(LOG_ERR, "bind failed: %m");
+ syslog(LOG_ERR, "bind failed: %s",strerror(errno));
_exit(1);
}
@@ -862,7 +863,7 @@
perror("target: connect");
if (dosyslog)
- syslog(LOG_ERR, "bind failed: %m");
+ syslog(LOG_ERR, "bind failed: %s",strerror(errno));
_exit(1);
}
@@ -923,7 +924,7 @@
perror("server: socket");
if (dosyslog)
- syslog(LOG_ERR, "socket failed: %m");
+ syslog(LOG_ERR, "socket failed: %s",strerror(errno));
exit(1);
}
@@ -962,7 +963,7 @@
perror("server: bind");
if (dosyslog)
- syslog(LOG_ERR, "bind failed: %m");
+ syslog(LOG_ERR, "bind failed: %s",strerror(errno));
exit(1);
}
@@ -980,7 +981,7 @@
perror("server: listen");
if (dosyslog)
- syslog(LOG_ERR, "listen failed: %m");
+ syslog(LOG_ERR, "listen failed: %s",strerror(errno));
exit(1);
}
@@ -1059,7 +1060,7 @@
if (inetd) {
int targetsock;
struct sockaddr_in client;
- int client_size = sizeof(client);
+ size_t client_size = sizeof(client);
#ifdef USE_TCP_WRAPPERS
request_init(&request, RQ_DAEMON, ident, RQ_FILE, 0, 0);
@@ -1079,7 +1080,7 @@
perror("target: socket");
if (dosyslog)
- syslog(LOG_ERR, "targetsock failed: %m");
+ syslog(LOG_ERR, "targetsock failed: %s",strerror(errno));
exit(1);
}
@@ -1097,7 +1098,7 @@
perror("bind_addr: cannot bind to forcerd outgoing addr");
if (dosyslog)
- syslog(LOG_ERR, "bind failed: %m");
+ syslog(LOG_ERR, "bind failed: %s",strerror(errno));
exit(1);
}
@@ -1109,7 +1110,7 @@
perror("target: connect");
if (dosyslog)
- syslog(LOG_ERR, "connect failed: %m");
+ syslog(LOG_ERR, "connect failed: %s",strerror(errno));
exit(1);
}

View file

@ -0,0 +1,63 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 06_fix_shaper_buffer.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: properly allocate copyloop buffer
@DPATCH@
diff -urNad redir-2.2.1~/redir.c redir-2.2.1/redir.c
--- redir-2.2.1~/redir.c 2005-10-22 23:20:05.235901424 -0400
+++ redir-2.2.1/redir.c 2005-10-22 23:22:20.198384008 -0400
@@ -260,7 +260,7 @@
#endif
int *transproxy,
#ifndef NO_SHAPER
- unsigned int * bufsize,
+ unsigned int * bufsizeout,
int * max_bandwidth,
int * random_wait,
int * wait_in_out,
@@ -367,7 +367,7 @@
#ifndef NO_SHAPER
case 'z':
- *bufsize = (unsigned int)atol(optarg);
+ *bufsizeout = (unsigned int)atol(optarg);
break;
case 'm':
@@ -594,7 +594,7 @@
unsigned long bytes_in = 0;
unsigned long bytes_out = 0;
unsigned int start_time, end_time;
- char buf[bufsize];
+ char* buf = malloc(bufsize);
/* Record start time */
start_time = (unsigned int) time(NULL);
@@ -637,7 +637,7 @@
}
if(FD_ISSET(insock, &c_iofds)) {
- if((bytes = read(insock, buf, sizeof(buf))) <= 0)
+ if((bytes = read(insock, buf, bufsize)) <= 0)
break;
#ifndef NO_FTP
if (ftp & FTP_PORT)
@@ -652,7 +652,7 @@
bytes_out += bytes;
}
if(FD_ISSET(outsock, &c_iofds)) {
- if((bytes = read(outsock, buf, sizeof(buf))) <= 0)
+ if((bytes = read(outsock, buf, bufsize)) <= 0)
break;
/* if we're correcting for PASV on ftp redirections, then
fix buf and bytes to have the new address, among other
@@ -689,6 +689,7 @@
syslog(LOG_NOTICE, "disconnect %d secs, %ld in %ld out",
(end_time - start_time), bytes_in, bytes_out);
}
+ free(buf);
return;
}

View file

@ -0,0 +1,28 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 07_cosmetics.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Cosmetic fixes which could be applied upstream
@DPATCH@
diff -urNad redir-2.2.1~/redir.man redir-2.2.1/redir.man
--- redir-2.2.1~/redir.man 2005-10-22 21:41:51.284918168 -0400
+++ redir-2.2.1/redir.man 2005-10-22 21:42:42.115190792 -0400
@@ -73,7 +73,7 @@
Specify program name to be used for TCP wrapper checks and syslog logging.
.TP
.B --timeout
-Timeout and close the connection after n seconds on inactivity.
+Timeout and close the connection after n seconds of inactivity.
.TP
.B \--syslog
Log information to syslog.
@@ -90,7 +90,7 @@
undesirable.
.TP
.B \--transproxy
-On a linux system with transparany proxying enables, causes redir to
+On a linux system with transparent proxying enabled, causes redir to
make connections appear as if they had come from their true origin.
(see transproxy.txt in the source archive)
.TP

View file

@ -0,0 +1,22 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 08_add_wrappers.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Enabling TCP wrapper support
@DPATCH@
--- redir-2.2.1.orig/Makefile
+++ redir-2.2.1/Makefile
@@ -9,8 +9,8 @@
# if you would like support for TCP wrappers (and have libwrap.a
# installed), remove these comments.
-WRAP_CFLAGS = # -DUSE_TCP_WRAPPERS
-WRAP_LIBS = # -lwrap
+WRAP_CFLAGS = -DUSE_TCP_WRAPPERS
+WRAP_LIBS = -lwrap
# if your system needs any additional libraries (solaris, for example,
# needs the ones commented out below), edit this line.

View file

@ -0,0 +1,23 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 09_add_linux_software_map.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Add linux software map file
@DPATCH@
--- redir-2.2.1.orig/redir-2.2.lsm
+++ redir-2.2.1/redir-2.2.lsm
@@ -0,0 +1,11 @@
+Begin3
+Title: redir
+Version: 2.2
+Entered-date: 15DEC1999
+Description: TCP Port redirector (for firewalls etc).
+Keywords: tcp port redirector bouncer proxy
+Author: sammy@oh.verio.com
+Primary-site: sunsite.unc.edu /pub/Linux/system/Network/daemons
+ 39936 redir-2.2.tar.gz
+Copying-policy: GPL
+End

View file

@ -0,0 +1,19 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 15_deb_cosmetics.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Cosmetic changes applicable only to debian
@DPATCH@
diff -urNad redir-2.2.1~/redir.man redir-2.2.1/redir.man
--- redir-2.2.1~/redir.man 2005-10-22 21:47:44.067287096 -0400
+++ redir-2.2.1/redir.man 2005-10-22 21:48:34.218662928 -0400
@@ -92,7 +92,7 @@
.B \--transproxy
On a linux system with transparent proxying enabled, causes redir to
make connections appear as if they had come from their true origin.
-(see transproxy.txt in the source archive)
+(see /usr/share/doc/redir/transproxy.txt)
.TP
.B \--connect
Redirects connections through an HTTP proxy which supports the CONNECT

View file

@ -0,0 +1,19 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 20_do_not_strip.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: don't strip by default. let dh_strip take care of it.
@DPATCH@
diff -urNad redir-2.2.1~/Makefile redir-2.2.1/Makefile
--- redir-2.2.1~/Makefile 2007-08-15 14:53:41.908911693 -0400
+++ redir-2.2.1/Makefile 2007-08-15 14:53:59.409909018 -0400
@@ -33,7 +33,7 @@
OBJS = redir.o $(GETOPT_OBJS)
CFLAGS = -O2 -Wall --pedantic $(STR_CFLAGS) $(WRAP_CFLAGS) $(EXTRA_CFLAGS)
-LDFLAGS = -s
+LDFLAGS = # -s
# solaris, and others, may also need these libraries to link
# also edit here if you're using the TCP wrappers code

View file

@ -0,0 +1,62 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 25_fix_setsockopt.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Ensure that the server socket has SO_REUSEADDR and SO_LINGER set properly.
@DPATCH@
diff -urNad redir~/redir.c redir/redir.c
--- redir~/redir.c 2009-03-03 17:35:12.022427586 -0500
+++ redir/redir.c 2009-03-03 17:45:28.998426896 -0500
@@ -90,8 +90,8 @@
/* let's set up some globals... */
int dodebug = 0;
int dosyslog = 0;
-unsigned char reuse_addr = 1;
-unsigned char linger_opt = 0;
+int reuse_addr = 1; /* allow address reuse */
+struct linger linger_opt = { 0, 0}; /* do not linger */
char * bind_addr = NULL;
struct sockaddr_in addr_out;
int timeout = 0;
@@ -906,6 +906,7 @@
int servsock;
struct sockaddr_in server;
+ int ret;
/*
* Get a socket to work with. This socket will
@@ -944,8 +945,30 @@
server.sin_addr.s_addr = htonl(inet_addr("0.0.0.0"));
}
- setsockopt(servsock, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr));
- setsockopt(servsock, SOL_SOCKET, SO_LINGER, &linger_opt, sizeof(SO_LINGER));
+ ret = setsockopt(servsock, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr));
+ if (ret != 0) {
+ if(fail) {
+ return -1;
+ }
+ else {
+ perror("server: setsockopt (SO_REUSEADDR)");
+ if (dosyslog)
+ syslog(LOG_ERR, "setsockopt failed with SO_REUSEADDR: %s",strerror(errno));
+ exit(1);
+ }
+ }
+ ret = setsockopt(servsock, SOL_SOCKET, SO_LINGER, &linger_opt, sizeof(linger_opt));
+ if (ret != 0) {
+ if(fail) {
+ return -1;
+ }
+ else {
+ perror("server: setsockopt (SO_LINGER)");
+ if (dosyslog)
+ syslog(LOG_ERR, "setsockopt failed with SO_LINGER: %s",strerror(errno));
+ exit(1);
+ }
+ }
/*
* Try to bind the address to the socket.

View file

@ -0,0 +1,183 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 30_fix_manpage.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Clean up questionable formatting in man page.
@DPATCH@
diff -urNad redir~/redir.man redir/redir.man
--- redir~/redir.man 2009-03-03 18:55:37.790428922 -0500
+++ redir/redir.man 2009-03-03 18:58:48.486428715 -0500
@@ -1,43 +1,42 @@
-.PU
.TH REDIR 1 local
.SH NAME
-redir \- redirect tcp connections
+redir - redirect tcp connections
.SH SYNOPSIS
.ll +8
.B redir
-.RB [ \--laddr=incoming.ip.address ]
-.RB [ \--caddr=host ]
-.RB [ \--debug ]
-.RB [ \--syslog
-.RB [ \--name=str ]
-.RB [ \--timeout=n ]
-.RB [ \--bind_addr=my.other.ip.address ]
-.RB [ \--ftp=type ]
-.RB [ \--transproxy ]
-.RB [ \--connect=host:port ]
-.I --lport=port
-.I --cport=port
-.RB [ \--bufsize=n ]
-.RB [ \--max_bandwidth=n ]
-.RB [ \--random_wait=n ]
-.RB [ \--wait_in_out=n ]
+.RB [ \-\-laddr=incoming.ip.address ]
+.RB [ \-\-caddr=host ]
+.RB [ \-\-debug ]
+.RB [ \-\-syslog ]
+.RB [ \-\-name=str ]
+.RB [ \-\-timeout=n ]
+.RB [ \-\-bind_addr=my.other.ip.address ]
+.RB [ \-\-ftp=type ]
+.RB [ \-\-transproxy ]
+.RB [ \-\-connect=host:port ]
+.I \-\-lport=port
+.I \-\-cport=port
+.RB [ \-\-bufsize=n ]
+.RB [ \-\-max_bandwidth=n ]
+.RB [ \-\-random_wait=n ]
+.RB [ \-\-wait_in_out=n ]
.ll -8
.br
.B redir
-.RB \--inetd
-.RB [ \--caddr=host ]
-.RB [ \--debug ]
-.RB [ \--syslog
-.RB [ \--name=str ]
-.RB [ \--timeout=n ]
-.RB [ \--ftp=type ]
-.RB [ \--transproxy ]
-.RB [ \--connect=host:port ]
-.I --cport=port
-.RB [ \--bufsize=n ]
-.RB [ \--max_bandwidth=n ]
-.RB [ \--random_wait=n ]
-.RB [ \--wait_in_out=n ]
+.RB \-\-inetd
+.RB [ \-\-caddr=host ]
+.RB [ \-\-debug ]
+.RB [ \-\-syslog ]
+.RB [ \-\-name=str ]
+.RB [ \-\-timeout=n ]
+.RB [ \-\-ftp=type ]
+.RB [ \-\-transproxy ]
+.RB [ \-\-connect=host:port ]
+.I \-\-cport=port
+.RB [ \-\-bufsize=n ]
+.RB [ \-\-max_bandwidth=n ]
+.RB [ \-\-random_wait=n ]
+.RB [ \-\-wait_in_out=n ]
.ll -8
.br
.SH DESCRIPTION
@@ -49,74 +48,73 @@
Depending on how redir was compiled, not all options may be available.
.SH OPTIONS
.TP
-.B \--lport
+.B \-\-lport
Specifies port to listen for connections on (when not running from inetd)
.TP
-.B \--laddr
+.B \-\-laddr
IP address to bind to when listening for connections (when not
running from inetd)
.TP
-.B \--cport
+.B \-\-cport
Specifies port to connect to.
.TP
-.B \--caddr
+.B \-\-caddr
Specifies remote host to connect to. (localhost if omitted)
.TP
-.B \--inetd
+.B \-\-inetd
Run as a process started from inetd, with the connection passed as stdin
and stdout on startup.
.TP
-.B \--debug
+.B \-\-debug
Write debug output to stderr or syslog.
.TP
-.B \--name
+.B \-\-name
Specify program name to be used for TCP wrapper checks and syslog logging.
.TP
-.B --timeout
+.B \-\-timeout
Timeout and close the connection after n seconds of inactivity.
.TP
-.B \--syslog
+.B \-\-syslog
Log information to syslog.
.TP
-.B \--bind_addr
+.B \-\-bind_addr
Forces redir to pick a specific address/interface to bind to when it listens
for incoming connections.
.TP
-.B \--ftp
+.B \-\-ftp
When using redir for an FTP server, this will cause redir to also
redirect ftp connections. Type should be specified as either "port",
"pasv", or "both", to specify what type of FTP connection to handle.
-Note that --transproxy often makes one or the other (generally port)
+Note that \-\-transproxy often makes one or the other (generally port)
undesirable.
.TP
-.B \--transproxy
+.B \-\-transproxy
On a linux system with transparent proxying enabled, causes redir to
make connections appear as if they had come from their true origin.
(see /usr/share/doc/redir/transproxy.txt)
.TP
-.B \--connect
+.B \-\-connect
Redirects connections through an HTTP proxy which supports the CONNECT
-command. Specify the address and port of the proxy using --caddr and
---cport. --connect requires the hostname and port which the HTTP
+command. Specify the address and port of the proxy using \-\-caddr and
+\-\-cport. \-\-connect requires the hostname and port which the HTTP
proxy will be asked to connect to.
.TP
-.B \--bufsize n
+.B \-\-bufsize n
Set the bufsize (defaut 4096) in bytes. Can be used combined with
---max_bandwidth or --random_wait to simulate a slow connection.
+\-\-max_bandwidth or \-\-random_wait to simulate a slow connection.
.TP
-.B \--max_bandwidth n
+.B \-\-max_bandwidth n
Reduce the bandwidth to be no more than n bits/sec. The algorithme is
basic, the goal is to simulate a slow connection, so there is no pic
acceptance.
.TP
-.B \--random_wait n
+.B \-\-random_wait n
Wait between 0 and 2 x n milliseconds before each "packet". A "packet" is
a bloc of data read in one time by redir. A "packet" size is always less
-than the bufsize (see also --bufsize).
+than the bufsize (see also \-\-bufsize).
.TP
-.B \--wait_in_out n
-Apply --max_bandwidth and --random_wait for input if n=1, output if n=2 and
+.B \-\-wait_in_out n
+Apply \-\-max_bandwidth and \-\-random_wait for input if n=1, output if n=2 and
both if n=3.
.SH "SEE ALSO"
inetd(1)
-

View file

@ -0,0 +1,97 @@
#!/bin/sh
# Slackware build script for redir
# Copyright 2013 Matteo Bernardini <ponce@slackbuilds.org>, Pisa, Italy
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PRGNAM=redir
VERSION=${VERSION:-2.2.1}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
DOCS="CHANGES COPYING README contrib transproxy.txt"
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.?z*
cd $PRGNAM-$VERSION
chown -R root:root .
find . \
\( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
-exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
for i in $CWD/patches/* ; do patch -p1 < $i ; done
sed -i "s|^EXTRA_LIBS.*|EXTRA_LIBS = -lnsl|" Makefile
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
make
install -D -m 0755 $PRGNAM $PKG/usr/bin/$PRGNAM
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
mkdir -p $PKG/usr/man/man1
gzip -9c $PRGNAM.man > $PKG/usr/man/man1/$PRGNAM.1.gz
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}

10
network/redir/redir.info Normal file
View file

@ -0,0 +1,10 @@
PRGNAM="redir"
VERSION="2.2.1"
HOMEPAGE="http://sammy.net/~sammy/hacks/"
DOWNLOAD="http://sammy.net/~sammy/hacks/redir-2.2.1.tar.gz"
MD5SUM="4342fadac30504c86c8db7beefe01995"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES=""
MAINTAINER="Matteo Bernardini"
EMAIL="ponce@slackbuilds.org"

19
network/redir/slack-desc Normal file
View file

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
redir: redir (Redirect TCP connections)
redir:
redir: redir is all you need to redirect traffic across firewalls.
redir: The functionality of inetd/tcpd and "redir" will allow you to
redir: do everything you need without screwy telnet/ftp etc gateways.
redir:
redir: homepage: http://sammy.net/~sammy/hacks/
redir:
redir:
redir:
redir: