chore: apply formatting and db.go fixes

This commit is contained in:
Dikiy13371 2025-10-07 23:46:47 +03:00
parent 97e9aca156
commit b2ae172623
7 changed files with 584 additions and 563 deletions

26
exit Normal file
View file

@ -0,0 +1,26 @@
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=schannel
core.autocrlf=true
core.fscache=true
core.symlinks=false
pull.rebase=false
credential.helper=manager
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=master
user.name=Dikiy13371
user.email=css81933@gmail.com
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url=https://github.com/Dikiy13371/3x-uiRuys71.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.main.remote=origin
branch.main.merge=refs/heads/main
branch.main.vscode-merge-base=origin/main

View file

@ -140,5 +140,3 @@ func AuthenticateUser(cfg Config, username, password string) (bool, error) {
}
return true, nil
}

View file

@ -54,7 +54,6 @@ func mustGetStringOr(fn func() (string, error), fallback string) string {
return v
}
func NewLdapSyncJob() *LdapSyncJob {
return new(LdapSyncJob)
}
@ -170,8 +169,6 @@ func (j *LdapSyncJob) Run() {
}
}
func splitCsv(s string) []string {
if s == "" {
return DefaultTruthyValues
@ -187,7 +184,6 @@ func splitCsv(s string) []string {
return out
}
// buildClient creates a new client for auto-create
func (j *LdapSyncJob) buildClient(ib *model.Inbound, email string, defGB, defExpiryDays, defLimitIP int) model.Client {
c := model.Client{
@ -310,20 +306,20 @@ func (j *LdapSyncJob) deleteClientsNotInLDAP(inboundTag string, ldapEmails map[s
}
}
// clientsToJSON serializes an array of clients to JSON
func (j *LdapSyncJob) clientsToJSON(clients []model.Client) string {
b := strings.Builder{}
b.WriteString("{\"clients\":[")
for i, c := range clients {
if i > 0 { b.WriteString(",") }
if i > 0 {
b.WriteString(",")
}
b.WriteString(j.clientToJSON(c))
}
b.WriteString("]}")
return b.String()
}
// ensureClientExists adds client with defaults to inbound tag if not present
func (j *LdapSyncJob) ensureClientExists(inboundTag string, email string, defGB int, defExpiryDays int, defLimitIP int) {
inbounds, err := j.inboundService.GetAllInbounds()
@ -403,7 +399,11 @@ func (j *LdapSyncJob) clientToJSON(c model.Client) string {
b.WriteString(c.Email)
b.WriteString("\",")
b.WriteString("\"enable\":")
if c.Enable { b.WriteString("true") } else { b.WriteString("false") }
if c.Enable {
b.WriteString("true")
} else {
b.WriteString("false")
}
b.WriteString(",")
b.WriteString("\"limitIp\":")
b.WriteString(strconv.Itoa(c.LimitIP))
@ -417,5 +417,3 @@ func (j *LdapSyncJob) clientToJSON(c model.Client) string {
b.WriteString("}")
return b.String()
}

View file

@ -1569,7 +1569,6 @@ func (s *InboundService) ToggleClientEnableByEmail(clientEmail string) (bool, bo
return !clientOldEnabled, needRestart, nil
}
// SetClientEnableByEmail sets client enable state to desired value; returns (changed, needRestart, error)
func (s *InboundService) SetClientEnableByEmail(clientEmail string, enable bool) (bool, bool, error) {
current, err := s.checkIsEnabledByEmail(clientEmail)