proxied 0.1.3 → 0.1.4
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -1
- data/lib/proxied.rb +1 -0
- data/lib/proxied/shared.rb +9 -21
- data/lib/proxied/utilities.rb +39 -0
- data/lib/proxied/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb6b1d839edb6a86acc7e15c72ae74e4e94e61d6302fe12d11378c18edadea36
|
4
|
+
data.tar.gz: ee71b159f7d46d703a9c819c6d52a79060262ae984999d3083b6fa72d2581371
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7115524c83549e66f528dc1764a029e79ea43c9c38f006657b17ae5ef8ba24fc6eaff7abd33756a1122c1d0cd6bb11947ad5322d215032cdab437c2c56d18648
|
7
|
+
data.tar.gz: 1ec14f18413f2168f3e437c544d6389171ab5567c0c74375f96bf110b4a41408aa957f84ff3c11cd122c572e2eddab7ca8fb21daaa51c9ec6dad2c3c0ddede96
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -28,10 +28,14 @@ Generate the initializer for your Rails app:
|
|
28
28
|
|
29
29
|
$ rails generate proxied:install MODEL
|
30
30
|
|
31
|
-
|
31
|
+
If you're using ActiveRecord, generate the migration and model:
|
32
32
|
|
33
33
|
$ rails generate proxied MODEL
|
34
34
|
|
35
|
+
If you're using Mongoid, generate the model using the following command:
|
36
|
+
|
37
|
+
$ rails generate proxied MODEL --orm=mongoid
|
38
|
+
|
35
39
|
## Features
|
36
40
|
|
37
41
|
Features:
|
data/lib/proxied.rb
CHANGED
data/lib/proxied/shared.rb
CHANGED
@@ -10,43 +10,31 @@ module Proxied
|
|
10
10
|
return proxies
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
return proxy_address
|
13
|
+
# Keep these for compatibility for now, they just wrap the utility functions
|
14
|
+
def format_proxy_address(host, port = 80, include_http = false)
|
15
|
+
::Proxied::Utilities.format_proxy_address(host: host, port: port, include_http: include_http)
|
17
16
|
end
|
18
17
|
|
19
18
|
def format_proxy_credentials(username, password)
|
20
|
-
|
19
|
+
::Proxied::Utilities.format_proxy_credentials(username, password)
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
24
23
|
module InstanceMethods
|
25
|
-
def proxy_address(include_http
|
26
|
-
|
24
|
+
def proxy_address(include_http: false)
|
25
|
+
::Proxied::Utilities.format_proxy_address(host: self.host, port: self.port, include_http: include_http)
|
27
26
|
end
|
28
27
|
|
29
28
|
def proxy_credentials
|
30
|
-
|
29
|
+
::Proxied::Utilities.format_proxy_credentials(self.username, self.password)
|
31
30
|
end
|
32
31
|
|
33
32
|
def socks_proxy_credentials
|
34
|
-
|
35
|
-
|
36
|
-
credentials[:user] = self.username if !self.username.to_s.empty?
|
37
|
-
credentials[:password] = self.password if !self.password.to_s.empty?
|
38
|
-
|
39
|
-
return credentials
|
33
|
+
::Proxied::Utilities.socks_proxy_credentials(username: self.username, password: self.password)
|
40
34
|
end
|
41
35
|
|
42
36
|
def proxy_options_for_faraday
|
43
|
-
|
44
|
-
|
45
|
-
proxy_options[:uri] = self.class.format_proxy_address(self.host, self.port, true)
|
46
|
-
proxy_options[:user] = self.username if !self.username.to_s.empty?
|
47
|
-
proxy_options[:password] = self.password if !self.password.to_s.empty?
|
48
|
-
|
49
|
-
return proxy_options
|
37
|
+
::Proxied::Utilities.proxy_options_for_faraday(host: self.host, port: self.port, username: self.username, password: self.password)
|
50
38
|
end
|
51
39
|
end
|
52
40
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Proxied
|
2
|
+
class Utilities
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def format_proxy_address(host:, port: 80, include_http: false)
|
7
|
+
address = "#{host}:#{port}"
|
8
|
+
address = "http://#{address}" if include_http && !address.start_with?("http://")
|
9
|
+
|
10
|
+
return address
|
11
|
+
end
|
12
|
+
|
13
|
+
def format_proxy_credentials(username, password)
|
14
|
+
return "#{username}:#{password}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def socks_proxy_credentials(username: nil, password: nil)
|
18
|
+
credentials = {}
|
19
|
+
|
20
|
+
credentials[:user] = username if !username.to_s.empty?
|
21
|
+
credentials[:password] = password if !password.to_s.empty?
|
22
|
+
|
23
|
+
return credentials
|
24
|
+
end
|
25
|
+
|
26
|
+
def proxy_options_for_faraday(host:, port:, username: nil, password: nil)
|
27
|
+
proxy_options = {}
|
28
|
+
|
29
|
+
proxy_options[:uri] = format_proxy_address(host: host, port: port, include_http: true)
|
30
|
+
proxy_options[:user] = username if !username.to_s.empty?
|
31
|
+
proxy_options[:password] = password if !password.to_s.empty?
|
32
|
+
|
33
|
+
return proxy_options
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/lib/proxied/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxied
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -299,6 +299,7 @@ files:
|
|
299
299
|
- lib/proxied/railtie.rb
|
300
300
|
- lib/proxied/shared.rb
|
301
301
|
- lib/proxied/sql/proxy_methods.rb
|
302
|
+
- lib/proxied/utilities.rb
|
302
303
|
- lib/proxied/version.rb
|
303
304
|
- lib/tasks/tasks.rake
|
304
305
|
- proxied.gemspec
|