代码提交
This commit is contained in:
+2
-2
@@ -4,8 +4,8 @@ redis:
|
||||
passwd: "Redis@fish2026!"
|
||||
subscribe: true
|
||||
mongodb:
|
||||
addr: "mongodb://admin:3NjreBBLVOkptSWbV%21@172.104.56.78:47018,172.104.56.119:47018,172.104.56.146:47018/web_huangguo2?replicaSet=web_jiqun3&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2"
|
||||
logaddr: "mongodb://admin:3NjreBBLVOkptSWbV%21@172.104.56.78:47018,172.104.56.119:47018,172.104.56.146:47018/web_huangguo2_log?replicaSet=web_jiqun3&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2"
|
||||
addr: "mongodb://web_huangguo2:xDdEkf6m0HDpkEpxpphi@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/web_huangguo2?replicaSet=fish0&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2"
|
||||
logaddr: "mongodb://web_huangguo2:xDdEkf6m0HDpkEpxpphi@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/web_huangguo2_log?replicaSet=fish0&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2"
|
||||
es:
|
||||
addr: "http://139.162.47.194:9200"
|
||||
user: "elastic"
|
||||
|
||||
@@ -79,6 +79,16 @@ func GetRandomLetters(n int) string {
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// GetRandomAlphanumeric 生成 n 位大小写字母 + 数字随机串
|
||||
func GetRandomAlphanumeric(n int) string {
|
||||
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
b := make([]byte, n)
|
||||
for i := range b {
|
||||
b[i] = chars[rand.IntN(len(chars))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func GetSlugInfo(text string) string {
|
||||
return SanitizeSlug(slug.Make(text))
|
||||
}
|
||||
@@ -114,12 +124,12 @@ func IsSlugAllDigits(s string) bool {
|
||||
}
|
||||
|
||||
// RandomSlugLength 随机 slug 长度
|
||||
const RandomSlugLength = 8
|
||||
const RandomSlugLength = 10
|
||||
|
||||
// MakeRandomSlug 生成唯一的随机 slug(8 位小写字母);exists 返回 true 表示已被占用。
|
||||
// MakeRandomSlug 生成唯一的随机 slug(10 位大小写字母+数字混合);exists 返回 true 表示已被占用。
|
||||
func MakeRandomSlug(exists func(string) bool) string {
|
||||
for {
|
||||
s := strings.ToLower(GetRandomLetters(RandomSlugLength))
|
||||
s := GetRandomAlphanumeric(RandomSlugLength)
|
||||
if !exists(s) {
|
||||
return s
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@ redis:
|
||||
passwd: "Redis@fish2026!"
|
||||
subscribe: true
|
||||
mongodb:
|
||||
addr: "mongodb://admin:3NjreBBLVOkptSWbV%21@172.104.56.78:47018,172.104.56.119:47018,172.104.56.146:47018/web_huangguo2?replicaSet=web_jiqun3&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2"
|
||||
logaddr: "mongodb://admin:3NjreBBLVOkptSWbV%21@172.104.56.78:47018,172.104.56.119:47018,172.104.56.146:47018/web_huangguo2_log?replicaSet=web_jiqun3&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2"
|
||||
addr: "mongodb://web_huangguo2:xDdEkf6m0HDpkEpxpphi@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/web_huangguo2?replicaSet=fish0&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2"
|
||||
logaddr: "mongodb://web_huangguo2:xDdEkf6m0HDpkEpxpphi@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/web_huangguo2_log?replicaSet=fish0&maxPoolSize=200&connectTimeout=30&authSource=web_huangguo2"
|
||||
es:
|
||||
addr: "http://139.162.47.194:9200"
|
||||
user: "elastic"
|
||||
|
||||
Reference in New Issue
Block a user