Skip to content
Snippets Groups Projects
Commit 847a971d authored by alexander.lysikov's avatar alexander.lysikov
Browse files

fixed initialize vpn service

parent 6d8da648
No related branches found
No related tags found
1 merge request!6fixed initialize vpn service
...@@ -479,6 +479,12 @@ void s_new(dap_stream_ch_t* a_stream_ch, void* a_arg) ...@@ -479,6 +479,12 @@ void s_new(dap_stream_ch_t* a_stream_ch, void* a_arg)
a_stream_ch->internal = DAP_NEW_Z(dap_chain_net_srv_ch_vpn_t); a_stream_ch->internal = DAP_NEW_Z(dap_chain_net_srv_ch_vpn_t);
dap_chain_net_srv_ch_vpn_t * l_srv_vpn = CH_VPN(a_stream_ch); dap_chain_net_srv_ch_vpn_t * l_srv_vpn = CH_VPN(a_stream_ch);
if(a_stream_ch->stream->session->_inheritor == NULL && a_stream_ch->stream->session != NULL)
dap_chain_net_srv_stream_session_create(a_stream_ch->stream->session);
dap_chain_net_srv_uid_t l_uid = { .uint64 = DAP_CHAIN_NET_SRV_VPN_ID };
l_srv_vpn->net_srv = dap_chain_net_srv_get(l_uid);
dap_chain_net_srv_stream_session_t * l_srv_session = (dap_chain_net_srv_stream_session_t *) a_stream_ch->stream->session->_inheritor; dap_chain_net_srv_stream_session_t * l_srv_session = (dap_chain_net_srv_stream_session_t *) a_stream_ch->stream->session->_inheritor;
pthread_mutex_init(&l_srv_vpn->mutex, NULL); pthread_mutex_init(&l_srv_vpn->mutex, NULL);
l_srv_vpn->raw_l3_sock = socket(PF_INET, SOCK_RAW, IPPROTO_RAW); l_srv_vpn->raw_l3_sock = socket(PF_INET, SOCK_RAW, IPPROTO_RAW);
...@@ -525,7 +531,9 @@ void srv_ch_vpn_delete(dap_stream_ch_t* ch, void* arg) ...@@ -525,7 +531,9 @@ void srv_ch_vpn_delete(dap_stream_ch_t* ch, void* arg)
} }
pthread_rwlock_wrlock(&s_clients_rwlock); pthread_rwlock_wrlock(&s_clients_rwlock);
HASH_DEL(s_ch_vpn_addrs,l_ch_vpn); if(s_ch_vpn_addrs) {
HASH_DEL(s_ch_vpn_addrs, l_ch_vpn);
}
if ( l_is_unleased ){ // If unleased if ( l_is_unleased ){ // If unleased
dap_chain_net_srv_vpn_item_ipv4_t * l_item_unleased = DAP_NEW_Z(dap_chain_net_srv_vpn_item_ipv4_t); dap_chain_net_srv_vpn_item_ipv4_t * l_item_unleased = DAP_NEW_Z(dap_chain_net_srv_vpn_item_ipv4_t);
...@@ -549,7 +557,9 @@ void srv_ch_vpn_delete(dap_stream_ch_t* ch, void* arg) ...@@ -549,7 +557,9 @@ void srv_ch_vpn_delete(dap_stream_ch_t* ch, void* arg)
HASH_ITER(hh, l_ch_vpn->socks , cur, tmp) HASH_ITER(hh, l_ch_vpn->socks , cur, tmp)
{ {
log_it(L_DEBUG, "delete socket: %i", cur->sock); log_it(L_DEBUG, "delete socket: %i", cur->sock);
HASH_DEL(l_ch_vpn->socks, cur); if(l_ch_vpn->socks){
HASH_DEL(l_ch_vpn->socks, cur);
}
if(cur) if(cur)
free(cur); free(cur);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment