41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import type { HttpUsedLogItem, HttpUsedSummary } from "@/lib/models/record"
|
|
|
|
export const MOCK_USED_SUMMARY: HttpUsedSummary = {
|
|
todayShortPackIpUsed: 3,
|
|
shortPackIpUsed: 45,
|
|
}
|
|
|
|
const PACK_IP_PREFIX = [
|
|
{ packType: 21, prefix: "211.90.13" },
|
|
{ packType: 22, prefix: "112.65.28" },
|
|
]
|
|
|
|
function pad(value: number): string {
|
|
return String(value).padStart(2, "0")
|
|
}
|
|
|
|
function buildLogs(count: number): HttpUsedLogItem[] {
|
|
const now = new Date()
|
|
const logs: HttpUsedLogItem[] = []
|
|
|
|
for (let i = 0; i < count; i += 1) {
|
|
const source = PACK_IP_PREFIX[i % PACK_IP_PREFIX.length]
|
|
const time = new Date(now.getTime() - i * 37 * 60 * 1000)
|
|
const createTime =
|
|
`${time.getFullYear()}-${pad(time.getMonth() + 1)}-${pad(time.getDate())} ` +
|
|
`${pad(time.getHours())}:${pad(time.getMinutes())}:${pad(time.getSeconds())}`
|
|
|
|
logs.push({
|
|
packType: source.packType,
|
|
userIp: `113.118.${(i % 200) + 10}.${(i % 250) + 3}`,
|
|
ip: `${source.prefix}.${(i % 240) + 10}`,
|
|
port: 6000 + (i % 300),
|
|
createTime,
|
|
})
|
|
}
|
|
|
|
return logs
|
|
}
|
|
|
|
export const MOCK_USED_LOGS = buildLogs(56)
|