add gateway

This commit is contained in:
2025-03-30 13:23:46 +08:00
parent ca00b34e24
commit 93daa022bc
4 changed files with 53 additions and 14 deletions

View File

@@ -59,17 +59,17 @@ func NotNil(values ...string) {
}
}
func PrintInfo(ip string, port int) {
func PrintInfo(addr string) {
print.Success("[BSM - %s] Config Check Success.", vars.ServiceKey)
print.Info("[BSM - %s] Service Name: %s", vars.ServiceKey, vars.ServiceKey)
print.Info("[BSM - %s] Runtime Mode: %s", vars.ServiceKey, env.Runtime.Mode)
print.Info("[BSM - %s] Listen Addr: %s:%d", vars.ServiceKey, ip, port)
}
func CheckPort(port int) int {
if port <= 0 || port >= 65535 {
func CheckPort(port string) string {
if port == "" {
r := rand.New(rand.NewPCG(1000, uint64(time.Now().UnixNano())))
return r.IntN(65535-1024) + 1024 // 生成1024到65535之间的随机端口
p := r.IntN(65535-1024) + 1024 // 生成1024到65535之间的随机端口
return utils.Int2String(p)
}
return port
}

View File

@@ -2,10 +2,11 @@ package conf
type Base struct {
Service string `yaml:"Service"` // 服务名称
Port int `yaml:"Port"` // 服务监听端口,0为自动随机端口
Port string `yaml:"Port"` // 服务监听端口,0为自动随机端口
Cache string `yaml:"Cache"` // REDIS缓存
SecretKey string `yaml:"SecretKey"` // 服务秘钥
BindIP string `yaml:"BindIP"` // 绑定IP
Addr string `yaml:"Addr"`
}
type DBConf struct {