Giter Club home page Giter Club logo

ss-apiserver's Introduction

ss-apiserver

This is a simple restful API server that translates requests to an upstream ss-manager instance. This program requires netcat (check with which nc).

Usage

Run ss-manager first:

ss-manager --manager-address 127.0.0.1:1080 [...]

Then run ss-apiserver:

ss-apiserver -hostname 127.0.0.1 -port 1080 -listen 8080

Now you can control ss-manager using restful API:

# returns "ok" if ss-apiserver is running
curl http://localhost:8080/healthcheck

# get all ports and traffic stats
curl http://localhost:8080/ports

# add a port. this creates a new ss-server instance.
curl -X POST http://localhost:8080/ports/12345 -d MyPassword

# you can't change the password once the port is created. to modify, remove that port and add again.
curl -X DELETE http://localhost:8080/ports/12345

You can substitute localhost above to your host's domain.

Compile

You need a golang development environment (v1.12)

cd /go/src
export SS_API_BRANCH_NAME="v1.0"
SS_API_SRC_DIR="/go/src/github.com/imacks/ss-apiserver"
SS_API_GIT_DIR="https://github.com/imacks/ss-apiserver.git/"
mkdir -p "$SS_API_SRC_DIR"
cd "$SS_API_SRC_DIR"
git clone "$SS_API_GIT_DIR" --recursive --single-branch --branch "$SS_API_BRANCH_NAME" ./
git checkout "tags/${SS_API_BRANCH_NAME}"
export GIT_DESCRIBE=$(git describe --tags)
export LDFLAGS="-X main.VERSION=${GIT_DESCRIBE} -s -w"
export GCFLAGS=""
export CGO_ENABLED=0
export GOOS="linux"
export GOARCH="amd64"
export GO111MODULE=on
go mod download
go build -v -ldflags "$LDFLAGS" -gcflags "$GCFLAGS" -o /go/bin/ss-apiserver

ss-apiserver's People

Contributors

imacks avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.