完善docker部署和readme
This commit is contained in:
@ -33,6 +33,22 @@ func SessionPagingEndpoint(c echo.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := 0; i < len(items); i++ {
|
||||
if len(items[i].Recording) > 0 {
|
||||
recording := items[i].Recording + "/recording"
|
||||
|
||||
if utils.FileExists(recording) {
|
||||
log.Infof("检测到录屏文件[%v]存在", recording)
|
||||
items[i].Recording = "1"
|
||||
} else {
|
||||
log.Warnf("检测到录屏文件[%v]不存在", recording)
|
||||
items[i].Recording = "0"
|
||||
}
|
||||
} else {
|
||||
items[i].Recording = "0"
|
||||
}
|
||||
}
|
||||
|
||||
return Success(c, H{
|
||||
"total": total,
|
||||
"items": items,
|
||||
@ -436,11 +452,11 @@ func SessionRmEndpoint(c echo.Context) error {
|
||||
|
||||
func SessionRecordingEndpoint(c echo.Context) error {
|
||||
sessionId := c.Param("id")
|
||||
recordingPath, err := model.GetRecordingPath()
|
||||
session, err := model.FindSessionById(sessionId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
recording := path.Join(recordingPath, sessionId, "recording")
|
||||
recording := path.Join(session.Recording, "recording")
|
||||
log.Printf("读取录屏文件:%s", recording)
|
||||
return c.File(recording)
|
||||
}
|
||||
|
@ -49,18 +49,9 @@ func TunEndpoint(c echo.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
for name := range propertyMap {
|
||||
if name == guacd.FontSize {
|
||||
fontSize, _ := strconv.Atoi(propertyMap[name])
|
||||
fontSize = fontSize * 2
|
||||
configuration.SetParameter(name, strconv.Itoa(fontSize))
|
||||
} else {
|
||||
configuration.SetParameter(name, propertyMap[name])
|
||||
}
|
||||
}
|
||||
|
||||
if propertyMap[guacd.EnableRecording] == "true" {
|
||||
configuration.SetParameter(guacd.RecordingPath, path.Join(propertyMap[guacd.RecordingPath], sessionId))
|
||||
configuration.SetParameter(guacd.CreateRecordingPath, propertyMap[guacd.CreateRecordingPath])
|
||||
} else {
|
||||
configuration.SetParameter(guacd.RecordingPath, "")
|
||||
}
|
||||
@ -77,17 +68,34 @@ func TunEndpoint(c echo.Context) error {
|
||||
|
||||
configuration.SetParameter("dpi", "96")
|
||||
configuration.SetParameter("resize-method", "reconnect")
|
||||
configuration.SetParameter("enable-sftp", "")
|
||||
configuration.SetParameter(guacd.EnableDrive, propertyMap[guacd.EnableDrive])
|
||||
configuration.SetParameter(guacd.DriveName, propertyMap[guacd.DriveName])
|
||||
configuration.SetParameter(guacd.DrivePath, propertyMap[guacd.DrivePath])
|
||||
configuration.SetParameter(guacd.EnableWallpaper, propertyMap[guacd.EnableWallpaper])
|
||||
configuration.SetParameter(guacd.EnableTheming, propertyMap[guacd.EnableTheming])
|
||||
configuration.SetParameter(guacd.EnableFontSmoothing, propertyMap[guacd.EnableFontSmoothing])
|
||||
configuration.SetParameter(guacd.EnableFullWindowDrag, propertyMap[guacd.EnableFullWindowDrag])
|
||||
configuration.SetParameter(guacd.EnableDesktopComposition, propertyMap[guacd.EnableDesktopComposition])
|
||||
configuration.SetParameter(guacd.EnableMenuAnimations, propertyMap[guacd.EnableMenuAnimations])
|
||||
configuration.SetParameter(guacd.DisableBitmapCaching, propertyMap[guacd.DisableBitmapCaching])
|
||||
configuration.SetParameter(guacd.DisableOffscreenCaching, propertyMap[guacd.DisableOffscreenCaching])
|
||||
configuration.SetParameter(guacd.DisableGlyphCaching, propertyMap[guacd.DisableGlyphCaching])
|
||||
break
|
||||
case "ssh":
|
||||
if session.PrivateKey == "-" {
|
||||
configuration.SetParameter("username", session.Username)
|
||||
configuration.SetParameter("password", session.Password)
|
||||
} else {
|
||||
if len(session.PrivateKey) > 0 && session.PrivateKey != "-" {
|
||||
configuration.SetParameter("private-key", session.PrivateKey)
|
||||
configuration.SetParameter("passphrase", session.Passphrase)
|
||||
} else {
|
||||
configuration.SetParameter("username", session.Username)
|
||||
configuration.SetParameter("password", session.Password)
|
||||
}
|
||||
|
||||
fontSize, _ := strconv.Atoi(propertyMap[guacd.FontSize])
|
||||
fontSize = fontSize * 2
|
||||
configuration.SetParameter(guacd.FontSize, strconv.Itoa(fontSize))
|
||||
configuration.SetParameter(guacd.FontName, propertyMap[guacd.FontName])
|
||||
configuration.SetParameter(guacd.ColorScheme, propertyMap[guacd.ColorScheme])
|
||||
|
||||
sftpClient, err = CreateSftpClient(session.AssetId)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -62,10 +62,18 @@ func UserUpdateEndpoint(c echo.Context) error {
|
||||
}
|
||||
|
||||
func UserDeleteEndpoint(c echo.Context) error {
|
||||
id := c.Param("id")
|
||||
split := strings.Split(id, ",")
|
||||
ids := c.Param("id")
|
||||
account, found := GetCurrentAccount(c)
|
||||
if !found {
|
||||
return Fail(c, -1, "获取当前登录账户失败")
|
||||
}
|
||||
split := strings.Split(ids, ",")
|
||||
for i := range split {
|
||||
model.DeleteUserById(split[i])
|
||||
userId := split[i]
|
||||
if account.ID == userId {
|
||||
return Fail(c, -1, "不允许删除自身账户")
|
||||
}
|
||||
model.DeleteUserById(userId)
|
||||
}
|
||||
|
||||
return Success(c, nil)
|
||||
|
@ -34,7 +34,7 @@ const (
|
||||
)
|
||||
|
||||
const Delimiter = ';'
|
||||
const Version = "VERSION_1_1_0"
|
||||
const Version = "VERSION_1_2_0"
|
||||
|
||||
type Configuration struct {
|
||||
ConnectionID string
|
||||
|
@ -87,7 +87,7 @@ func InitProperties() error {
|
||||
Name: guacd.RecordingPath,
|
||||
Value: path + "/recording/",
|
||||
}
|
||||
if !utils.Exists(property.Value) {
|
||||
if !utils.FileExists(property.Value) {
|
||||
if err := os.Mkdir(property.Value, os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -125,7 +125,7 @@ func InitProperties() error {
|
||||
Name: guacd.DrivePath,
|
||||
Value: path + "/drive/",
|
||||
}
|
||||
if !utils.Exists(property.Value) {
|
||||
if !utils.FileExists(property.Value) {
|
||||
if err := os.Mkdir(property.Value, os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ func Tcping(ip string, port int) bool {
|
||||
}
|
||||
|
||||
// 判断所给路径文件/文件夹是否存在
|
||||
func Exists(path string) bool {
|
||||
func FileExists(path string) bool {
|
||||
_, err := os.Stat(path) //os.Stat获取文件信息
|
||||
if err != nil {
|
||||
if os.IsExist(err) {
|
||||
|
Reference in New Issue
Block a user