Help us shape the future of Go! Take the 2026 Go Developer Survey

cmd

package
v1.24.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 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 PostgresDSNFlag = &cli.StringFlag{
	Name:    "postgres",
	Value:   "",
	Usage:   "PostgreSQL 数据库连接字符串 (DSN),例如: postgres://user:password@localhost:5432/bepusdt?sslmode=disable&connect_timeout=3",
	Sources: cli.EnvVars("POSTGRESQL_DSN"),
}
View Source
var Reset = &cli.Command{
	Name:  "reset",
	Usage: "忘记密码时,此命令可重置账号密码登录入口",
	Flags: []cli.Flag{SQLiteFlag, PostgresDSNFlag},
	Before: func(ctx context.Context, c *cli.Command) (context.Context, error) {
		sqlite := c.String("sqlite")
		postgres := c.String("postgres")
		if err := model.Init(sqlite, postgres); 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, PostgresDSNFlag, LogFlag, ListenFlag},
	Before: func(ctx context.Context, c *cli.Command) (context.Context, error) {
		postgres := c.String("postgres")
		sqlite := c.String("sqlite")
		if err := model.Init(sqlite, postgres); 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