ip-address

Cannot get user IP address (proxy/firewall/load balancer)

江枫思渺然 提交于 2019-12-19 02:49:08
问题 I used code below to get client ip with asp.net before but after I moved to VDS this function begin returning only my subnet mask which is 178.18.198.1 or 178.18.198.2. Can anyone help me with this problem? Private Function GetIPAddress() As String Dim sIPAddress As String = Nothing sIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR") If String.IsNullOrEmpty(sIPAddress) Then sIPAddress = Request.ServerVariables("REMOTE_ADDR") End If Return sIPAddress End Function EDIT Found similar

Python randomly generated IP address as string

限于喜欢 提交于 2019-12-18 18:56:30
问题 In Python, what should I do if I want to generate a random string in the form of an IP address? For example: "10.0.1.1" , "10.0.3.14" , "172.23.35.1" and so on. Could someone give me some help? 回答1: >>> import random >>> import socket >>> import struct >>> socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff))) '197.38.59.143' >>> socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff))) '228.237.175.64' NOTE This could generate IPs like 0.0.0.0 , 255.255.255.255 . 回答2: If

Use a proxy with webBrowser control C#/.net 3.5

我只是一个虾纸丫 提交于 2019-12-18 16:56:10
问题 I need some help from someone who has already use the webBrowser control along with a proxys. What I need is the following. 1 - Set a proxy for a webBrowser control. 2 - Load a specific site. 3 - Execute a routine over the site. 4 - Set a diferent proxy for the webBrowser control. 5 - Load another site. 6 - Execute the same routine from point number 3. And the process keeps in that way, looping from a list of proxys, until all of them had been used. But. I'm having some problems with the app.

Find IP address in iphone

三世轮回 提交于 2019-12-18 15:57:06
问题 I want to find IP address in an application. I am able to find it. But, problem is, it works fins in iphone os 2.0 or so. But, in iphone os 3.0 it is giving me a warning: warning: no '+currentHost' method found warning: (Messages without a matching method signature) I am using this code, and it works fine with os version 2.0. -(NSString*)getAddress { char iphone_ip[255]; strcpy(iphone_ip,"127.0.0.1"); // if everything fails NSHost* myhost = [NSHost currentHost]; if (myhost) { NSString *ad =

Smart way to get the public Internet IP address/geo loc

旧街凉风 提交于 2019-12-18 13:38:22
问题 I have a computer on the local network, behind a NAT router. I have some 192.168.0.x addresses, but I really want to know my public IP address, not something mentioned in How to get the IP address of the server on which my C# application is running on? or How to get the IP address of a machine in C# I need C# code. Is it possible? If so, how? 回答1: I prefer http://icanhazip.com. It returns a simple text string. No HTML parsing required. string myIp = new WebClient().DownloadString(@"http:/

remote_addr not returning IPv4 address

自作多情 提交于 2019-12-18 13:14:44
问题 I am using xampp on localhost and when I use $_SERVER["REMOTE_ADDR"] it returns ::1 (also does this in phpinfo() ). Why does it do this? I want it to return a normal ip address like 127.0.0.1. My operating system is windows vista. 回答1: ::1 is an IPv6 address and an abbreviation for 0:0:0:0:0:0:0:1 that is the loopback address to the local machine. So ::1 is the same as 127.0.0.1 only via IPv6 instead of IPv4. 回答2: Your apache is listening for IPv6 connections by default ( ::1 being local

How to know ip address of the router from code in android?

耗尽温柔 提交于 2019-12-18 12:45:24
问题 How can you find the IP address of the router (gateway address) from code? WifiInfo.getIpAddress() - returns IP address of device. In a shell command "ipconfig" does not return any value. Here is my solution, but please let me know if there is a better way to do this: WifiManager manager = (WifiManager)getSystemService(WIFI_SERVICE); DhcpInfo info = manager.getDhcpInfo(); info.gateway; 回答1: Hey this might help you: DHCPInfo final WifiManager manager = (WifiManager) super.getSystemService(WIFI

Static IP address for Role in Windows Azure?

[亡魂溺海] 提交于 2019-12-18 12:28:43
问题 Does anyone knows if obtaining a static IP address for a Web or Worker Role on Windows Azure is possible (possibly only in private beta)? 回答1: A few years later, Azure now lets you reserve IP addresses for VMs and cloud services (Web and Worker roles). However, it is only accessible from PowerShell for the time being (this will change in the future, apparently). The first five static IP addresses are free. To create an IP you will need to make sure you have the latest version of the Azure

How to get IP address from sockaddr

元气小坏坏 提交于 2019-12-18 11:19:23
问题 I want to try and get the ip address of a client after calling accept. This is what I have so far, but I just end up getting some long number that is clearly not an ip address. What could be wrong? int tcp_sock = socket(AF_INET, SOCK_STREAM, 0); sockaddr_in client; client.sin_family = AF_INET; socklen_t c_len = sizeof(client); int acc_tcp_sock = accept(tcp_sock, (sockaddr*)&client, &c_len); cout << "Connected to: " << client.sin_addr.s_addr << endl; 回答1: That long number is the IP address, in

Restrict / Block Directory Based on IP Address

拜拜、爱过 提交于 2019-12-18 08:56:51
问题 Trying to block directory access from everyone except 1 IP address. This .htaccess code blocks access but it blocks access to everything including images, css, etc. What do I need to change? RewriteCond %{REMOTE_ADDR} !^XX\.XXX\.XX\.XXX$ RewriteRule ^hidedirectory(.*)$ http://site.com/ [R,L] Anyone accessing mysite.com/hidedirectory except me should redirect to mysite.com. Is there a better, more secure way to do this including something like an http response code? 回答1: Better way is to do