Browse Source

Fix VPN apis for Android 4.x

pull/773/head
Max Lv 8 years ago
parent
commit
d31210c217
2 changed files with 23 additions and 9 deletions
  1. 17
      src/local.c
  2. 15
      src/tunnel.c

17
src/local.c

@ -264,11 +264,18 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
if (!remote->send_ctx->connected) {
#ifdef ANDROID
if (vpn) {
if (protect_socket(remote->fd) == -1) {
ERROR("protect_socket");
close_and_free_remote(EV_A_ remote);
close_and_free_server(EV_A_ server);
return;
int not_protect = 0;
if (remote->addr.ss_family == AF_INET) {
struct sockaddr_in *s = (struct sockaddr_in *)&remote->addr;
if (s->sin_addr.s_addr == inet_addr("127.0.0.1")) not_protect = 1;
}
if (!not_protect) {
if (protect_socket(remote->fd) == -1) {
ERROR("protect_socket");
close_and_free_remote(EV_A_ remote);
close_and_free_server(EV_A_ server);
return;
}
}
}
#endif

15
src/tunnel.c

@ -633,10 +633,17 @@ static void accept_cb(EV_P_ ev_io *w, int revents)
#ifdef ANDROID
if (vpn) {
if (protect_socket(remotefd) == -1) {
ERROR("protect_socket");
close(remotefd);
return;
int not_protect = 0;
if (remote_addr->sa_family == AF_INET) {
struct sockaddr_in *s = (struct sockaddr_in *)remote_addr;
if (s->sin_addr.s_addr == inet_addr("127.0.0.1")) not_protect = 1;
}
if (!not_protect) {
if (protect_socket(remotefd) == -1) {
ERROR("protect_socket");
close(remotefd);
return;
}
}
}
#endif

Loading…
Cancel
Save