All Projects → shadowsocks → shadowsocks-restful-api

shadowsocks / shadowsocks-restful-api

Licence: other
Secure, reliable, standard restful api for managing shadowsocks-libev

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to shadowsocks-restful-api

ss-v2ray-docker
Deprecated: please use https://hub.docker.com/r/mazy/ss-xray
Stars: ✭ 28 (-61.11%)
Mutual labels:  shadowsocks, shadowsocks-libev
Shadowsocks Hub Api
A set of open and standard restful APIs for managing shadowsocks users, servers, nodes, products, accounts, and traffic.
Stars: ✭ 25 (-65.28%)
Mutual labels:  shadowsocks, restful-api
shadowsocks erlite3
Shadowsocks for EdgeRouter Lite3
Stars: ✭ 22 (-69.44%)
Mutual labels:  shadowsocks, shadowsocks-libev
ssmgr-deploy
shadowsocks面板节点一键脚本,libev最新版
Stars: ✭ 17 (-76.39%)
Mutual labels:  shadowsocks, shadowsocks-libev
Shadowsocksbio
记录一下Shadowsocks的前世今生,以及一个简单的教程总结
Stars: ✭ 2,518 (+3397.22%)
Mutual labels:  shadowsocks, shadowsocks-libev
Lightyearvpn
翻墙,科学上网,梯子,VPN下载,加速器,外网,代理,路由,防火墙,GFW。支持UDP,游戏必备。免费VPN试用,全球Shadowsocks节点。免费SS节点,SSR节点和V2ray节点。
Stars: ✭ 282 (+291.67%)
Mutual labels:  shadowsocks, shadowsocks-libev
Openwrt Fanqiang
最好的路由器翻墙、科学上网教程—OpenWrt—shadowsocks
Stars: ✭ 3,894 (+5308.33%)
Mutual labels:  shadowsocks, shadowsocks-libev
Shadowsocks install
Auto Install Shadowsocks Server for CentOS/Debian/Ubuntu
Stars: ✭ 7,516 (+10338.89%)
Mutual labels:  shadowsocks, shadowsocks-libev
Breaking Gfw Book
整理所有的翻墙方法,持续更新....欢迎PR
Stars: ✭ 105 (+45.83%)
Mutual labels:  shadowsocks, shadowsocks-libev
Shadowsocks Munager
Middleware of shadowsocks-libev and sspanel
Stars: ✭ 44 (-38.89%)
Mutual labels:  shadowsocks, shadowsocks-libev
Twist
A light script for you to setup shadowsocks-libev server with high-speed connections and newest powerful features
Stars: ✭ 229 (+218.06%)
Mutual labels:  shadowsocks, shadowsocks-libev
Proxysu
Xray,V2ray,Trojan,NaiveProxy, Trojan-Go, ShadowsocksR(SSR),Shadowsocks-libev及相关插件,MTProto+TLS 一键安装工具,windows下用(一键科学上网)
Stars: ✭ 3,309 (+4495.83%)
Mutual labels:  shadowsocks, shadowsocks-libev
shadowsocks-libev-tomato
Pre-compiled shadowsocks-libev for TomatoUSB, Tomato Shibby, Toastman and Asuswrt Merlin.
Stars: ✭ 32 (-55.56%)
Mutual labels:  shadowsocks, shadowsocks-libev
project-tracking-system-backend-app
Enterprise project tracker, tracks commits done by employees after getting assigned to a couple of projects by their managers
Stars: ✭ 62 (-13.89%)
Mutual labels:  restful-api
SugarRestSharp
SugarRestSharp is a .NET C# SugarCRM/SuiteCRM Rest API Client. It is .NET C# Wrapper for the SugarCRM/SuiteCRM REST API Client.
Stars: ✭ 29 (-59.72%)
Mutual labels:  restful-api
portal
A lightweight framework for golang object (struct) serialization (mapping). Inspired heavily by marshmallow (a Python library).
Stars: ✭ 24 (-66.67%)
Mutual labels:  restful-api
angular6-httpclient-example
Angular 6 HttpClient: Consume RESTful API Example
Stars: ✭ 38 (-47.22%)
Mutual labels:  restful-api
CourseCake
By serving course 📚 data that is more "edible" 🍰 for developers, we hope CourseCake offers a smooth approach to build useful tools for students.
Stars: ✭ 21 (-70.83%)
Mutual labels:  restful-api
wgrest
WireGuard REST API
Stars: ✭ 92 (+27.78%)
Mutual labels:  restful-api
api
DotKernel's PSR-7 REST style API built around the Mezzio API skeleton.
Stars: ✭ 16 (-77.78%)
Mutual labels:  restful-api

