Module: Net
- Defined in:
- lib/nub/net.rb
Overview
Collection of simply network related helpers
Constant Summary collapse
- @@_proxy =
nil
- @@_agents =
OpenStruct.new({ windows_ie_6: 'Windows IE 6', windows_ie_7: 'Windows IE 7', windows_mozilla: 'Windows Mozilla', mac_safari: 'Mac Safari', mac_firefox: 'Mac FireFox', mac_mozilla: 'Mac Mozilla', linux_mozilla: 'Linux Mozilla', linux_firefox: 'Linux Firefox', linux_konqueror: 'Linux Konqueror', iphone: 'iPhone' })
Class Method Summary collapse
-
.agents ⇒ Object
Accessors.
- .ftp_proxy ⇒ Object
-
.get_proxy ⇒ Object
Get the system proxy variables.
- .http_proxy ⇒ Object
- .https_proxy ⇒ Object
-
.ip_forward? ⇒ Boolean
Check if the system is configured for the kernel to forward ip traffic.
- .no_proxy ⇒ Object
-
.proxy_exist? ⇒ Boolean
Check if a proxy is set.
-
.proxy_export ⇒ Object
Get a shell export string for proxies.
- .proxy_port ⇒ Object
- .proxy_uri ⇒ Object
Class Method Details
.agents ⇒ Object
Accessors
41 |
# File 'lib/nub/net.rb', line 41 def self.agents; @@_agents; end |
.ftp_proxy ⇒ Object
44 |
# File 'lib/nub/net.rb', line 44 def self.ftp_proxy; get_proxy if @@_proxy.nil?; @@_proxy['ftp_proxy']; end |
.get_proxy ⇒ Object
Get the system proxy variables
50 51 52 53 54 55 56 57 |
# File 'lib/nub/net.rb', line 50 def self.get_proxy @@_proxy = { 'ftp_proxy' => ENV['ftp_proxy'], 'http_proxy' => ENV['http_proxy'], 'https_proxy' => ENV['https_proxy'], 'no_proxy' => ENV['no_proxy'] } end |
.http_proxy ⇒ Object
45 |
# File 'lib/nub/net.rb', line 45 def self.http_proxy; get_proxy if @@_proxy.nil?; @@_proxy['http_proxy']; end |
.https_proxy ⇒ Object
46 |
# File 'lib/nub/net.rb', line 46 def self.https_proxy; get_proxy if @@_proxy.nil?; @@_proxy['https_proxy']; end |
.ip_forward? ⇒ Boolean
Check if the system is configured for the kernel to forward ip traffic
72 73 74 |
# File 'lib/nub/net.rb', line 72 def self.ip_forward? return `cat /proc/sys/net/ipv4/ip_forward`.include?('1') end |
.no_proxy ⇒ Object
47 |
# File 'lib/nub/net.rb', line 47 def self.no_proxy; get_proxy if @@_proxy.nil?; @@_proxy['no_proxy']; end |
.proxy_exist? ⇒ Boolean
Check if a proxy is set
66 67 68 69 |
# File 'lib/nub/net.rb', line 66 def self.proxy_exist? get_proxy if @@_proxy.nil? return !@@_proxy['http_proxy'].nil? end |
.proxy_export ⇒ Object
Get a shell export string for proxies
60 61 62 63 |
# File 'lib/nub/net.rb', line 60 def self.proxy_export get_proxy if @@_proxy.nil? return proxy_exist? ? (@@_proxy.map{|k,v| "export #{k}=#{v}"} * ';') + ";" : nil end |
.proxy_port ⇒ Object
43 |
# File 'lib/nub/net.rb', line 43 def self.proxy_port; http_proxy ? http_proxy.split(':').last : nil; end |
.proxy_uri ⇒ Object
42 |
# File 'lib/nub/net.rb', line 42 def self.proxy_uri; http_proxy ? http_proxy.split(':')[1][2..-1] : nil; end |