{"id":18522410,"url":"https://github.com/astro/socksify-ruby","last_synced_at":"2025-05-14T14:08:39.615Z","repository":{"id":525702,"uuid":"154311","full_name":"astro/socksify-ruby","owner":"astro","description":"Redirect any TCP connection initiated by a Ruby script through a SOCKS5 proxy","archived":false,"fork":false,"pushed_at":"2024-11-19T15:12:57.000Z","size":115,"stargazers_count":166,"open_issues_count":10,"forks_count":81,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-02-22T23:02:03.940Z","etag":null,"topics":["ruby","rubygem","socks","socks5"],"latest_commit_sha":null,"homepage":"http://socksify.rubyforge.org/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/astro.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["astro"]}},"created_at":"2009-03-19T15:48:55.000Z","updated_at":"2025-02-20T16:35:49.000Z","dependencies_parsed_at":"2024-11-05T20:09:47.990Z","dependency_job_id":"d21254a2-03db-427e-84a5-0550ee8fb568","html_url":"https://github.com/astro/socksify-ruby","commit_stats":{"total_commits":101,"total_committers":18,"mean_commits":5.611111111111111,"dds":0.594059405940594,"last_synced_commit":"d486263ffd45fe1df40c2160123a54dc514f24ea"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fsocksify-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fsocksify-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fsocksify-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fsocksify-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/astro","download_url":"https://codeload.github.com/astro/socksify-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240771873,"owners_count":19854981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby","rubygem","socks","socks5"],"created_at":"2024-11-06T17:30:42.515Z","updated_at":"2025-03-14T08:00:13.694Z","avatar_url":"https://github.com/astro.png","language":"Ruby","readme":"[![Gem Version](https://badge.fury.io/rb/socksify.svg)](https://badge.fury.io/rb/socksify)\n[![Actions Status](https://github.com/astro/socksify-ruby/workflows/CI/badge.svg?branch=master)](https://github.com/astro/socksify-ruby/actions?query=workflow%3ACI)\n\nSOCKSify Ruby\n=============\n\nWhat is it?\n-----------\n\n**SOCKSify Ruby** redirects any TCP connection initiated by a Ruby script through a SOCKS5 proxy. It serves as a small drop-in alternative to [tsocks](http://tsocks.sourceforge.net/), except that it handles Ruby programs only and doesn't leak DNS queries.\n\n### How does it work?\n\n```rb\nrequire 'socksify/http'\n```\nThis adds a new class method `Net::HTTP.socks_proxy` which takes the host and port address of a socks proxy. Once set, all requests will be routed via socks. This is acheived by patching a private method in `Net::HTTP`, as sadly Ruby no longer has native socks proxy support out of the box.\n\nAdditionally, `Socksify.resolve` can be used to resolve hostnames to IPv4 addresses via SOCKS.\n\nInstallation\n------------\n\n`$ gem install socksify`\n\nUsage\n-----\n\n### Redirect all TCP connections of a Ruby program\n\nRun a Ruby script with redirected TCP through a local [Tor](https://www.torproject.org/) anonymizer:\n\n`$ socksify_ruby localhost 9050 script.rb`\n\n### Explicit SOCKS usage in a Ruby program (Deprecated in Ruby 3.1 onwards)\n\nSet up SOCKS connections for a local [Tor](https://www.torproject.org/) anonymizer, TCPSockets can be used as usual:\n\n```rb\nrequire 'socksify'\n\nTCPSocket.socks_server = \"127.0.0.1\"\nTCPSocket.socks_port = 9050\nrubyforge_www = TCPSocket.new(\"rubyforge.org\", 80)\n# =\u003e #\u003cTCPSocket:0x...\u003e\n```\n\n### Use Net::HTTP explicitly via SOCKS\n\nRequire the additional library `socksify/http` and use the `Net::HTTP.socks_proxy` method. It is similar to `Net::HTTP.Proxy` from the Ruby standard library:\n```rb\nrequire 'socksify/http'\n\nuri = URI.parse('http://ipecho.net/plain')\nNet::HTTP.socks_proxy('127.0.0.1', 9050).start(uri.host, uri.port) do |http|\n  req = Net::HTTP::Get.new uri\n  resp = http.request(req)\n  puts resp.inspect\n  puts resp.body\nend\n# =\u003e #\u003cNet::HTTPOK 200 OK readbody=true\u003e\n# =\u003e \u003cA tor exit node ip address\u003e\n```\nNote that `Net::HTTP.socks_proxy` never relies on `TCPSocket.socks_server`/`socks_port`. You should either set `socks_proxy` arguments explicitly or use `Net::HTTP` directly.\n\n### Resolve addresses via SOCKS\n```rb\nSocksify.resolve(\"spaceboyz.net\")\n# =\u003e \"87.106.131.203\"\n```\n### Testing and Debugging\n\nA tor proxy is required before running the tests. Install tor from your usual package manager, check it is running with `pidof tor` then run the tests with:\n\n`bundle exec rake`\n\nColorful diagnostic messages are enabled by default via:\n```rb\nSocksify::debug = true`\n```\nDevelopment\n-----------\n\nThe [repository](https://github.com/astro/socksify-ruby/) can be checked out with:\n\n`$ git-clone git@github.com:astro/socksify-ruby.git`\n\nSend patches via pull requests.\n\n### Further ideas\n\n*   `Resolv` replacement code, so that programs which resolve by themselves don't leak DNS queries\n*   IPv6 address support\n*   UDP as soon as [Tor](https://www.torproject.org/) supports it\n*   Perhaps using standard exceptions for better compatibility when acting as a drop-in?\n\nAuthor\n------\n\n*   [Stephan Maka](mailto:stephan@spaceboyz.net)\n\nLicense\n-------\n\nSOCKSify Ruby is distributed under the terms of the GNU General Public License version 3 (see file `COPYING`) or the Ruby License (see file `LICENSE`) at your option.","funding_links":["https://github.com/sponsors/astro"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastro%2Fsocksify-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastro%2Fsocksify-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastro%2Fsocksify-ruby/lists"}