in-gfw
Identify current location is located in mainland China.
Last updated 8 years ago by gucong .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install in-gfw 
SYNC missed versions from official npm registry.

in-gfw

NPM version Travis AppVeyor Codecov David

Identify if current location is located in mainland China.

Install

npm install in-gfw

Usage

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

inGFW(blockedHost, cnHost);
inGFW.sync(blockedHost, cnHost);	// Synchronous version of `inGFW()`

Get result by inGFW.os() and fallback to inGFW.net()

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.
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.

Current Tags

  • 1.2.0                                ...           latest (8 years ago)

5 Versions

  • 1.2.0                                ...           8 years ago
  • 1.1.2                                ...           8 years ago
  • 1.1.1                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (18)

Copyright 2013 - present © cnpmjs.org | Home |