2024-07-19 19:04:11 +08:00
|
|
|
package global
|
|
|
|
|
|
|
|
|
|
import (
|
2025-11-28 11:05:27 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/core/init/auth"
|
2024-07-19 19:04:11 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/core/init/session/psession"
|
|
|
|
|
"github.com/go-playground/validator/v10"
|
|
|
|
|
"github.com/nicksnyder/go-i18n/v2/i18n"
|
2024-08-08 15:38:37 +08:00
|
|
|
"github.com/robfig/cron/v3"
|
2024-07-19 19:04:11 +08:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
DB *gorm.DB
|
2025-07-18 11:44:20 +08:00
|
|
|
AlertDB *gorm.DB
|
2024-11-26 14:34:47 +08:00
|
|
|
TaskDB *gorm.DB
|
2025-03-04 22:37:20 +08:00
|
|
|
AgentDB *gorm.DB
|
2024-07-19 19:04:11 +08:00
|
|
|
LOG *logrus.Logger
|
2025-01-24 11:00:07 +08:00
|
|
|
CONF ServerConfig
|
2024-07-19 19:04:11 +08:00
|
|
|
VALID *validator.Validate
|
|
|
|
|
SESSION *psession.PSession
|
|
|
|
|
Viper *viper.Viper
|
|
|
|
|
|
2025-01-21 18:32:14 +08:00
|
|
|
I18n *i18n.Localizer
|
|
|
|
|
I18nForCmd *i18n.Localizer
|
2024-08-08 15:38:37 +08:00
|
|
|
|
|
|
|
|
Cron *cron.Cron
|
2025-10-13 21:29:14 +08:00
|
|
|
|
|
|
|
|
ScriptSyncJobID cron.EntryID
|
2025-11-28 11:05:27 +08:00
|
|
|
|
|
|
|
|
IPTracker *auth.IPTracker
|
2024-07-19 19:04:11 +08:00
|
|
|
)
|
2024-11-30 19:42:41 +08:00
|
|
|
|
|
|
|
|
type DBOption func(*gorm.DB) *gorm.DB
|
2026-02-25 10:56:06 +08:00
|
|
|
|
|
|
|
|
func RepoURL() string {
|
2026-05-07 09:53:28 +08:00
|
|
|
if CONF.Base.IsEnterprise {
|
|
|
|
|
return "https://resource.fit2cloud.com/1panel/package/enterprise"
|
|
|
|
|
}
|
2026-02-27 15:17:51 +08:00
|
|
|
if CONF.Base.Edition != "intl" {
|
2026-02-25 10:56:06 +08:00
|
|
|
return "https://resource.fit2cloud.com/1panel/package/v2"
|
|
|
|
|
}
|
2026-03-02 12:05:59 +08:00
|
|
|
return "https://resource.1panel.pro/v2"
|
2026-02-25 10:56:06 +08:00
|
|
|
}
|
|
|
|
|
func ResourceURL() string {
|
2026-05-07 09:53:28 +08:00
|
|
|
if CONF.Base.IsEnterprise {
|
2026-05-15 10:14:03 +08:00
|
|
|
return "https://resource.fit2cloud.com/1panel/resource/v2"
|
2026-05-07 09:53:28 +08:00
|
|
|
}
|
2026-02-27 15:17:51 +08:00
|
|
|
if CONF.Base.Edition != "intl" {
|
2026-02-25 10:56:06 +08:00
|
|
|
return "https://resource.fit2cloud.com/1panel/resource/v2"
|
|
|
|
|
}
|
2026-02-28 10:38:35 +08:00
|
|
|
return "https://resource.1panel.pro/v2/resource"
|
2026-02-25 10:56:06 +08:00
|
|
|
}
|
|
|
|
|
func AppRepoURL() string {
|
2026-05-07 09:53:28 +08:00
|
|
|
if CONF.Base.IsEnterprise {
|
|
|
|
|
return "https://apps-assets.fit2cloud.com"
|
|
|
|
|
}
|
2026-02-27 15:17:51 +08:00
|
|
|
if CONF.Base.Edition != "intl" {
|
2026-02-25 10:56:06 +08:00
|
|
|
return "https://apps-assets.fit2cloud.com"
|
|
|
|
|
}
|
2026-03-03 15:20:02 +08:00
|
|
|
return "https://apps.1panel.pro"
|
2026-02-25 10:56:06 +08:00
|
|
|
}
|