Shadowsocks Restful Api

A secure, reliable, standard restful api for managing shadowsocks-libev.

A web app that manages users, server, nodes, products, accounts, and traffic can be found from shadowsocks-hub.

Install (Ubuntu 16.04)

Download shadowsocks-restful-api:

cd ~
git clone https://github.com/shadowsocks/shadowsocks-restful-api.git

Install Node:

curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
sudo apt-get install nodejs -y

Install dependencies:

sudo apt-get install -y python-dev make g++ screen
cd ~/shadowsocks-restful-api
npm i

Install shadowsocks-libev:

sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:max-c-lv/shadowsocks-libev -y
sudo apt-get update
sudo apt install shadowsocks-libev

Create digital certificate:

cd ~/shadowsocks-restful-api
openssl req -nodes -x509 -newkey rsa:4096 -keyout server.key -out server.cert -days 365

Create config file:

cd ~/shadowsocks-restful-api
touch .env
echo 'LOGIN_PASSWORD = pleaseChangeThisPassword' >> .env
echo 'LISTEN_PORT = 4001' >> .env

Run

Run shadowsocks-libev in the background:

screen -dm ss-manager -u --manager-address /tmp/shadowsocks-manager.sock --fast-open

Run shadowsocks-restful-api in the background:

cd ~/shadowsocks-restful-api
screen -dm node app.js

API

Login

Request method: POST
Request URL: https://host_name:port/login
Request Header: Content-Type: application/json
Request Body: {"password": "your_login_password"}
Response HTTP Status Code: 201 Created
Response Body: {"token","your_authentication_token"}
Response Error Status Code: 401 Unauthorized
500 Internal Server Error

Request example (curl):

curl -ik -H "Content-Type: application/json" -X POST -d '{"password":"pleaseChangeThisPassword"}' https://localhost:4001/login

Response example:

