Which MySQL datatype to use for an IP address? [duplicate]

Since IPv4 addresses are 4 byte long, you could use an INT (UNSIGNED) that has exactly 4 bytes: `ipv4` INT UNSIGNED And INET_ATON and INET_NTOA to convert them: INSERT INTO `table` (`ipv4`) VALUES (INET_ATON(“127.0.0.1”)); SELECT INET_NTOA(`ipv4`) FROM `table`; For IPv6 addresses you could use a BINARY instead: `ipv6` BINARY(16) And use PHP’s inet_pton and inet_ntop … Read more

CloudFlare and logging visitor IP addresses via in PHP

Extra server variables that are available to cloud flare are: $_SERVER[“HTTP_CF_CONNECTING_IP”] real visitor ip address, this is what you want $_SERVER[“HTTP_CF_IPCOUNTRY”] country of visitor $_SERVER[“HTTP_CF_RAY”] $_SERVER[“HTTP_CF_VISITOR”] this can help you know if its http or https you can use it like this: if (isset($_SERVER[“HTTP_CF_CONNECTING_IP”])) { $_SERVER[‘REMOTE_ADDR’] = $_SERVER[“HTTP_CF_CONNECTING_IP”]; } If you do this, and the … Read more

Can You Get A Users Local LAN IP Address Via JavaScript?

As it turns out, the recent WebRTC extension of HTML5 allows javascript to query the local client IP address. A proof of concept is available here: http://net.ipcalf.com This feature is apparently by design, and is not a bug. However, given its controversial nature, I would be cautious about relying on this behaviour. Nevertheless, I think … Read more

How can I check if an ip is in a network in Python?

Using ipaddress (in the stdlib since 3.3, at PyPi for 2.6/2.7): >>> import ipaddress >>> ipaddress.ip_address(‘192.168.0.1’) in ipaddress.ip_network(‘192.168.0.0/24′) True If you want to evaluate a lot of IP addresses this way, you’ll probably want to calculate the netmask upfront, like n = ipaddress.ip_network(‘192.0.0.0/16’) netw = int(n.network_address) mask = int(n.netmask) Then, for each address, calculate the … Read more

How to extract IP Address in Spring MVC Controller get call?

The solution is @RequestMapping(value = “processing”, method = RequestMethod.GET) public @ResponseBody ProcessResponse processData(@RequestParam(“workflow”) final String workflow, @RequestParam(“conf”) final String value, @RequestParam(“dc”) final String dc, HttpServletRequest request) { System.out.println(workflow); System.out.println(value); System.out.println(dc); System.out.println(request.getRemoteAddr()); // some other code } Add HttpServletRequest request to your method definition and then use the Servlet API Spring Documentation here said in 15.3.2.3 … Read more

Get the client’s IP address in socket.io

Okay, as of 0.7.7 this is available, but not in the manner that lubar describes. I ended up needing to parse through some commit logs on git hub to figure this one out, but the following code does actually work for me now: var io = require(‘socket.io’).listen(server); io.sockets.on(‘connection’, function (socket) { var address = socket.handshake.address; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)