1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-20 04:02:27 +00:00

- Add new -b option for outcoming connection binding

PR:		ports/96263 (in follow-up)
Submitted by:	SeaD <sead@mail.ru>
Approved by:	Matt Wilbur <matt@efs.org> (maintainer)
This commit is contained in:
Pav Lucistnik 2006-07-04 14:49:27 +00:00
parent f4212e1cd8
commit b74350bdb3
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=166917
2 changed files with 41 additions and 10 deletions

View File

@ -8,7 +8,7 @@
PORTNAME= bounce
PORTVERSION= 1.0
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= net security
MASTER_SITES= http://www.iagora.com/~espel/ \
${MASTER_SITE_LOCAL}

View File

@ -1,6 +1,35 @@
--- bounce.c.orig Tue May 2 10:14:42 2006
+++ bounce.c Tue May 2 10:16:02 2006
@@ -220,6 +220,7 @@
--- bounce.c.orig Fri Jun 2 12:58:37 2006
+++ bounce.c Fri Jun 2 13:25:28 2006
@@ -138,7 +138,7 @@
}
int main(int argc,char *argv[]) {
- int srv_fd, rem_fd, len, cl_fd, on=1;
+ int srv_fd, rem_fd, len, cl_fd, on=1, b=0;
int myport=DEFAULT_PORT, remoteport;
struct sockaddr_in rem_addr, srv_addr, cl_addr;
char *myname;
@@ -153,8 +153,9 @@
/* Process arguments */
- while( (ch = getopt(argc, argv, "p:a:")) != -1 ) {
+ while( (ch = getopt(argc, argv, "p:a:b:")) != -1 ) {
switch(ch) {
+ case 'b': b = 1;
case 'a':
hostname = malloc( strlen(optarg) + 1);
if( !hostname ) {
@@ -177,7 +178,7 @@
argv += optind;
if (argc!=2) {
- fprintf(stderr,"Use: %s [-a localaddr] [-p localport] machine port \n",myname);
+ fprintf(stderr,"Use: %s [-a localaddr | -b localaddr] [-p localport] machine port \n",myname);
exit(-1);
}
if ((remoteport=atoi(argv[1]))<=0) {
@@ -220,6 +221,7 @@
exit(-1);
}
listen(srv_fd,QLEN);
@ -8,14 +37,16 @@
signal(SIGCHLD, sigchld);
printf("Ready to bounce connections from port %i to %s on port %i\n",
@@ -252,6 +253,10 @@
default: /* parent process */
close(srv_fd); /* close original socket */
@@ -254,6 +256,12 @@
if ((cl_fd=socket(PF_INET, SOCK_STREAM, 0))<0) {
close(rem_fd);
exit(-1);
+ }
+ if (b) {
+ if (bind(cl_fd,(struct sockaddr *)&srv_addr,sizeof(srv_addr))<0) {
+ close(rem_fd);
+ exit(-1);
+ }
+ if (bind(cl_fd,(struct sockaddr *)&srv_addr,sizeof(srv_addr))<0) {
close(rem_fd);
exit(-1);
}
if (connect(cl_fd, (struct sockaddr *)&cl_addr,
sizeof(cl_addr))<0) {