Skip to content

itning/reset-s-ui-traffic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reset S-UI Traffic

GitHub stars GitHub forks GitHub watchers GitHub followers

GitHub issues GitHub license GitHub last commit GitHub release GitHub repo size in bytes Hits language GitHub Downloads (all assets, all releases)

中文说明

A simple tool to reset traffic statistics (upload/download) for the s-ui panel. It features both a monthly scheduled task and an HTTP API for manual triggers.

Features

  • Automated Monthly Reset: Automatically clears traffic for all clients on the 1st of every month at 00:00 (Asia/Shanghai).
  • Manual Reset API: Provides an HTTP endpoint to trigger the reset manually at any time.
  • Pure Go Implementation: Uses modernc.org/sqlite, so no CGO is required for compilation.
  • Easy Deployment: Includes a systemd installation script for Linux servers.

Installation

1. One-Click Installation (Recommended)

Run the following command on your Linux server to automatically download the latest version and install it as a systemd service:

curl -fsSL https://raw.githubusercontent.com/itning/reset-s-ui-traffic/master/deploy.sh | sudo bash -s install

2. Manual Installation

If you prefer to build from source or have already downloaded the binary:

Option A: Build from Source

Ensure you have Go installed.

# Clone the repository
git clone https://github.com/itning/reset-s-ui-traffic.git
cd reset-s-ui-traffic

# Build for your platform (e.g., Linux AMD64)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o reset-traffic main.go

Option B: Deploy with local binary

  1. Upload your compiled binary and install.sh to your server.
  2. Run the installation script:
sudo chmod +x install.sh
sudo ./install.sh

Follow the menu prompts to install the service. The script will create a systemd service named reset-traffic.

Usage

HTTP API

The service listens on 127.0.0.1:52893 by default. You can manually trigger a reset by sending a request to the following endpoint:

Endpoint: GET http://127.0.0.1:52893/api/traffic/reset

Response Example:

{
  "status": "success",
  "message": "Traffic reset successfully",
  "rows_affected": 10
}

Scheduled Task

The cron job runs automatically inside the binary. By default, it is set to: 0 0 1 * * (At 00:00 on day-of-month 1).

Configuration

You can customize the behavior using environment variables in the systemd service file or before running the binary:

Variable Description Default
SUI_DB_PATH Path to the s-ui.db file /usr/local/s-ui/db/s-ui.db
PORT Listening port for the HTTP API 52893

License

Apache-2.0

About

A simple Go-based tool to reset traffic statistics for s-ui panels automatically (monthly) or manually via HTTP API.

Topics

Resources

License

Stars

5 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors