sing-rules-converter

command module
v3.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

README

sing-rules-converter

A Go-based tool to convert various rule provider files (Clash/Surge/Shadowrocket) to sing-box rule-set format.

Features

  • Converts various rule formats to sing-box rule-set format:
    • Clash YAML rule provider files
    • Surge/Shadowrocket LIST format rules
  • Outputs in both formats:
    • Source type (.json)
    • Binary type (.srs)
  • Supports various rule types:
    • Domain rules (DOMAIN, DOMAIN-SUFFIX, DOMAIN-KEYWORD, DOMAIN-REGEX)
    • IP rules (IP-CIDR, IP-CIDR6, SRC-IP-CIDR)
    • Port rules (DST-PORT, SRC-PORT)
    • Process rules (PROCESS-NAME, PROCESS-PATH)
  • Optional mix mode to combine different rule types into a single file

Installation

go install github.com/solanab/sing-rules-converter@latest

Usage

Basic usage:

sing-rules-converter [source-path]

Options:

Flags:
  -h, --help            help for sing-rules-converter
  -m, --mix            Enable mix mode to combine different rule types
  -o, --output string  Output file name (default "<file_name>")
  -v, --version uint8  Rule set version (1-3) (default 3)

Supported Formats

The converter supports two input formats:

  1. YAML format (with payload):
payload:
  - DOMAIN,example.com
  - IP-CIDR,192.168.1.0/24
  1. LIST format (direct rules):
DOMAIN,example.com
IP-CIDR,192.168.1.0/24

Both formats can be used with either .yaml or .list file extensions.

Version Control

Use -v flag to specify the rule set version:

sing-rules-converter rules.yaml -o output -v 2  # Generate version 2 rule set

Supported versions:

  • Version 1: Legacy format
  • Version 2: Current format
  • Version 3: Latest format (default)

Output Files

Without mix mode (-m):

  • <output>-domain-v2.json: Domain related rules in source format
  • <output>-domain.srs: Domain related rules in binary format
  • <output>-ip-v2.json: IP related rules in source format
  • <output>-ip.srs: IP related rules in binary format
  • <output>-port-v2.json: Port related rules in source format
  • <output>-port.srs: Port related rules in binary format
  • <output>-process-v2.json: Process related rules in source format
  • <output>-process.srs: Process related rules in binary format

With mix mode (-m):

  • <output>-v2.json: All rules combined in source format
  • <output>.srs: All rules combined in binary format

Example

Convert a Clash rule provider file:

sing-rules-converter rules.yaml -o converted

Convert and combine all rules into single files:

sing-rules-converter rules.yaml -o converted -m

License

This project is licensed under the MIT License.

Development

GitHub Release Process
  1. Create a new release in GitHub
    • Tag format: v1.0.0 (following semantic versioning)
    • The release workflow will automatically build and attach binaries for all supported platforms
Build From Source
# Clone the repository
git clone https://github.com/puernya/sing-rules-converter.git

# Change to project directory
cd sing-rules-converter

# Build the project
go build
Supported Platforms
  • Linux (x86_64, x86_64_v3, arm64)
  • Windows (x86_64, x86_64_v3, arm64)
  • macOS (x86_64, x86_64_v3, arm64)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL