Initial commit

This commit is contained in:
2026-06-30 15:14:37 +08:00
commit 15dab96872
311 changed files with 95639 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
package meshseed
import "time"
// MeshSeed 组网凭证 - 按照 README 5.1 节定义
type MeshSeed struct {
// ===== 必选参数 =====
NetworkName string `json:"networkName"` // 组网名称
NetworkSecret string `json:"networkSecret"` // 高熵密钥,派生 NetworkID(绝不公开)
Subnet string `json:"subnet"` // CIDR 格式,如 10.0.0.0/24
IssuerNodeID string `json:"issuerNodeId"` // 签发者节点 ID(对应 Ed25519 公钥)
// ===== 可选参数 =====
MaxUses int `json:"maxUses,omitempty"` // 最大使用次数(默认 10
ExpiresInHours int `json:"expiresInHours,omitempty"` // 有效期小时数(默认 168 = 7 天)
Permissions uint32 `json:"permissions,omitempty"` // 权限位掩码
BootstrapPeers []string `json:"bootstrapPeers,omitempty"` // 初始引导节点列表
TURNServers []TURNRef `json:"turnServers,omitempty"` // TURN 服务器引用
DDNSEnabled bool `json:"ddnsEnabled,omitempty"` // 是否允许 DDNS 同步
UpdateVersion int `json:"updateVersion,omitempty"` // 配置版本号(默认 0
// ===== 自动生成 =====
SeedID string `json:"seedId"` // 16 字节随机 Base64
NetworkID uint64 `json:"networkId"` // ❄️ 雪花算法 ID(原为 stringv2.1.0 改为 uint64
IssuedAt time.Time `json:"issuedAt"` // 签发时间戳
ExpiresAt time.Time `json:"expiresAt"` // 过期时间戳
Signature []byte `json:"signature"` // Ed25519 签名
}
// TURNRef TURN 服务器引用
type TURNRef struct {
Address string `json:"address"`
Port int `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
Realm string `json:"realm,omitempty"`
}