Sha256: b77288299632bb1e9f8193d2660aea01b9b67e063bb0873e6ab9b9f8b44a767c

Contents?: true

Size: 737 Bytes

Versions: 2

Compression:

Stored size: 737 Bytes

Contents

require 'socksify'
require 'socksify/http'

module Telegram
  module Bot
    module Adapters
      class Socks5 < Faraday::Adapter::NetHttp
        def net_http_connection(env)
          if proxy = env[:request][:proxy]
            if proxy[:socks]
              TCPSocket.socks_username = proxy[:user] if proxy[:user]
              TCPSocket.socks_password = proxy[:password] if proxy[:password]
              Net::HTTP::SOCKSProxy(proxy[:uri].host, proxy[:uri].port)
            else
              Net::HTTP::Proxy(proxy[:uri].host, proxy[:uri].port, proxy[:uri].user, proxy[:uri].password)
            end
          else
            Net::HTTP
          end.new(env[:url].host, env[:url].port)
        end
      end
    end
  end
end 

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dialog_bot_ruby-0.8.8 lib/telegram/bot/adapters/socks5.rb
dialog_bot_ruby-0.8.7 lib/telegram/bot/adapters/socks5.rb