ip

Get user ip with jquery

馋奶兔 提交于 2019-12-24 03:34:18
问题 I want to get the user's IP address with jQuery or JavaScript, it doesn't really matter but I prefer jQuery. I've seen some answers here but they didn't work for me. 回答1: This has been taken from How to get client IP address using jQuery $.getJSON("http://jsonip.appspot.com?callback=?", function(data){ alert( "Your ip: " + data.ip); }); 回答2: That isn't exposed to javascript, but if you really need it you could spit it out in your markup (assuming php): <head> <meta name="ip" content="<?php

convert number of bits in subnet mask to dotted decimal form in java [duplicate]

旧城冷巷雨未停 提交于 2019-12-24 03:06:42
问题 This question already has answers here : Converting CIDR address to subnet mask and network address (11 answers) Closed 6 years ago . I need to convert the IP Subnet Mask like say 24 to 255.255.255.0 or say 23 to 255.255.254.0 in Java. Is there any API that I can use ? thanks. 回答1: Without any libraries : int cidrMask = 23; long bits = 0; bits = 0xffffffff ^ (1 << 32 - cidrMask) - 1; String mask = String.format("%d.%d.%d.%d", (bits & 0x0000000000ff000000L) >> 24, (bits & 0x0000000000ff0000) >

How to detect the actual IP address of visitors

五迷三道 提交于 2019-12-24 02:45:11
问题 I have used the "REMOTE_ADDR" to detect the ip address of the visitors in PHP. But how could i detect the visitors ip address even if he is trying to hide them. I have used "HTTP_X_FORWARDED_FOR" and "HTTP_CLIENT_IP" too. But I am just not able to implement them correctly. 回答1: It's pretty inherently impossible. The other end could just set up their computer to lie to you entirely. There are things that will get you correct answers more often, but even they're pretty easy to get around.

Conversion from IP Range to CIDR Mask

半世苍凉 提交于 2019-12-24 02:14:41
问题 I've been working on an algorithm for converting an IP Range to a list IPs in CIDR Notation (will be mentioned as tuples henceforth). Now, what puzzles me is figuring out what is the Worst Case Scenario for this conversion; What is the maximum number of tuples I can get for an IPv4 Range? What is the maximum number of tuples I can get for an IPv6 Range? How was this calculated?erp I'm using a modified C version (which is not recursive) of the following Python script: 1 #!/usr/bin/env python 2

My IP is showing up wrong in PHP home server

蹲街弑〆低调 提交于 2019-12-24 02:04:37
问题 Ok simple enough <?PHP echo $_SERVER[REMOTE_ADDR]; ?> Ok maybe not, I my IP is currently 72.184.212.85 however the code above which I am using on an IP blocking system for a script shows my IP as my home server IP of 127.0.0.1 So when I go to my script my IP is shown as 127.0.0.1 but when I go to other websites it is shown as 72.184.212.85 How can I get the first value to show on my test server? 回答1: $_SERVER['REMOTE_ADDR'] will always show the IP address from which the request came. If you

how to shrink consecutive B ip classes in bigger one

给你一囗甜甜゛ 提交于 2019-12-24 01:58:09
问题 After reading List of IP Space used by Facebook: "Real" list is the last answer, but I wonder how Igy (with the answer marked as solution) managed to shrink the list a lot by adding consecutive classes into a bigger one (by decreasing accordingly from network mask for each new consecutive network), is there a tool, or only manually ? This is a HUGE improvement for firewall, where number of rules counts (the shorter the better). 回答1: A simple solution is to use netaddr: import netaddr ips =

joining two conditions in amazon s3 bucket policy

老子叫甜甜 提交于 2019-12-24 01:14:24
问题 say I have a condition like where I want that if the request is not from these ips ["192.0.2.0/24","203.0.113.0/24"] and if the request doesn't have a referrer among the following [example1.com, example2.com ] then deny it. I know individually I can do something like this: { "Sid": "6", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::my_bucket/*", "Condition": { "IpAddress":{ "aws:SourceIp": ["192.0.2.0/24","203.0.113.0/24"] } } } { "Sid": "7", "Effect

What's the best way for an Android app to listen for incomming TCP/IP messages?

房东的猫 提交于 2019-12-24 00:42:47
问题 I want to write an app that will listen for alarm messages whenever it is in the range of a server (on the same WiFi network). What is the best way to do this? Should I simply write a service that will act as a TCP/IP server and when it receives messages, have them generate an Android notification? or is there a better way to do this? I need this app to be running all the time while Android is running. How would I ensure that my 'listener' service is always running? thanks in advance..

.net HTTP_X_FORWARDED_FOR NULL on localhost

☆樱花仙子☆ 提交于 2019-12-23 21:23:30
问题 Apologises if this has been answered else where, I could not find it. In the case it has not, I am trying to find the original IP of a machine who has accessed the site. In my basic understanding, the variable HTTP_X_FORWARDED_FOR will display the user's IP regardless of proxy's and other filters. if this is true, I am trying to code this but I get a null string System.Web.HttpContext context = System.Web.HttpContext.Current; string ipAddress = context.Request.ServerVariables["HTTP_X

How to programatically determine which source IP address will be used to reach a given destination IP address

ⅰ亾dé卋堺 提交于 2019-12-23 19:18:52
问题 I have an embedded application which will be deployed on numerous third party systems and I need it to check that a deterministic and static source IP address is used for each destination address it communicates with (I know which destination IP addresses it will talk to). The third party must remain free to implement their IP routing how they feel fit (while complying to these constraints), I just need to check that it is deterministic and static and ideally know what it will be. Its a C