54 lines
1.9 KiB
Ruby
Executable File
54 lines
1.9 KiB
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# Copyright (c) 2010 Jeff Lindsay
|
|
# Copyright (c) 2013 R. Tyler Croy
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person
|
|
# obtaining a copy of this software and associated documentation
|
|
# files (the "Software"), to deal in the Software without
|
|
# restriction, including without limitation the rights to use,
|
|
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
# copies of the Software, and to permit persons to whom the
|
|
# Software is furnished to do so, subject to the following
|
|
# conditions:
|
|
#
|
|
# The above copyright notice and this permission notice shall be
|
|
# included in all copies or substantial portions of the Software.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
# OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
require 'rubygems'
|
|
require 'optparse'
|
|
require 'passageway'
|
|
|
|
key = nil
|
|
options = OptionParser.new do |o|
|
|
o.banner =
|
|
"Usage: passageway [options] <localport>\n\n" +
|
|
"The file .localtunnel_callback, if it exists in the current working directory,\n"+
|
|
"will be executed with the tunnel endpoint as the first argument once the \n" +
|
|
"tunnel is started\n\n"
|
|
|
|
o.on("-k", "--key FILE", "upload a public key for authentication") do |k|
|
|
key = File.exist?(k.to_s) ? File.open(k).read : nil
|
|
end
|
|
o.on('-h', "--help", "show this help") { puts o; exit }
|
|
end
|
|
|
|
args = options.parse!
|
|
local_port = args[0]
|
|
unless local_port.to_i.between?(1, 65535)
|
|
puts options
|
|
exit
|
|
end
|
|
|
|
t = Passageway::Client.new(local_port, key)
|
|
t.register_tunnel
|
|
t.start_tunnel
|