zokor 0.2.1
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 +7 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +15 -0
- data/bin/zokor +169 -0
- data/ca-certs-small.crt +2252 -0
- data/double-proxy.rb +58 -0
- data/lib/zokor.rb +18 -0
- data/lib/zokor/config.rb +178 -0
- data/lib/zokor/logger.rb +97 -0
- data/lib/zokor/proxy_connection.rb +329 -0
- data/lib/zokor/proxy_magic.rb +65 -0
- data/lib/zokor/version.rb +3 -0
- data/zokor.gemspec +39 -0
- metadata +136 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'socket'
|
2
|
+
|
3
|
+
# TODO: not sure if this is desirable
|
4
|
+
Thread.abort_on_exception = true
|
5
|
+
|
6
|
+
module Zokor
|
7
|
+
class ProxyMagic
|
8
|
+
attr_reader :server, :remote_host, :remote_port, :opts
|
9
|
+
|
10
|
+
def initialize(local_host, local_port, remote_host, remote_port, opts={})
|
11
|
+
@remote_host = remote_host
|
12
|
+
@remote_port = remote_port
|
13
|
+
|
14
|
+
@opts = opts
|
15
|
+
|
16
|
+
@server = serve(local_host, local_port)
|
17
|
+
|
18
|
+
if @opts[:proxy_url]
|
19
|
+
log.info "Intermediate proxy: #{@opts.fetch(:proxy_url)}"
|
20
|
+
else
|
21
|
+
log.info "Intermediate proxy: none"
|
22
|
+
end
|
23
|
+
|
24
|
+
if @opts[:use_ssl]
|
25
|
+
ssl_msg = '[SSL]'
|
26
|
+
else
|
27
|
+
ssl_msg = '[no SSL]'
|
28
|
+
end
|
29
|
+
|
30
|
+
log.info "External proxy: #{ssl_msg} #{remote_host}:#{remote_port}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def serve(local_host, local_port)
|
34
|
+
server = TCPServer.open(local_host, local_port)
|
35
|
+
|
36
|
+
port = server.addr[1]
|
37
|
+
addrs = server.addr[2..-1].uniq
|
38
|
+
log.info "Listening on #{addrs.collect{|a|"#{a}:#{port}"}.join(' ')}"
|
39
|
+
server
|
40
|
+
end
|
41
|
+
|
42
|
+
def run_loop
|
43
|
+
log.info "Starting main loop..."
|
44
|
+
|
45
|
+
# Add thread to process Ctrl-C on Windows
|
46
|
+
_sleep_thread = Thread.new { loop { sleep 1 } }
|
47
|
+
|
48
|
+
@threads = []
|
49
|
+
|
50
|
+
while true
|
51
|
+
@threads.select!(&:alive?)
|
52
|
+
log.debug "#{@threads.length} open connections" unless @threads.empty?
|
53
|
+
@threads << Thread.start(server.accept) {|sock|
|
54
|
+
c = Zokor::ProxyConnection.new(sock, remote_host, remote_port, opts)
|
55
|
+
c.connect
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def log
|
61
|
+
@log ||= Zokor::ProgLogger.new('zokor')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
data/zokor.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'zokor/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'zokor'
|
8
|
+
spec.version = Zokor::VERSION
|
9
|
+
spec.authors = ['Andy Brody']
|
10
|
+
spec.email = ['git@abrody.com']
|
11
|
+
spec.summary = 'Nested HTTP proxy tunnel tool'
|
12
|
+
spec.description = <<-EOM
|
13
|
+
Zokor is an HTTP proxy tunnelling tool that collapses multiple HTTP proxies
|
14
|
+
into one. It's useful when you want to send traffic through a chain of two
|
15
|
+
HTTP proxies where the first supports the CONNECT verb.
|
16
|
+
|
17
|
+
Zokor presents a local server that transparently tunnels packets through
|
18
|
+
the first proxy as though clients were directly connected to the second
|
19
|
+
proxy. It optionally uses TLS to connect to the second proxy.
|
20
|
+
EOM
|
21
|
+
spec.homepage = 'https://github.com/ab/zokor'
|
22
|
+
spec.license = 'GPL-3'
|
23
|
+
|
24
|
+
spec.files = `git ls-files`.split($/)
|
25
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
26
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_dependency 'proxifier', '~> 1.0'
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
32
|
+
spec.add_development_dependency 'pry'
|
33
|
+
spec.add_development_dependency 'rake'
|
34
|
+
# spec.add_development_dependency 'rspec', '~> 3.0'
|
35
|
+
# spec.add_development_dependency 'rubocop', '~> 0'
|
36
|
+
spec.add_development_dependency 'yard'
|
37
|
+
|
38
|
+
spec.required_ruby_version = '>= 2.0'
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zokor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andy Brody
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: proxifier
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: |2
|
84
|
+
Zokor is an HTTP proxy tunnelling tool that collapses multiple HTTP proxies
|
85
|
+
into one. It's useful when you want to send traffic through a chain of two
|
86
|
+
HTTP proxies where the first supports the CONNECT verb.
|
87
|
+
|
88
|
+
Zokor presents a local server that transparently tunnels packets through
|
89
|
+
the first proxy as though clients were directly connected to the second
|
90
|
+
proxy. It optionally uses TLS to connect to the second proxy.
|
91
|
+
email:
|
92
|
+
- git@abrody.com
|
93
|
+
executables:
|
94
|
+
- zokor
|
95
|
+
extensions: []
|
96
|
+
extra_rdoc_files: []
|
97
|
+
files:
|
98
|
+
- ".gitignore"
|
99
|
+
- Gemfile
|
100
|
+
- Rakefile
|
101
|
+
- bin/zokor
|
102
|
+
- ca-certs-small.crt
|
103
|
+
- double-proxy.rb
|
104
|
+
- lib/zokor.rb
|
105
|
+
- lib/zokor/config.rb
|
106
|
+
- lib/zokor/logger.rb
|
107
|
+
- lib/zokor/proxy_connection.rb
|
108
|
+
- lib/zokor/proxy_magic.rb
|
109
|
+
- lib/zokor/version.rb
|
110
|
+
- zokor.gemspec
|
111
|
+
homepage: https://github.com/ab/zokor
|
112
|
+
licenses:
|
113
|
+
- GPL-3
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '2.0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.4.5.1
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Nested HTTP proxy tunnel tool
|
135
|
+
test_files: []
|
136
|
+
has_rdoc:
|