security: stop tracking env files; admin gate via VITE_SITE_ADMIN_GATE; Redis/cache/docs

Remove InfoGenie-frontend and Go .env from version control; add .env.example templates; ignore .claude local settings. Admin UI reads site gate from env only. Note: rotate secrets if repo history was ever public.

Made-with: Cursor
This commit is contained in:
2026-04-03 16:10:12 +08:00
parent 284b5a5260
commit 6b3fcc1791
25 changed files with 1078 additions and 972 deletions

View File

@@ -0,0 +1,84 @@
package main
import (
"context"
"fmt"
"os"
"strconv"
"strings"
"time"
"github.com/redis/go-redis/v9"
)
// 用法: go run . <host:port> [password]
// 例: go run . 10.1.1.100:6379
func main() {
addr := "10.1.1.100:6379"
pass := os.Getenv("REDIS_PASSWORD")
if len(os.Args) >= 2 {
addr = os.Args[1]
}
if len(os.Args) >= 3 {
pass = os.Args[2]
}
ctx, cancel := context.WithTimeout(context.Background(), 8*time.Second)
defer cancel()
r := redis.NewClient(&redis.Options{Addr: addr, Password: pass})
defer r.Close()
if err := r.Ping(ctx).Err(); err != nil {
fmt.Fprintf(os.Stderr, "连接失败 %s: %v\n", addr, err)
os.Exit(1)
}
s, err := r.Info(ctx, "keyspace").Result()
if err != nil {
fmt.Fprintf(os.Stderr, "INFO keyspace: %v\n", err)
os.Exit(1)
}
used := make(map[int]int64)
for _, line := range strings.Split(s, "\r\n") {
line = strings.TrimSpace(line)
if line == "" || strings.HasPrefix(line, "#") {
continue
}
if !strings.HasPrefix(line, "db") {
continue
}
colon := strings.IndexByte(line, ':')
if colon <= 2 {
continue
}
dbStr := line[2:colon]
dbNum, err := strconv.Atoi(dbStr)
if err != nil {
continue
}
var keys int64
for _, part := range strings.Split(line[colon+1:], ",") {
part = strings.TrimSpace(part)
if strings.HasPrefix(part, "keys=") {
keys, _ = strconv.ParseInt(strings.TrimPrefix(part, "keys="), 10, 64)
break
}
}
used[dbNum] = keys
}
fmt.Printf("Redis %s — 逻辑库 key 统计(INFO keyspace)\n\n", addr)
for i := 0; i < 16; i++ {
k, ok := used[i]
if !ok {
fmt.Printf(" db%-2d : 无记录(通常为 0 个 key / 未写入过)\n", i)
} else if k == 0 {
fmt.Printf(" db%-2d : 0 keys\n", i)
} else {
fmt.Printf(" db%-2d : %d keys (已占用)\n", i, k)
}
}
fmt.Println()
fmt.Println("说明: Redis 默认 16 个逻辑库(0-15);「无记录」一般可当空闲选用。")
fmt.Println("若 redis.conf 里 databases=N实际库数量可能更大可用 redis-cli CONFIG GET databases 查看。")
}