Liu Song’s Projects


~/Projects/clash-api

git clone https://code.lsong.org/clash-api

clash-proxy

simple javascript api for clash

clash-proxy Build Status

Installation

$ npm install clash-proxy

Example

import { Clash } from 'clash-api'

const clash = new 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.