자바스크립트를 사용하여 클라이언트의 IP 주소를 얻는 방법?

서버 사이드 코드도 SSI도 아닌 자바스크립트를 사용하여 어떻게든 클라이언트의 IP 주소를 검색해야 합니다.

그러나 저는 무료 타사 스크립트/서비스를 사용하는 것에 반대하지 않습니다.

꼭 이래야겠어요 웹 서비스를 사용할 수 있는 JSON 반품하십시오 (jQuery 함께 할 것을 간단해진다는). 다음은 무료 IP 조회 서비스를 할 수 있는 한 모든 활성 찾아 그 정보는 귀의하노라 제발 더 이상 추가 후 주석과 I& # 39 의 알고 있다면, ll 업데이트이 대답.

[Ip 데이터베이스 (db)] (https://db-ip.com/)

{
  "address": "116.12.250.1",
  "country": "SG",
  "stateprov": "Central Singapore",
  "city": "Singapore"
}
  • Limitations:*
  • 하루 2500 요청률
  • T 지원 제슨프 콜백 Doesn& # 39.
  • 별도의 IP 주소를 매개변수입니다
  • 이메일 주소로 API 키가 전달하십시오 필요합니다
  • 아니 SSL (https) 무료로 제공되는 계획
  • [조비츠] (http://geobytes.com/)

$.getJSON('http://gd.geobytes.com/GetCityDetails?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "geobytesforwarderfor": "",
  "geobytesremoteip": "116.12.250.1",
  "geobytesipaddress": "116.12.250.1",
  "geobytescertainty": "99",
  "geobytesinternet": "SA",
  "geobytescountry": "Saudi Arabia",
  "geobytesregionlocationcode": "SASH",
  "geobytesregion": "Ash Sharqiyah",
  "geobytescode": "SH",
  "geobyteslocationcode": "SASHJUBA",
  "geobytescity": "Jubail",
  "geobytescityid": "13793",
  "geobytesfqcn": "Jubail, SH, Saudi Arabia",
  "geobyteslatitude": "27.004999",
  "geobyteslongitude": "49.660999",
  "geobytescapital": "Riyadh ",
  "geobytestimezone": "+03:00",
  "geobytesnationalitysingular": "Saudi Arabian ",
  "geobytespopulation": "22757092",
  "geobytesnationalityplural": "Saudis",
  "geobytesmapreference": "Middle East ",
  "geobytescurrency": "Saudi Riyal",
  "geobytescurrencycode": "SAR",
  "geobytestitle": "Saudi Arabia"
}
  • Limitations:*
  • 시간당 16,384 요청률
  • 아니 SSL (https) 무료로 제공되는 계획
  • 반품해야 수 있습니다 잘못된 위치 (I& # 39 만 아니라, 싱가포르, 사우디아라비아)
  • [GeoIPLookup.io] (https://geoiplookup.io/)

$.getJSON('https://json.geoiplookup.io/api?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
    "ip": "116.12.250.1",
    "isp": "SGPOST",
    "org": "Singapore Post Ltd",
    "hostname": "116.12.250.1",
    "longitude": "103.807",
    "latitude": "1.29209",
    "postal_code": "",
    "city": "Singapore",
    "country_code": "SG",
    "country_name": "Singapore",
    "continent_code": "AS",
    "region": "Central Singapore",
    "district": "",
    "timezone_name": "Asia\/Singapore",
    "connection_type": "",
    "asn": "AS3758 SingNet",
    "currency_code": "SGD",
    "currency_name": "Singapore Dollar",
    "success": true
}
  • Limitations:*
$.getJSON('http://www.geoplugin.net/json.gp?jsoncallback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "geoplugin_request": "116.12.250.1",
  "geoplugin_status": 200,
  "geoplugin_credit": "Some of the returned data includes GeoLite data created by MaxMind, available from <a href=\\'http://www.maxmind.com\\'>http://www.maxmind.com</a>.",
  "geoplugin_city": "Singapore",
  "geoplugin_region": "Singapore (general)",
  "geoplugin_areaCode": "0",
  "geoplugin_dmaCode": "0",
  "geoplugin_countryCode": "SG",
  "geoplugin_countryName": "Singapore",
  "geoplugin_continentCode": "AS",
  "geoplugin_latitude": "1.2931",
  "geoplugin_longitude": "103.855797",
  "geoplugin_regionCode": "00",
  "geoplugin_regionName": "Singapore (general)",
  "geoplugin_currencyCode": "SGD",
  "geoplugin_currencySymbol": "$",
  "geoplugin_currencySymbol_UTF8": "$",
  "geoplugin_currencyConverter": 1.4239
}
  • Limitations:*
IP Address: 116.12.250.1
Country: SG
State: N/A
City: Singapore
Latitude: 1.293100
Longitude: 103.855797
  • Limitations:*
  • 하루 50 요청률
  • T 지원 제슨프 콜백 Doesn& # 39.
  • 별도의 IP 주소를 매개변수입니다
  • 일반 텍스트 되돌려줍니다
  • [ipapi.co] (https://ipapi.co/)

$.getJSON('https://ipapi.co/json/', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "ip": "116.12.250.1",
  "city": "Singapore",
  "region": "Central Singapore Community Development Council",
  "country": "SG",
  "country_name": "Singapore",
  "postal": null,
  "latitude": 1.2855,
  "longitude": 103.8565,
  "timezone": "Asia/Singapore"
}
  • Limitations:*
$.getJSON('http://ip-api.com/json?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "as": "AS3758 SingNet",
  "city": "Singapore",
  "country": "Singapore",
  "countryCode": "SG",
  "isp": "SingNet Pte Ltd",
  "lat": 1.2931,
  "lon": 103.8558,
  "org": "Singapore Telecommunications",
  "query": "116.12.250.1",
  "region": "01",
  "regionName": "Central Singapore Community Development Council",
  "status": "success",
  "timezone": "Asia/Singapore",
  "zip": ""
}
  • Limitations:*
  • 분당 150 요청률
  • 아니 SSL (https) 무료로 제공되는 계획
  • [Ipdata.co] (https://ipdata.co/)

$.getJSON('https://api.ipdata.co', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "ip": "116.12.250.1",
  "city": "Singapore",
  "region": "Central Singapore Community Development Council",
  "region_code": "01",
  "country_name": "Singapore",
  "country_code": "SG",
  "continent_name": "Asia",
  "continent_code": "AS",
  "latitude": 1.2931,
  "longitude": 103.8558,
  "asn": "AS3758",
  "organisation": "SingNet",
  "postal": "",
  "calling_code": "65",
  "flag": "https://ipdata.co/flags/sg.png",
  "emoji_flag": "\ud83c\uddf8\ud83c\uddec",
  "emoji_unicode": "U+1F1F8 U+1F1EC",
  "is_eu": false,
  "languages": [
    {
      "name": "English",
      "native": "English"
    },
    {
      "name": "Malay",
      "native": "Bahasa Melayu"
    },
    {
      "name": "Tamil",
      "native": "\u0ba4\u0bae\u0bbf\u0bb4\u0bcd"
    },
    {
      "name": "Chinese",
      "native": "\u4e2d\u6587"
    }
  ],
  "currency": {
    "name": "Singapore Dollar",
    "code": "SGD",
    "symbol": "S$",
    "native": "$",
    "plural": "Singapore dollars"
  },
  "time_zone": {
    "name": "Asia/Singapore",
    "abbr": "+08",
    "offset": "+0800",
    "is_dst": false,
    "current_time": "2018-05-09T12:28:49.183674+08:00"
  },
  "threat": {
    "is_tor": false,
    "is_proxy": false,
    "is_anonymous": false,
    "is_known_attacker": false,
    "is_known_abuser": false,
    "is_threat": false,
    "is_bogon": false
  }
}
  • Limitations:*
  • 하루 1,500 요청률
  • 이메일 주소로 API 키가 전달하십시오 필요합니다
  • 单捞磐啊 SSL (https)
  • [IP groupx] (https://ipfind.co/)

$.getJSON('https://ipfind.co/me?auth=', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "ip_address": "116.12.250.1",
  "country": "Singapore",
  "country_code": "SG",
  "continent": "Asia",
  "continent_code": "AS",
  "city": "Singapore",
  "county": null,
  "region": "Central Singapore",
  "region_code": "01",
  "timezone": "Asia/Singapore",
  "owner": null,
  "longitude": 103.8565,
  "latitude": 1.2855,
  "currency": "SGD",
  "languages": [
    "cmn",
    "en-SG",
    "ms-SG",
    "ta-SG",
    "zh-SG"
  ]
}
  • Limitations:*
$.getJSON('https://api.ipgeolocation.io/ipgeo?apiKey=', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "ip": "116.12.250.1",
  "continent_code": "AS",
  "continent_name": "Asia",
  "country_code2": "SG",
  "country_code3": "SGP",
  "country_name": "Singapore",
  "country_capital": "Singapore",
  "state_prov": "Central Singapore",
  "district": "",
  "city": "Singapore",
  "zipcode": "",
  "latitude": "1.29209",
  "longitude": "103.807",
  "is_eu": false,
  "calling_code": "+65",
  "country_tld": ".sg",
  "languages": "cmn,en-SG,ms-SG,ta-SG,zh-SG",
  "country_flag": "https://ipgeolocation.io/static/flags/sg_64.png",
  "isp": "SGPOST",
  "connection_type": "",
  "organization": "Singapore Post Ltd",
  "geoname_id": "1880252",
  "currency": {
    "name": "Dollar",
    "code": "SGD"
  },
  "time_zone": {
    "name": "Asia/Singapore",
    "offset": 8,
    "is_dst": false,
    "current_time": "2018-06-12 09:06:49.028+0800"
  }
}
  • Limitations:*
$.getJSON('https://api.ipify.org?format=jsonp&callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "ip": "116.12.250.1"
}
  • Limitations:*
$.getJSON('https://api.ipinfodb.com/v3/ip-city/?key=&format=json&callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "statusCode": "OK",
  "statusMessage": "",
  "ipAddress": "116.12.250.1",
  "countryCode": "SG",
  "countryName": "Singapore",
  "regionName": "Singapore",
  "cityName": "Singapore",
  "zipCode": "048941",
  "latitude": "1.28967",
  "longitude": "103.85",
  "timeZone": "+08:00"
}
  • Limitations:*
  • 두 개의 초당 요청
  • 单捞磐啊 맞춰찍기 구해 apiu 키
  • [ipinfo.io] (https://ipinfo.io/)

$.getJSON('https://ipinfo.io/json', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "ip": "116.12.250.1",
  "hostname": "No Hostname",
  "city": "Singapore",
  "region": "Central Singapore Community Development Council",
  "country": "SG",
  "loc": "1.2931,103.8558",
  "org": "AS3758 SingNet"
}
  • Limitations:*
$.getJSON('https://api.ipregistry.co/?key=', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "ip" : "116.12.250.1",
  "type" : "IPv4",
  "hostname" : null,
  "carrier" : {
    "name" : null,
    "mcc" : null,
    "mnc" : null
  },
  "connection" : {
    "asn" : 3758,
    "domain" : "singnet.com.sg",
    "organization" : "SingNet Pte Ltd",
    "type" : "isp"
  },
  "currency" : {
    "code" : "SGD",
    "name" : "Singapore Dollar",
    "plural" : "Singapore dollars",
    "symbol" : "SGD",
    "symbol_native" : "SGD",
    "format" : {
      "negative" : {
        "prefix" : "-SGD",
        "suffix" : ""
      },
      "positive" : {
        "prefix" : "SGD",
        "suffix" : ""
      }
    }
  },
  "location" : {
    "continent" : {
      "code" : "AS",
      "name" : "Asia"
    },
    "country" : {
      "area" : 692.0,
      "borders" : [ ],
      "calling_code" : "65",
      "capital" : "Singapore",
      "code" : "SG",
      "name" : "Singapore",
      "population" : 5638676,
      "population_density" : 8148.38,
      "flag" : {
        "emoji" : "🇸🇬",
        "emoji_unicode" : "U+1F1F8 U+1F1EC",
        "emojitwo" : "https://cdn.ipregistry.co/flags/emojitwo/sg.svg",
        "noto" : "https://cdn.ipregistry.co/flags/noto/sg.png",
        "twemoji" : "https://cdn.ipregistry.co/flags/twemoji/sg.svg",
        "wikimedia" : "https://cdn.ipregistry.co/flags/wikimedia/sg.svg"
      },
      "languages" : [ {
        "code" : "cmn",
        "name" : "cmn",
        "native" : "cmn"
      }, {
        "code" : "en",
        "name" : "English",
        "native" : "English"
      }, {
        "code" : "ms",
        "name" : "Malay",
        "native" : "Melayu"
      }, {
        "code" : "ta",
        "name" : "Tamil",
        "native" : "தமிழ்"
      }, {
        "code" : "zh",
        "name" : "Chinese",
        "native" : "中文"
      } ],
      "tld" : ".sg"
    },
    "region" : {
      "code" : null,
      "name" : "Singapore"
    },
    "city" : "Singapore",
    "postal" : "96534",
    "latitude" : 1.28967,
    "longitude" : 103.85007,
    "language" : {
      "code" : "cmn",
      "name" : "cmn",
      "native" : "cmn"
    },
    "in_eu" : false
  },
  "security" : {
    "is_bogon" : false,
    "is_cloud_provider" : false,
    "is_tor" : false,
    "is_tor_exit" : false,
    "is_proxy" : false,
    "is_anonymous" : false,
    "is_abuser" : false,
    "is_attacker" : false,
    "is_threat" : false
  },
  "time_zone" : {
    "id" : "Asia/Singapore",
    "abbreviation" : "SGT",
    "current_time" : "2019-09-29T23:13:32+08:00",
    "name" : "Singapore Standard Time",
    "offset" : 28800,
    "in_daylight_saving" : false
  }
}
  • Limitations:*
  • 무료 등의 계획에 100,000 요청률
  • 单捞磐啊 맞춰찍기 구해 apiu 키
  • [이프스타크] (https://ipstack.com/) (이전 명칭: freegeoip.net)

$.getJSON('http://api.ipstack.com/?access_key=', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
    "ip": "116.12.250.1",
    "type": "ipv4",
    "continent_code": "AS",
    "continent_name": "Asia",
    "country_code": "SG",
    "country_name": "Singapore",
    "region_code": "01",
    "region_name": "Central Singapore Community Development Council",
    "city": "Singapore",
    "zip": null,
    "latitude": 1.2931,
    "longitude": 103.8558,
    "location": {
        "geoname_id": 1880252,
        "capital": "Singapore",
        "languages": [{
            "code": "en",
            "name": "English",
            "native": "English"
        },
        {
            "code": "ms",
            "name": "Malay",
            "native": "Bahasa Melayu"
        },
        {
            "code": "ta",
            "name": "Tamil",
            "native": "\u0ba4\u0bae\u0bbf\u0bb4\u0bcd"
        },
        {
            "code": "zh",
            "name": "Chinese",
            "native": "\u4e2d\u6587"
        }],
        "country_flag": "http:\/\/assets.ipstack.com\/flags\/sg.svg",
        "country_flag_emoji": "\ud83c\uddf8\ud83c\uddec",
        "country_flag_emoji_unicode": "U+1F1F8 U+1F1EC",
        "calling_code": "65",
        "is_eu": false
    }
}
  • Limitations:* 월 ~ 10,000 명의 요청률
  • 별도의 IP 주소를 매개변수입니다
  • 单捞磐啊 맞춰찍기 구해 apiu 키
  • 아니 SSL (https) 무료로 제공되는 계획
  • [jsonip.com] (http://getjsonip.com/)

$.getJSON('https://jsonip.com/?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "ip": "116.12.250.1",
  "about": "/about",
  "Pro!": "http://getjsonip.com",
  "reject-fascism": "Liberal America will prevail"
}
  • Limitations:*
$.getJSON('http://ip.jsontest.com/?callback=?', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "ip": "116.12.250.1"
}
  • Limitations:*
  • 아니 SSL (https)
  • 그래서 wouldn& 다운되는 많이유 (이상 할당량입니다), t # 39 생산을 위해 사용한다.
  • 되돌려줍니다 IPv6 주소 존재하는 경우, 이는 그리웠댔지 않을 수 있습니다.
  • [네쿠도] (http://geoip.nekudo.com/)

$.getJSON('https://geoip.nekudo.com/api', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "city": "Singapore",
  "country": {
    "name": "Singapore",
    "code": "SG"
  },
  "location": {
    "accuracy_radius": 50,
    "latitude": 1.2855,
    "longitude": 103.8565,
    "time_zone": "Asia/Singapore"
  },
  "ip": "116.12.250.1"
}
  • Limitations:*
  • 차단되었음을 사용하여 광고 차단 의해 이사이프리바시 목록
  • [스마트리프] (https://smartip.io/)

$.getJSON('https://api.smartip.io/?api_key=', function(data) {
  console.log(JSON.stringify(data, null, 2));
});

되돌려줍니다:

{
  "status-code": 200,
  "country": {
    "is-metric": true,
    "is-in-europe": false,
    "region-geo-id": null,
    "continent-geo-id": 6255147,
    "country-geo-id": 1880251,
    "region-code": null,
    "region-name": null,
    "continent-code": "AS",
    "continent-name": "Asia",
    "capital": "Singapur",
    "country-name": "Singapore",
    "country-two-letter-iso-code": "SG",
    "country-iso-code": "SG"
  },
  "location": {
    "metro-code": null,
    "longitude": 103.8547,
    "latitude": 1.2929,
    "timezone": "Asia/Singapore",
    "zip-code": null,
    "city": "Singapore"
  },
  "asn": {
    "organization": "SingNet",
    "asn": "AS3758"
  },
  "currency": {
    "native-name": "新币",
    "code": "SGD",
    "name": "Singapore Dollar",
    "symbol": "$"
  },
  "timezone": {
    "is-daylight-saving": false,
    "gmt-offset": 28800,
    "date-time": "2019-08-23T14:22:11+08:00",
    "microsoft-name": "Singapore Standard Time",
    "iana-name": "Asia/Singapore"
  },
  "security": {
    "is-crawler": false,
    "is-proxy": false,
    "is-tor": false,
    "tor-insights": null,
    "proxy-insights": null,
    "crawler-insights": null
  },
  "crypto": {
    "is-crypto-node": false,
    "crypto-insights": null
  },
  "user-agent": {
    "os": {
      "name": "Windows",
      "platform": "x64",
      "version": "10",
      "family": "Windows"
    },
    "device": {
      "brand": "",
      "model": "",
      "family": "desktop"
    },
    "engine-version": "",
    "engine": "Blink",
    "name": "Chrome",
    "type": "browser",
    "header": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36",
    "version": "76.0.3809.100",
    "family": "Chrome"
  },
  "error": null,
  "hostname": "116.12.250.1",
  "ip-type": "ipv4",
  "ip": "116.12.250.1"
}
  • Limitations:*
  • 월 250,000 요청률
  • 单捞磐啊 맞춰찍기 구해 apiu 키
  • 单捞磐啊 SSL (https)
  • 이후 이들은 모두 다를 수 있다는 점을 적용부 너회의 마일리지 서비스를 무료로 충족시켰습니다 측면에서 할당액과 업무가동시간, 누가 될 때 / 슬래시나 계시나니 오프라인으로 down the road (공시물 A: [테리즈] (http://www.telize.com/)). 이들 중 대부분은 더 많은 기능을 제공하는 서비스 역시 같은 경우에 대비하여 계층화할 지불됨 SSL 지원. 이밖에 스코발이치 아래 명시된 주석 이후 대부분의 최종 사용자들은 대부분 이 문제가 발생하였는가 클라이언트 측 및 학술 reques 할당량이 초과할 결코 할당량입니다.

  • 업데이트 *
해설 (35)
  • 업데이트 *: 내가 하고 싶었던 최소 / 우글리피들 버전의 코드, 여기에서 백업이었습니다 ES6 약속하나요 코드:

<! - begin 스니핏: js 숨기십시오: 거짓값 콘솔: 진정한 바벨. &gt 거짓값 -;

var findIP = new Promise(r=>{var w=window,a=new (w.RTCPeerConnection||w.mozRTCPeerConnection||w.webkitRTCPeerConnection)({iceServers:[]}),b=()=>{};a.createDataChannel("");a.createOffer(c=>a.setLocalDescription(c,b,b),b);a.onicecandidate=c=>{try{c.candidate.candidate.match(/([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g).forEach(r)}catch(e){}}})

/*Usage example*/
findIP.then(ip => document.write('your ip: ', ip)).catch(e => console.error(e))

끝 - &lt 스니핏 >;!

  • Note:* 이 새로운 축소 된 코드를 반환하는 단일 IP 전용 ip 확인표시를 모든 사용자 (videocopilot. net/tutorials. 따라 더 많은 수 있는 네트워크) 을 사용하여 원본 코드가.

webrtc , 덕분에 매우 쉽습니다 afaq 로컬 IP 에서 지원되는 브라우저 WebRTC (적어도 지금은). 나는 아무 것도 아닌, 소스 코드를 수정되었음 흐름선 줄일 수 있는 경우에만 충격 이후 요청률 스맥랜드의 국민이 아닌 로컬 IP, 파이어폭스, 크롬, IP 아래 코드를 최신값 도망쳐야해 이 스니핏 및 확인할지 교도관님도요 작동합니다.

<! - begin 스니핏: js 숨기십시오: &gt 거짓값 -;

function findIP(onNewIP) { //  onNewIp - your listener function for new IPs
  var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; //compatibility for firefox and chrome
  var pc = new myPeerConnection({iceServers: []}),
    noop = function() {},
    localIPs = {},
    ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g,
    key;

  function ipIterate(ip) {
    if (!localIPs[ip]) onNewIP(ip);
    localIPs[ip] = true;
  }
  pc.createDataChannel(""); //create a bogus data channel
  pc.createOffer(function(sdp) {
    sdp.sdp.split('\n').forEach(function(line) {
      if (line.indexOf('candidate') < 0) return;
      line.match(ipRegex).forEach(ipIterate);
    });
    pc.setLocalDescription(sdp, noop, noop);
  }, noop); // create offer and set local description
  pc.onicecandidate = function(ice) { //listen for candidate events
    if (!ice || !ice.candidate || !ice.candidate.candidate || !ice.candidate.candidate.match(ipRegex)) return;
    ice.candidate.candidate.match(ipRegex).forEach(ipIterate);
  };
}

var ul = document.createElement('ul');
ul.textContent = 'Your IPs are: '
document.body.appendChild(ul);

function addIP(ip) {
  console.log('got ip: ', ip);
  var li = document.createElement('li');
  li.textContent = ip;
  ul.appendChild(li);
}

findIP(addIP);
<h1> Demo retrieving Client IP using WebRTC </h1>

끝 - &lt 스니핏 >;!

우리는 무슨일인거죠 슬라이드에서는 분판할 더미 (dummy) 에 대해 원격 접속, 우리가 일반적으로 피어 (peer 문의하려면 마운트-exchange 착빙성 후보가 서로. 이 후보 및 판독값 착빙성 () 의 로컬 세션이 설명 및 오니스칸돈 이다테벤트) 사용자의 IP 주소를 알 수 있습니다.

어디서 코드로부터 - &gt 했다. [출처] (https://github.com/diafygi/webrtc-ips)

해설 (16)

서버, 맞춤화할 제슨프 편을 통해 이를 수 있습니다.

그래서 구글링 찾을 수 있는 한 동안 여기에서 볼 수 있는 https://stackoverflow.com/questions/102605/can-i-lookup-the-ip-address-of-a-hostname-from-javascript

<script type="application/javascript">
    function getip(json){
      alert(json.ip); // alerts the ip address
    }
</script>

<script type="application/javascript" src="http://www.telize.com/jsonip?callback=getip"></script>

&gt. 참고 : (telize.com) 는 15일 11월 2015년 종료하십시오 vmware. api 를 영구적으로.

해설 (9)

여기에 나와 있는 대부분의 답변은 서버 측 코드의 필요성에 대해 다음과 같이 설명합니다. 다른 사용자의 서버를 때리는 중입니다. 서버에 접속하지 않고 IP 주소를 얻을 필요가 없는 한, 이는 완전히 유효한 기술입니다.

이전에는 플러그인이 없어도(NAT 라우터 뒤에 있으면 잘못된 IP 주소를 얻을 수 있음) 이러한 작업이 불가능했지만 WebRTC의 등장으로 실제로 가능합니다. ** WebRTC를 지원하는 브라우저(현재: Firefox, Chrome 및 Opera).

WebRTC를 사용하여 유용한 클라이언트 IP 주소를 검색할 수 있는 방법에 대한 자세한 내용은 mido's answer를 참조하십시오.

해설 (6)

Ajax 호출을 (hostip.info) 또는 이와 비슷한 서비스를 수행할 수 있습니다.

function myIP() {
    if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
    else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

    xmlhttp.open("GET","http://api.hostip.info/get_html.php",false);
    xmlhttp.send();

    hostipInfo = xmlhttp.responseText.split("\n");

    for (i=0; hostipInfo.length >= i; i++) {
        ipAddress = hostipInfo[i].split(":");
        if ( ipAddress[0] == "IP" ) return ipAddress[1];
    }

    return false;
}

보너스로, 조로카리사션 정보 반환됨 같은 가능하다.

해설 (5)

&lt blockquote&gt this&lt 시도하시겠습니까 /blockquote>;;;

$.get("http://ipinfo.io", function(response) {
    alert(response.ip);
}, "jsonp");

또는

$(document).ready(function () {
    $.getJSON("http://jsonip.com/?callback=?", function (data) {
        console.log(data);
        alert(data.ip);
    });
});

[바이올린] [1]

해설 (3)

여바바 더 이상

체크아웃하려고 http://www.ipify.org/

그들을 따라. &gt. - 제한 없이 사용할 수 있습니다 (# 39, re 하는 경우에도 you& 수백만 요청률 (분당). &gt. - 리피피 완전히 오픈 소스 (체크아웃합니다 [깃허브 리포지토리를] (https://github.com/rdegges/ipify-api)).

39 의 here& 작업 JS 예 (대신 혹시 왜 몇 표, 현재까지 이 질문에 직접 시도하시겠습니까 그것을 볼 수 있는 작업).

<script>
function getIP(json) {
  alert("My public IP address is: " + json.ip);
}
</script>
<script src="https://api.ipify.org?format=jsonp&callback=getIP"></script>

너무 게을러서 복사 / 붙여넣기? 맘에들었어요. [ # 39, & # 128187 Here& 한다. 데모 ] (http://jsbin.com/bajubacaju/edit? html, 출력)

너무 게을러서 을? '' o

&gt. 참고 : 선반가공 끄기도구 애드블록 플러스 / 브로크 &amp amp;; co 를 실행하기 전에 데모. 그렇지 않으면 그냥 won& work. t # 39.

    • 리피피 나는 아무 것도 할 수 있는 팀. 내 생각엔 it& # 39 의 터무니없이 준활성 가는 것을 등 일반 优秀 대한 서비스를 제공할 것이라고 밝혔다.
해설 (4)

39, t can& 있습니다. # 39; d you& 서버 여쭤보세요.

해설 (6)

내 서비스 (http://ipinfo.io) 이 있으며, 사용할 수 있는 ip, 호스트 이름, 위치 정보 및 네트워크 소유자에게도 부여하느뇨 클라이언트뿐 있습니다. 간단한 예를 로깅합니다 here& # 39 에 있는 IP:

$.get("http://ipinfo.io", function(response) {
    console.log(response.ip);
}, "jsonp");

39 의 here& 자세한 이스피들 예 수 있는 전체 응답 정보를 를출력합니다 사용 가능한 모든 정보를 볼 수 있습니다. http://jsfiddle.net/zK5FN/2/

해설 (1)

이 코드를 포함할 수 있는 페이지: '&lt 스크립트입니다 유형 = &quot text/javascript";; src = &quot, http://l2.io/ip.js&quot, &gt &lt /script> ';;

더 독 here

해설 (3)

꼭 이래야겠어요 말하도다) 는 차드, 몰타 멋지구리해요 대답. 그러나 그들의 복잡한 양상을 띠고 있다. 그래서 내가 찾은 이 코드를 통해 해당 국가에 플러그인에는 제안하세요 광고

<script>
<script language="javascript" src="http://j.maxmind.com/app/geoip.js"></script>
<script language="javascript">
mmjsCountryCode = geoip_country_code();
mmjsCountryName = geoip_country_name();

</script>
  • 아니요 아약스. 그냥 일반 javascript 를. * D

가면 http://j.maxmind.com/app/geoip.js 포함되어 있음을 알 수 있습니다.

function geoip_country_code() { return 'ID'; }
function geoip_country_name() { return 'Indonesia'; }
function geoip_city()         { return 'Jakarta'; }
function geoip_region()       { return '04'; }
function geoip_region_name()  { return 'Jakarta Raya'; }
function geoip_latitude()     { return '-6.1744'; }
function geoip_longitude()    { return '106.8294'; }
function geoip_postal_code()  { return ''; }
function geoip_area_code()    { return ''; }
function geoip_metro_code()   { return ''; }

이 질문에 답해야 있기 때문에 아직 t really doesn& # 39.

39, t 컨테인먼트하는 http://j.maxmind.com/app/geoip.js doesn& IP (비록 그렇겠지 recoverpoint 는 IP 얻을 수 있다).

그러나 it& # 39 의 PhP 스크립트입니다 같은 일이 그렇게 쉽게 만들 수 있는 팝

function visitorsIP()   { return '123.123.123.123'; }

합니다. Put on http://yourdomain.com/yourip.php.

재동기화할

<script language="javascript" src="http://yourdomain.com/yourip.php"></script>

특히 하라님의 사용하도록 하는 타사 스크립트입니다. 다른 방법이 없다. Javascript 알 수 없는 사용자의 IP. 그러나 다른 서버에 문제가 없음을 잘 수 있는 작동합니까 javascript 를 통해 액세스할 수 있는 것처럼.

해설 (5)

이 두 가지 해석을 질문이예요 대부분의 사람들은 &quot, 클라이언트 IP&quot 해석했다. 국민이 볼 수 있는 IP 주소를 # 39 의 웹 server& 짓궂군요 위부의 LAN 및 외부에 있는 추세다. 대부분의 경우 클라이언트 컴퓨터의 IP 주소 표시되어도 아닙니다

진짜 내가 필요한 내 있지만브라우저에 실행하는 컴퓨터의 IP 주소를 호스팅하는 JavaScript 소프트웨어 (원하는거요 거의 항상 배후에 있는 로컬 IP 주소를 생각하신거야 NAT 레이어에는 LAN 에서).

미도는 게시하기를 것으로 보이는데, 위, 정말 환상적인 오토메이티드 의 IP 주소를 제공하는 유일한 해답은 클라이언트입니다.

미도는 고맙구나!

그러나 이 함수는 비동기적으로 런입니다 제시했다. 실제로 데릭쉐퍼드와 IP 주소를 사용할 수 있는 솔루션, 난 내 코드와 비동기적입니다 전에 배운 읽어들여집니다 / / 저장됩니까 IP 주소를 사용할 수 있도록 노력하겠다. 전 그 결과 대기 사용하기 전에 도착할 수 있었다.

이것은 &quot Waitable"; # 39 의 Mido& 버전을 지원한다. 이를 통해 다른 사람이 됐으면 좋겠다 "고 말했다.

<! - begin 스니핏: js 숨기십시오: &gt 거짓값 -;

function findIP(onNewIP) { //  onNewIp - your listener function for new IPs
    var promise = new Promise(function (resolve, reject) {
        try {
            var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; //compatibility for firefox and chrome
            var pc = new myPeerConnection({ iceServers: [] }),
                noop = function () { },
                localIPs = {},
                ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g,
                key;
            function ipIterate(ip) {
                if (!localIPs[ip]) onNewIP(ip);
                localIPs[ip] = true;
            }
            pc.createDataChannel(""); //create a bogus data channel
            pc.createOffer(function (sdp) {
                sdp.sdp.split('\n').forEach(function (line) {
                    if (line.indexOf('candidate') < 0) return;
                    line.match(ipRegex).forEach(ipIterate);
                });
                pc.setLocalDescription(sdp, noop, noop);
            }, noop); // create offer and set local description

            pc.onicecandidate = function (ice) { //listen for candidate events
                if (ice && ice.candidate && ice.candidate.candidate && ice.candidate.candidate.match(ipRegex)) {
                    ice.candidate.candidate.match(ipRegex).forEach(ipIterate);
                }
                resolve("FindIPsDone");
                return;
            };
        }
        catch (ex) {
            reject(Error(ex));
        }
    });// New Promise(...{ ... });
    return promise;
};

//This is the callback that gets run for each IP address found
function foundNewIP(ip) {
    if (typeof window.ipAddress === 'undefined')
    {
        window.ipAddress = ip;
    }
    else
    {
        window.ipAddress += " - " + ip;
    }
}

//This is How to use the Waitable findIP function, and react to the
//results arriving
var ipWaitObject = findIP(foundNewIP);        // Puts found IP(s) in window.ipAddress
ipWaitObject.then(
    function (result) {
        alert ("IP(s) Found.  Result: '" + result + "'. You can use them now: " + window.ipAddress)
    },
    function (err) {
        alert ("IP(s) NOT Found.  FAILED!  " + err)
    }
);
<h1>Demo "Waitable" Client IP Retrieval using WebRTC </h1>

끝 - &lt 스니핏 >;!

해설 (0)

저는 탈선, 하지만 난 오늘 내가 하는 질문에 있는 한, 비록 비슷한 couldn& # 39 의 ID, I did 다음 Javascript 를 사용하여 클라이언트입니다 찾을 수 없다.

서버 측에서: -

<div style="display:none;visibility:hidden" id="uip"></div>

Javascript 를 사용하여

var ip = $get("uip").innerHTML;

Ajax 를 사용하고 있지만, 아스피네 게테르망베이드 $ 프레젠테이션이든 () 대신 사용할 수 있습니다.

39 는 what& I& # 39, ve got a 숨겨짐 div 에 일어나고 있는 페이지 요소 # 39 의 IP 렌더링됩니다 user& 서버에서. 그냥 로드형 Javascript 에 비해 그 값을.

비슷한 조건을 가진 사람들이 당신 같은 일부 도움이 될 수 있습니다 (I like me 낼수있지않나 hadn& t # 39, 분명 이 아웃하려면).

건배!

해설 (4)

39, s, t # 39 더 쉬운 무료 접근 방식을 there& won& 하나님께용서를 방문자를 대한 권한.

Http://freegeoip.net/json. Ajax 요청을 게시물로의 있으며 아주 단순해졌습니다 제출 일단 위치 정보를 받을 수 있습니다, json 으로 업데이트를 통해 새로운 한 페이지 또는 리디렉션하는 이에 따라 반응합니다.

다음은 제출한 어떻게 요청이 위치 정보:

jQuery.ajax( { 
  url: '//freegeoip.net/json/', 
  type: 'POST', 
  dataType: 'jsonp',
  success: function(location) {
     console.log(location)
  }
} );
해설 (1)

(Smart-IP.net) 를 사용하여 지역 ip apiu. 예를 들어, 사용하여 포함한다.

$(document).ready( function() {
    $.getJSON( "http://smart-ip.net/geoip-json?callback=?",
        function(data){
            alert( data.host);
        }
    );
});
해설 (2)

외부 서비스를 이용하지 않는 한 일반적으로는 불가능합니다.

해설 (1)

사용할 수 있습니다. [userinfo.io] (http://userinfo.io) 자바스크립트 라이브러리.

<script type="text/javascript" src="userinfo.0.0.1.min.js"></script>

UserInfo.getInfo(function(data) {
  alert(data.ip_address);
}, function(err) {
  // Do something with the error
});

읽어들입니다 스크립트입니다 레키레이스 사용할 수도 있습니다.

이 IP 주소를 너회가 부여하느뇨 방문자를 뿐만 아니라, 몇 의 데이터를 위치 (국가, 도시 등). 조세프 막스 린드 데이터베이스를 기반으로 합니다.

  • 부인문을: * I wrote 이 라이브러리
해설 (0)
  • 전달하십시오 IP 를 포함한다.

한 줄로 JS 공용 IP 주소와 함께 받을 수 있습니다. 이 모든 좁히어 가 제공하는 무료 서비스 및 요청인지 해야 할 수 있습니다.

   $.get('http://jsonip.com/', function(r){ console.log(r.ip); });

위의 예제를 작동합니까 너회의 고르 브라우저가 지원해야 합니다. (크로스 기원 reques 공유). 그렇지 않으면 좋은 보안 예외가 될 수 있다. 그 이전 버전에서는 http://competitivehelp json p 사용하는 브라우저를 사용할 수 있습니다.

   $.getJSON('http://jsonip.com/?callback=?', function(r){ console.log(r.ip); });
해설 (0)

# 39 의 IP 주소와 자바스크립트 / jQuery 프레젠테이션이든 Client& &; 위치 (국가, 도시)

포함, script&gt &lt 됩니다. 태그로 &quot src"; https://partner. microsoft. 합니다. 서버만을 &quot 반환되므로 codehelper_ip"; 객체로 / JSON, 바로 사용할 수 있습니다.

// First, embed this script in your head or at bottom of the page.
<script language="Javascript" src="http://www.codehelper.io/api/ips/?js"></script>
// You can use it
<script language="Javascript">
    alert(codehelper_ip.IP);
    alert(codehelper_ip.Country);
</script>

자세한 내용은 dell. Javascript 탐지합니다 IP 주소 및 실제 국가

Jquery 를 사용하는 경우 볼 수 있습니다.

console.log(codehelper_ip); 

반환되었습니다 객체에는 대한 자세한 정보를 보여줄 예정이다.

스케쳐내 시도하시오 콜백 함수, 이:

// First, embed this script in your head or at bottom of the page.
<script language="Javascript" src="http://www.codehelper.io/api/ips/?callback=yourcallback"></script>
// You can use it
<script language="Javascript">
    function yourcallback(json) {
       alert(json.IP);
     }
</script>
해설 (4)

Appspot.com # 39, s, t # 39 callback& isn& 서비스를 사용할 수 있습니다. ipinfo.io 작동하는 것으로 보인다.

I did 추가 단계가 사용하여 모든 지역 정보 및 읽어들입니다 앙굴라이스. (덕분에 리카르도) 체크아웃합니다.

<div ng-controller="geoCtrl">
  <p ng-bind="ip"></p>
  <p ng-bind="hostname"></p>
  <p ng-bind="loc"></p>
  <p ng-bind="org"></p>
  <p ng-bind="city"></p>
  <p ng-bind="region"></p>
  <p ng-bind="country"></p>
  <p ng-bind="phone"></p>
</div>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.angularjs.org/1.2.12/angular.min.js"></script>
<script src="http://code.angularjs.org/1.2.12/angular-route.min.js"></script>
<script>
'use strict';
var geo = angular.module('geo', [])
.controller('geoCtrl', ['$scope', '$http', function($scope, $http) {
  $http.jsonp('http://ipinfo.io/?callback=JSON_CALLBACK')
    .success(function(data) {
    $scope.ip = data.ip;
    $scope.hostname = data.hostname;
    $scope.loc = data.loc; //Latitude and Longitude
    $scope.org = data.org; //organization
    $scope.city = data.city;
    $scope.region = data.region; //state
    $scope.country = data.country;
    $scope.phone = data.phone; //city area code
  });
}]);
</script>

Apc® 페이지 수 있습니다. http://www.orangecountyseomarketing.com/projects/_ip_angularjs.html

해설 (0)