{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1Mjk0ODg0MTcsImV4cCI6MTUyOTU3NDgxN30.9wdDV4hXvHdCkWhcOFpW2YXvSL6WupWSj2kTI6XMhFk"}

Ping

Request method: GET
Request URL: https://host_name:port/ping
Request Header: Authorization: Bearer your_authentication_toke
Response HTTP Status Code: 200 OK
Response Body: {"pong":"pong"}
Response Error Status Code: 401 Unauthorized
424 (shadowsocks unreachable)
425 (shadowsocks no response)
500 Internal Server Error

Request example (curl):

curl -ik -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1Mjk0ODg0MTcsImV4cCI6MTUyOTU3NDgxN30.9wdDV4hXvHdCkWhcOFpW2YXvSL6WupWSj2kTI6XMhFk" https://localhost:4001/ping

Response example:

{"pong":"pong"}

Add a port

Request method: POST
Request URL: https://host_name:port/
Request Header: Content-Type: application/json
Authorization: Bearer your_authentication_toke
Request Body: {"port": port_number, "password": "port_password", "method": "encryption_method"}
Response HTTP Status Code: 201 Created
Response Error Status Code: 401 Unauthorized
409 (port already exists from shadowsocks)
410 (port not available from operating system)
422 (shadowsocks failed adding port)
427 (operating system failed adding port) 424 (shadowsocks unreachable)
425 (shadowsocks no response)
500 Internal Server Error

Request example (curl):

curl -ik -H "Content-Type: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1Mjk0ODg0MTcsImV4cCI6MTUyOTU3NDgxN30.9wdDV4hXvHdCkWhcOFpW2YXvSL6WupWSj2kTI6XMhFk" -X POST -d '{"port": 50000,"password":"2owkq9wu2elwst7","method":"chacha20-ietf-poly1305"}' https://localhost:4001/

Supported encryption methods are:

  • aes-128-gcm
  • aes-192-gcm
  • aes-256-gcm
  • aes-128-cfb
  • aes-192-cfb
  • aes-256-cfb
  • aes-128-ctr
  • aes-192-ctr
  • aes-256-ctr
  • camellia-128-cfb
  • camellia-192-cfb
  • camellia-256-cfb
  • bf-cfb
  • chacha20-ietf-poly1305
  • xchacha20-ietf-poly1305
  • salsa20
  • chacha20
  • chacha20-ietf

If the method field is not supplied, the default method is aes-256-cfb.

Delete a port

Request method: DELETE
Request URL: https://host_name:port?port=port_number
Request Header: Authorization: Bearer your_authentication_toke
Response HTTP Status Code: 204 No Content
Response Error Status Code: 401 Unauthorized
422 (shadowsocks failed removing port)
427 (operating system failed removing port)
424 (shadowsocks unreachable)
425 (shadowsocks no response)
500 Internal Server Error

Request example (curl):

curl -ik -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1Mjk0ODg0MTcsImV4cCI6MTUyOTU3NDgxN30.9wdDV4hXvHdCkWhcOFpW2YXvSL6WupWSj2kTI6XMhFk" -X DELETE https://localhost:4001?port=50000

Get all ports

Request method: GET
Request URL: https://host_name:port/all
Request Header: Authorization: Bearer your_authentication_toke
Response HTTP Status Code: 200 OK
Response Body: [{"port":port_number, "password":"port_password","method":"encryption_method"}, ... ]
Response Error Status Code: 401 Unauthorized
424 (shadowsocks unreachable)
425 (shadowsocks no response)
500 Internal Server Error

Request example (curl):

curl -ik -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1Mjk0ODg0MTcsImV4cCI6MTUyOTU3NDgxN30.9wdDV4hXvHdCkWhcOFpW2YXvSL6WupWSj2kTI6XMhFk" https://localhost:4001/all

Response example:

[{"port": 50000,"password":"2owkq9wu2elwst7","method":"chacha20-ietf-poly1305"}, {"port": 50001,"password":"dowl3829j3suniw6","method":"aes-256-cfb"}]

Get traffic for all ports

Request method: GET
Request URL: https://host_name:port/traffic/all
Request Header: Authorization: Bearer your_authentication_toke
Response HTTP Status Code: 200 OK
Response Body: [{"port":port_number, "traffic": traffic_usage}, ... ]
Response Error Status Code: 401 Unauthorized
424 (shadowsocks unreachable)
425 (shadowsocks no response)
500 Internal Server Error

Request example (curl):

curl -ik -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1Mjk0ODg0MTcsImV4cCI6MTUyOTU3NDgxN30.9wdDV4hXvHdCkWhcOFpW2YXvSL6WupWSj2kTI6XMhFk" https://localhost:4001/traffic/all

Response example:

[{"port": 50000,"traffic":928727287}, {"port": 50001,"traffic":0}]

Authentication

All the api requests except for login require an Authorization header. The header pattern is: Authorization: Bearer <token>. The token can be obtained from the login api.

A token expires in 24 hours. A new token is needed once the old one expires. Tokens can be re-used in multiple requests before exiration.

Security

This program encrypts all the traffic end-to-end using https. It requires you to set up a digital certificate. There are many ways that you can get a free digital certificate. You may also generate your own self-signed digital certificate:

cd ~/shadowsocks-restful-api/
openssl req -nodes -x509 -newkey rsa:4096 -keyout server.key -out server.cert -days 365

Reliability

This program aims to achieve best reliability. It will attempt to re-open the ports upon restart of shadowsocks or this program itself. It also keeps monitoring the opened ports. Should anyone were dropped (due to any unprecedented reason), this program would attemp to re-open it.

Bug report and feature request

Welcome to create an issue for them. Bugs have high priority to get addressed. Feature requests will depend on their popularity, importance.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].