proxymachine 0.2.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ = 1.0.0 / 2009-10-19
2
+ * No changes. Production ready!
3
+
1
4
  = 0.2.8 / 2009-10-14
2
5
  * Minor changes
3
6
  * Always log proxy connection
data/README.md CHANGED
@@ -3,10 +3,6 @@ ProxyMachine
3
3
 
4
4
  By Tom Preston-Werner (tom@mojombo.com)
5
5
 
6
- WARNING: This software is alpha and should not be used in production without
7
- extensive testing. You should not consider this project production ready until
8
- it is released as 1.0.
9
-
10
6
 
11
7
  Description
12
8
  -----------
@@ -30,6 +26,8 @@ backend connections are hooked up to form a transparent proxy. This
30
26
  bidirectional proxy continues to exist until either the client or backend
31
27
  close the connection.
32
28
 
29
+ ProxyMachine was developed for GitHub's federated architecture and is successfully used in production to proxy millions of requests every day. The performance and memory profile have both proven to be excellent.
30
+
33
31
 
34
32
  Installation
35
33
  ------------
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 2
3
- :patch: 8
4
- :major: 0
2
+ :minor: 0
3
+ :patch: 0
4
+ :major: 1
data/proxymachine.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{proxymachine}
8
- s.version = "0.2.8"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tom Preston-Werner"]
12
- s.date = %q{2009-10-14}
12
+ s.date = %q{2009-10-19}
13
13
  s.default_executable = %q{proxymachine}
14
14
  s.email = %q{tom@mojombo.com}
15
15
  s.executables = ["proxymachine"]
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  "lib/proxymachine/client_connection.rb",
34
34
  "lib/proxymachine/server_connection.rb",
35
35
  "proxymachine.gemspec",
36
+ "test/configs/simple.rb",
36
37
  "test/proxymachine_test.rb",
37
38
  "test/test_helper.rb"
38
39
  ]
@@ -42,7 +43,8 @@ Gem::Specification.new do |s|
42
43
  s.rubygems_version = %q{1.3.5}
43
44
  s.summary = %q{ProxyMachine is a simple content aware (layer 7) TCP routing proxy.}
44
45
  s.test_files = [
45
- "test/proxymachine_test.rb",
46
+ "test/configs/simple.rb",
47
+ "test/proxymachine_test.rb",
46
48
  "test/test_helper.rb",
47
49
  "examples/git.rb",
48
50
  "examples/long.rb",
@@ -0,0 +1,19 @@
1
+ LOGGER = Logger.new(File.new('/dev/null', 'w'))
2
+
3
+ proxy do |data|
4
+ if data == 'a'
5
+ { :remote => "localhost:9980" }
6
+ elsif data == 'b'
7
+ { :remote => "localhost:9981" }
8
+ elsif data == 'c'
9
+ { :remote => "localhost:9980", :data => 'ccc' }
10
+ elsif data == 'd'
11
+ { :close => 'ddd' }
12
+ elsif data == 'e' * 2048
13
+ { :noop => true }
14
+ elsif data == 'e' * 2048 + 'f'
15
+ { :remote => "localhost:9980" }
16
+ else
17
+ { :close => true }
18
+ end
19
+ end
@@ -1,7 +1,39 @@
1
1
  require 'test_helper'
2
2
 
3
+ def assert_proxy(host, port, send, recv)
4
+ sock = TCPSocket.new(host, port)
5
+ sock.write(send)
6
+ assert_equal recv, sock.read
7
+ sock.close
8
+ end
9
+
3
10
  class ProxymachineTest < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
11
+ should "handle simple routing" do
12
+ assert_proxy('localhost', 9990, 'a', '9980:a')
13
+ assert_proxy('localhost', 9990, 'b', '9981:b')
14
+ end
15
+
16
+ should "handle connection closing" do
17
+ sock = TCPSocket.new('localhost', 9990)
18
+ sock.write('xxx')
19
+ assert_equal nil, sock.read(1)
20
+ sock.close
21
+ end
22
+
23
+ should "handle rewrite routing" do
24
+ assert_proxy('localhost', 9990, 'c', '9980:ccc')
25
+ end
26
+
27
+ should "handle rewrite closing" do
28
+ assert_proxy('localhost', 9990, 'd', 'ddd')
29
+ end
30
+
31
+ should "handle noop" do
32
+ sock = TCPSocket.new('localhost', 9990)
33
+ sock.write('e' * 2048)
34
+ sock.flush
35
+ sock.write('f')
36
+ assert_equal '9980:' + 'e' * 2048 + 'f', sock.read
37
+ sock.close
6
38
  end
7
39
  end
data/test/test_helper.rb CHANGED
@@ -1,10 +1,57 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'shoulda'
4
+ require 'socket'
4
5
 
5
6
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
7
8
  require 'proxymachine'
8
9
 
9
- class Test::Unit::TestCase
10
+ # A simple echo server to use in tests
11
+ module EventMachine
12
+ module Protocols
13
+ class TestConnection < Connection
14
+ def self.start(host, port)
15
+ @@port = port
16
+ EM.start_server(host, port, self)
17
+ end
18
+
19
+ def receive_data(data)
20
+ send_data("#{@@port}:#{data}")
21
+ close_connection_after_writing
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ def harikari(ppid)
28
+ Thread.new do
29
+ loop do
30
+ begin
31
+ Process.kill(0, ppid)
32
+ rescue
33
+ exit
34
+ end
35
+ sleep 1
36
+ end
37
+ end
10
38
  end
39
+
40
+ ppid = Process.pid
41
+
42
+ # Start the simple proxymachine
43
+ fork do
44
+ harikari(ppid)
45
+ load(File.join(File.dirname(__FILE__), *%w[configs simple.rb]))
46
+ ProxyMachine.run('simple', 'localhost', 9990)
47
+ end
48
+
49
+ # Start two test daemons
50
+ [9980, 9981].each do |port|
51
+ fork do
52
+ harikari(ppid)
53
+ EM.run do
54
+ EventMachine::Protocols::TestConnection.start('localhost', port)
55
+ end
56
+ end
57
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxymachine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-14 00:00:00 -07:00
12
+ date: 2009-10-19 00:00:00 -07:00
13
13
  default_executable: proxymachine
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -47,6 +47,7 @@ files:
47
47
  - lib/proxymachine/client_connection.rb
48
48
  - lib/proxymachine/server_connection.rb
49
49
  - proxymachine.gemspec
50
+ - test/configs/simple.rb
50
51
  - test/proxymachine_test.rb
51
52
  - test/test_helper.rb
52
53
  has_rdoc: true
@@ -78,6 +79,7 @@ signing_key:
78
79
  specification_version: 3
79
80
  summary: ProxyMachine is a simple content aware (layer 7) TCP routing proxy.
80
81
  test_files:
82
+ - test/configs/simple.rb
81
83
  - test/proxymachine_test.rb
82
84
  - test/test_helper.rb
83
85
  - examples/git.rb