ip-address

Getting IPAddress via a proxy with PHP?

假如想象 提交于 2019-12-05 07:43:46
I run security checks on a number of AJAX calls to see if the same IP requested that I have on record. I used the following set of class functions to establish the IP (which can come via load balancers, hence the lengthly methodology. private function IPMask_Match ($network, $ip) { $ip_arr = explode('/', $network); if (count($ip_arr) < 2) { $ip_arr = array($ip_arr[0], null); } $network_long = ip2long($ip_arr[0]); $x = ip2long($ip_arr[1]); $mask = long2ip($x) == $ip_arr[1] ? $x : 0xffffffff << (32 - $ip_arr[1]); $ip_long = ip2long($ip); return ($ip_long & $mask) == ($network_long & $mask); }

IP Address Lookup in VB.net (XP vs Windows 7)

允我心安 提交于 2019-12-05 07:14:49
问题 Currently I use the following code to retrieve the IP address of the local workstation... strIPAddress = System.Net.Dns.GetHostEntry(strComputerName).AddressList(0).ToString() This is fine for the Windows XP workstations. However, in Vista and Windows 7, this returns the IPv6 address which is not used at all. Is there a method of setting this to work so it always returns the IPv4 address regardless of platform? I know I can increment the AddressList value to 1 and get the correct IP in

How to resolve hostname to an ip address in node js

最后都变了- 提交于 2019-12-05 04:32:03
I need to resolve hostname defined in hosts file to its corresponding IP address. For example my host file look like this - "/etc/hosts" 127.0.0.1 ggns2dss81 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 192.168.253.8 abcdserver 192.168.253.20 testwsserver Now in my node.js , i can read content of this file, but i need to fetch for given hostname . hostname = "testwsserver" hostIP = getIP(hostname); console.log(hostIP); // This should print 192.168.253.20 PS - npm pkg or any third party package cannot be installed on machine. Help is much appreciated!! How about NodeJS

Is there a function that can take an ipAddress as string and tell me if its a non-routable IP address?

允我心安 提交于 2019-12-05 04:11:53
I am trying to determine if an IP address is routable. For example, if I receive 127.0.0.1, I know that this is loopback(ie: localhost). I wasn't able to find a function for this in .NET or any other language, so I have started writing my own which is far from complete. Before I spend lots of time writing this function, does anyone know if a function that determines if a ip address is non-routable exist? I would prefer a .NET solution, but beggers cant be choosers and I'll happily convert any solution. EDIT: Answered my question with a function. I have answered my own question by creating a

How to get the Cellular IP address in iOS app

浪尽此生 提交于 2019-12-05 03:38:27
问题 I like to display the IP address in my app, I already know how to display the WiFi IP address but when I am at callular it will display an error, so is there an methode to display the cellular IP address on iPhone? Here is the code I use for the WiFi IP address: NSString *address = @"error"; struct ifaddrs *interfaces = NULL; struct ifaddrs *temp_addr = NULL; int success = 0; // retrieve the current interfaces - returns 0 on success success = getifaddrs(&interfaces); if (success == 0) { //

Android Find the device's ip address when it's hosting a hotspot

天大地大妈咪最大 提交于 2019-12-05 02:49:55
I need to find the device's ip address when it's hosting a hotspot. I've used this code so far : //if is using Hotspot for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); if (intf.getName().contains("wlan")) { for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress() && (inetAddress.getAddress().length == 4)) { return inetAddress.getHostAddress(); } } } } This works

HttpContext.Current.Request.UserHostAddress is null

自闭症网瘾萝莉.ら 提交于 2019-12-05 00:53:43
In my Dev Machine HttpContext.Current.Request.UserHostAddress is null. Why? how can I turn it on? How can I get list of Ips in case of a proxy client? WCF Service with ASP.net 4 window7. Thanks Viral Sarvaiya to avoid this problem you can parse the HTTP_X_FORWARDED_FOR for the last entery IP. ip=Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ; if (!string.IsNullOrEmpty(ip)) { string[] ipRange = ip.Split(','); int le = ipRange.Length - 1; string trueIP = ipRange[le]; } else { ip=Request.ServerVariables["REMOTE_ADDR"]; } Hope this will helps you 来源: https://stackoverflow.com/questions/7674731

External ip address in Android programmatically

前提是你 提交于 2019-12-05 00:05:19
问题 I have searched everywhere on how to get the external ip address with no avail. I am able to successfully get the local ip address. In short what i want to do to get the same ip address as when I go on whatip.com or whatismyipaddress.com. However, I do not want to make any calls to the websites, is there a built in way to get this? Also, I want the external ipaddress if the user is connected to wifi. 回答1: However, I do not want to make any calls to the websites, is there a built in way to get

Parsing IP Address to string doesn't work for some reason [closed]

三世轮回 提交于 2019-12-04 23:29:51
it's telling me this "An unhandled exception of type 'System.FormatException' occurred in System.dll Additional information: An invalid IP address was specified" IPAddress ipAddr = IPAddress.Parse(richTextBox1.Text); that's the code, richTextBox1 is the default name for a rich textbox. i don't know why this isn't working Edit: i'm really dumb i parsed the wrong textbox IPAddress.Parse does not accept spaces or other characters in the string. Use string.Trim to eliminate such characters and it should work: var result = IpAddress.Parse(richTextBox1.Text.Trim()); 来源: https://stackoverflow.com

External IP Address of the client

倖福魔咒の 提交于 2019-12-04 22:41:42
问题 Sounds funny, but how can I get the external IP address from a client? I tried few things, but didn't work for me. in first place I tried request.getRemoteAddr() and I am getting the result as: 0:0:0:0:0:0:0:1 in second place I tried InetAddress ip = InetAddress.getLocalHost(); ip.getHostAddress()); and I am getting the result as: 127.0.0.1 in third place I tried URL whatismyip = new URL("http://checkip.dyndns.org:8245/"); BufferedReader inIP = new BufferedReader(new InputStreamReader