52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package internal
|
|
|
|
import (
|
|
"encoding/hex"
|
|
gonanoid "github.com/matoous/go-nanoid"
|
|
"matrix-common/pkg/logger"
|
|
"time"
|
|
|
|
"fmt"
|
|
"math"
|
|
"net"
|
|
"testing"
|
|
)
|
|
|
|
func TestBatchLookup(t *testing.T) {
|
|
for i := 0; i < 10; i++ {
|
|
TestLookup(t)
|
|
time.Sleep(1 * time.Second)
|
|
}
|
|
}
|
|
|
|
func TestLookup(t *testing.T) {
|
|
id, _ := gonanoid.Generate("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 6)
|
|
originalText := time.Now().Format("2006-01-02 15:04:05.000")
|
|
|
|
text := hex.EncodeToString([]byte(originalText))
|
|
|
|
chunkSize := 18
|
|
data := make([]string, 0)
|
|
|
|
fLen := float64(len(text)) / float64(chunkSize)
|
|
l := int(math.Ceil(fLen))
|
|
|
|
for i := 0; i < l; i++ {
|
|
if i == 0 {
|
|
data = append(data, text[:chunkSize])
|
|
} else {
|
|
if (i+1)*chunkSize > len(text) {
|
|
data = append(data, text[i*chunkSize:])
|
|
} else {
|
|
data = append(data, text[i*chunkSize:(i+1)*chunkSize])
|
|
}
|
|
}
|
|
}
|
|
logger.Log().Infof("%#v", data)
|
|
|
|
for i, datum := range data {
|
|
_, _ = net.LookupIP(fmt.Sprintf("%s.%s.%d.%s.log.skcks.cn", "a", id, i, datum))
|
|
}
|
|
_, _ = net.LookupIP(fmt.Sprintf("%s.%s.%s.%s.log.skcks.cn", "e", id, "x", "x"))
|
|
}
|