| 1289 | } |
| 1290 | |
| 1291 | func checkWebsitePort(defaultHTTPsPort, port int, websiteType string) error { |
| 1292 | if existPorts, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithPort(port)); len(existPorts) > 0 { |
| 1293 | return nil |
| 1294 | } |
| 1295 | if websiteType == constant.Stream { |
| 1296 | websites, _ := websiteRepo.List(websiteRepo.WithType(constant.Stream)) |
| 1297 | for _, website := range websites { |
| 1298 | ports := strings.Split(website.StreamPorts, ",") |
| 1299 | for _, p := range ports { |
| 1300 | pInt, _ := strconv.Atoi(p) |
| 1301 | if pInt == port { |
| 1302 | return nil |
| 1303 | } |
| 1304 | } |
| 1305 | } |
| 1306 | } |
| 1307 | |
| 1308 | errMap := make(map[string]interface{}) |
| 1309 | errMap["port"] = port |
| 1310 | appInstall, _ := appInstallRepo.GetFirst(appInstallRepo.WithPort(port)) |
| 1311 | if appInstall.ID > 0 { |
| 1312 | errMap["type"] = i18n.GetMsgByKey("TYPE_APP") |
| 1313 | errMap["name"] = appInstall.Name |
| 1314 | return buserr.WithMap("ErrPortExist", errMap, nil) |
| 1315 | } |
| 1316 | runtime, _ := runtimeRepo.GetFirst(context.Background(), runtimeRepo.WithPort(port)) |
| 1317 | if runtime != nil { |
| 1318 | errMap["type"] = i18n.GetMsgByKey("TYPE_RUNTIME") |
| 1319 | errMap["name"] = runtime.Name |
| 1320 | return buserr.WithMap("ErrPortExist", errMap, nil) |
| 1321 | } |
| 1322 | if port != defaultHTTPsPort && common.ScanPort(port) { |
| 1323 | return buserr.WithDetail("ErrPortInUsed", port, nil) |
| 1324 | } |
| 1325 | return nil |
| 1326 | } |
| 1327 | |
| 1328 | func saveCertificateFile(websiteSSL *model.WebsiteSSL, logger *log.Logger) { |
| 1329 | if websiteSSL.PushDir { |