45 lines
974 B
Go
45 lines
974 B
Go
package internal
|
|
|
|
import (
|
|
"encoding/hex"
|
|
gonanoid "github.com/matoous/go-nanoid"
|
|
"matrix-common/pkg/logger"
|
|
|
|
"fmt"
|
|
"math"
|
|
"net"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestLookup(t *testing.T) {
|
|
id, _ := gonanoid.Generate("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 6)
|
|
originalText := strings.Repeat("1234567890", 66)
|
|
|
|
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"))
|
|
}
|