|
NEC
Products
Technical
Resources
FAQs
|
|
|

How to
SOCKSify clients
The library of SOCKS
v5 Reference Implementation has functions that are equivalent to the
standard BSD socket functions. Converting an application to use the SOCKS
protocol normally only requires adding an #include directive
and linking with the library of SOCKS v5 Reference Implementation.
Applications that follow the SOCKS friendly
guidelines should work without any further modification.
- Identify the program for syslog
Add this line at or near the beginning of the main procedure:
SOCKSinit(argv[0]);
If you omit this line, the syslog lines that display on the client
host describe a generic program name, instead of the actual client
program name.
- Map functions to the SOCKSified replacement functions
If you use a makefile, add
this line to the CFLAGS macro definition.
- Link with the appropriate SOCKS library
Add these to the command that creates the executable:
- SOCKS V4 users:
-L<socks_lib_dir> -lsocks
- SOCKS v5 users:
-L<socks_lib_dir>
-lsocks5
Note: The SOCKS V4 client library cannot SOCKSify
UDP sockets because SOCKS V4 doesn't support UDP.
Example: This example assumes SOCKS v5 Reference
Implementation was compiled in the /user/gjh/socks5 directory and
gcc is available. If a program was compiled with:
SOCKSify it with:
% gcc -include /user/gjh/socks5/include/socks.h \ -DSOCKS
-L/user/gjh/socks5/lib -lsocks5 -o foo foo.c
If the
source code is written using the SOCKS V4 library, compile it with the
library of SOCKS v5 Reference Implementation.
- Map functions to the replacement functions of SOCKS v5 Reference
Implementation
To all cc lines, add:
-DRconnect=SOCKSconnect \ -DRgetsockname=SOCKSgetsockname
\ -DRgetpeername=SOCKSgetpeername \ -DRbind=SOCKSbind
\ -DRaccept=SOCKSaccept \ -DRlisten=SOCKSlisten
\ -DRselect=SOCKSselect \ -Drecvfrom=SOCKSrecvfrom
\ -Dsendto=SOCKSsendto \ -Drecv=SOCKSrecv \ -Dsend=SOCKSsend
\ -Dread=SOCKSread \ -Dwrite=SOCKSwrite
\ -Drresvport=SOCKSrresvport \ -Dshutdown=SOCKSshutdown
\ -Dlisten=SOCKSlisten \ -Dclose=SOCKSclose \ -Ddup=SOCKSdup
\ -Ddup2=SOCKSdup2 \ -Dfclose=SOCKSfclose
\ -Dgethostbyname=SOCKSgethostbyname
- Link with the library of SOCKS v5 Reference Implementation
To the command that creates the executable, add:
-L<socks_lib_dir> -lsocks5
runsocks is a shell script that loads the shared
library of SOCKS v5 Reference Implementation. If your operating system
supports shared libraries (see SOCKS v5 Reference
Implementation), runsocks dynamically allows the application to use
the SOCKSified networking function calls in the shread libraries of SOCKS
v5 Reference Implementation instead of the standard networking function
calls.
See the runsocks(1) man
page.
SocksCap is a WinSock extension that SOCKSifies
Winsock Applications. See the SocksCap page
for more information about SocksCap and the SOCKS FAQ for other
ways to SOCKSify Windows applications.
|
|