From 7466916e0206d55826d74f37c251bb5e40182c00 Mon Sep 17 00:00:00 2001 From: Vladislav Tupikin Date: Sun, 19 Apr 2026 22:24:24 +0300 Subject: Add custom geosite/geoip URL sources (#3980) * feat: add custom geosite/geoip URL sources Register DB model, panel API, index/xray UI, and i18n. * fix --- database/db.go | 4 ++-- database/model/model.go | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'database') diff --git a/database/db.go b/database/db.go index 6b579dd9..2e468587 100644 --- a/database/db.go +++ b/database/db.go @@ -38,6 +38,7 @@ func initModels() error { &model.InboundClientIps{}, &xray.ClientTraffic{}, &model.HistoryOfSeeders{}, + &model.CustomGeoResource{}, } for _, model := range models { if err := db.AutoMigrate(model); err != nil { @@ -175,9 +176,8 @@ func GetDB() *gorm.DB { return db } -// IsNotFound checks if the given error is a GORM record not found error. func IsNotFound(err error) bool { - return err == gorm.ErrRecordNotFound + return errors.Is(err, gorm.ErrRecordNotFound) } // IsSQLiteDB checks if the given file is a valid SQLite database by reading its signature. diff --git a/database/model/model.go b/database/model/model.go index 6225df52..63f4a1b4 100644 --- a/database/model/model.go +++ b/database/model/model.go @@ -104,6 +104,18 @@ type Setting struct { Value string `json:"value" form:"value"` } +type CustomGeoResource struct { + Id int `json:"id" gorm:"primaryKey;autoIncrement"` + Type string `json:"type" gorm:"not null;uniqueIndex:idx_custom_geo_type_alias;column:geo_type"` + Alias string `json:"alias" gorm:"not null;uniqueIndex:idx_custom_geo_type_alias"` + Url string `json:"url" gorm:"not null"` + LocalPath string `json:"localPath" gorm:"column:local_path"` + LastUpdatedAt int64 `json:"lastUpdatedAt" gorm:"default:0;column:last_updated_at"` + LastModified string `json:"lastModified" gorm:"column:last_modified"` + CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime;column:created_at"` + UpdatedAt int64 `json:"updatedAt" gorm:"autoUpdateTime;column:updated_at"` +} + // Client represents a client configuration for Xray inbounds with traffic limits and settings. type Client struct { ID string `json:"id"` // Unique client identifier -- cgit v1.2.3