diff options
| author | mo khan <mo@mokhan.ca> | 2015-02-09 20:40:06 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-02-09 20:40:06 -0700 |
| commit | 2b679683b19322a568225a69949e5d8ed61fe9a9 (patch) | |
| tree | c429152b92c4af7276b2c4e4daaf8be2fad4137e /lib | |
| parent | 41c8858025eb14cab34635b058ccf761dd04eb90 (diff) | |
protect from forgery and cache ip and hostname on fake agent.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/fake_agent.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/fake_agent.rb b/lib/fake_agent.rb index 2cf3309..bfa20d3 100644 --- a/lib/fake_agent.rb +++ b/lib/fake_agent.rb @@ -10,7 +10,7 @@ class FakeAgent end def register - response = Typhoeus.post(registration_url, body: { agent: { hostname: Socket.gethostname } }) + response = Typhoeus.post(registration_url, body: { agent: { hostname: hostname } }) json = JSON.parse(response.body) @id = json["id"] end @@ -80,7 +80,7 @@ class FakeAgent data: { fingerprint: fingerprint_for(file), path: file, - hostname: Socket.gethostname, + hostname: hostname, ip_addresses: ip_addresses, } } @@ -98,8 +98,12 @@ class FakeAgent sha end + def hostname + @hostname ||= Socket.gethostname + end + def ip_addresses - Socket.ip_address_list.find_all { |x| x.ipv4? }.map { |x| x.ip_address } + @ipaddresses ||= Socket.ip_address_list.find_all { |x| x.ipv4? }.map { |x| x.ip_address } end def disposition_for(file) |
