How to block proxy / vpn in an android / java app

0

Good afternoon, I'm redoing an app that suffered ban on adsense because many of the users who accessed it used proxy / vpn and google identified it as bots.

So I did code to detect these proxy and not display ads to them the problem is that the site I was using has a limit of requests and my email was blocked, I thought then to use the user's email to accomplish this requests, but if the guy is an active user, in 1 or 2 weeks his email is blocked and the response is going to be -5 and then he can not log into the app in the same way.

I would like to know if there is a library that allows me to do it in a different way, more practical, or even not, but that is efficient and free.

I'll leave the code here for someone with experience to review and tell me what to improve. Att,

ipRequest = new StringRequest(Request.Method.GET, url_ip,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    url = "http://check.getipintel.net/check.php?ip="+
                            response+"&contact="+user.getEmail()+"&flags=b";
                    proxyRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
                        @Override
                        public void onResponse(String response) {
                            float re = Float.parseFloat(response);
                            if(re > 0.995){
                                Toast.makeText(getApplicationContext(), "Proxy/VPN/Bots não são permitidos no app!", Toast.LENGTH_SHORT).show();
                            } else {
                                Intent i = new Intent(getApplicationContext(), MainActivity.class);
                                startActivity(i);
                                finish();
                                progressBar.setVisibility(View.GONE);
                            }


                        }
                    }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                             Toast.makeText(getApplicationContext(), "Erro: " + error.getMessage(), Toast.LENGTH_SHORT).show();
                                progressBar.setVisibility(View.GONE);
                                Intent in = new Intent(getApplicationContext(), SplashActivity.class);
                                startActivity(in);
                                finish();
                               }
                    });
                    queue.add(proxyRequest);
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Toast.makeText(getApplicationContext(), "Erro: " + error.getMessage(), Toast.LENGTH_SHORT).show();
        }
    });
    queue.add(ipRequest);
    
asked by anonymous 22.09.2018 / 22:19

0 answers