@@ -33,6 +33,7 @@ public class DnsPrefetcher {
3333
3434 public static DnsPrefetcher dnsPrefetcher = null ;
3535 private static String token ;
36+ private static Configuration config ;
3637
3738 private static ConcurrentHashMap <String , List <InetAddress >> mConcurrentHashMap = new ConcurrentHashMap <String , List <InetAddress >>();
3839 private static List <String > mHosts = new ArrayList <String >();
@@ -74,8 +75,9 @@ public void localFetch() {
7475 }
7576
7677
77- public DnsPrefetcher init (String token ) throws UnknownHostException {
78+ public DnsPrefetcher init (String token , Configuration config ) throws UnknownHostException {
7879 this .token = token ;
80+ this .config = config ;
7981 List <String > preHosts = preHosts ();
8082 if (preHosts != null && preHosts .size () > 0 )
8183 preFetch (preHosts );
@@ -242,7 +244,11 @@ ZoneInfo preQueryIndex(DnsPrefetcher.ZoneIndex index) {
242244
243245 ResponseInfo getZoneJsonSync (DnsPrefetcher .ZoneIndex index ) {
244246 Client client = new Client ();
245- String address = "http://" + Config .preQueryHost + "/v2/query?ak=" + index .accessKey + "&bucket=" + index .bucket ;
247+ String schema = "https://" ;
248+ if (!config .useHttps ) {
249+ schema = "http://" ;
250+ }
251+ String address = schema + Config .preQueryHost + "/v2/query?ak=" + index .accessKey + "&bucket=" + index .bucket ;
246252 return client .syncGet (address , null );
247253 }
248254
@@ -366,7 +372,7 @@ public static void startPrefetchDns(String token, Configuration config) {
366372 DnsPrefetcher dnsPrefetcher = null ;
367373 try {
368374 recorder = new DnsCacheFile (Config .dnscacheDir );
369- dnsPrefetcher = DnsPrefetcher .getDnsPrefetcher ().init (token );
375+ dnsPrefetcher = DnsPrefetcher .getDnsPrefetcher ().init (token , config );
370376 //确认预取结束后,需要更新缓存mDnsCacheKey
371377 mDnsCacheKey = dnsCacheKey ;
372378 } catch (IOException e ) {
0 commit comments