1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 17:39:53 +03:00

Cedar: change ProtoHandleConnection() so that it supports direct protocol specification

This commit is contained in:
Davide Beatrici 2020-07-12 03:05:51 +02:00
parent e0c6813d44
commit eb5150a002
3 changed files with 23 additions and 8 deletions

View File

@ -2936,7 +2936,7 @@ void ConnectionAccept(CONNECTION *c)
if (c->Cedar != NULL && c->Cedar->Server != NULL) if (c->Cedar != NULL && c->Cedar->Server != NULL)
{ {
PROTO *proto = c->Cedar->Server->Proto; PROTO *proto = c->Cedar->Server->Proto;
if (proto && ProtoHandleConnection(proto, s) == true) if (proto && ProtoHandleConnection(proto, s, NULL) == true)
{ {
c->Type = CONNECTION_TYPE_OTHER; c->Type = CONNECTION_TYPE_OTHER;
goto FINAL; goto FINAL;

View File

@ -309,10 +309,10 @@ bool ProtoSetUdpPorts(PROTO *proto, const LIST *ports)
return true; return true;
} }
bool ProtoHandleConnection(PROTO *proto, SOCK *sock) bool ProtoHandleConnection(PROTO *proto, SOCK *sock, const char *protocol)
{ {
const PROTO_IMPL *impl = NULL;
void *impl_data = NULL; void *impl_data = NULL;
const PROTO_IMPL *impl;
UCHAR *buf; UCHAR *buf;
TCP_RAW_DATA *recv_raw_data; TCP_RAW_DATA *recv_raw_data;
@ -325,6 +325,20 @@ bool ProtoHandleConnection(PROTO *proto, SOCK *sock)
return false; return false;
} }
if (protocol != NULL)
{
UINT i;
for (i = 0; i < LIST_NUM(proto->Impls); ++i)
{
const PROTO_IMPL *tmp = LIST_DATA(proto->Impls, i);
if (StrCmp(tmp->Name(), protocol) == 0)
{
impl = tmp;
break;
}
}
}
else
{ {
UCHAR tmp[PROTO_CHECK_BUFFER_SIZE]; UCHAR tmp[PROTO_CHECK_BUFFER_SIZE];
if (Peek(sock, tmp, sizeof(tmp)) == 0) if (Peek(sock, tmp, sizeof(tmp)) == 0)
@ -333,10 +347,11 @@ bool ProtoHandleConnection(PROTO *proto, SOCK *sock)
} }
impl = ProtoImplDetect(proto, PROTO_MODE_TCP, tmp, sizeof(tmp)); impl = ProtoImplDetect(proto, PROTO_MODE_TCP, tmp, sizeof(tmp));
if (impl == NULL) }
{
return false; if (impl == NULL)
} {
return false;
} }
im = NewInterruptManager(); im = NewInterruptManager();

View File

@ -68,7 +68,7 @@ void ProtoDeleteSession(PROTO_SESSION *session);
bool ProtoSetListenIP(PROTO *proto, const IP *ip); bool ProtoSetListenIP(PROTO *proto, const IP *ip);
bool ProtoSetUdpPorts(PROTO *proto, const LIST *ports); bool ProtoSetUdpPorts(PROTO *proto, const LIST *ports);
bool ProtoHandleConnection(PROTO *proto, SOCK *sock); bool ProtoHandleConnection(PROTO *proto, SOCK *sock, const char *protocol);
void ProtoHandleDatagrams(UDPLISTENER *listener, LIST *datagrams); void ProtoHandleDatagrams(UDPLISTENER *listener, LIST *datagrams);
void ProtoSessionThread(THREAD *thread, void *param); void ProtoSessionThread(THREAD *thread, void *param);