Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Finish implementation of SOCKS5 proxy client with example usage.
- Loading branch information
Showing
with
66 additions
and 10 deletions.
- +39 −0 example.py
- +25 −8 txsocksx/client.py
- +2 −2 txsocksx/parser.py
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| @@ -0,0 +1,39 @@ | ||
| from twisted.internet import reactor | ||
| from twisted.internet.protocol import Protocol, Factory | ||
| from twisted.internet.endpoints import TCP4ClientEndpoint | ||
|
|
||
| from txsocksx.client import SOCKS5ClientEndpoint | ||
|
|
||
| class GETSlash(Protocol): | ||
| def connectionMade(self): | ||
| self.transport.write("GET / HTTP/1.1\n\r\n\r") | ||
|
|
||
| def buildProtocol(self): | ||
| return self | ||
|
|
||
| def dataReceived(self, data): | ||
| print "Got this as a response" | ||
| print data | ||
|
|
||
| class GETSlashFactory(Factory): | ||
| def buildProtocol(self, addr): | ||
| print "Building protocol towards" | ||
| return GETSlash() | ||
|
|
||
| socks_addr = '127.0.0.1' | ||
| socks_port = 9050 | ||
| TCPPoint = TCP4ClientEndpoint(reactor, socks_addr, socks_port) | ||
|
|
||
| dst_addr = 'checkip.dyndns.com' | ||
| dst_port = 80 | ||
| SOCKSPoint = SOCKS5ClientEndpoint(dst_addr, | ||
| dst_port, TCPPoint) | ||
|
|
||
| d = SOCKSPoint.connect(GETSlashFactory()) | ||
| @d.addErrback | ||
| def _gotError(error): | ||
| print "Error in connection" | ||
| reactor.stop() | ||
|
|
||
| reactor.run() | ||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters