cmd

package
v1.23.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ListenFlag = &cli.StringFlag{
	Name:    "listen",
	Value:   ":8080",
	Usage:   "监听地址,格式为 ip:port,例如 :8080",
	Sources: cli.EnvVars("LISTEN"),
}
View Source
var LogFlag = &cli.StringFlag{
	Name:    "log",
	Value:   "/var/log/bepusdt/",
	Usage:   "日志文件保存路径",
	Sources: cli.EnvVars("LOG"),
}
View Source
var MySQLDSNFlag = &cli.StringFlag{
	Name:    "mysql",
	Value:   "",
	Usage:   "MySQL 数据库连接字符串 (DSN),例如: user:password@tcp(127.0.0.1:3306)/bepusdt?charset=utf8mb4&parseTime=True&loc=Local&timeout=3s&readTimeout=10s&writeTimeout=10s",
	Sources: cli.EnvVars("MYSQL_DSN"),
}
View Source
var Reset = &cli.Command{
	Name:  "reset",
	Usage: "忘记密码时,此命令可重置账号密码登录入口",
	Flags: []cli.Flag{SQLiteFlag, MySQLDSNFlag},
	Before: func(ctx context.Context, c *cli.Command) (context.Context, error) {
		dsn := c.String("mysql")
		sqlite := c.String("sqlite")
		if err := model.Init(sqlite, dsn); err != nil {
			return ctx, fmt.Errorf("数据库初始化失败 %w", err)
		}

		return ctx, task.Init()
	},
	After: func(ctx context.Context, c *cli.Command) error {
		model.Close()

		return nil
	},
	Action: func(ctx context.Context, cmd *cli.Command) error {
		hash := utils.Md5String(time.Now().String())

		username := hash[8:16]
		password := hash[0:8]
		entrance := fmt.Sprintf("/%s", hash[10:20])
		encrypt, _ := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)

		model.SetK(model.AdminSecure, entrance)
		model.SetK(model.AdminUsername, username)
		model.SetK(model.AdminPassword, string(encrypt))

		fmt.Println("重置成功,对应信息如下:")
		fmt.Printf("管理员账号:%s\n管理员密码:%s\n后台管理入口:%s\n", username, password, entrance)
		fmt.Println("请妥善保存以上信息!")
		fmt.Println("-------------------------------")

		return nil
	},
}
View Source
var SQLiteFlag = &cli.StringFlag{
	Name:    "sqlite",
	Value:   "/var/lib/bepusdt/sqlite.db",
	Usage:   "SQLite 数据库文件路径",
	Sources: cli.EnvVars("SQLITE"),
}
View Source
var Start = &cli.Command{
	Name:  "start",
	Usage: "启动收款网关",
	Flags: []cli.Flag{SQLiteFlag, MySQLDSNFlag, LogFlag, ListenFlag},
	Before: func(ctx context.Context, c *cli.Command) (context.Context, error) {
		dsn := c.String("mysql")
		sqlite := c.String("sqlite")
		if err := model.Init(sqlite, dsn); err != nil {
			return ctx, fmt.Errorf("数据库初始化失败 %w", err)
		}

		if err := log.Init(c.String("log")); err != nil {
			return ctx, fmt.Errorf("日志初始化失败 %w", err)
		}

		return ctx, task.Init()
	},
	After: func(ctx context.Context, c *cli.Command) error {
		log.Close()
		model.Close()

		return nil
	},
	Action: start,
}
View Source
var Version = &cli.Command{
	Name:  "version",
	Usage: "显示版本信息",
	Action: func(ctx context.Context, cmd *cli.Command) error {
		fmt.Println("BEpusdt 版本:" + app.Version)

		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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