Sha256: eec822750d1d6ebaf38aaff183a43398f5cee6e87ee8816f1030c28f59567a70
Contents?: true
Size: 917 Bytes
Versions: 2
Compression:
Stored size: 917 Bytes
Contents
require 'janis/version' require 'janis/parsing' require 'yaml' module Janis IP_PORT_SEPARATOR = ':' def self.find(amount, path_to_list = './proxy_server_list.yml') proxy_list = YAML.load_file("#{path_to_list}").split(' ') results = [] proxy_list.each do |url| if results.size < amount parsed_from_url = Parsing.parse(url) unless url.include?('#') # Elements should look like ["1.1.1.1:8080", "2.2.2.2:9090"] results_from_this_url = parsed_from_url.map { |entry| convert_to_hash(entry) } # Result should look like [ { ip: "1.1.1.1", port: "8080" }, { ip: "2.2.2.2", port: "9090" } ] results += results_from_this_url end end results[0..amount - 1] end private def self.convert_to_hash(proxy_string) { ip: proxy_string.split(IP_PORT_SEPARATOR).first, port: proxy_string.split(IP_PORT_SEPARATOR).last } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
janis-0.1.1 | lib/janis.rb |
janis-0.1.0 | lib/janis.rb |