feat: import Sea vHost single-server testing release
This commit is contained in:
commit
248badd33e
441 files changed
+63221
No files matched your search
@@ -0,0 +1,61 @@
|
||||
package panel
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// aaPanel indexes orders with the MD5 of Python's JSON identifiers array.
|
||||
func managedACMEIndex(domains []string) string {
|
||||
parts := make([]string, 0, len(domains))
|
||||
for _, domain := range domains {
|
||||
raw, _ := json.Marshal(domain)
|
||||
parts = append(parts, `{"type": "dns", "value": `+string(raw)+`}`)
|
||||
}
|
||||
sum := md5.Sum([]byte("[" + strings.Join(parts, ", ") + "]"))
|
||||
return hex.EncodeToString(sum[:])
|
||||
}
|
||||
func sameDomainSet(a, b []string) bool {
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
}
|
||||
set := map[string]bool{}
|
||||
for _, v := range b {
|
||||
set[strings.ToLower(v)] = true
|
||||
}
|
||||
for _, v := range a {
|
||||
key := strings.ToLower(v)
|
||||
if !set[key] {
|
||||
return false
|
||||
}
|
||||
delete(set, key)
|
||||
}
|
||||
return len(set) == 0
|
||||
}
|
||||
func (c *Client) ClearManagedCertificateOrder(ctx context.Context, index string) error {
|
||||
if !validIdentifierForOrder(index) {
|
||||
return errors.New("invalid managed certificate order")
|
||||
}
|
||||
_, err := c.call(ctx, http.MethodPost, "/acme", url.Values{"action": {"remove_order"}, "index": {index}})
|
||||
if err != nil && strings.Contains(err.Error(), "指定订单不存在") {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
func validIdentifierForOrder(v string) bool {
|
||||
if len(v) < 1 || len(v) > 128 {
|
||||
return false
|
||||
}
|
||||
for _, c := range v {
|
||||
if !(c >= 'a' && c <= 'z') && !(c >= 'A' && c <= 'Z') && !(c >= '0' && c <= '9') && c != '-' && c != '_' {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
Reference in new issue
Block a user