湘游汇 v1.0版本的 MD5 值为:85338391d88b5d57da66e240ece801c7

以下内容为反编译后的 h.java 源代码,内容仅作参考


package com.tencent.c.a;

import android.content.Context;
import android.content.IntentFilter;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.regex.Pattern;
import org.apache.http.HttpHost;
import org.cocos2dx.lib.BuildConfig;
import org.json.JSONObject;
public class h {
    private static h g;
    private com.tencent.c.a.a.g e;
    private Context h;
    private com.tencent.c.a.a.b i;
    private List<String> f781a = null;
    private volatile int b = 2;
    private volatile String c = BuildConfig.FLAVOR;
    private volatile HttpHost d = null;
    private int f = 0;

    private h(Context context) {
        this.e = null;
        this.h = null;
        this.i = null;
        this.h = context.getApplicationContext();
        this.e = new com.tencent.c.a.a.g();
        aj.a(context);
        this.i = com.tencent.c.a.a.n.b();
        l();
        i();
        g();
    }

    public static h a(Context context) {
        if (g == null) {
            synchronized (h.class) {
                if (g == null) {
                    g = new h(context);
                }
            }
        }
        return g;
    }

    private boolean b(String str) {
        return Pattern.compile("(2[5][0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2})\\.(25[0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2})\\.(25[0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2})\\.(25[0-5]|2[0-4]\\d|1\\d{2}|\\d{1,2})").matcher(str).matches();
    }

    private void i() {
        this.f781a = new ArrayList(10);
        this.f781a.add("117.135.169.101");
        this.f781a.add("140.207.54.125");
        this.f781a.add("180.153.8.53");
        this.f781a.add("120.198.203.175");
        this.f781a.add("14.17.43.18");
        this.f781a.add("163.177.71.186");
        this.f781a.add("111.30.131.31");
        this.f781a.add("123.126.121.167");
        this.f781a.add("123.151.152.111");
        this.f781a.add("113.142.45.79");
        this.f781a.add("123.138.162.90");
        this.f781a.add("103.7.30.94");
    }

    private String j() {
        try {
            return !b("pingma.qq.com") ? InetAddress.getByName("pingma.qq.com").getHostAddress() : BuildConfig.FLAVOR;
        } catch (Exception e) {
            this.i.b((Throwable) e);
            return BuildConfig.FLAVOR;
        }
    }

    private void k() {
        String j = j();
        if (c.b()) {
            com.tencent.c.a.a.b bVar = this.i;
            bVar.b("remoteIp ip is " + j);
        }
        if (com.tencent.c.a.a.n.c(j)) {
            if (!this.f781a.contains(j)) {
                String str = this.f781a.get(this.f);
                if (c.b()) {
                    com.tencent.c.a.a.b bVar2 = this.i;
                    bVar2.d(j + " not in ip list, change to:" + str);
                }
                j = str;
            }
            c.b("http://" + j + ":80/mstat/report");
        }
    }

    private void l() {
        this.b = 0;
        this.d = null;
        this.c = null;
    }

    public HttpHost a() {
        return this.d;
    }

    public void a(String str) {
        String[] split;
        if (c.b()) {
            this.i.b("updateIpList " + str);
        }
        try {
            if (com.tencent.c.a.a.n.c(str)) {
                JSONObject jSONObject = new JSONObject(str);
                if (jSONObject.length() > 0) {
                    Iterator<String> keys = jSONObject.keys();
                    while (keys.hasNext()) {
                        String string = jSONObject.getString(keys.next());
                        if (com.tencent.c.a.a.n.c(string)) {
                            for (String str2 : string.split(";")) {
                                if (com.tencent.c.a.a.n.c(str2)) {
                                    String[] split2 = str2.split(":");
                                    if (split2.length > 1) {
                                        String str3 = split2[0];
                                        if (b(str3) && !this.f781a.contains(str3)) {
                                            if (c.b()) {
                                                this.i.b("add new ip:" + str3);
                                            }
                                            this.f781a.add(str3);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            this.i.b((Throwable) e);
        }
        this.f = new Random().nextInt(this.f781a.size());
    }

    public String b() {
        return this.c;
    }

    public int c() {
        return this.b;
    }

    public void d() {
        this.f = (this.f + 1) % this.f781a.size();
    }

    public boolean e() {
        return this.b == 1;
    }

    public boolean f() {
        return this.b != 0;
    }

    public void g() {
        if (!com.tencent.c.a.a.t.f(this.h)) {
            if (c.b()) {
                this.i.b("NETWORK TYPE: network is close.");
            }
            l();
            return;
        }
        if (c.g) {
            k();
        }
        this.c = com.tencent.c.a.a.n.i(this.h);
        if (c.b()) {
            com.tencent.c.a.a.b bVar = this.i;
            bVar.b("NETWORK name:" + this.c);
        }
        if (com.tencent.c.a.a.n.c(this.c)) {
            this.b = "WIFI".equalsIgnoreCase(this.c) ? 1 : 2;
            this.d = com.tencent.c.a.a.n.a(this.h);
        }
        if (f.a()) {
            f.e(this.h);
        }
    }

    public void h() {
        this.h.getApplicationContext().registerReceiver(new y(this), new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
    }
}