Search code examples
javasocketsproxyserversocketsocks

jsocks library for proxy


it's been a 2 days i find "jSocks" library.

i tried so may to findout how i can code with this library.

i must say that documentation is very poor.

i don't want you to code for me, i just want a simple workflow.

here is my scenario:

1) i want to write 2 app, one for client and one for server.(it's simple client server proxy)

2) client app will listen to specific port on localhost (127.0.0.1) for incoming connection (for example browser request).

3) client app accept incoming connection from browser and create a socks socket between her and browser for send and recieve data.

4) client app create a socks socket between her and server app (server app hosted on web and listening to a port for incoming connection).

5) server app accept incoming connection and create a socks socket for Communicate.

6) server app recieve data ( may be browser request ), process it and connect to a remote web site(on internet).

7) server app recive data from web and send it to client app.

8) client app send the recived data to browser.

i create this app with java standard "Socket" & "ServerSocket" for http request without problem, now i want to write this program with socks socket for all request.

i tried every thing with jsocks without any success.

i need a workflow on how to work with jsocks for creating this app.

tnx.


@BGR

acording to your mentioned file (SOCKS.java) the simple line like below must work :

ServerAuthenticator auth = new ServerAuthenticatorNone();

ProxyServer pServer = new ProxyServer(auth);

pServer.setLog(System.out);

pServer.start(50352);

when i execute this, the log is : Starting SOCKS Proxy on:0.0.0.0:50352 (if i pass 127.0.0.1 as address to start() method, log is "Starting SOCKS Proxy on:127.0.0.1:50352 but the result is the same)

but when i redirect my browser request to this port nothing happens.

acually i'am not sure how the start(port) method works, because it's void.

when i use ServerSocket, accept() method it return me a Socket for communication.

but when i use start(port) nothing will return


Solution

  • I am not sure I full understand your request (a socks server is meant for proxying; it is constantly listening on a single port and forwards requests) but looking at this java file it seems reasonable easy to create a Socks proxy server using jsocks.

    Once you proxy server is running, you create a java socket on your client using this constructor where you specify the location of your socks proxy server. You then connect to your remote server SocketAddress and

    ... that should be it.

    You seem to have lot of redirections going on. Maybe you should chart a diagram of your flows and see where you need a Socks proxy server and why.