in-gfw

Identify current location is located in mainland China.

  • in-gfw

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
in-gfw
821.2.06 years ago6 years agoMinified + gzip package size for in-gfw in KB

Readme

in-gfw ===== NPM version Travis AppVeyor Codecov David Identify if current location is located in mainland China.

Install

```bash npm install in-gfw ```

Usage

```js const inGFW = require("in-gfw"); inGFW().then(console.log); // true for located in mainland China inGFW.os().then(console.log); // true for system located in mainland China inGFW.net().then(console.log); // true for network located in mainland China ```

API

```js inGFW(blockedHost, cnHost); inGFW.sync(blockedHost, cnHost); // Synchronous version of inGFW() ``` Get result by inGFW.os() and fallback to inGFW.net() ```js inGFW.os(); inGFW.osSync(); // Synchronous version of inGFW.os() ```
  • Windows: Check if current location settings is PRC.
> Control Panel: Regional and language -> Location
  • POSIX systems: Check if timezone is set to Beijing, Chongqing, Shanghai, Urumqi or PRC.
```js inGFW.net(blockedHost, cnHost); inGFW.netSync(blockedHost, cnHost); // Synchronous version of inGFW.net() ``` Based on the speed of network access to identify if current location is located in mainland China.
  • blockedHost
Type: string|URL Default: "www.npmjs.com" host for speed test that blocked by GFW
  • cnHost
Type: string|URL Default: "npm.taobao.org" host for speed test that mirrored in mainland China.