mirror of
https://github.com/proxytunnel/proxytunnel.git
synced 2026-01-23 02:34:59 +00:00
Moved base64 code to base64.[ch]
More cleanups git-svn-id: https://proxytunnel.svn.sourceforge.net/svnroot/proxytunnel/trunk/proxytunnel@19 bc163920-b10d-0410-b2c5-a5491ca2ceef
This commit is contained in:
parent
e4bb139a97
commit
785411bb8b
7 changed files with 89 additions and 54 deletions
2
CHANGES
2
CHANGES
|
|
@ -6,6 +6,8 @@ Changes to proxytunnel version 1.1.0 -- Sat Apr 20 16:00:00 CET 2002
|
|||
port and forwarding these connections through the specified
|
||||
proxy/tunnel.
|
||||
|
||||
- Forked base64 encoding code to base64.[ch] file
|
||||
|
||||
Changes to proxytunnel version 1.0.8 -- Fri Apr 19 10:25:00 CET 2002
|
||||
|
||||
- Fixed help-text when system doesn't support long-options
|
||||
|
|
|
|||
3
Makefile
3
Makefile
|
|
@ -13,7 +13,8 @@ INSTALLPATH = /usr/local/bin
|
|||
|
||||
PROGNAME = proxytunnel
|
||||
OBJ = proxytunnel.o \
|
||||
cmdline.o
|
||||
base64.o \
|
||||
cmdline.o
|
||||
|
||||
proxytunnel: $(OBJ)
|
||||
$(CC) -o $(PROGNAME) $(LDFLAGS) $(OBJ)
|
||||
|
|
|
|||
74
base64.c
Normal file
74
base64.c
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/* Proxytunnel - (C) 2001-2002 Jos Visser / Mark Janssen */
|
||||
/* Contact: josv@osp.nl / maniac@maniac.nl */
|
||||
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "config.h"
|
||||
#include "cmdline.h"
|
||||
#include "base64.h"
|
||||
|
||||
/* Needed for base64 encoding... */
|
||||
static const char base64digits[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
/*
|
||||
* Small MAX macro
|
||||
*/
|
||||
#ifndef MAX
|
||||
#define MAX( x, y ) ( ( (x)>(y) ) ? (x) : (y) )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This base64 code is heavily modified from fetchmail (also GPL'd, of
|
||||
* course) by Brendan Cully <brendan@kublai.com>.
|
||||
*
|
||||
* Original copyright notice:
|
||||
*
|
||||
* The code in the fetchmail distribution is Copyright 1997 by Eric
|
||||
* S. Raymond. Portions are also copyrighted by Carl Harris, 1993
|
||||
* and 1995. Copyright retained for the purpose of protecting free
|
||||
* redistribution of source.
|
||||
*
|
||||
*/
|
||||
|
||||
/* raw bytes to null-terminated base 64 string */
|
||||
void base64(unsigned char *out, const unsigned char *in, int len)
|
||||
{
|
||||
while (len >= 3) {
|
||||
*out++ = base64digits[in[0] >> 2];
|
||||
*out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
|
||||
*out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
|
||||
*out++ = base64digits[in[2] & 0x3f];
|
||||
len -= 3;
|
||||
in += 3;
|
||||
}
|
||||
|
||||
/* clean up remainder */
|
||||
if (len > 0) {
|
||||
unsigned char fragment;
|
||||
|
||||
*out++ = base64digits[in[0] >> 2];
|
||||
fragment = (in[0] << 4) & 0x30;
|
||||
if (len > 1)
|
||||
fragment |= in[1] >> 4;
|
||||
*out++ = base64digits[fragment];
|
||||
*out++ = (len < 2) ? '=' : base64digits[(in[1] << 2) & 0x3c];
|
||||
*out++ = '=';
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
5
base64.h
Normal file
5
base64.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/* Proxytunnel base64.h */
|
||||
|
||||
void base64(unsigned char *out, const unsigned char *in, int len);
|
||||
char basicauth[80]; /* Buffer to hold the proxies basic authentication data */
|
||||
|
||||
2
config.h
2
config.h
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define VERSION "1.0.8"
|
||||
#define VERSION "1.1.0"
|
||||
#define PACKAGE "Proxytunnel"
|
||||
#define PURPOSE "Build generic tunnels through HTTPS proxies"
|
||||
#define AUTHORS "Jos Visser (Muppet) <josv@osp.nl>, Mark Janssen (Maniac) <maniac@maniac.nl>"
|
||||
|
|
|
|||
BIN
proxytunnel
BIN
proxytunnel
Binary file not shown.
|
|
@ -34,10 +34,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "cmdline.h"
|
||||
|
||||
/* Needed for base64 encoding... */
|
||||
static const char base64digits[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
#include "base64.h"
|
||||
|
||||
/*
|
||||
* Some variables
|
||||
|
|
@ -54,11 +51,8 @@ int i_am_daemon; /* Also... */
|
|||
*/
|
||||
struct gengetopt_args_info args_info;
|
||||
|
||||
#define SIZE 80
|
||||
char basicauth[SIZE]; /* Buffer to hold the proxies basic authentication data */
|
||||
|
||||
#define SIZE2 65536
|
||||
char buf[SIZE2]; /* Data transfer buffer */
|
||||
#define SIZE 65536
|
||||
char buf[SIZE]; /* Data transfer buffer */
|
||||
|
||||
/*
|
||||
* Small MAX macro
|
||||
|
|
@ -110,47 +104,6 @@ void signal_handler( int signal )
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* This base64 code is heavily modified from fetchmail (also GPL'd, of
|
||||
* course) by Brendan Cully <brendan@kublai.com>.
|
||||
*
|
||||
* Original copyright notice:
|
||||
*
|
||||
* The code in the fetchmail distribution is Copyright 1997 by Eric
|
||||
* S. Raymond. Portions are also copyrighted by Carl Harris, 1993
|
||||
* and 1995. Copyright retained for the purpose of protecting free
|
||||
* redistribution of source.
|
||||
*
|
||||
*/
|
||||
|
||||
/* raw bytes to null-terminated base 64 string */
|
||||
void base64(unsigned char *out, const unsigned char *in, int len)
|
||||
{
|
||||
while (len >= 3) {
|
||||
*out++ = base64digits[in[0] >> 2];
|
||||
*out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
|
||||
*out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
|
||||
*out++ = base64digits[in[2] & 0x3f];
|
||||
len -= 3;
|
||||
in += 3;
|
||||
}
|
||||
|
||||
/* clean up remainder */
|
||||
if (len > 0) {
|
||||
unsigned char fragment;
|
||||
|
||||
*out++ = base64digits[in[0] >> 2];
|
||||
fragment = (in[0] << 4) & 0x30;
|
||||
if (len > 1)
|
||||
fragment |= in[1] >> 4;
|
||||
*out++ = base64digits[fragment];
|
||||
*out++ = (len < 2) ? '=' : base64digits[(in[1] << 2) & 0x3c];
|
||||
*out++ = '=';
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create and connect the socket that connects to the proxy. After
|
||||
* this routine the sd socket is connected to the proxy.
|
||||
|
|
@ -258,7 +211,7 @@ void readline()
|
|||
* Read one character at a time into buf, until a newline is
|
||||
* encountered.
|
||||
*/
|
||||
while ( c != 10 && i < SIZE2 - 1 )
|
||||
while ( c != 10 && i < SIZE - 1 )
|
||||
{
|
||||
if( recv( sd, &c ,1 ,0 ) < 0)
|
||||
{
|
||||
|
|
@ -402,7 +355,7 @@ int copy(int from, int to)
|
|||
/*
|
||||
* Read a buffer from the source socket
|
||||
*/
|
||||
if ( ( n = read( from, buf, SIZE2 ) ) < 0 )
|
||||
if ( ( n = read( from, buf, SIZE ) ) < 0 )
|
||||
{
|
||||
my_perror( "Socket read error" );
|
||||
exit( 1 );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue