星辰影院解锁vip v1.0.4版本的 MD5 值为:3d99bbcbb0d5d5e568b9f6134424c24e

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


package org.qiyi.net.o.g;

import android.net.TrafficStats;
import android.text.TextUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.qiyi.net.s.g;

public class a {
    private String a;

    private String f17654b;

    private String f17655c;

    private Random f17656d;

    private String f17657e;

    private int f17658f;

    private Pattern f17659g;

    public a(String str, String str2) {
        this.a = str;
        this.f17655c = str2;
        this.f17654b = null;
        this.f17656d = new Random();
        this.f17657e = "";
        this.f17658f = 0;
        this.f17659g = Pattern.compile("(\\d|\\d{2}|\\d{3})(\\.(\\d|\\d{2}|\\d{3})){3}$");
    }

    private String a(String str) throws IOException {
        if (str == null || str.length() == 0) {
            return null;
        }
        if (this.f17654b == null) {
            String e2 = e(String.format("http://%s/d?dn=%s&ttl=%s&business=%s", this.a, this.f17655c, Integer.valueOf(this.f17658f), this.f17657e));
            this.f17654b = e2;
            if (org.qiyi.net.a.f17370b) {
                org.qiyi.net.a.c("getDomainIp-> %s: %s", this.f17655c, e2);
            }
        }
        String e3 = e(String.format("http://%s/d?dn=%s", this.f17654b, str));
        if (org.qiyi.net.a.f17370b) {
            org.qiyi.net.a.c("getDomainIp-> %s: %s", str, e3);
        }
        return e3;
    }

