next-terminal/main.go
dushixiang b0891a7c38 release (#150)
* 修改首页卡片间距

* 修改普通用户分享资产时只能查看到普通用户 close #133

* 修复普通用户访问非自己创建的资产无法打开原生ssh的bug

* release v0.4.1

* 修复使用命令修改加密key失败的问题

* 修改初始化RDP属性「禁用字形缓存」为打开

* 增加kubernetes协议的筛选

* 修改安装文档&修复首页链接限制无效的问题

* 修改guacd版本为1.3.0

* 支持导入资产时带标签的数据

* - 修改原生安装文档中guacamole版本为1.3.0
- 修改点击名称为编辑

* release 0.5.0
2021-06-01 23:14:55 +08:00

71 lines
2.0 KiB
Go

package main
import (
"crypto/md5"
"fmt"
"next-terminal/pkg/config"
"next-terminal/pkg/global"
"next-terminal/pkg/task"
"next-terminal/server/api"
"next-terminal/server/repository"
"github.com/labstack/gommon/log"
)
const Version = "v0.5.0"
func main() {
err := Run()
if err != nil {
log.Fatal(err)
}
}
func Run() error {
fmt.Printf(`
_______ __ ___________ .__ .__
\ \ ____ ___ ____/ |_ \__ ___/__________ _____ |__| ____ _____ | |
/ | \_/ __ \\ \/ /\ __\ | |_/ __ \_ __ \/ \| |/ \\__ \ | |
/ | \ ___/ > < | | | |\ ___/| | \/ Y Y \ | | \/ __ \| |__
\____|__ /\___ >__/\_ \ |__| |____| \___ >__| |__|_| /__|___| (____ /____/
\/ \/ \/ \/ \/ \/ \/ ` + Version + "\n\n")
// 为了兼容之前调用global包的代码 后期预期会改为调用pgk/config
global.Config = config.GlobalCfg
if global.Config.EncryptionKey == "" {
global.Config.EncryptionKey = "next-terminal"
}
md5Sum := fmt.Sprintf("%x", md5.Sum([]byte(global.Config.EncryptionKey)))
global.Config.EncryptionPassword = []byte(md5Sum)
global.Cache = api.SetupCache()
db := api.SetupDB()
e := api.SetupRoutes(db)
if global.Config.ResetPassword != "" {
return api.ResetPassword(global.Config.ResetPassword)
}
if global.Config.ResetTotp != "" {
return api.ResetTotp(global.Config.ResetTotp)
}
if global.Config.NewEncryptionKey != "" {
return api.ChangeEncryptionKey(global.Config.EncryptionKey, global.Config.NewEncryptionKey)
}
sessionRepo := repository.NewSessionRepository(db)
propertyRepo := repository.NewPropertyRepository(db)
ticker := task.NewTicker(sessionRepo, propertyRepo)
ticker.SetupTicker()
if global.Config.Server.Cert != "" && global.Config.Server.Key != "" {
return e.StartTLS(global.Config.Server.Addr, global.Config.Server.Cert, global.Config.Server.Key)
} else {
return e.Start(global.Config.Server.Addr)
}
}