refactor: 收口为hub/peer/bridge 三程序并统一 支持 tcp/udp/kcp"

This commit is contained in:
nnbcccscdscdsc
2026-03-17 16:28:35 +08:00
parent 6c975d9ae3
commit 20b2050706
17 changed files with 2766 additions and 6398 deletions

View File

@@ -36,6 +36,20 @@ static const struct ProtoVTable *select_vtable(OmniProtocol proto)
}
}
static const char *proto_name(OmniProtocol proto)
{
switch (proto) {
case OMNI_PROTO_TCP:
return "tcp";
case OMNI_PROTO_UDP:
return "udp";
case OMNI_PROTO_KCP:
return "kcp";
default:
return "unknown";
}
}
OmniContext *omni_init(OmniRole role,
OmniProtocol proto,
const char *bind_ip,
@@ -44,6 +58,11 @@ OmniContext *omni_init(OmniRole role,
uint16_t peer_port)
{
logger_init();
logger_set_context("network",
proto_name(proto),
NULL,
role == OMNI_ROLE_SERVER ? "server" : "client",
NULL);
const struct ProtoVTable *vt = select_vtable(proto);
if (!vt || !vt->init) {