refactor: 收口为hub/peer/bridge 三程序并统一 支持 tcp/udp/kcp"
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user