【修复】修复长期持有tcp连接未关闭

【修复】修复生成新的acme账号时有概率覆盖所有账号
【修复】修复新旧let账号不统一的兼容性问题
1.0.7 v1.0.7
v-me-50 2025-08-18 15:58:01 +08:00
parent e939724f37
commit bf0971f405
8 changed files with 39 additions and 19 deletions

View File

@ -50,12 +50,18 @@ func SaveUserToDB(db *public.Sqlite, user *MyUser, Type string) error {
Bytes: keyBytes, Bytes: keyBytes,
}) })
now := time.Now().Format("2006-01-02 15:04:05") now := time.Now().Format("2006-01-02 15:04:05")
data, err := db.Where(`email=? and type=?`, []interface{}{user.Email, Type}).Select() var data []map[string]interface{}
if Type == "letsencrypt" || Type == "Let's Encrypt" {
data, err = db.Where(`email=? and type in ('letsencrypt','Let''s Encrypt')`, []interface{}{user.Email}).Select()
} else {
data, err = db.Where(`email=? and type=?`, []interface{}{user.Email, Type}).Select()
}
if err != nil { if err != nil {
return err return err
} }
if len(data) > 0 { if len(data) > 0 {
_, err = db.Update(map[string]interface{}{ _, err = db.Where(`id = ?`, []interface{}{data[0]["id"]}).Update(map[string]interface{}{
"private_key": string(pemBytes), "private_key": string(pemBytes),
"reg": regBytes, "reg": regBytes,
"update_time": now, "update_time": now,
@ -112,7 +118,13 @@ func GetAcmeUser(email string, logger *public.Logger, accData map[string]any) (u
} }
func GetAccount(db *public.Sqlite, email, ca string) (map[string]interface{}, error) { func GetAccount(db *public.Sqlite, email, ca string) (map[string]interface{}, error) {
data, err := db.Where(`email=? and type=?`, []interface{}{email, ca}).Select() var data []map[string]interface{}
var err error
if ca == "letsencrypt" || ca == "Let's Encrypt" {
data, err = db.Where(`email=? and type in ('letsencrypt','Let''s Encrypt')`, []interface{}{email}).Select()
} else {
data, err = db.Where(`email=? and type=?`, []interface{}{email, ca}).Select()
}
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -204,13 +216,14 @@ func GetAccountList(search, ca string, p, limit int64) ([]map[string]interface{}
if ca == "custom" { if ca == "custom" {
whereSql += `and type not in ('Let's Encrypt','buypass', 'google', 'sslcom', 'zerossl')` whereSql += `and type not in ('Let's Encrypt','buypass', 'google', 'sslcom', 'zerossl')`
} else { } else {
if ca == "letsencrypt" { if ca == "letsencrypt" || ca == "Let's Encrypt" {
ca = "Let's Encrypt" whereSql += " and type in ('Let''s Encrypt', 'letsencrypt')"
} } else {
whereSql += " and type=?" whereSql += " and type=?"
whereArgs = append(whereArgs, ca) whereArgs = append(whereArgs, ca)
} }
} }
}
count, err := db.Where(whereSql, whereArgs).Count() count, err := db.Where(whereSql, whereArgs).Count()
data, err := db.Where(whereSql, whereArgs).Limit(limits).Select() data, err := db.Where(whereSql, whereArgs).Limit(limits).Select()
if err != nil { if err != nil {

View File

@ -496,6 +496,7 @@ func Apply(cfg map[string]any, logger *public.Logger) (map[string]any, error) {
httpClient = &http.Client{ httpClient = &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
Proxy: http.ProxyURL(proxyURL), Proxy: http.ProxyURL(proxyURL),
DisableKeepAlives: true,
}, },
Timeout: 30 * time.Second, Timeout: 30 * time.Second,
} }

View File

@ -92,6 +92,7 @@ func Request1panel(data *map[string]any, method, providerID, requestUrl string)
} }
tr := &http.Transport{ tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: ignoreSsl}, TLSClientConfig: &tls.Config{InsecureSkipVerify: ignoreSsl},
DisableKeepAlives: true,
} }
client := &http.Client{Transport: tr} client := &http.Client{Transport: tr}

View File

@ -66,6 +66,7 @@ func RequestBt(data *url.Values, method, providerID, requestUrl string) (map[str
} }
tr := &http.Transport{ tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: ignoreSsl}, TLSClientConfig: &tls.Config{InsecureSkipVerify: ignoreSsl},
DisableKeepAlives: true,
} }
client := &http.Client{Transport: tr} client := &http.Client{Transport: tr}

View File

@ -66,6 +66,7 @@ func RequestBtWaf(data *map[string]any, method, providerID, requestUrl string) (
} }
tr := &http.Transport{ tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: ignoreSsl}, TLSClientConfig: &tls.Config{InsecureSkipVerify: ignoreSsl},
DisableKeepAlives: true,
} }
client := &http.Client{Transport: tr} client := &http.Client{Transport: tr}

View File

@ -54,6 +54,7 @@ func requestLecdn(url, method, token string, params map[string]any, ignoreSsl bo
client := &http.Client{ client := &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: ignoreSsl}, TLSClientConfig: &tls.Config{InsecureSkipVerify: ignoreSsl},
DisableKeepAlives: true,
}, },
} }

View File

@ -51,6 +51,7 @@ func RequestSafeLineWaf(data *map[string]any, method, providerID, requestUrl str
} }
tr := &http.Transport{ tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: ignoreSsl}, TLSClientConfig: &tls.Config{InsecureSkipVerify: ignoreSsl},
DisableKeepAlives: true,
} }
client := &http.Client{Transport: tr} client := &http.Client{Transport: tr}

View File

@ -69,8 +69,8 @@ func Check(certs []*x509.Certificate, host string, advanceDay int) (result *Cert
} }
result.CommonName = leafCert.Subject.CommonName result.CommonName = leafCert.Subject.CommonName
result.NotBefore = leafCert.NotBefore.Format("2006-01-02 15:04:05") result.NotBefore = leafCert.NotBefore.In(time.Local).Format("2006-01-02 15:04:05")
result.NotAfter = leafCert.NotAfter.Format("2006-01-02 15:04:05") result.NotAfter = leafCert.NotAfter.In(time.Local).Format("2006-01-02 15:04:05")
result.DaysLeft = int(leafCert.NotAfter.Sub(time.Now()).Hours() / 24) result.DaysLeft = int(leafCert.NotAfter.Sub(time.Now()).Hours() / 24)
result.SANs = strings.Join(leafCert.DNSNames, ",") result.SANs = strings.Join(leafCert.DNSNames, ",")
result.SignatureAlgo = leafCert.SignatureAlgorithm.String() result.SignatureAlgo = leafCert.SignatureAlgorithm.String()
@ -141,8 +141,9 @@ func CheckHttps(target string, advanceDay int) (result *CertInfo, err error) {
TLSClientConfig: &tls.Config{ TLSClientConfig: &tls.Config{
InsecureSkipVerify: true, InsecureSkipVerify: true,
}, },
DisableKeepAlives: true,
}, },
//Timeout: 5 * time.Second, Timeout: 30 * time.Second,
} }
// 发送请求 // 发送请求