in-gfw
Identify if current location is located in mainland China.
Install
npm install in-gfw
Usage
const inGFW = require("in-gfw");
inGFW.os().then(console.log);
const inGFW = require("in-gfw");
inGFW.net().then(console.log);
API
inGFW.os();
inGFW.osSync();
- 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
.
inGFW.net(blockedHost, cnHost);
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.