Skip to content

Commit

Permalink
Merge pull request #63 from epicagency/master
Browse files Browse the repository at this point in the history
Added support for opening app with appname.x.x.x.x.xip.io
  • Loading branch information
rodreegez committed Jun 9, 2012
2 parents 2d6e4ec + eda8193 commit 8d2b564
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ powder manages [pow](http://pow.cx/)
=> Opens the pow link in a browser
# aliased as powder -o

$ powder open --xip
=> Opens the xip.io link in a browser
# aliased as powder -o -x

$ powder open [bacon]
=> Opens http://bacon.dev in a browser
# if you have set up alternative top level domains in .powconfig,
Expand Down
17 changes: 16 additions & 1 deletion bin/powder
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,23 @@ module Powder
end

desc "open", "Open a pow in the browser"
method_option :xip, :type => :boolean, :default => false, :alias => '-x', :desc => "open xip.io instead of .domain"
def open(name=nil)
%x{open http://#{name || get_pow_name}.#{domain}}
if options.xip?
local_ip = '0.0.0.0'
begin
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
UDPSocket.open do |s|
s.connect '64.233.187.99', 1
local_ip = s.addr.last.to_s
end
ensure
Socket.do_not_reverse_lookup = orig
end
%x{open http://#{name || get_pow_name}.#{local_ip}.xip.io}
else
%x{open http://#{name || get_pow_name}.#{domain}}
end
end

desc "unlink", "Unlink a pow app"
Expand Down

0 comments on commit 8d2b564

Please sign in to comment.