mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-23 06:42:41 +00:00
chore: apply formatting and db.go fixes
This commit is contained in:
parent
97e9aca156
commit
b2ae172623
7 changed files with 584 additions and 563 deletions
26
exit
Normal file
26
exit
Normal 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
|
||||||
|
|
@ -140,5 +140,3 @@ func AuthenticateUser(cfg Config, username, password string) (bool, error) {
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ func mustGetStringOr(fn func() (string, error), fallback string) string {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func NewLdapSyncJob() *LdapSyncJob {
|
func NewLdapSyncJob() *LdapSyncJob {
|
||||||
return new(LdapSyncJob)
|
return new(LdapSyncJob)
|
||||||
}
|
}
|
||||||
|
|
@ -170,8 +169,6 @@ func (j *LdapSyncJob) Run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func splitCsv(s string) []string {
|
func splitCsv(s string) []string {
|
||||||
if s == "" {
|
if s == "" {
|
||||||
return DefaultTruthyValues
|
return DefaultTruthyValues
|
||||||
|
|
@ -187,7 +184,6 @@ func splitCsv(s string) []string {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// buildClient creates a new client for auto-create
|
// buildClient creates a new client for auto-create
|
||||||
func (j *LdapSyncJob) buildClient(ib *model.Inbound, email string, defGB, defExpiryDays, defLimitIP int) model.Client {
|
func (j *LdapSyncJob) buildClient(ib *model.Inbound, email string, defGB, defExpiryDays, defLimitIP int) model.Client {
|
||||||
c := 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
|
// clientsToJSON serializes an array of clients to JSON
|
||||||
func (j *LdapSyncJob) clientsToJSON(clients []model.Client) string {
|
func (j *LdapSyncJob) clientsToJSON(clients []model.Client) string {
|
||||||
b := strings.Builder{}
|
b := strings.Builder{}
|
||||||
b.WriteString("{\"clients\":[")
|
b.WriteString("{\"clients\":[")
|
||||||
for i, c := range clients {
|
for i, c := range clients {
|
||||||
if i > 0 { b.WriteString(",") }
|
if i > 0 {
|
||||||
|
b.WriteString(",")
|
||||||
|
}
|
||||||
b.WriteString(j.clientToJSON(c))
|
b.WriteString(j.clientToJSON(c))
|
||||||
}
|
}
|
||||||
b.WriteString("]}")
|
b.WriteString("]}")
|
||||||
return b.String()
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ensureClientExists adds client with defaults to inbound tag if not present
|
// 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) {
|
func (j *LdapSyncJob) ensureClientExists(inboundTag string, email string, defGB int, defExpiryDays int, defLimitIP int) {
|
||||||
inbounds, err := j.inboundService.GetAllInbounds()
|
inbounds, err := j.inboundService.GetAllInbounds()
|
||||||
|
|
@ -403,7 +399,11 @@ func (j *LdapSyncJob) clientToJSON(c model.Client) string {
|
||||||
b.WriteString(c.Email)
|
b.WriteString(c.Email)
|
||||||
b.WriteString("\",")
|
b.WriteString("\",")
|
||||||
b.WriteString("\"enable\":")
|
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(",")
|
||||||
b.WriteString("\"limitIp\":")
|
b.WriteString("\"limitIp\":")
|
||||||
b.WriteString(strconv.Itoa(c.LimitIP))
|
b.WriteString(strconv.Itoa(c.LimitIP))
|
||||||
|
|
@ -417,5 +417,3 @@ func (j *LdapSyncJob) clientToJSON(c model.Client) string {
|
||||||
b.WriteString("}")
|
b.WriteString("}")
|
||||||
return b.String()
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1569,7 +1569,6 @@ func (s *InboundService) ToggleClientEnableByEmail(clientEmail string) (bool, bo
|
||||||
return !clientOldEnabled, needRestart, nil
|
return !clientOldEnabled, needRestart, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SetClientEnableByEmail sets client enable state to desired value; returns (changed, needRestart, error)
|
// SetClientEnableByEmail sets client enable state to desired value; returns (changed, needRestart, error)
|
||||||
func (s *InboundService) SetClientEnableByEmail(clientEmail string, enable bool) (bool, bool, error) {
|
func (s *InboundService) SetClientEnableByEmail(clientEmail string, enable bool) (bool, bool, error) {
|
||||||
current, err := s.checkIsEnabledByEmail(clientEmail)
|
current, err := s.checkIsEnabledByEmail(clientEmail)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue