gdcodeclub / nedry

MIT License
2 stars 1 forks source link

As a user I want to record the name of the requesting computer #5

Open eebbesen opened 8 years ago

eebbesen commented 8 years ago

http://api.rubyonrails.org/classes/ActionDispatch/Request.html

eebbesen commented 8 years ago

Clarify: I had said to use request.hostname, but that's not a thing. request.remote_host is just the ip.

I know that this can be done -- it logs requesting computer name when you are running a server with ruby -run -e httpd . -p 9090.

eebbesen commented 8 years ago

I did some digging in webrick 2.2.0 -- not sure if we have access to this, but it looks like

For our purposes we may be able to use Resolv (http://ruby-doc.org/stdlib-2.2.2/libdoc/resolv/rdoc/Resolv.html#method-c-getname)

require 'resolv'
Resolv.getname(request.remote_ip)

I'm not sure that this will work outside of the network.