pipe2me-client 0.2.1 → 0.2.2

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: f9f132b1573f1f4fb103d1862ef4a0f4c8bc70f3
4
- data.tar.gz: 680041d4879c6b15e81e6e68c8b57d6a76ab702e
3
+ metadata.gz: 42624605ab61b1e56bf53471eebe5d321699f5bb
4
+ data.tar.gz: 7624869dc720e1ecc272f86c67d1be7d66ec06a8
5
5
  SHA512:
6
- metadata.gz: 06cb41c0cfb69a9e275d798d0938e220092a7c8cc45eb36ac75557777598f8a825f2377d36a5162cc490e36816281f736d0c772b7de38649d97b2a01f7b6425e
7
- data.tar.gz: d77b13376efe3a4b6bc34431b3d82d8b72190f5d1c1712b2b63fe37f792c03e38924ded69cd0274c001224ac21b52a6b08a6e29d7ee3bd13a2fba46f5a9de81a
6
+ metadata.gz: 156fa716529c419b83c0fe2859758ef291991b37966dfe1c0455a3b2b9d5d7aad8fd8dcbe55224c1f18235d65d788e4600f02ee4f2765118810463497ca92fea
7
+ data.tar.gz: 2d053da9bc4a94e57b2fcfa4f1eb35fc43b33eb329ce0b7f9a170ed86eb6e8ce7df7dd881508817678d54c5a0b35a3d6f2fd9b9c584a027c30d8237c2a4dac5b
data/README.mdown CHANGED
@@ -9,7 +9,7 @@ see [pipe2me](https://github.com/kinko/pipe2me)
9
9
 
10
10
  gem install pipe2me-client
11
11
  # optional: install man page
12
- sudo rake install
12
+ sudo cp doc/pipe2me.1 /usr/local/share/man/man1
13
13
 
14
14
  ## Usage
15
15
 
data/bin/pipe2me CHANGED
@@ -6,16 +6,21 @@ require "pipe2me/cli"
6
6
  require "pipe2me/cli-foreman"
7
7
  require "pipe2me/cli-monit"
8
8
 
9
+ if ENV["BACKTRACE"].to_i == 1
10
+ Pipe2me::CLI.start ARGV
11
+ exit 0
12
+ end
13
+
9
14
  begin
10
15
  Pipe2me::CLI.start ARGV
11
16
  rescue
12
17
  if UI.verbosity >= 2
13
- UI.error $!
18
+ UI.error $!.message
14
19
  raise
15
20
  elsif UI.verbosity >= 0
16
- UI.error $!
21
+ UI.error $!.message
17
22
  else
18
- STDERR.puts $!
23
+ STDERR.puts $!.message
19
24
  end
20
25
  exit 1
21
26
  end
data/bin/pipe2med ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV["BACKTRACE"] = "1"
3
+ Kernel.exec File.dirname(__FILE__) + "/pipe2me", *ARGV
@@ -16,6 +16,13 @@ class Pipe2me::CLI < Thor
16
16
  end
17
17
  end
18
18
 
19
+ config = Pipe2me::Tunnel.send(:config)
20
+ fqdn = config[:fqdn]
21
+
22
+ Pipe2me::Tunnel.tunnels.each do |protocol, remote_port, local_port|
23
+ UI.success "Tunneling #{protocol}://localhost:#{local_port} <=> #{protocol}://#{fqdn}:#{remote_port}"
24
+ end
25
+
19
26
  Kernel.exec "foreman start -f #{procfile}"
20
27
  end
21
28
  end
data/lib/pipe2me/cli.rb CHANGED
@@ -12,7 +12,7 @@ class Pipe2me::CLI < Thor
12
12
  option :server, :default => "http://test.pipe2.me:8080"
13
13
  option :auth, :required => true # "auth token"
14
14
  option :protocols, :default => "https" # "protocol names, e.g. 'http,https,imap'"
15
- option :ports # "local ports, one per protocol"
15
+ option :ports, :type => :string # "local ports, one per protocol"
16
16
  def setup
17
17
  Pipe2me::Config.server = options[:server]
18
18
  server_info = Pipe2me::Tunnel.setup options
@@ -27,6 +27,11 @@ class Pipe2me::CLI < Thor
27
27
  puts File.read("pipe2me.info.inc")
28
28
  end
29
29
 
30
+ desc "verify", "Verify the tunnel"
31
+ def verify
32
+ Pipe2me::Tunnel.verify
33
+ end
34
+
30
35
  desc "update", "Updates configuration"
31
36
  def update
32
37
  Pipe2me::Tunnel.update
@@ -1,5 +1,6 @@
1
1
  require "net/http"
2
2
  require "ostruct"
3
+ require "forwardable"
3
4
 
4
5
  # The HTTP module implements a simple wrapper around Net::HTTP, intended to
5
6
  # ease the pain of dealing with HTTP requests.
@@ -19,12 +20,11 @@ module Pipe2me::HTTP
19
20
  @response = response
20
21
  end
21
22
 
22
- def code
23
- response.code
24
- end
23
+ extend Forwardable
24
+ delegate [ :code, :url ] => :@response
25
25
 
26
26
  def message #:nodoc:
27
- "#{@response.response.class}: #{@response[0..120]}"
27
+ "#{url}: #{code} #{@response[0..120]} (#{@response.response.class})"
28
28
  end
29
29
  end
30
30
 
@@ -82,7 +82,8 @@ module Pipe2me::HTTP
82
82
  (200..299).include? status
83
83
  end
84
84
 
85
- # returns the response object itself, if it is valid (i.e. has a ), or raise
85
+ # returns the response object itself, if it is valid (i.e. has a 2XX status),
86
+ # or raise an Error.
86
87
  def validate!
87
88
  return self if valid?
88
89
 
@@ -3,12 +3,10 @@ module Pipe2me::Tunnel::Commands
3
3
 
4
4
  T = Pipe2me::Tunnel
5
5
 
6
- private
7
-
8
6
  # returns an array of [ protocol, remote_port, local_port ] entries
9
7
  def tunnels
10
8
  @tunnels ||= begin
11
- urls, ports = config.urls, config.ports
9
+ urls, ports = config.urls, config.ports.to_s.split(",")
12
10
 
13
11
  urls.zip(ports).map do |url, local_port|
14
12
  uri = URI.parse(url)
@@ -32,7 +30,7 @@ module Pipe2me::Tunnel::Commands
32
30
  def echo_commands
33
31
  tunnels.map do |protocol, remote_port, local_port|
34
32
  next unless cmd = echo_server_command(protocol, local_port)
35
- [ "echo_#{remote_port}", cmd ]
33
+ [ "echo_#{local_port}", cmd ]
36
34
  end.compact
37
35
  end
38
36
 
@@ -50,7 +50,7 @@ module Pipe2me::Tunnel
50
50
 
51
51
  # The base URL for this tunnels' configuration
52
52
  def url
53
- "#{config.server}/tunnels/#{config.token}"
53
+ "#{config.server}/tunnels/#{config.id}"
54
54
  end
55
55
 
56
56
  def config
@@ -64,6 +64,11 @@ module Pipe2me::Tunnel
64
64
 
65
65
  public
66
66
 
67
+ def verify
68
+ HTTP.get! "#{url}/verify"
69
+ puts config.fqdn
70
+ end
71
+
67
72
  def update
68
73
  unless File.exists?(SSH_PRIVKEY)
69
74
  ssh_keygen
@@ -1,4 +1,4 @@
1
1
  module Pipe2me
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  BANNER = "pipe2.me command line client V#{Pipe2me::VERSION}; (c) The kink team, 2013, 2014."
4
4
  end
data/test/env-test.sh CHANGED
@@ -11,7 +11,7 @@ it_start_a_tunnel() {
11
11
  echo "== env done ============="
12
12
 
13
13
  cat env | grep PIPE2ME_SERVER
14
- cat env | grep PIPE2ME_TOKEN
14
+ cat env | grep PIPE2ME_ID
15
15
  cat env | grep PIPE2ME_FQDN
16
16
  cat env | grep PIPE2ME_URLS_0
17
17
  cat env | grep PIPE2ME_TUNNEL
data/test/setup-test.sh CHANGED
@@ -5,7 +5,7 @@ describe "tunnel setup"
5
5
 
6
6
  # setup a tunnel
7
7
  it_sets_up_tunnels() {
8
- fqdn=$($pipe2me setup --server $pipe2me_server --auth $pipe2me_token)
8
+ fqdn=$($pipe2me setup --server $pipe2me_server --auth $pipe2me_token --ports 8100,8101 --protocols http,https)
9
9
 
10
10
  # pipe2me setup --server $pipe2me_server returns the fqdn of the subdomain and nothing else
11
11
  test 1 -eq $(echo $fqdn | wc -l)
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env roundup
2
+ describe "verify subcommand"
3
+
4
+ . $(dirname $1)/testhelper.inc
5
+
6
+ # setup a tunnel
7
+ it_sets_up_tunnels_and_verifies() {
8
+ fqdn=$($pipe2me setup --server $pipe2me_server --auth short@test.kinko.me)
9
+
10
+ # pipe2me setup --server $pipe2me_server returns the fqdn of the subdomain and nothing else
11
+ test 1 -eq $(echo $fqdn | wc -l)
12
+
13
+ verified=$($pipe2me verify)
14
+ test "$fqdn" == "$verified"
15
+
16
+ # sleep 4 seconds. The tunnel lives for 3 seconds
17
+ sleep 4
18
+ ! $pipe2me verify
19
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipe2me-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-18 00:00:00.000000000 Z
11
+ date: 2014-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: pipe2.me command line client V0.2.1; (c) The kink team, 2013, 2014.
69
+ description: pipe2.me command line client V0.2.2; (c) The kink team, 2013, 2014.
70
70
  email: contact@kinko.me
71
71
  executables:
72
72
  - pipe2me
@@ -75,6 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - README.mdown
77
77
  - bin/pipe2me
78
+ - bin/pipe2med
78
79
  - lib/pipe2me.rb
79
80
  - lib/pipe2me/cli-foreman.rb
80
81
  - lib/pipe2me/cli-monit.rb
@@ -106,6 +107,7 @@ files:
106
107
  - test/testhelper.debug
107
108
  - test/testhelper.inc
108
109
  - test/testhelper.release
110
+ - test/verify-test.sh
109
111
  - test/version-test.sh
110
112
  homepage: https://github.com/kinko/pipe2me-client
111
113
  licenses: []
@@ -129,5 +131,5 @@ rubyforge_project:
129
131
  rubygems_version: 2.2.1
130
132
  signing_key:
131
133
  specification_version: 4
132
- summary: pipe2.me command line client V0.2.1; (c) The kink team, 2013, 2014.
134
+ summary: pipe2.me command line client V0.2.2; (c) The kink team, 2013, 2014.
133
135
  test_files: []