# Ipaddr sublet file
# Created with sur-0.2
# 
# Code to get external IP taken from http://coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/

require 'socket'

configure :ipaddr do |s|
  s.interval = 60
end

on :run do |s|

  def local_ip
    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
      s.addr.last
    end
  ensure
    Socket.do_not_reverse_lookup = orig
  end

  # irb:0> local_ip


  # => "192.168.0.127"

  s.data = local_ip

end
