Files
v2ray_simple/utils/strings_unix.go
e1732a364fed f28f0d0bee 修订代码, 默认loglevel 改为 Log_info.
对一般用户而言,还是需要使用Info等级 来了解一下 一般的 日志情况,等到使用熟练之后,且确认运行没有错误后, 可以自行调为 warning 来提升性能

发现 bubble包 还自己引入了 命令行参数,这十分不可取,所以我们还是直接使用其代码。

将其它包中 的 命令行参数 统一 移动 到 cmd/verysimple 中;tls lazy 特性因为还在 调试阶段,所以 命令行参数 仍然放到 v2ray_simple 包中。
2022-04-26 13:22:18 +08:00

46 lines
779 B
Go

//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
// +build darwin dragonfly freebsd linux netbsd openbsd
package utils
import (
"io/ioutil"
"math/rand"
"os"
"strings"
)
var words []string
var getWordListFailed bool
func GetRandomWord() (result string) {
if len(words) == 0 && !getWordListFailed {
words = readAvailableDictionary()
}
if theLen := len(words); theLen == 0 {
getWordListFailed = true
result = GenerateRandomString()
} else {
result = words[rand.Int()%theLen]
}
return
}
func readAvailableDictionary() (words []string) {
file, err := os.Open("/usr/share/dict/words")
if err != nil {
return
}
bytes, err := ioutil.ReadAll(file)
if err != nil {
return
}
words = strings.Split(string(bytes), "\n")
return
}