Compare commits

..

No commits in common. "76d8a23f44173efba7d243e1fc502b8998fb5202" and "f165eecf89727b6e96f4f257f3d9dcdf562b552c" have entirely different histories.

7 changed files with 24 additions and 60 deletions

View File

@ -18,7 +18,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-s -w" -o
FROM scratch
# 复制配置文件
COPY --from=builder /app/vp.conf /home/videoplayer/vp.conf
COPY --from=builder /app/saw-ai.conf /home/saw/saw-ai.conf
# 复制二进制文件
COPY --from=builder /app/videoplayer /home/videoplayer/videoplayer

View File

@ -1,12 +0,0 @@
version: '3.8'
services:
app:
image: vp-image:latest
container_name: vp-container
ports:
- "8088:8083"
volumes:
- logs:/var/log/vp.log
- /etc/vp-app:/etc/vp-app
- /data/file:/data/file

View File

@ -72,13 +72,13 @@ func RunCID(c *gin.Context) {
if err := c.ShouldBind(&req); err == nil {
// 获取用户ID
//username, _ := c.Get("username")
username, _ := c.Get("username")
cid := dao.FindCIDByID(req.ID, authID)
if cid.ID == 0 {
c.JSON(200, gin.H{"error": "CID not found", "code": proto.OperationFailed, "message": "failed"})
return
} else {
go RunShell("", cid.Url, cid.Script, req.ID, authID)
go RunShell(username.(string), cid.Url, cid.Script, req.ID, authID)
c.JSON(200, gin.H{"code": proto.SuccessCode, "message": "success", "data": "success"})
}
} else {

View File

@ -62,8 +62,7 @@ func init() {
os.MkdirAll(proto.CID_BASE_DIR+"workspace", os.ModePerm)
//读取配置文件
//文件地址/home/videoplayer/vp.conf
//configPath := "/home/videoplayer/vp.conf"
configPath := "/etc/vp-app/vp.conf"
configPath := "/home/videoplayer/vp.conf"
//读取配置文件
err := proto.ReadConfig(configPath)
if err != nil {
@ -178,9 +177,7 @@ func JWTAuthMiddleware() gin.HandlerFunc {
// 将用户信息添加到上下文中
id := token.Claims.(jwt.MapClaims)["id"]
username := token.Claims.(jwt.MapClaims)["username"]
c.Set("id", id)
c.Set("username", username)
c.Set("user_id", int(id.(float64)))
if UserFuncIntercept(int(id.(float64)), c.Request.URL.Path) {

View File

@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"gorm.io/gorm"
"log"
"os"
)
@ -125,12 +124,6 @@ func ReadConfig(path string) error {
Config.SERVER_PORT = "8083" // 默认端口
}
}
configJson, cErr := json.Marshal(Config)
if cErr != nil {
log.Println("ReadConfig Error encoding config,err :", cErr)
} else {
log.Println("ReadConfig configJson:", string(configJson))
}
SigningKey = []byte(Config.TOKEN_SECRET)
return err
}

View File

@ -2,11 +2,11 @@
"db":0,
"mysql_dsn":"vp-db:ZcxsP7s7kaBxxDPc@tcp(tx.ljsea.top:3306)/vp-db?charset=utf8mb4&parseTime=True&loc=Local",
"pg_dsn":"host=localhost user=video_t2 dbname=video_t2 password=2t2SKHmWEYj2xFKF port=5432 TimeZone=Asia/Shanghai",
"redis_addr":"tx.ljsea.top:6379",
"redis_addr":"host.docker.internal:6379",
"redis_db":2,
"redis_user_pw":true,
"token_use_redis":false,
"redis_password":"vbgyfea87423wear",
"redis_password":"lj502138",
"token_secret":"mfjurnc_32ndj9dfhj",
"cid_base_dir":"/home/lijun/cid/",
"file_base_dir":"/home/lijun/file/",

View File

@ -2,7 +2,6 @@ package worker
import (
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"io"
@ -21,23 +20,7 @@ var client *http.Client
// 初始化
func InitReq() {
client = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true, // 设置为true将跳过证书验证
},
},
}
}
func InitReqClient() {
client = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true, // 设置为true将跳过证书验证
},
},
}
client = &http.Client{}
}
// 发起post请求
@ -121,8 +104,9 @@ func SyncDataFromMasterReq(url string, token string) proto.UserSync {
m["device"] = ""
if client == nil {
InitReqClient()
client = &http.Client{}
}
client = &http.Client{}
//获取数据
resp, err := client.Do(req)
if err != nil {
@ -189,7 +173,7 @@ func SyncDataFromMasterReq2(url string, data proto.SyncUserReq) (proto.UserSync,
req.Header.Set("Content-Type", "application/json")
//传输数据
if client == nil {
InitReqClient()
client = &http.Client{}
}
//获取数据
resp, err := client.Do(req)
@ -234,7 +218,7 @@ func SyncDataFromMasterShellReq2(url string, data proto.SyncUserShellReq) ([]dao
req.Header.Set("token", data.Token)
//传输数据
if client == nil {
InitReqClient()
client = &http.Client{}
}
//获取数据
resp, err := client.Do(req)
@ -278,7 +262,7 @@ func SyncDataFromMasterShellReq3(url string, data proto.SyncUserShellResp) ([]pr
req.Header.Set("token", data.Token)
//传输数据
if client == nil {
InitReqClient()
client = &http.Client{}
}
//获取数据
resp, err := client.Do(req)
@ -301,6 +285,7 @@ func SyncDataFromMasterShellReq3(url string, data proto.SyncUserShellResp) ([]pr
}
func DoPostRequestJSON(url string, jsonData []byte, headers map[string]string) (error, []byte) {
httpClient := &http.Client{}
defer func() {
if r := recover(); r != nil {
fmt.Println("SyncDataFromMasterReq2 error:", r)
@ -319,12 +304,11 @@ func DoPostRequestJSON(url string, jsonData []byte, headers map[string]string) (
req.Header.Set(k, v)
}
//传输数据
if client == nil {
InitReqClient()
client = client
if httpClient == nil {
httpClient = &http.Client{}
}
//获取数据
resp, err := client.Do(req)
resp, err := httpClient.Do(req)
if err != nil {
return err, nil
}
@ -338,6 +322,7 @@ func DoPostRequestJSON(url string, jsonData []byte, headers map[string]string) (
}
func DoPostRequestForm(url string, jsonData []byte, headers map[string]string) (error, []byte) {
httpClient := &http.Client{}
defer func() {
if r := recover(); r != nil {
fmt.Println("SyncDataFromMasterReq2 error:", r)
@ -397,7 +382,7 @@ func DoPostRequestForm(url string, jsonData []byte, headers map[string]string) (
}
// 发送请求
resp, err := client.Do(req)
resp, err := httpClient.Do(req)
if err != nil {
return err, nil
}
@ -413,6 +398,7 @@ func DoPostRequestForm(url string, jsonData []byte, headers map[string]string) (
}
func DoPostRequestFormUrlEncoded(url_ string, jsonData []byte, headers map[string]string) (error, []byte) {
httpClient := &http.Client{}
defer func() {
if r := recover(); r != nil {
log.Println("SyncDataFromMasterReq2 error:", r)
@ -463,7 +449,7 @@ func DoPostRequestFormUrlEncoded(url_ string, jsonData []byte, headers map[strin
}
// 发送请求
resp, err := client.Do(req)
resp, err := httpClient.Do(req)
if err != nil {
return err, nil
}
@ -479,6 +465,7 @@ func DoPostRequestFormUrlEncoded(url_ string, jsonData []byte, headers map[strin
}
func DoGetRequest(url string, headers map[string]string) (error, []byte) {
httpClient := &http.Client{}
defer func() {
if r := recover(); r != nil {
fmt.Println("SyncDataFromMasterReq2 error:", r)
@ -496,12 +483,11 @@ func DoGetRequest(url string, headers map[string]string) (error, []byte) {
req.Header.Set(k, v)
}
//传输数据
if client == nil {
InitReqClient()
client = client
if httpClient == nil {
httpClient = &http.Client{}
}
//获取数据
resp, err := client.Do(req)
resp, err := httpClient.Do(req)
if err != nil {
return err, nil
}