github.com/Dakad/socksify-cr

Crystal version of Socksify-ruby gem

1 stars
0 dependents
License: MIT

Nothing has been indexed for 0.2.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  socksify:
    github: Dakad/socksify-cr
    version: ~> 0.2.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.2.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

socksify-cr

Little Proxy client library for HTTP and SOCKS type

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      socksify:
        github: dakad/socksify-cr
  2. Run shards install

Usage

require "socksify"

Socksify::Proxy.configure do |config|
   config.timeout_sec = 60
   config.max_retries = 2
end

host = URI.parse "https://example.com"
client = Socksify::HTTPClient.new(host, ignore_env: true)
proxy = Socksify::Proxy.new "http://127.0.0.1:18080"
proxy = Socksify::Proxy.new "socks5://127.0.0.1:9150"
client.set_proxy proxy
response = client.exec("GET", "/me")
client close

Configure the Proxy connection

require "socksify"

Socksify::Proxy.configure do |config|
   config.connect_timeout_sec = 60
   config.timeout_sec = 30
   config.max_retries = 2
end
  • connect_timeout_sec: Limit the connection timeout on the proxy socket and HTTT::Client
  • timeout_sec: Other timeout (dns,read,write)
  • max_retries: Number of retries after error during TCPSocket creation or connection

Development

Run crystal spec to run project's tests. To run and setup a real SOCKS server, we can use this lib under docker

You can also manually run the examples under /examples

To debug, follow this link's guide to setup gdb/lldb with VSCode.

For Vim, run the commands below:

  1. shards build --debug --progress simple to build for debug one the specified target in shards.yml

  2. Or crystal build --debug --progress -o bin/simple examples/simple.cr build your file directly

  3. gdb bin/simple to debug the compiled code

  4. (gdb) run Will run the compiled source and maybe throw an error in the console, but don't mind :)

Program received signal SIGSEGV, Segmentation fault. 0x000055555589365e in GC_find_limit_with_bound () 5. (gdb) continue 6. Here is a gdb cheatsheet's link

Contributing

  1. Fork it (https://github.com/Dakad/socksify-cr)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Merge Request

Contributors

  • @DakaD - creator and maintainer