rebuild: split core into separate repo; move wg-go integration to internal/ctr/corebind

- go.mod: require git.zkcoi.com/zkcoi/meshray/core, replace => ../Meshray
- internal/ctr/corebind: EnhancedBind + registry + adapter (wg-go integration isolated)
- cmd/mr-wg migrated from old core/cmd/meshray-core
- core/ removed; CHANGELOG updated; fix checkdb vet warning
This commit is contained in:
2026-07-15 16:08:13 +08:00
parent 15dab96872
commit 59e3059246
39 changed files with 2350 additions and 4361 deletions
+67
View File
@@ -0,0 +1,67 @@
// Package corebind 的契约类型转换:在 meshray-contract 与 meshray/core 内部类型间双向转换。
package corebind
import (
"git.zkcoi.com/zkcoi/meshray-contract"
"git.zkcoi.com/zkcoi/meshray/core/connect"
"git.zkcoi.com/zkcoi/meshray/core/engine"
)
// 以下函数完成开源契约类型(contract 包)与 meshray/core 内部类型之间的双向转换。
// 数值型 Layer 在 contract 与 connect 中定义一致,可直接转型。
func toCoreCandidates(in []contract.Candidate) []core.Candidate {
out := make([]core.Candidate, 0, len(in))
for _, c := range in {
out = append(out, core.Candidate{
Addr: c.Addr,
Type: c.Type,
Priority: c.Priority,
Protocol: c.Protocol,
})
}
return out
}
func toCoreICEConfig(in contract.ICEConfig) connect.ICEConfig {
turn := make([]connect.TURNServerConfig, 0, len(in.TURNServers))
for _, s := range in.TURNServers {
turn = append(turn, connect.TURNServerConfig{URLs: []string{s}})
}
return connect.ICEConfig{
STUNServers: in.STUNServers,
TURNServers: turn,
}
}
func toCoreLayerOrder(in []contract.Layer) []connect.Layer {
out := make([]connect.Layer, 0, len(in))
for _, l := range in {
out = append(out, connect.Layer(l))
}
return out
}
func toContractStatus(in *core.EngineStatus) *contract.EngineStatus {
if in == nil {
return nil
}
peers := make(map[string]*contract.PeerStatus, len(in.Peers))
for k, v := range in.Peers {
peers[k] = &contract.PeerStatus{
PeerKey: v.PeerKey,
Connected: v.Connected,
Layer: v.Layer,
}
}
return &contract.EngineStatus{
PeerCount: in.PeerCount,
Peers: peers,
ActiveConnections: in.ActiveConnections,
TotalConnections: in.TotalConnections,
BytesSent: in.BytesSent,
BytesReceived: in.BytesReceived,
StrategyFallbacks: in.StrategyFallbacks,
LastSwitchTime: in.LastSwitchTime,
}
}