envoy-proxy 0.0.10 → 0.0.11

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: 3731648e8dc81bda63ae75d5bd2d7f8bb25d6ba9
4
- data.tar.gz: 30cf973ba9dc29e8d155b97c0f71a0c2f324b2d4
3
+ metadata.gz: 7c5709f40d5ee7755b306039b9878a39741b7639
4
+ data.tar.gz: 391a91d1eeaf9dbb01f08582e4d3438619df8bf9
5
5
  SHA512:
6
- metadata.gz: 219e1ab7b2e51d31baacc8b3bbad3f036bf7091cde633c67a67dc18f68abfa4209fef66a6eceb725ed0a65308067d57df06a0322c8148e3e0fe5d61f7ac43090
7
- data.tar.gz: 4444bfa29c6e3a56e238c49cd7a377e7d34b25c8e3f9f3b2bd0728e1c6dec0c5e15e6808ddaa282029f7a55b59f7b6be8f65210f84b55f596234a242f99c2a12
6
+ metadata.gz: 0f8450d98c55022734694f34fba10255893931c890c3a0159a93a6a92f4ad49e5bc1a3d159e22b2cd8e645ac246938e80d1bdd9575f59a939bb69796fc0725ba
7
+ data.tar.gz: c726cf5ede32c1931d8b9df400d23fa1f5cde03986a51d5bafe827d39cd96b7e37de90ca963360d32a904d20ef4c6022cadca66395cf2e3c62fcfd2a397156ba
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 [--host HOST] [--tls] [--server SERVER] [[ADDRESS:]PORT]
9
+ envoyc [--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
@@ -16,6 +16,9 @@ By default, the service will be available on a randomly generated domain name.
16
16
  e.g. 4iur.p45.eu. To specify the first component of the name, use the HOST
17
17
  argument.
18
18
 
19
+ You can connect multiple clients to the same host name. To help prevent abuse,
20
+ each client must present the KEY.
21
+
19
22
  ## The server
20
23
 
21
24
  envoys [--listen [HOST:]PORT] ZONE
@@ -32,4 +32,3 @@ module Envoy
32
32
 
33
33
  end
34
34
  end
35
-
@@ -20,6 +20,9 @@ OptionParser.new do |op|
20
20
  options[:hosts] ||= []
21
21
  options[:hosts] << v
22
22
  end
23
+ op.on "-k", "--key KEY" do |v|
24
+ options[:key] = v
25
+ end
23
26
  op.on "-t", "--[no-]tls", "Encrypt communications with the envoy server" do |v|
24
27
  options[:tls] = v
25
28
  end
@@ -48,11 +48,14 @@ module Envoy
48
48
  end
49
49
 
50
50
  def receive_halt
51
+ @halting = true
51
52
  EventMachine.stop_event_loop
52
53
  end
53
54
 
54
55
  def unbind
55
- if r = @options[:reconnect]
56
+ if @halting
57
+ STDERR.puts "Server shut us down."
58
+ elsif !@halting && r = @options[:reconnect]
56
59
  STDERR.write "Lost connection. Retrying... #{r[0]}\r"
57
60
  EM.add_timer 0.5 do
58
61
  @options[:reconnect] = r.rotate
@@ -64,16 +67,14 @@ module Envoy
64
67
  else
65
68
  STDERR.puts "Couldn't connect. Abandoning ship."
66
69
  end
67
- receive_halt
70
+ EventMachine.stop_event_loop
68
71
  end
69
72
  end
70
73
 
71
74
  def ssl_handshake_completed
72
75
  options[:did_connect] = true
73
76
  options[:reconnect] = %w"- \\ | /" if options[:hosts]
74
- o = options.dup
75
- o.delete(:local_host)
76
- send_object :options, o
77
+ send_object :options, options
77
78
  end
78
79
 
79
80
  def post_init
@@ -33,25 +33,41 @@ module Envoy
33
33
  channels[id].web.send_data data
34
34
  end
35
35
 
36
+ def key
37
+ @options[:key]
38
+ end
39
+
40
+ def halt
41
+ send_object :halt
42
+ close_connection(true)
43
+ end
44
+
36
45
  def receive_options options
37
46
  @options = options
38
47
  hosts = @options[:hosts] || []
39
- hosts.delete_if do |label|
48
+ hosts.any? do |label|
40
49
  if label == "s"
41
- send_object :message, "`s' is a reserved label"
50
+ send_object :message, "#{label}: label is reserved"
42
51
  true
43
52
  elsif label =~ /\./
44
- send_object :message, "labels may not contain dots"
53
+ send_object :message, "#{label}: labels may not contain dots"
45
54
  true
55
+ elsif other_trunk = Trunk.trunks[label][0]
56
+ unless other_trunk.key == key
57
+ send_object :message, "#{label}: label in use, and you don't have the key"
58
+ true
59
+ end
46
60
  end
47
- end
61
+ end && halt
48
62
  hosts << SecureRandom.random_number(36 ** 4).to_s(36) if hosts.empty?
49
- m = ["Local server on port #{options[:local_port]} is now publicly available via:"]
63
+ m = ["#{options[:local_host]}:#{options[:local_port]} now available at:"]
50
64
  @hosts = hosts.each do |host|
51
65
  Trunk.trunks[host] << self
52
66
  m << "http://#{host}.#{$zone}/"
53
67
  end
54
- send_object :message, m.join("\n")
68
+ @options[:key] ||= SecureRandom.hex(8)
69
+ send_object :message, m.join(" ")
70
+ send_object :message, "Your key is #{@options[:key]}"
55
71
  end
56
72
 
57
73
  def unbind
data/lib/envoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Envoy
2
- VERSION = '0.0.10'
2
+ VERSION = '0.0.11'
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.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Baum