mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-03-22 19:11:51 +00:00
refactor: simplify server & service manipulation (#993)
* refactor: simplify server & service manipulation * update * fix * update for nat, ddns & notification * chore * update cron * update dependencies * use of function iterators * update default dns servers
This commit is contained in:
@@ -67,16 +67,9 @@ func createServerGroup(c *gin.Context) (uint64, error) {
|
||||
}
|
||||
sgf.Servers = slices.Compact(sgf.Servers)
|
||||
|
||||
singleton.ServerLock.RLock()
|
||||
for _, sid := range sgf.Servers {
|
||||
if server, ok := singleton.ServerList[sid]; ok {
|
||||
if !server.HasPermission(c) {
|
||||
singleton.ServerLock.RUnlock()
|
||||
return 0, singleton.Localizer.ErrorT("permission denied")
|
||||
}
|
||||
}
|
||||
if !singleton.ServerShared.CheckPermission(c, slices.Values(sgf.Servers)) {
|
||||
return 0, singleton.Localizer.ErrorT("permission denied")
|
||||
}
|
||||
singleton.ServerLock.RUnlock()
|
||||
|
||||
uid := getUid(c)
|
||||
|
||||
@@ -142,16 +135,9 @@ func updateServerGroup(c *gin.Context) (any, error) {
|
||||
}
|
||||
sg.Servers = slices.Compact(sg.Servers)
|
||||
|
||||
singleton.ServerLock.RLock()
|
||||
for _, sid := range sg.Servers {
|
||||
if server, ok := singleton.ServerList[sid]; ok {
|
||||
if !server.HasPermission(c) {
|
||||
singleton.ServerLock.RUnlock()
|
||||
return nil, singleton.Localizer.ErrorT("permission denied")
|
||||
}
|
||||
}
|
||||
if !singleton.ServerShared.CheckPermission(c, slices.Values(sg.Servers)) {
|
||||
return nil, singleton.Localizer.ErrorT("permission denied")
|
||||
}
|
||||
singleton.ServerLock.RUnlock()
|
||||
|
||||
var sgDB model.ServerGroup
|
||||
if err := singleton.DB.First(&sgDB, id).Error; err != nil {
|
||||
|
||||
Reference in New Issue
Block a user