mirror of
https://github.com/taixingyiji/openit.git
synced 2025-11-03 12:12:14 +00:00
72 lines
1.4 KiB
Markdown
72 lines
1.4 KiB
Markdown
## clash-proxy
|
|
|
|
> simple javascript api for [clash](https://github.com/Dreamacro/clash)
|
|
|
|
[](https://npmjs.org/clash-proxy)
|
|
[](https://travis-ci.org/song940/clash-proxy)
|
|
|
|
### Installation
|
|
|
|
```bash
|
|
$ npm install clash-proxy
|
|
```
|
|
|
|
### Example
|
|
|
|
```js
|
|
const Clash = require('clash-proxy');
|
|
|
|
const clash = Clash({
|
|
secret: '-- YOUR CLASH TOKEN HERE --',
|
|
api: 'http://127.0.0.1:9090'
|
|
});
|
|
|
|
clash.traffic(({ up, down }) => {
|
|
console.log('traffic: up:%i; down:%i', up, down);
|
|
});
|
|
|
|
clash.logs('debug', log => {
|
|
console.log('log', log);
|
|
});
|
|
|
|
(async () => {
|
|
|
|
const proxies = await clash.proxies();
|
|
console.log(proxies);
|
|
|
|
const name = 'ss-ru1';
|
|
|
|
const proxy = await clash.proxy(name);
|
|
console.log(proxy);
|
|
|
|
const delay = await clash.delay(name);
|
|
console.log('delay', delay);
|
|
|
|
const rules = await clash.rules();
|
|
console.log(rules);
|
|
|
|
const config = await clash.config();
|
|
console.log(config);
|
|
|
|
const result = await clash.switch('auto');
|
|
console.log(result);
|
|
|
|
})();
|
|
|
|
```
|
|
|
|
### Contributing
|
|
- Fork this Repo first
|
|
- Clone your Repo
|
|
- Install dependencies by `$ npm install`
|
|
- Checkout a feature branch
|
|
- Feel free to add your features
|
|
- Make sure your features are fully tested
|
|
- Publish your local branch, Open a pull request
|
|
- Enjoy hacking <3
|
|
|
|
### MIT
|
|
|
|
This work is licensed under the [MIT license](./LICENSE).
|
|
|
|
--- |