MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / checkWebsitePort

Function checkWebsitePort

agent/app/service/website_utils.go:1291–1326  ·  view source on GitHub ↗
(defaultHTTPsPort, port int, websiteType string)

Source from the content-addressed store, hash-verified

1289}
1290
1291func 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
1328func saveCertificateFile(websiteSSL *model.WebsiteSSL, logger *log.Logger) {
1329 if websiteSSL.PushDir {

Callers 3

getWebsiteDomainsFunction · 0.85
CreateWebsiteMethod · 0.85
UpdateStreamMethod · 0.85

Calls 5

GetByMethod · 0.65
WithPortMethod · 0.65
ListMethod · 0.65
WithTypeMethod · 0.65
GetFirstMethod · 0.65

Tested by

no test coverage detected