r_proxy 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/r_proxy/callback_connection.rb +8 -5
- data/lib/r_proxy/callback_service.rb +0 -1
- data/lib/r_proxy/connection_handler.rb +0 -4
- data/lib/r_proxy/master_process.rb +1 -1
- data/lib/r_proxy/usage_manager.rb +13 -6
- data/lib/r_proxy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50837a373486d272c73b9ed6db87ad8b493ddb8e1f8414cbeefc57fb48fe70fd
|
4
|
+
data.tar.gz: 871267b24a049f223e3685445744472cd0f4b1d34d907f080a0e0d7ae00abc1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3988856e3fd0aebf0cab190d8a56130db797d41f06b280fa880be8b083546223ace4d729c5e53bc1b125bf0bc614253bed106e55ef0f92a4c05a3d6d882a8e50
|
7
|
+
data.tar.gz: b6b1170d829f7167fafd6fceb72e125cb032aaf667a7e7cea3bd3cf03dbd0ab79b984b8d982c58b606c65eec21681d9b353ec985561749babfd8a4cb11641a96
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -14,21 +14,24 @@ module RProxy
|
|
14
14
|
@logger = logger
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def post_init
|
18
18
|
start_tls if @need_tls
|
19
19
|
set_comm_inactivity_timeout(20)
|
20
|
+
end
|
21
|
+
|
22
|
+
def ssl_handshake_completed
|
20
23
|
send_data(@http_request)
|
21
24
|
end
|
22
25
|
|
26
|
+
def connection_completed
|
27
|
+
send_data(@http_request) if !@need_tls
|
28
|
+
end
|
29
|
+
|
23
30
|
def receive_data(data)
|
24
31
|
@response = data.split("\r\n")[0]
|
25
32
|
close_connection
|
26
33
|
end
|
27
34
|
|
28
|
-
def ssl_handshake_completed
|
29
|
-
send_data(@http_request)
|
30
|
-
end
|
31
|
-
|
32
35
|
def unbind
|
33
36
|
@logger.info("#{@uri.host}#{@path} response status: #{@response}") if @logger
|
34
37
|
end
|
@@ -14,7 +14,6 @@ module RProxy
|
|
14
14
|
@cache_pool = cache_pool
|
15
15
|
@usage_manager = RProxy::UsageManager.new(config, @cache_pool, @redis)
|
16
16
|
@http_parser = HttpProxyParser.new(@usage_manager)
|
17
|
-
@snapshot_service = RProxy::CheckSnapshotService.new(@redis, @config)
|
18
17
|
@enable_force_quit = config.enable_force_quit
|
19
18
|
end
|
20
19
|
|
@@ -59,9 +58,6 @@ module RProxy
|
|
59
58
|
@username = @http_parser.username
|
60
59
|
@password = @http_parser.password
|
61
60
|
@target_connection.assign_user_and_password(@username, @password)
|
62
|
-
|
63
|
-
# check snapshot
|
64
|
-
@snapshot_service.call(@username, @password, remain)
|
65
61
|
end
|
66
62
|
rescue RProxy::HTTPAuthFailed
|
67
63
|
send_data(RProxy::Constants::HTTP_FAILED_AUTH)
|
@@ -5,12 +5,11 @@ module RProxy
|
|
5
5
|
@cache_pool = cache_pool
|
6
6
|
@redis = redis
|
7
7
|
@no_cache_below = config.no_cache_below
|
8
|
+
@check_snapshot_service = RProxy::CheckSnapshotService.new(@redis, config)
|
8
9
|
end
|
9
10
|
|
10
11
|
def auth_user(user, pass)
|
11
|
-
|
12
|
-
|
13
|
-
value = fetch_usage(key)
|
12
|
+
value = fetch_usage(user, pass)
|
14
13
|
|
15
14
|
return value if !value.nil? && value.to_i > 0
|
16
15
|
nil
|
@@ -32,15 +31,23 @@ module RProxy
|
|
32
31
|
|
33
32
|
private
|
34
33
|
|
35
|
-
def fetch_usage(
|
36
|
-
|
34
|
+
def fetch_usage(user, pass)
|
35
|
+
key = proxy_key(user, pass)
|
36
|
+
if !@enable_cache || !@cache_pool.writable?
|
37
|
+
value = @redis.get(key)
|
38
|
+
@check_snapshot_service.call(user, pass, value)
|
39
|
+
end
|
37
40
|
|
38
41
|
cache = @cache_pool[key]
|
39
42
|
|
40
43
|
if cache.nil?
|
44
|
+
|
41
45
|
value = @redis.get(key)
|
42
46
|
|
43
|
-
|
47
|
+
if !value.nil?
|
48
|
+
@check_snapshot_service.call(user, pass, value)
|
49
|
+
return value if value.to_i <= @no_cache_below
|
50
|
+
end
|
44
51
|
|
45
52
|
@cache_pool[key] = {
|
46
53
|
usage: value,
|
data/lib/r_proxy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick An
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|