ip-address

How to get the ip address under Windows

故事扮演 提交于 2019-12-11 16:55:53
问题 all i already had a "socketfd", and i was wondering how to use it to retrieve the local ip address. under linux, i can do something like this(not exactly correct): struct ifreq ifr; ifr.ifr_addr.sa_family = AF_INET; ioctl(socketfd, SIOCGIFADDR, &ifr); char *address = inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr); but, on Windows, how can i achieve the same goal? (not using MFC) many thanks. edit: maybe my host has multiple ip addresses, and i want the one "connected" with

How to filter dataframe based on ip range

橙三吉。 提交于 2019-12-11 15:17:41
问题 I have dataframe which has 2 columns. I want to filter this dataframe based on ip ranges present in json file. ip_ranges.json [ {"start": "45.43.144.0", "end": "45.43.161.255"} {"start": "104.222.130.0", "end": "104.222.191.255"} ... ] Dataframe: ip,p_value 97.98.173.96,3.7 73.83.192.21,6.9 ... Note: ip_range.json contains 100k elements and my dataframe has 300k rows. Currently, I implemented like this Created python list to store all ips in each range. For example ["45.43.144.0", "45.43.144

Determine country from IP - IPv6

北战南征 提交于 2019-12-11 12:26:28
问题 In my project, I have a function in postgres (plpgsql) that determines country from a given ip address: CREATE OR REPLACE FUNCTION get_country_for_ip(character varying) RETURNS character varying AS $BODY$ declare ip ALIAS for $1; ccode varchar; cparts varchar[]; nparts bigint[]; addr bigint; begin cparts := string_to_array(ip, '.'); if array_upper(cparts, 1) <> 4 then raise exception 'gcfi01: Invalid IP address: %', ip; end if; nparts := array[a2i(cparts[1])::bigint, a2i(cparts[2])::bigint,

using ip address component C#

江枫思渺然 提交于 2019-12-11 12:16:49
问题 I am trying to use a component which named as A C# IP Address Control but it has a problem I think. because when I increase its value 1, it gives me some wrong result. forexample ipAddressControl3.Text = "192.168.1.25"; IPAddress ipAddress1 = new IPAddress(ipAddressControl3.GetAddressBytes()); ipAddress1.Address++; MessageBox.Show(ipAddress1.ToString()); returns : "193.168.1.25" ! but I expect "192.168.1.26" what is the problem ? here is the components link : A C# IP Address Control edit :

Sniffing packets of communication with specific domain - Scapy

左心房为你撑大大i 提交于 2019-12-11 11:12:02
问题 What's the best way to sniff packets with the source or destination being a specific domain (for example "www.facebook.com"). And why won't this filter work? def filter_facebook(packet): return DNS in packet and "www.facebook.com" in packet I'm new to Scapy so please don't kill me. 来源: https://stackoverflow.com/questions/36117913/sniffing-packets-of-communication-with-specific-domain-scapy

Change IP Address in VB.Net

时光总嘲笑我的痴心妄想 提交于 2019-12-11 10:52:16
问题 I am writing a Windows Forms App in VB.Net that will (among other things) change the IP Address, Default Gateway, Subnet Mask, and set the IP Address to Static on an image of Winfows 7 only. Sysprep is not being used. I have searched Google and only come up with 2 options. I don't believe the first solution will work for me because I do not necessarily know the name of the connection. It uses netsh to change IP settings. I was going to give a link to this example but I can't post more than 2

multicast ip address - blocked in call to recvfrom

烈酒焚心 提交于 2019-12-11 09:56:17
问题 i am writing a simple multicast application. i intend to run it on localhost. i have done the following: char *maddr; . . . sendfd = socket(...); struct sockaddr_in sasend; sasend.sin_family = AF_INET; sasend.sin_port = htonl(portno); inet_ntop(maddr, &(sasend.sin_addr.s_addr)); struct sockaddr_in sarecv; memcpy(&sarecv, &sasend); recvfd = socket(...); const int on = 1; setsockopt(recvfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); // can you explain why // this is needed bind(recvfd, &sarecv

Block ip addresses automatically using PHP and htaccess

余生颓废 提交于 2019-12-11 09:38:48
问题 I have a login system that I am trying to make as secure as possible. After ten failed attempts, I would like to block the IP address. How can I open a file in PHP and add a line to my .htaccess file to block the IP Address? Here is my .htaccess file: # Turn on RewriteEngine RewriteEngine on # Block IP addresses with too many failed attempts RewriteCond %{REMOTE_ADDR} ^217.172.179.*$ [OR] RewriteCond %{REMOTE_ADDR} ^217.172.180.*$ RewriteCond %{REQUEST_URI} !/error/blocked.php$ [NC]

CFHostStartInfoResolution always fail ubunteros

ⅰ亾dé卋堺 提交于 2019-12-11 08:57:38
问题 I have found this nice piece of code to get a hostname from a IP Address. The problem is that it always fail both on simulator and on my 3GS. See below the code, the error is commented within: + (NSArray *)hostnamesForAddress:(NSString *)address { // Get the host reference for the given address. CFStreamError streamError; struct addrinfo hints; struct addrinfo *result = NULL; memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_NUMERICHOST; hints.ai_family = PF_UNSPEC; hints.ai_socktype =

Search on partial IP addresses stored as integers

北城余情 提交于 2019-12-11 07:47:15
问题 I currently have a MySQL database that includes IP addresses. On a search form, the client wants to search on a partial IP address and have (perhaps) many results pop up. I am currently storing the IP addresses in mysql as unsigned int. I am using PHP 5.2, so do not have access to PHP 5.7 and its INET6_NTOA function. The current database has over 50,000 records and continues to grow, so I don't want to have to convert all the IP's to dotted notation, then do a match - that seems a bit