mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-29 20:43:44 +00:00
Fix VPN apis for Android 4.x
This commit is contained in:
+12
-5
@@ -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
|
||||
|
||||
+11
-4
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user