envoy-proxy 0.0.12 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 281c4bfc469bce4dd3f577cd04e8c788b0803646
4
- data.tar.gz: 5ea2ace10ed0341ecc6292756a5f9665f0fb23a1
3
+ metadata.gz: 1b54921a713d37da78b7a2bbd63448f7ebc8be2c
4
+ data.tar.gz: 29a76e5a111c75216a3e7bc246e6bae29ea397f6
5
5
  SHA512:
6
- metadata.gz: c4b51e8065e16f039d2ebb72915ab1bd15ffa603c318240441985d509ce813ddb351477f9cc022e0611430cdb645347fafe1359cbeffaf995320cf233df943ad
7
- data.tar.gz: 665991472fe262ead0cfb1080ea062966960ac54f34e260f300ff93b4d07764d2e9a7de889e859fdad0bd67db6049bbe5d2ce1c8a6f0b8dc07310a05ac9948fd
6
+ metadata.gz: e1adb7a4b761b994c7d2dda63f29ca00cc7b29bbe11dcc847e78cb51a6cdb2a774b21b93d0bcd8eddf2b32be4c3ca643466fa1d94632f68940a574160dcc40e0
7
+ data.tar.gz: dc5d9a2b267f8355529ccedef95566522a3596adebfebf3805dd8d37c3d1ae265e0182981e11343f574bfb306474fa0f5a6bdeddfb9bc8998da6c5f154ea6682
data/README.md CHANGED
@@ -6,7 +6,7 @@ A clone of proxylocal. Both client and server are included.
6
6
 
7
7
  ## The client
8
8
 
9
- envoyc [--key KEY] [--host HOST] [--tls] [--server SERVER] [[ADDRESS:]PORT]
9
+ envoy [--key KEY] [--host HOST] [--tls] [--server SERVER] [[ADDRESS:]PORT]
10
10
 
11
11
  Makes the HTTP* service running at ADDRESS:PORT available via a proxylocal
12
12
  service running on SERVER. The default server is p45.eu, and the default address
@@ -21,9 +21,11 @@ each client must present the KEY.
21
21
 
22
22
  ## The server
23
23
 
24
- envoys [--listen [HOST:]PORT] ZONE
24
+ envoyd [--key KEY] [--listen [HOST:]PORT] ZONE
25
25
 
26
26
  Starts a proxylocal-compatible server. Listens for HTTP requests on the
27
27
  specified host and port, which default to 0.0.0.0 and 8080.
28
28
 
29
+ If KEY is specified, clients _must_ specify that key.
30
+
29
31
  The ZONE specifies the domain name suffix.
File without changes
File without changes
@@ -3,6 +3,7 @@ require 'envoy/server/web'
3
3
  require 'optparse'
4
4
 
5
5
  listen = ["0.0.0.0", "8080"]
6
+ key = nil
6
7
 
7
8
  OptionParser.new do |op|
8
9
  op.banner = "Usage: #{$0} [options] ZONE"
@@ -10,6 +11,9 @@ OptionParser.new do |op|
10
11
  port, host = v.split(":").reverse
11
12
  listen = [host || "0.0.0", port]
12
13
  end
14
+ op.on "-k", "--key KEY", "Require authentication using KEY" do |v|
15
+ key = v
16
+ end
13
17
  op.on "--version" do
14
18
  puts Envoy::VERSION
15
19
  exit
@@ -22,7 +26,7 @@ $zone = ARGV[0].gsub(/^\.+/, '')
22
26
 
23
27
  unless EM.reactor_running?
24
28
  EM.run do
25
- EM.start_server "0.0.0.0", 8282, Envoy::Server::Trunk
29
+ EM.start_server "0.0.0.0", 8282, Envoy::Server::Trunk, key
26
30
  EM.start_server *listen, Envoy::Server::Web
27
31
  end
28
32
  end
@@ -5,6 +5,11 @@ module Envoy
5
5
  module Trunk
6
6
  include Protocol
7
7
 
8
+ def initialize key
9
+ super
10
+ @key = key
11
+ end
12
+
8
13
  def self.trunks
9
14
  @trunks ||= Hash.new{|h,k|h[k] = []}
10
15
  end
@@ -39,13 +44,18 @@ module Envoy
39
44
  @options[:key]
40
45
  end
41
46
 
42
- def halt
47
+ def halt message = nil
48
+ send_object :message, message if message
43
49
  send_object :halt
44
50
  close_connection(true)
45
51
  end
46
52
 
47
53
  def receive_options options
48
54
  @options = options
55
+ if @key and @key != @options[:key]
56
+ halt "Key is invalid"
57
+ return
58
+ end
49
59
  hosts = @options[:hosts] || []
50
60
  hosts.any? do |label|
51
61
  if label == "s"
@@ -67,9 +77,11 @@ module Envoy
67
77
  Trunk.trunks[host] << self
68
78
  m << "http://#{host}.#{$zone}/"
69
79
  end
70
- @options[:key] ||= SecureRandom.hex(8)
71
80
  send_object :message, m.join(" ")
72
- send_object :message, "Your key is #{@options[:key]}"
81
+ unless @options[:key]
82
+ @options[:key] ||= SecureRandom.hex(8)
83
+ send_object :message, "Your key is #{@options[:key]}"
84
+ end
73
85
  end
74
86
 
75
87
  def unbind
@@ -1,3 +1,3 @@
1
1
  module Envoy
2
- VERSION = '0.0.12'
2
+ VERSION = '0.0.14'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envoy-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Baum
@@ -70,8 +70,8 @@ description:
70
70
  email:
71
71
  - n@p12a.org.uk
72
72
  executables:
73
- - envoyc
74
- - envoys
73
+ - envoy
74
+ - envoyd
75
75
  extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
@@ -80,8 +80,8 @@ files:
80
80
  - LICENSE.txt
81
81
  - README.md
82
82
  - Rakefile
83
- - bin/envoyc
84
- - bin/envoys
83
+ - bin/envoy
84
+ - bin/envoyd
85
85
  - envoy-proxy.gemspec
86
86
  - lib/envoy/client/channel.rb
87
87
  - lib/envoy/client/command.rb