add callback function for hin2n to protect socket (#684)

This commit is contained in:
randomize00 2021-04-14 13:46:50 +08:00 committed by GitHub
parent e2c687558f
commit cfa92d28d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -516,6 +516,9 @@ typedef struct n2n_edge_callbacks {
/* Called periodically in the main loop. */
void (*main_loop_period)(n2n_edge_t *eee, time_t now);
/* Called when a new socket to supernode is created. */
void (*sock_opened)(n2n_edge_t *eee);
} n2n_edge_callbacks_t;
typedef struct n2n_tuntap_priv_config {

View File

@ -219,6 +219,9 @@ int supernode_connect(n2n_edge_t *eee) {
return -1;
}
if(eee->cb.sock_opened)
eee->cb.sock_opened(eee);
struct sockaddr_in sock;
sock.sin_family = AF_INET;
sock.sin_port = htons(eee->curr_sn->sock.port);