Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zswang/ipbase
ip common function
https://github.com/zswang/ipbase
Last synced: about 1 month ago
JSON representation
ip common function
- Host: GitHub
- URL: https://github.com/zswang/ipbase
- Owner: zswang
- Created: 2017-08-25T06:37:30.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-16T04:06:16.000Z (about 6 years ago)
- Last Synced: 2024-10-08T02:07:43.431Z (about 1 month ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ipbase
-----------# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coverage-image]][coverage-url]
IP common function
## 使用方法
### 白名单判断
```js
console.log(ipbase.ipInList('127.0.0.1', '127.0.0.1'));
// > trueconsole.log(ipbase.ipInList('127.0.0.1', ['127.0.0.1', '10.10.110.10']));
// > true
```### 获取客户端地址
```js
var req = {
headers: {
'x-real-ip': '198.168.100.54'
}
}
console.log(ipbase.getClientAddress(req));
// > 198.168.100.54
```## License
MIT © [zswang](http://weibo.com/zswang)
[npm-url]: https://npmjs.org/package/ipbase
[npm-image]: https://badge.fury.io/js/ipbase.svg
[travis-url]: https://travis-ci.org/zswang/ipbase
[travis-image]: https://travis-ci.org/zswang/ipbase.svg?branch=master
[coverage-url]: https://coveralls.io/github/zswang/ipbase?branch=master
[coverage-image]: https://coveralls.io/repos/zswang/ipbase/badge.svg?branch=master&service=github