Skip to content

Commit 74c5464

Browse files
committed
feat: support multi-addrs
1 parent ca36529 commit 74c5464

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

main.go

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"flag"
1010
"fmt"
1111
"io/fs"
12+
"net"
1213
"os"
1314
"strings"
1415
"unicode"
@@ -57,30 +58,37 @@ func main() {
5758
*(*unsafe.Pointer)(unsafe.Pointer(&md5s[i])) = unsafe.Pointer(&buf)
5859
*(*uintptr)(unsafe.Add(unsafe.Pointer(&md5s[i]), unsafe.Sizeof(uintptr(0)))) = uintptr(16)
5960
}
60-
r := registry.NewRegedit("reilia.fumiama.top:32664", "", "fumiama", os.Getenv("REILIA_SPS"))
61-
err = r.Connect()
61+
names, err := net.LookupAddr("reilia.fumiama.top")
6262
if err != nil {
6363
panic(err)
6464
}
65-
for i, fn := range files {
66-
for c := 0; c < 16; c++ {
67-
err = r.Set("data/"+fn, md5s[i])
68-
fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i])))
69-
if err == nil {
70-
break
71-
}
72-
if c >= 15 {
73-
panic("ERROR:" + err.Error() + ", max retry times exceeded")
74-
} else {
75-
fmt.Println("ERROR:", err, ", retry times:", c)
76-
}
77-
_ = r.Close()
78-
process.SleepAbout1sTo2s()
79-
err = r.Connect()
80-
if err != nil {
81-
panic(err)
65+
for _, nm := range names {
66+
fmt.Println("推送到:", nm)
67+
r := registry.NewRegedit(net.JoinHostPort(nm, "32664"), "", "fumiama", os.Getenv("REILIA_SPS"))
68+
err = r.Connect()
69+
if err != nil {
70+
panic(err)
71+
}
72+
for i, fn := range files {
73+
for c := 0; c < 16; c++ {
74+
err = r.Set("data/"+fn, md5s[i])
75+
fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i])))
76+
if err == nil {
77+
break
78+
}
79+
if c >= 15 {
80+
panic("ERROR:" + err.Error() + ", max retry times exceeded")
81+
} else {
82+
fmt.Println("ERROR:", err, ", retry times:", c)
83+
}
84+
_ = r.Close()
85+
process.SleepAbout1sTo2s()
86+
err = r.Connect()
87+
if err != nil {
88+
panic(err)
89+
}
8290
}
8391
}
92+
_ = r.Close()
8493
}
85-
_ = r.Close()
8694
}

0 commit comments

Comments
 (0)