2022-03-27 14:27:16 +09:00
|
|
|
//go:build ignore
|
|
|
|
// +build ignore
|
|
|
|
|
2021-12-25 21:15:28 +09:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/md5"
|
|
|
|
"encoding/hex"
|
|
|
|
"fmt"
|
|
|
|
"io/fs"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
"unicode"
|
|
|
|
"unsafe"
|
|
|
|
|
2023-03-25 16:40:09 +09:00
|
|
|
"github.com/FloatTech/floatbox/process"
|
2021-12-25 21:15:28 +09:00
|
|
|
"github.com/fumiama/go-registry"
|
|
|
|
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var files []string
|
|
|
|
fs.WalkDir(os.DirFS("./"), ".", func(path string, d fs.DirEntry, err error) error {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if !d.IsDir() && strings.Contains(path, "/") && unicode.IsUpper([]rune(path)[0]) {
|
|
|
|
files = append(files, path)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
fmt.Println(files)
|
|
|
|
md5s := make([]string, len(files))
|
|
|
|
for i, fn := range files {
|
|
|
|
data, err := os.ReadFile(fn)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
buf := md5.Sum(data)
|
|
|
|
*(*unsafe.Pointer)(unsafe.Pointer(&md5s[i])) = unsafe.Pointer(&buf)
|
|
|
|
*(*uintptr)(unsafe.Add(unsafe.Pointer(&md5s[i]), unsafe.Sizeof(uintptr(0)))) = uintptr(16)
|
|
|
|
}
|
2022-11-22 18:11:02 +09:00
|
|
|
r := registry.NewRegedit("reilia.fumiama.top:32664", "", "fumiama", os.Getenv("REILIA_SPS"))
|
2021-12-25 21:15:28 +09:00
|
|
|
err := r.Connect()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
for i, fn := range files {
|
2023-03-25 16:40:09 +09:00
|
|
|
for c := 0; c < 16; c++ {
|
2022-05-04 21:26:05 +09:00
|
|
|
err = r.Set("data/"+fn, md5s[i])
|
|
|
|
fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i])))
|
|
|
|
if err == nil {
|
|
|
|
break
|
2022-04-17 21:34:18 +09:00
|
|
|
}
|
2023-03-25 16:40:09 +09:00
|
|
|
if c >= 15 {
|
|
|
|
panic("ERROR:" + err.Error() + ", max retry times exceeded")
|
2022-05-04 21:26:05 +09:00
|
|
|
} else {
|
|
|
|
fmt.Println("ERROR:", err, ", retry times:", c)
|
|
|
|
}
|
|
|
|
_ = r.Close()
|
2023-03-25 16:40:09 +09:00
|
|
|
process.SleepAbout1sTo2s()
|
2022-05-04 21:26:05 +09:00
|
|
|
err = r.Connect()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
2021-12-25 21:15:28 +09:00
|
|
|
}
|
2022-05-04 21:26:05 +09:00
|
|
|
_ = r.Close()
|
2021-12-25 21:15:28 +09:00
|
|
|
}
|