Module: Spior::Status
- Defined in:
- lib/spior/status.rb
Overview
Status display information on your current IP addresse
If you use an IPV6 address, it should fail to display a Tor IP…
Class Method Summary collapse
-
.enable ⇒ Object
Check on check.torproject.org/api/ip if Tor is enable or not and display the result.
-
.info ⇒ Object
info check and display information from ipleak.net/json.
Class Method Details
.enable ⇒ Object
Check on check.torproject.org/api/ip if Tor is enable or not and display the result.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/spior/status.rb', line 13 def self.enable status = 'Disable' URI.open('https://check.torproject.org/api/ip') do |l| hash = JSON.parse l.read status = 'Enable' if hash['IsTor'] == true end status rescue OpenURI::HTTPError => e res = e.io puts "Fail to join server #{res.status}" end |
.info ⇒ Object
info check and display information from ipleak.net/json
Check for:
-
ip
-
continent_name
-
time_zone
We can add later info on City/Region or other things.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/spior/status.rb', line 33 def self.info URI.open('https://ipleak.net/json') do |l| hash = JSON.parse l.read puts " Current ip ===> #{hash['ip']}" puts " Continent ===> #{hash['continent_name']}" puts " Timezone ===> #{hash['time_zone']}" end puts " Status ===> #{enable}" rescue SocketError => e Msg.err e rescue OpenURI::HTTPError => e res = e.io puts "Fail to join server #{res.status}" end |