Class: SocksHandler::TCP
- Inherits:
-
Object
- Object
- SocksHandler::TCP
- Extended by:
- SocksHandler
- Defined in:
- lib/socks_handler/tcp.rb
Constant Summary
Constants included from SocksHandler
Class Method Summary collapse
- .desocksify ⇒ nil
-
.establish_connection(socket, remote_host, remote_port, username = nil, password = nil) ⇒ nil
Connects a host through a socks server.
- .find_rule(host) ⇒ DirectAccessRule, ...
-
.socksify(rules) ⇒ nil
Socksifies all TCP connections created by TCPSocket.new or Socket.tcp.
Class Method Details
.desocksify ⇒ nil
61 62 63 64 |
# File 'lib/socks_handler/tcp.rb', line 61 def desocksify @rules = [] nil end |
.establish_connection(socket, remote_host, remote_port, username = nil, password = nil) ⇒ nil
Connects a host through a socks server
92 93 94 95 96 |
# File 'lib/socks_handler/tcp.rb', line 92 def establish_connection(socket, remote_host, remote_port, username = nil, password = nil) negotiate(socket, username, password) send_details(socket, Command::CONNECT, remote_host, remote_port) nil end |
.find_rule(host) ⇒ DirectAccessRule, ...
68 69 70 |
# File 'lib/socks_handler/tcp.rb', line 68 def find_rule(host) rules.find { |r| r.match?(host) } end |
.socksify(rules) ⇒ nil
Socksifies all TCP connections created by TCPSocket.new or Socket.tcp
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/socks_handler/tcp.rb', line 46 def socksify(rules) @rules = rules unless TCPSocket.ancestors.include?(SocksHandler::TCPSocketSocksify) TCPSocket.prepend(SocksHandler::TCPSocketSocksify) end unless Socket.singleton_class.ancestors.include?(SocksHandler::SocketSocksify) Socket.singleton_class.prepend(SocksHandler::SocketSocksify) end nil end |