ip-address

IP Range to CIDR in Ruby/Rails?

自作多情 提交于 2019-12-21 02:34:45
问题 I want to do two things: Convert IP Address inputs into CIDR Here are some example inputs: 1.1.1.1 192.168.*.* #=> 192.168.0-255.0-255 192.168.1.2-20 1.1.1-10.1-100 Check if a given IP Address falls into any CIDR. This must be a very fast query, as it's a very common lookup in my web app. I'm thinking of doing something like this: def matches?(request) valid = @ips.select {|cidr| cidr.contains?(request.remote_ip) } !valid.empty? end I think converting IP ranges into CIDR will let lookups be

Can we spoof $_SERVER['REMOTE_ADDR'] / user ip with php cURL?

狂风中的少年 提交于 2019-12-21 01:21:22
问题 Well the title basically says it. But for more info . . This method works but . . $ip = '1.1.1.1'; curl_setopt($handle, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip", "X_FORWARDED_FOR: $ip")); It only adds these two keys on the $_SERVER array HTTP_REMOTE_ADDR HTTP_X_FORWARDED_FOR The key REMOTE_ADDR still remains the same. Can REMOTE_ADDR be changed? The answer here says NO . But a comment also says It may, however, NOT be the user's real IP address because it may be hidden by proxies and

Can we spoof $_SERVER['REMOTE_ADDR'] / user ip with php cURL?

女生的网名这么多〃 提交于 2019-12-21 01:21:13
问题 Well the title basically says it. But for more info . . This method works but . . $ip = '1.1.1.1'; curl_setopt($handle, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip", "X_FORWARDED_FOR: $ip")); It only adds these two keys on the $_SERVER array HTTP_REMOTE_ADDR HTTP_X_FORWARDED_FOR The key REMOTE_ADDR still remains the same. Can REMOTE_ADDR be changed? The answer here says NO . But a comment also says It may, however, NOT be the user's real IP address because it may be hidden by proxies and

Ruby - Platform independent way to determine IPs of all network interfaces?

老子叫甜甜 提交于 2019-12-20 23:29:19
问题 Is there an easy way in Ruby for me to get a list of the IP addresses for all network interfaces? It needs to work in Linux/Win/OSX and I'd prefer to not have to parse ifconfig/ipconfig unless I absolutely have to. 回答1: As of Ruby 2.1, Socket#getifaddrs is available: 001:0> require 'socket' => true 002:0> Socket.getifaddrs.map { |i| i.addr.ip_address if i.addr.ipv4? }.compact => ["127.0.0.1", "192.168.1.121", "192.168.1.181"] 回答2: Check out the following post: http://coderrr.wordpress.com

Host Name Vs Canonical Host Name

假装没事ソ 提交于 2019-12-20 16:36:06
问题 Can anyone please explain me the difference between Host Name and Canonical Host Name? I am currently using InetAddress class to fetch host name using the IP Address. I came across these 2 APIs. So I am just wondering, which one I should opt for? 回答1: There are a few difference between the two: getCanonicalHostName() will attempt to resolve the FQDN. Therefore, you would get foo.mycompany.com whereas getHostName() might just return foo . getCanonicalHostName() will always do a reverse DNS

Host Name Vs Canonical Host Name

别来无恙 提交于 2019-12-20 16:34:27
问题 Can anyone please explain me the difference between Host Name and Canonical Host Name? I am currently using InetAddress class to fetch host name using the IP Address. I came across these 2 APIs. So I am just wondering, which one I should opt for? 回答1: There are a few difference between the two: getCanonicalHostName() will attempt to resolve the FQDN. Therefore, you would get foo.mycompany.com whereas getHostName() might just return foo . getCanonicalHostName() will always do a reverse DNS

Distinguish the between intranet and official IP addresses

社会主义新天地 提交于 2019-12-20 14:20:50
问题 How can I find out whether a given IP address is an official internet address or an internal intranet IP address? 回答1: Intranet IP's are often in the private IP range: 10.0.0.0 through 10.255.255.255 172.16.0.0 through 172.31.255.255 192.168.0.0 through 192.168.255.255 These are not usable for internet IP addresses. See also http://compnetworking.about.com/od/workingwithipaddresses/f/privateipaddr.htm 回答2: 10.0.0.0 - 10.255.255.255` (10.0.0.0/8, former Class A) 172.16.0.0 - 172.31.255.255`

Assigning IP address to docker containers?

夙愿已清 提交于 2019-12-20 13:58:25
问题 I'm new to Docker. Is it possible to assign an IP address (from a DHCP server) to Docker containers running on a host or VM? If yes, can someone point me in the correct direction. If no, is it a fundamental limitation of the container approach or it's just a feature that's not in Docker yet. 回答1: Caveat - Docker is under heavy development so confirming against current docs is advisable. The network element is one of those under current discussion on docker-dev , it looks like longer term

IP address of localhost:8080 -in webhooks of github +jenkins

♀尐吖头ヾ 提交于 2019-12-20 11:33:45
问题 I am trying to configure webhooks in github so that it will deploy every time I do a new push, I have added web hooks in github and given the address of jenkins which is http://localhost:8080/github-webhook/ but it did not work and I found out that we need to find our IP address and I added it as follows: http://'ipaddress'/github-webhook/ but I still did not get the jenkins to work? Thanks 回答1: You need a public address for Github to point to when detected a push request. localhost is on

Tool or PHP code to convert IP address into lat/lng coordinates [closed]

放肆的年华 提交于 2019-12-20 10:57:35
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have thousands of IP addresses of visitors to my site, what tools can I use to convert these into lat/lng coordinates? I will then be able visualise the data on a map with filters for further demographics gathered. 回答1: For one of my sites I made use of maxmind's free geolite country database which can be