proxylinker 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3a12db5ad833bb850d2e0e75c42293eefe337e5b7830fb3edde9b7a3c0a33233
4
+ data.tar.gz: 25ac22e2f76bc0c73bc0f22c43b8f427a4c477dfe03e4f76ed5c9195fe72fb73
5
+ SHA512:
6
+ metadata.gz: 79ba5b5da10bf1177a1ddec8821aae22a0808a5c07d9eddbbe6537729ae71cf7bb57dc8989e4df3a00e2852f4ea835e95f356ade9c3c96a257e8fbb8175f00bb
7
+ data.tar.gz: 1b46261eeb4d475adbd2f8b71486b15832528ce987f0c2bf58f54fde1dfd5ef7e4a508dd459b39ae1db6ff94b1cf287396446f329a34c46798451b41b175b555
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Proxymate
2
+
3
+ ## Installation
4
+ ```bash
5
+ gem install proxymate
6
+ ```
7
+
8
+ ## Usage
9
+ Format for proxy_list.txt:
10
+ ```
11
+ 127.0.0.1:8080
12
+ 127.0.0.1:8081
13
+ ```
14
+
15
+ ```ruby
16
+ require 'proxymate'
17
+
18
+ proxy_list = Proxymate::ProxyList.new('path/to/proxy_list.txt')
19
+
20
+ proxy = proxy_list.get_random_proxy
21
+
22
+ if proxy
23
+ puts "Bruger proxy: #{proxy.addr}:#{proxy.port}"
24
+ else
25
+ puts "Ingen fungerende proxy fundet."
26
+ end
27
+ ```
28
+
29
+ ## License
30
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
31
+
32
+ ## Code of Conduct
data/lib/proxy_list.rb ADDED
@@ -0,0 +1,49 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'ostruct'
4
+
5
+ module Proxylinker
6
+ class ProxyList
7
+ attr_reader :proxies, :timeout
8
+
9
+ # Initialiserer ProxyList med en filsti og timeout-parameter (standard: 5 sek.)
10
+ def initialize(proxy_file_path, timeout: 5)
11
+ @proxy_file_path = proxy_file_path
12
+ @timeout = timeout
13
+ @proxies = load_proxies
14
+ end
15
+
16
+ # Læs proxies fra en fil (forventet format: IP:PORT per linje)
17
+ def load_proxies
18
+ proxies = []
19
+ File.readlines(@proxy_file_path).each do |line|
20
+ addr, port = line.strip.split(':')
21
+ proxies << OpenStruct.new(addr: addr, port: port)
22
+ end
23
+ proxies
24
+ end
25
+
26
+ # Validér en proxy ved at forsøge at oprette forbindelse til en kendt URL
27
+ def validate_proxy(proxy)
28
+ uri = URI.parse('https://google.com')
29
+ http = Net::HTTP.new(uri.host, uri.port, proxy.addr, proxy.port)
30
+ http.open_timeout = @timeout
31
+ http.read_timeout = @timeout
32
+
33
+ begin
34
+ response = http.get(uri.path)
35
+ return response.is_a?(Net::HTTPSuccess)
36
+ rescue
37
+ false
38
+ end
39
+ end
40
+
41
+ # Hent en tilfældig fungerende proxy
42
+ def get_random_proxy
43
+ @proxies.shuffle.each do |proxy|
44
+ return proxy if validate_proxy(proxy)
45
+ end
46
+ nil
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ # lib/proxylinker/version.rb
2
+
3
+ module Proxylinker
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,8 @@
1
+ # lib/proxylinker.rb
2
+
3
+ require "proxylinker/proxy_list"
4
+
5
+ module Proxylinker
6
+ class Error < StandardError
7
+ end
8
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/proxylinker/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "proxylinker"
7
+ spec.version = Proxylinker::VERSION
8
+ spec.authors = ["Max Lindberg"]
9
+ spec.email = ["xflickv1@gmail.com"]
10
+
11
+ spec.summary = "A gem to manage proxies because other proxy gems didn't work for me."
12
+ spec.description = "ProxyLinker allows you to load, validate, and use proxies from a list."
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 3.0.0"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ spec.files = Dir.glob("lib/**/*.rb") + ["proxylinker.gemspec", "README.md"]
18
+ spec.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: proxylinker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Max Lindberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-10-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: ProxyLinker allows you to load, validate, and use proxies from a list.
14
+ email:
15
+ - xflickv1@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - README.md
21
+ - lib/proxy_list.rb
22
+ - lib/proxylinker.rb
23
+ - lib/proxylinker/version.rb
24
+ - proxylinker.gemspec
25
+ homepage:
26
+ licenses:
27
+ - MIT
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 3.0.0
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubygems_version: 3.5.9
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: A gem to manage proxies because other proxy gems didn't work for me.
48
+ test_files: []