proxylocal 0.1.1 → 0.2.0

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.
data/Rakefile CHANGED
@@ -5,12 +5,11 @@ require 'echoe'
5
5
  require 'lib/client'
6
6
 
7
7
  Echoe.new('proxylocal', ProxyLocal::VERSION) do |p|
8
- p.description = 'Proxy your local web-server and make it publicly available over the internet'
9
- p.url = 'http://proxylocal.com/'
10
- p.author = 'Just Lest'
11
- p.email = 'just.lest@gmail.com'
12
- p.runtime_dependencies = ['eventmachine >=0.12.10', 'bert >=1.1.2']
13
- p.development_dependencies = []
8
+ p.summary = 'Proxy your local web-server and make it publicly available over the internet'
9
+ p.url = 'http://proxylocal.com/'
10
+ p.author = 'Just Lest'
11
+ p.email = 'just.lest@gmail.com'
12
+ p.runtime_dependencies = ['eventmachine >=0.12.10', 'bert >=1.1.2']
14
13
  p.require_signed = true
15
- p.rubyforge_name = ''
14
+ p.project = nil
16
15
  end
data/lib/client.rb CHANGED
@@ -4,7 +4,7 @@ require 'eventmachine'
4
4
  require 'bert'
5
5
 
6
6
  module ProxyLocal
7
- VERSION = '0.1.1'
7
+ VERSION = '0.2.0'
8
8
 
9
9
  module Serializer
10
10
  def self.dump(object)
@@ -55,6 +55,10 @@ module ProxyLocal
55
55
  send_object(BERT::Tuple[:options, @options])
56
56
  end
57
57
 
58
+ def post_init
59
+ @connections = {}
60
+ end
61
+
58
62
  def ssl_handshake_completed
59
63
  send_options
60
64
  end
@@ -74,16 +78,24 @@ module ProxyLocal
74
78
  puts message[1]
75
79
  when :halt
76
80
  EventMachine.stop_event_loop
77
- when :request
78
- _, uuid, request = message
79
- @@logger.info(first_line(request))
80
- EventMachine.connect('127.0.0.1', @options[:local_port], ClientProxy) do |connection|
81
- connection.callback do |data|
82
- @@logger.info("#{first_line(data)} - #{first_line(request)}")
83
- send_object(BERT::Tuple[:response, uuid, data])
84
- end
85
- connection.send_data(request)
81
+ when :connection
82
+ _, id = message
83
+ @@logger.info("New connection")
84
+ connection = EventMachine.connect('127.0.0.1', @options[:local_port], ClientProxy)
85
+ connection.on_data do |data|
86
+ send_object(BERT::Tuple[:stream, id, data])
86
87
  end
88
+ connection.on_unbind do
89
+ @@logger.info("Connection closed")
90
+ send_object(BERT::Tuple[:close, id])
91
+ end
92
+ @connections[id] = connection
93
+ when :stream
94
+ _, id, data = message
95
+ @connections[id].send_data(data)
96
+ when :close
97
+ _, id = message
98
+ @connections[id].close_connection
87
99
  end
88
100
  end
89
101
 
@@ -95,19 +107,23 @@ module ProxyLocal
95
107
 
96
108
  class ClientProxy < EventMachine::Connection
97
109
  def post_init
98
- @data = ''
110
+ @callbacks = {}
99
111
  end
100
112
 
101
113
  def receive_data(data)
102
- @data << data
114
+ @callbacks[:on_data].call(data) if @callbacks.has_key?(:on_data)
103
115
  end
104
116
 
105
117
  def unbind
106
- @callback.call(@data) if @callback
118
+ @callbacks[:on_unbind].call if @callbacks.has_key?(:on_unbind)
119
+ end
120
+
121
+ def on_data(&block)
122
+ @callbacks[:on_data] = block
107
123
  end
108
124
 
109
- def callback(&block)
110
- @callback = block
125
+ def on_unbind(&block)
126
+ @callbacks[:on_unbind] = block
111
127
  end
112
128
  end
113
129
  end
data/proxylocal.gemspec CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{proxylocal}
5
- s.version = "0.1.1"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Just Lest"]
9
9
  s.cert_chain = ["/Users/lest/.gem/gem-public_cert.pem"]
10
- s.date = %q{2010-11-23}
10
+ s.date = %q{2010-12-08}
11
11
  s.default_executable = %q{proxylocal}
12
12
  s.description = %q{Proxy your local web-server and make it publicly available over the internet}
13
13
  s.email = %q{just.lest@gmail.com}
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
17
17
  s.homepage = %q{http://proxylocal.com/}
18
18
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Proxylocal"]
19
19
  s.require_paths = ["lib"]
20
- s.rubyforge_project = %q{}
21
20
  s.rubygems_version = %q{1.3.7}
22
21
  s.signing_key = %q{/Users/lest/.gem/gem-private_key.pem}
23
22
  s.summary = %q{Proxy your local web-server and make it publicly available over the internet}
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxylocal
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Just Lest
@@ -36,7 +36,7 @@ cert_chain:
36
36
  9HkV98wF6vQ=
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2010-11-23 00:00:00 +02:00
39
+ date: 2010-12-08 00:00:00 +02:00
40
40
  default_executable:
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: "1.2"
120
120
  requirements: []
121
121
 
122
- rubyforge_project: ""
122
+ rubyforge_project:
123
123
  rubygems_version: 1.3.7
124
124
  signing_key:
125
125
  specification_version: 3
metadata.gz.sig CHANGED
Binary file