Skip to content

Commit

Permalink
First translation
Browse files Browse the repository at this point in the history
  • Loading branch information
Alireza Ahmadi committed Jan 31, 2023
1 parent 024fc08 commit 3ebabfb
Show file tree
Hide file tree
Showing 50 changed files with 416 additions and 421 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ name: Docker
# documentation.

on:
workflow_dispatch: #github页面手动触发
workflow_dispatch:
push:
tags: [ 'v*' ]

env:
# github.repository as <account>/<repo>
IMAGE_NAME: jrohy/trojan
IMAGE_NAME: alireza0/trojan-english


jobs:
Expand Down
111 changes: 53 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,94 +8,89 @@

trojan多用户管理部署程序

## 功能
- 在线web页面和命令行两种方式管理trojan多用户
- 启动 / 停止 / 重启 trojan 服务端
- 支持流量统计和流量限制
- 命令行模式管理, 支持命令补全
- 集成acme.sh证书申请
- 生成客户端配置文件
- 在线实时查看trojan日志
- 在线trojan和trojan-go随时切换
- 支持trojan://分享链接和二维码分享(仅限web页面)
- 支持转化为clash订阅地址并导入到[clash_for_windows](https://github.com/Fndroid/clash_for_windows_pkg/releases)(仅限web页面)
- 限制用户使用期限

## 安装方式
*trojan使用请提前准备好服务器可用的域名*

### a. 一键脚本安装
## Features
-The way to manage Trojan multi -user on online web page and command lines
-Beoph / stop / restart the Trojan server
-Chide statistics and traffic restrictions
-Plord line mode management, support command complement
-In Integrated ACME.SH Certificate Application
-On the client configuration file
-Chat online real -time Trojan log
-Trojan and Trojan-GO switch at any time
-Chising Trojan: // Share links and QR code sharing (only web page)
-Cap to be converted to Clash subscription address and import to [CLASH_FOR_WINDOWS] (https://github.com/fndroid/clash_FOR_WINDOWS_PKG/releases) (only web page)
-The duration of user usage

## installation method
*Trojan, please prepare the domain name available to the server in advance*

### a. 一Key to install
```
#安装/更新
#Installation/update
source <(curl -sL https://git.io/trojan-install)
#卸载
#Uninstall
source <(curl -sL https://git.io/trojan-install) --remove
```
安装完后输入'trojan'可进入管理程序
浏览器访问 https://域名 可在线web页面管理trojan用户
前端页面源码地址: [trojan-web](https://github.com/Jrohy/trojan-web)
Enter the 'Trojan' to enter the management program after installation
Browser access https: // Domain name can be available online web page to manage Trojan user
Front page source code address: [train-web] (https://github.com/jrohy/trojan-web)

### b. docker运行
1. 安装mysql
### b. docker run
1. Install mysql

因为mariadb内存使用比mysql至少减少一半, 所以推荐使用mariadb数据库
Because MariaDB memory is at least half lower than mysql, it is recommended to use the MariaDB database
```
docker run --name trojan-mariadb --restart=always -p 3306:3306 -v /home/mariadb:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=trojan -e MYSQL_ROOT_HOST=% -e MYSQL_DATABASE=trojan -d mariadb:10.2
```
端口和root密码以及持久化目录都可以改成其他的

2. 安装trojan
Both ports and root passwords and persistence directory can be changed to other
2. Install Trojan
```
docker run -it -d --name trojan --net=host --restart=always --privileged jrohy/trojan init
```
运行完后进入容器 `docker exec -it trojan bash`, 然后输入'trojan'即可进行初始化安装
After running, enter the container `docker exec -it trojan bash`, Then enter 'trjan' to initialize the installation

启动web服务: `systemctl start trojan-web`
Start a web service: `systemctl start trojan-web`

设置自启动: `systemctl enable trojan-web`
Set self-activation: `systemctl enable trojan-web`

更新管理程序: `source <(curl -sL https://git.io/trojan-install)`
Update management program: `source <(curl -sL https://git.io/trojan-install)`

## 运行截图
## Run a screenshot
![avatar](asset/1.png)
![avatar](asset/2.png)

## 命令行
## Command Line
```
Usage:
trojan [flags]
trojan [command]
Available Commands:
add 添加用户
clean 清空指定用户流量
completion 自动命令补全(支持bash和zsh)
del 删除用户
add Add user
clean Clear designated user traffic
completion Automatically command to make up (support BASH and ZSH)
del delete users
help Help about any command
info 用户信息列表
log 查看trojan日志
port 修改trojan端口
restart 重启trojan
start 启动trojan
status 查看trojan状态
stop 停止trojan
tls 证书安装
update 更新trojan
updateWeb 更新trojan管理程序
version 显示版本号
import [path] 导入sql文件
export [path] 导出sql文件
web 以web方式启动
info User information list
log View trojan log
port Modify the trojan port
restart Restart trojan
start Start up trojan
status View trojan status
stop Stop trojan
tls Certificate installation
update Update trojan
updateWeb Update trojan management GUI
version Display version number
import [path] Import SQL file
export [path] Export sql file
web Start up with web
Flags:
-h, --help help for trojan
```

## 注意
安装完trojan后强烈建议开启BBR等加速: [Linux-NetSpeed](https://github.com/chiakge/Linux-NetSpeed)

## Thanks
感谢JetBrains提供的免费GoLand
[![avatar](asset/jetbrains.svg)](https://jb.gg/OpenSource)
## Notice
After installing Trojan, it is strongly recommended to open BBR and other acceleration: [Linux-NetSpeed](https://github.com/chiakge/Linux-NetSpeed)
2 changes: 1 addition & 1 deletion asset/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM --platform=$TARGETPLATFORM centos:7

LABEL maintainer="Jrohy <euvkzx@Jrohy.com>"
LABEL maintainer="Alireza <alireza7@gmail.com>"

ARG TARGETARCH

Expand Down
2 changes: 1 addition & 1 deletion asset/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "embed"
//go:embed trojan-install.sh client.json clash-rules.yaml
var f embed.FS

// GetAsset 获取资源[]byte
// GetAsset []byte
func GetAsset(name string) []byte {
data, _ := f.ReadFile(name)
return data
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

GITHUB_TOKEN=""

PROJECT="Jrohy/trojan"
PROJECT="alireza0/trojan-english"

#获取当前的这个脚本所在绝对路径
#Get the absolute path where the current script is located
SHELL_PATH=$(cd `dirname $0`; pwd)

function uploadfile() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// addCmd represents the add command
var addCmd = &cobra.Command{
Use: "add",
Short: "添加用户",
Short: "Add user",
Run: func(cmd *cobra.Command, args []string) {
trojan.AddUser()
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
// cleanCmd represents the clean command
var cleanCmd = &cobra.Command{
Use: "clean",
Short: "清空指定用户流量",
Long: `传入指定用户名来清空用户流量, 多个用户名空格隔开, 例如:
Short: "Clear designated user traffic",
Long: `Pass to the designated username to clear the user traffic, and separate multiple user name spaces, such as:
trojan clean zhangsan lisi
`,
Args: cobra.MinimumNArgs(1),
Expand Down
12 changes: 6 additions & 6 deletions cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import (
// completionCmd represents the completion command
var completionCmd = &cobra.Command{
Use: "completion",
Short: "自动命令补全(支持bash和zsh)",
Short: "Automatically command to make up (support BASH and ZSH)",
Long: `
支持bash和zsh的命令补全
a. bash环境添加下面命令到 ~/.bashrc
Command support for bash and zsh
a. bash: Add the following command to ~/.bashrc
source <(trojan completion bash)
b. zsh环境添加以下命令到~/.zshrc
b. zsh: Add the following command to ~/.zshrc
source <(trojan completion zsh)
`,
}

func init() {
rootCmd.AddCommand(completionCmd)
completionCmd.AddCommand(&cobra.Command{Use: "bash", Short: "bash命令补全", Run: func(cmd *cobra.Command, args []string) {
completionCmd.AddCommand(&cobra.Command{Use: "bash", Short: "bash command to make up", Run: func(cmd *cobra.Command, args []string) {
rootCmd.GenBashCompletion(os.Stdout)
}})
completionCmd.AddCommand(&cobra.Command{Use: "zsh", Short: "zsh命令补全", Run: func(cmd *cobra.Command, args []string) {
completionCmd.AddCommand(&cobra.Command{Use: "zsh", Short: "zsh command to make up", Run: func(cmd *cobra.Command, args []string) {
rootCmd.GenZshCompletion(os.Stdout)
}})
}
2 changes: 1 addition & 1 deletion cmd/del.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// delCmd represents the del command
var delCmd = &cobra.Command{
Use: "del",
Short: "删除用户",
Short: "delete users",
Run: func(cmd *cobra.Command, args []string) {
trojan.DelUser()
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
// exportCmd represents the export command
var exportCmd = &cobra.Command{
Use: "export",
Short: "导出数据库sql文件",
Short: " Export database sql file",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
mysql := core.GetMysql()
if err := mysql.DumpSql(args[0]); err != nil {
fmt.Println(util.Red(err.Error()))
} else {
fmt.Println(util.Green("导出sql成功!"))
fmt.Println(util.Green(" Export sql success!"))
}
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
// importCmd represents the import command
var importCmd = &cobra.Command{
Use: "import",
Short: "导入数据库sql文件",
Short: "Import database sql file",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
mysql := core.GetMysql()
if err := mysql.ExecSql(args[0]); err != nil {
fmt.Println(util.Red(err.Error()))
} else {
fmt.Println(util.Green("导入sql成功!"))
fmt.Println(util.Green("Import sql success!"))
}
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// infoCmd represents the info command
var infoCmd = &cobra.Command{
Use: "info",
Short: "用户信息列表",
Short: "User information list",
Run: func(cmd *cobra.Command, args []string) {
trojan.UserList()
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ var line int
// logCmd represents the log command
var logCmd = &cobra.Command{
Use: "log",
Short: "查看trojan日志",
Short: "View Trojan log",
Run: func(cmd *cobra.Command, args []string) {
util.Log("trojan", line)
},
}

func init() {
logCmd.Flags().IntVarP(&line, "line", "n", 300, "查看日志行数")
logCmd.Flags().IntVarP(&line, "line", "n", 300, "number of logs to view")
rootCmd.AddCommand(logCmd)
}
2 changes: 1 addition & 1 deletion cmd/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// portCmd represents the info command
var portCmd = &cobra.Command{
Use: "port",
Short: "修改trojan端口",
Short: "Modify the trojan port",
Run: func(cmd *cobra.Command, args []string) {
trojan.ChangePort()
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// restartCmd represents the restart command
var restartCmd = &cobra.Command{
Use: "restart",
Short: "重启trojan",
Short: "Restart trojan",
Run: func(cmd *cobra.Command, args []string) {
trojan.Restart()
},
Expand Down
8 changes: 4 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Execute() {

func check() {
if !util.IsExists("/usr/local/etc/trojan/config.json") {
fmt.Println("本机未安装trojan, 正在自动安装...")
fmt.Println("This machine has no trojan installed! Automatic installation in progress...")
trojan.InstallTrojan("")
core.WritePassword(nil)
trojan.InstallTls()
Expand All @@ -42,10 +42,10 @@ func mainMenu() {
exit:
for {
fmt.Println()
fmt.Println(util.Cyan("欢迎使用trojan管理程序"))
fmt.Println(util.Cyan("Welcome to trojan management GUI"))
fmt.Println()
menuList := []string{"trojan管理", "用户管理", "安装管理", "web管理", "查看配置", "生成json"}
switch util.LoopInput("请选择: ", menuList, false) {
menuList := []string{"trojan Management", "User Management", "Installation Management", "Web Management", "View configuration", "Generate json"}
switch util.LoopInput("Please choose: ", menuList, false) {
case 1:
trojan.ControllMenu()
case 2:
Expand Down
2 changes: 1 addition & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// startCmd represents the start command
var startCmd = &cobra.Command{
Use: "start",
Short: "启动trojan",
Short: "Start up trojan",
Run: func(cmd *cobra.Command, args []string) {
trojan.Start()
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// statusCmd represents the status command
var statusCmd = &cobra.Command{
Use: "status",
Short: "查看trojan状态",
Short: "View trojan status",
Run: func(cmd *cobra.Command, args []string) {
trojan.Status(true)
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// stopCmd represents the stop command
var stopCmd = &cobra.Command{
Use: "stop",
Short: "停止trojan",
Short: "Stop trojan",
Run: func(cmd *cobra.Command, args []string) {
trojan.Stop()
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// tlsCmd represents the tls command
var tlsCmd = &cobra.Command{
Use: "tls",
Short: "证书安装",
Short: "Certificate installation",
Run: func(cmd *cobra.Command, args []string) {
trojan.InstallTls()
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
// upgradeCmd represents the update command
var updateCmd = &cobra.Command{
Use: "update",
Short: "更新trojan",
Long: "可添加版本号更新特定版本, 比如'trojan update v0.10.0', 不添加版本号则安装最新版",
Short: "Update trojan",
Long: "Can be added with a specific version of the update, such as 'Trojan Update v0.10.0', and the latest version is installed without adding a version number",
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
version := ""
Expand Down
Loading

0 comments on commit 3ebabfb

Please sign in to comment.