    private String e(String str) throws IOException {
        TrafficStats.setThreadStatsTag(244192303);
        int nextInt = this.f17656d.nextInt();
        StringBuilder sb = new StringBuilder();
        HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
        httpURLConnection.setRequestProperty("Check-Number", Integer.toString(nextInt));
        httpURLConnection.setConnectTimeout(6000);
        httpURLConnection.setReadTimeout(6000);
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine == null) {
                break;
            }
            sb.append(readLine);
        }
        bufferedReader.close();
        for (Map.Entry<String, List<String>> entry : httpURLConnection.getHeaderFields().entrySet()) {
            if (entry.getKey() != null && entry.getKey().equalsIgnoreCase("Check-Number")) {
                if (!entry.getValue().get(0).trim().equals(Integer.toString(nextInt))) {
                    throw new IOException("Check-Number not match.");
                }
            } else if (entry.getKey() != null && entry.getKey().equalsIgnoreCase("Query-Result")) {
                if (!sb.toString().equals(entry.getValue().get(0))) {
                    throw new IOException("Query-Result not match");
                }
            }
        }
        String[] split = sb.toString().split(";");
        if (split.length > 0) {
            if (this.f17659g.matcher(split[0]).find()) {
                return split[0];
            }
            throw new IOException("error httpdns server " + split[0]);
        }
        throw new IOException("failed to get httpdns server");
    }

    private String f(String str, String str2) throws IOException {
        TrafficStats.setThreadStatsTag(244192303);
        int nextInt = this.f17656d.nextInt();
        StringBuilder sb = new StringBuilder();
        HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
        httpURLConnection.setRequestProperty("Check-Number", Integer.toString(nextInt));
        httpURLConnection.setRequestMethod("POST");
        httpURLConnection.setConnectTimeout(6000);
        httpURLConnection.setReadTimeout(6000);
        httpURLConnection.getOutputStream().write(str2.getBytes());
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine == null) {
                break;
            }
            sb.append(readLine);
        }
        bufferedReader.close();
        for (Map.Entry<String, List<String>> entry : httpURLConnection.getHeaderFields().entrySet()) {
            if (entry.getKey() != null && entry.getKey().equalsIgnoreCase("Check-Number")) {
                if (!entry.getValue().get(0).trim().equals(Integer.toString(nextInt))) {
                    throw new IOException("Check-Number not match.");
                }
            } else if (entry.getKey() != null && entry.getKey().equalsIgnoreCase("Query-Result")) {
                if (!sb.toString().equals(entry.getValue().get(0))) {
                    throw new IOException("Query-Result not match");
                }
            }
        }
        return sb.toString();
    }

    public List<InetAddress> b(String str) throws IOException {
        String a = a(str);
        if (TextUtils.isEmpty(a)) {
            return null;
        }
        int indexOf = a.indexOf(",");
        if (indexOf > 0) {
            a = a.substring(0, indexOf);
        }
        String[] split = a.split(";");
        ArrayList arrayList = new ArrayList();
        for (String str2 : split) {
            if (!TextUtils.isEmpty(str2)) {
                arrayList.add(InetAddress.getByName(str2));
            }
        }
        return arrayList;
    }

    public l.a.c c(String str) throws IOException {
        return new l.a.c(b(str), 2);
    }

    public Map<String, List<InetAddress>> d(List<String> list) throws IOException {
        JSONObject jSONObject;
        HashMap hashMap = null;
        if (list != null && list.size() != 0) {
            if (this.f17654b == null) {
                String e2 = e(String.format("http://%s/d?dn=%s&ttl=%s&business=%s", this.a, this.f17655c, Integer.valueOf(this.f17658f), this.f17657e));
                this.f17654b = e2;
                if (org.qiyi.net.a.f17370b) {
                    org.qiyi.net.a.c("getDomainIp-> %s : %s", this.f17655c, e2);
                }
                if (this.f17654b == null) {
                    throw new IOException("failed to get httpdns server");
                }
            }
            JSONObject jSONObject2 = new JSONObject();
            boolean f2 = g.f();
            try {
                jSONObject2.put("ttl", 1);
                JSONArray jSONArray = new JSONArray();
                for (String str : list) {
                    if (f2) {
                        JSONObject jSONObject3 = new JSONObject();
                        jSONObject3.put("dn", str);
                        jSONObject3.put("qtype", "aaaa");
                        jSONArray.put(jSONObject3);
                    }
                    JSONObject jSONObject4 = new JSONObject();
                    jSONObject4.put("dn", str);
                    jSONObject4.put("qtype", "a");
                    jSONArray.put(jSONObject4);
                }
                jSONObject2.put("query", jSONArray);
            } catch (JSONException e3) {
                e3.printStackTrace();
            }
            String f3 = f(String.format("http://%s/md?business=%s", this.f17654b, this.f17657e), jSONObject2.toString());
            org.qiyi.net.a.g("http dns result = %s", f3);
            try {
                jSONObject = new JSONObject(f3);
            } catch (JSONException e4) {
                e4.printStackTrace();
                jSONObject = null;
            }
            if (jSONObject == null) {
                return null;
            }
            int optInt = jSONObject.optInt("code", 0);
            if (optInt != 1) {
                org.qiyi.net.a.d("Multi Domain HttpDns failed, msg = %s, code = %s", jSONObject.optString("msg"), Integer.valueOf(optInt));
                return null;
            }
            JSONArray optJSONArray = jSONObject.optJSONArray("answer");
            hashMap = new HashMap();
            for (int i2 = 0; i2 < optJSONArray.length(); i2++) {
                try {
                    JSONObject jSONObject5 = optJSONArray.getJSONObject(i2);
                    String optString = jSONObject5.optString("dn");
                    jSONObject5.optInt("ttl");
                    JSONArray optJSONArray2 = jSONObject5.optJSONArray("a");
                    JSONArray optJSONArray3 = jSONObject5.optJSONArray("aaaa");
                    List list2 = (List) hashMap.get(optString);
                    if (list2 == null) {
                        list2 = new ArrayList();
                        hashMap.put(optString, list2);
                    }
                    if (optJSONArray3 != null && optJSONArray3.length() > 0) {
                        for (int i3 = 0; i3 < optJSONArray3.length(); i3++) {
                            list2.add(InetAddress.getByName(optJSONArray3.getString(i3)));
                        }
                    }
                    if (optJSONArray2 != null && optJSONArray2.length() > 0) {
                        for (int i4 = 0; i4 < optJSONArray2.length(); i4++) {
                            list2.add(InetAddress.getByName(optJSONArray2.getString(i4)));
                        }
                    }
                } catch (JSONException e5) {
                    e5.printStackTrace();
                }
            }
        }
        return hashMap;
    }

    public a(String str, String str2, String str3, int i2) {
        this(str, str2);
        this.f17657e = str3;
        this.f17658f = i2;
    }
}