Giter Site home page Giter Site logo

tc-ui's Introduction

tc-ui

WebUI for tcconfig which wraps TC(Linux Traffic Control)

tcui

Usage

Ensure there is ifb.ko on your server:

ls /lib/modules/$(uname -r)/kernel/drivers/net/ifb.ko 2>/dev/null && echo yes || echo no

Run TC WebUI by docker:

docker run --network=host --privileged -it --restart always -d \
    --name tc -v /lib/modules:/lib/modules:ro ossrs/tc-ui:1

Note: Only support Linux server, because it requires kernel module ifb and host network mode.

Note: Please use registry.cn-hangzhou.aliyuncs.com/ossrs/tc-ui:1 in China.

Open http://localhost:2023 in browser.

Export and Load Docker Image

If want to export the docker image:

docker pull ossrs/tc-ui:1
docker save ossrs/tc-ui:1 |gzip > tc-ui.tar.gz

If want to download the arm64 docker image:

docker pull --platform linux/arm64 ossrs/tc-ui:1
docker save ossrs/tc-ui:1 |gzip > tc-ui.tar.gz

Load the docker image:

docker load -i tc-ui.tar.gz

HTTP OpenAPI

There is an HTTP OpenAPI, pass cmd in HTTP POST body, for example:

curl http://localhost:2023/tc/api/v1/config/raw -X POST -d 'tcshow lo'

Set 10% loss of interface lo:

curl http://localhost:2023/tc/api/v1/config/raw -X POST -d 'tcset lo --loss 10%'
#{"code":0,"data":null}

Get settings of interface lo:

curl http://localhost:2023/tc/api/v1/config/raw -X POST -d 'tcshow lo'
#{"code":0,"data":{"lo":{"incoming":{},"outgoing":{}}}}

Reset all settings of interface lo:

curl http://localhost:2023/tc/api/v1/config/raw -X POST -d 'tcdel --all lo'
#{"code":0,"data":null}

Only allow tcset, tcshow and tcdel, or failed:

curl http://localhost:2023/tc/api/v1/config/raw -X POST -d 'ls'
#{"code":100,"data":"invalid cmd ls"}

For TC command, see:

Development in macOS

Run Go API server in Ubuntu20 server or docker:

docker build -t test -f Dockerfile.dev .
docker run --privileged --rm -it -p 2023:2023 -v $(pwd):/g -w /g test go run .

Note: Note that macOS docker doesn't support ingress, which requires kernel module ifb.

Note: Must run with --privileged or failed to run tc and tcpdump commands.

Build UI:

(cd ui && npm install && npm run build)
# Or
(cd ui && npm install && npm run start)

Open http://localhost:3000/ in browser.

Tools

Please install required tools, for Ubuntu20:

apt-get update -y
apt-get install -y curl tcpdump iputils-ping iproute2
curl -L https://golang.google.cn/dl/go1.16.12.linux-amd64.tar.gz |tar -xz -C /usr/local
export PATH=$PATH:/usr/local/go/bin

Please install tc and tcpdump:

sudo apt-get install -y iproute2 tcpdump

You can verify the installation by tc qdisc help and tcpdump --version.

Please install tcconfig:

# For Ubuntu20
sudo apt-get install -y python3-pip
sudo pip install tcconfig

# For CentOS7
sudo yum install -y python3-pip
sudo pip3 install tcconfig

You can verfiy the installation by tcset --version.

Please install Go 1.16+ by yourself and verfiy the installation by go version.

This is optional for docker.

Config

Config by environment variables, so create a .env file with:

API_HOST=ubuntu20
API_LISTEN=2023
UI_HOST=localhost
UI_PORT=3001
NODE_ENV=development
IFACE_FILTER_IPV4=true
IFACE_FILTER_IPV6=true

This is optional.

tc-ui's People

Contributors

winlinvip 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.