opt host lower case

This commit is contained in:
tongchenfei
2021-01-06 20:56:51 +08:00
parent 01133958a6
commit f74432453a
2 changed files with 9 additions and 7 deletions

View File

@@ -32,7 +32,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
implementation 'com.mogo.httpdns:httpdns-helper:1.0.16'
implementation 'com.mogo.httpdns:httpdns-helper:1.0.17'
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.httpdnsbase

View File

@@ -50,7 +50,7 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListe
@Override
public void getHttpDnsIp(String host, int type, boolean useCache, IHttpDnsCallback callback) {
Logger.d("MogoHttpDns", "getHttpDnsIp host: " + host + " type: " + type);
Map<String,String> map = httpDnsHelper.getAllAddress();
Map<String, String> map = httpDnsHelper.getAllAddress();
if (useCache) {
String address = httpDnsHelper.getHttpDnsCachedAddress(type, host);
if (address != null) {
@@ -67,7 +67,7 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListe
@Override
public void addHttpDnsTtlCallback(String host, int type, IHttpDnsTtlCallback callback) {
Logger.d("MogoHttpDns","addHttpDnsTtlCallback: host: "+host+" type: "+type);
Logger.d("MogoHttpDns", "addHttpDnsTtlCallback: host: " + host + " type: " + type);
if (ttlCallbackMap.get(type + "-" + host) == null) {
ttlCallbackMap.put(type + "-" + host, new ArrayList<IHttpDnsTtlCallback>());
}
@@ -93,7 +93,7 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListe
public HttpDnsSimpleLocation getCurrentLocation() {
HttpSimpleLocation simpleLocation = locationChanged.getLocation();
if (simpleLocation != null) {
return new HttpDnsSimpleLocation("0734", simpleLocation.getLat(), simpleLocation.getLon());
return new HttpDnsSimpleLocation(simpleLocation.getCityCode(), simpleLocation.getLat(), simpleLocation.getLon());
}
return null;
}
@@ -104,9 +104,11 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListe
@Override
public List<InetAddress> lookup(String hostname) throws UnknownHostException {
String cacheIp = httpDnsHelper.getHttpDnsCachedAddress(HTTP_DNS_ADDRESS_TYPE_HTTP, hostname);
Logger.d("MogoHttpDnsLook", "lookup host: " + hostname + " cacheIp: " + cacheIp);
if (cacheIp == null || TextUtils.isEmpty(cacheIp)) {
cacheIp = httpDnsHelper.getHttpDnsAddress(HttpDnsHelper.HTTP_DNS_TYPE_HTTP, hostname);
if(!TextUtils.isEmpty(cacheIp)){
Logger.d("MogoHttpDnsLook", "==== lookup host: " + hostname + " cacheIp: " + cacheIp);
if (!TextUtils.isEmpty(cacheIp)) {
String[] info = cacheIp.split(":");
if (info.length > 1) {
return Arrays.asList(InetAddress.getAllByName(info[0]));
@@ -130,10 +132,10 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListe
for (String key : map.keySet()) {
if (ttlCallbackMap.get(key) != null) {
Logger.d("MogoHttpDns", "onAddressChanged key: " + key);
for(IHttpDnsTtlCallback callback : ttlCallbackMap.get(key)){
for (IHttpDnsTtlCallback callback : ttlCallbackMap.get(key)) {
callback.onTtl();
}
}else{
} else {
Logger.d("MogoHttpDns", "callback is null: " + key);
}
}