online渠道替换成mogoHttpDns,其他渠道使用httpDnsNoop,暂时不用tencentHttpDns

This commit is contained in:
tongchenfei
2020-12-25 16:38:23 +08:00
parent a3faf2bdd7
commit f05cb42fe5
6 changed files with 26 additions and 50 deletions

1
.idea/gradle.xml generated
View File

@@ -85,6 +85,7 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

View File

@@ -2,28 +2,12 @@
project.dependencies {
if (Boolean.valueOf(RELEASE)) {
bydautoImplementation rootProject.ext.dependencies.httpdnsnoop
d82xImplementation rootProject.ext.dependencies.httpdnsnoop
em1Implementation rootProject.ext.dependencies.httpdnsnoop
d8xxImplementation rootProject.ext.dependencies.httpdnsnoop
d80xImplementation rootProject.ext.dependencies.httpdnsnoop
em4Implementation rootProject.ext.dependencies.httpdnsnoop
e8xxImplementation rootProject.ext.dependencies.httpdnstencent
f8xxImplementation rootProject.ext.dependencies.httpdnstencent
f80xImplementation rootProject.ext.dependencies.httpdnstencent
f8AmapImplementation rootProject.ext.dependencies.httpdnstencent
em3Implementation rootProject.ext.dependencies.httpdnsnoop
qaImplementation rootProject.ext.dependencies.httpdnsnoop
demoImplementation rootProject.ext.dependencies.httpdnsnoop
onlineImplementation rootProject.ext.dependencies.httpdnsmogo
} else {
bydautoImplementation project(':foudations:httpdns-noop')
d82xImplementation project(':foudations:httpdns-noop')
em1Implementation project(':foudations:httpdns-noop')
d8xxImplementation project(':foudations:httpdns-noop')
d80xImplementation project(':foudations:httpdns-noop')
em4Implementation project(':foudations:httpdns-noop')
e8xxImplementation project(':foudations:httpdns-tencent')
f8xxImplementation project(':foudations:httpdns-tencent')
f80xImplementation project(':foudations:httpdns-tencent')
f8AmapImplementation project(':foudations:httpdns-tencent')
em3Implementation project(':foudations:httpdns-noop')
qaImplementation project(':foudations:httpdns-noop')
demoImplementation project(':foudations:httpdns-noop')
onlineImplementation project(':foudations:httpdns-mogo')
}
}

View File

@@ -223,6 +223,7 @@ ext {
httpdnsbase : "com.mogo.httpdns:httpdns-base:${HTTPDNS_BASE_VERSION}",
httpdnsnoop : "com.mogo.httpdns:httpdns-noop:${HTTPDNS_NOOP_VERSION}",
httpdnstencent : "com.mogo.httpdns:httpdns-tencent:${HTTPDNS_TENCENT_VERSION}",
httpdnsmogo : "com.mogo.httpdns:httpdns-mogo:${HTTPDNS_MOGO_VERSION}",
]
}

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.3'
implementation 'com.mogo.httpdns:httpdns-helper:1.0.6'
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.httpdnsbase

View File

@@ -14,14 +14,12 @@ import com.mogo.httpdns.IHttpDnsTtlCallback;
import com.mogo.httpdns.IMogoHttpDns;
import com.mogo.httpdnshelper.sdk.HttpDnsHelper;
import com.mogo.httpdnshelper.sdk.bean.HttpDnsSimpleLocation;
import com.mogo.httpdnshelper.sdk.listener.IHttpDnsConfig;
import com.mogo.httpdnshelper.sdk.listener.IHttpDnsCurrentLocation;
import com.mogo.httpdnshelper.sdk.listener.OnAddressChangedListener;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.utils.network.HttpDns;
import org.jetbrains.annotations.NotNull;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
@@ -31,9 +29,10 @@ import java.util.Map;
import static com.mogo.httpdns.HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP;
@Route( path = HttpDnsConst.PATH )
public class MogoHttpDns implements IMogoHttpDns, HttpDns,OnAddressChangedListener{
private final HttpDnsHelper httpDnsHelper = new HttpDnsHelper();
@Route(path = HttpDnsConst.PATH)
public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListener {
private HttpDnsHelper httpDnsHelper;
@Nullable
@Override
public HttpDns dns() {
@@ -47,19 +46,20 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns,OnAddressChangedListen
@Override
public void getHttpDnsIp(String host, int type, boolean useCache, IHttpDnsCallback callback) {
if(useCache) {
if (useCache) {
String address = httpDnsHelper.getHttpDnsCachedAddress(type, host);
if (address != null) {
callback.onParsed(address);
}else{
} else {
callback.onParsed(httpDnsHelper.getHttpDnsAddress(type, host));
}
}else {
} else {
callback.onParsed(httpDnsHelper.getHttpDnsAddress(type, host));
}
}
private final Map<String, IHttpDnsTtlCallback> ttlCallbackMap = new ArrayMap<>();
@Override
public void addHttpDnsTtlCallback(String host, int type, IHttpDnsTtlCallback callback) {
ttlCallbackMap.put(type + "-" + host, callback);
@@ -73,41 +73,30 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns,OnAddressChangedListen
@Override
public void init(final Context context) {
httpDnsHelper.init(context, new IHttpDnsConfig() {
@NotNull
httpDnsHelper = new HttpDnsHelper.Builder().setContext(context).setSn(Utils.getSn()).setShowDebugLog(true).setLoopCheckDelay(15 * 60 * 1000).setCurrentLocation(new IHttpDnsCurrentLocation() {
@org.jetbrains.annotations.Nullable
@Override
public HttpDnsSimpleLocation getCurrentLocation() {
MogoLocation last = MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient(context).getLastKnowLocation();
if(last!=null){
if (last != null) {
return new HttpDnsSimpleLocation(last.getCityCode(), last.getLatitude(), last.getLongitude());
}
return null;
}
@Override
public boolean showDebugLog() {
return true;
}
@NotNull
@Override
public String getSn() {
return Utils.getSn();
}
});
}).build();
httpDnsHelper.setAddressChangedListener(this);
}
@Override
public List<InetAddress> lookup(String hostname) throws UnknownHostException {
String cacheIp = httpDnsHelper.getHttpDnsCachedAddress(HTTP_DNS_ADDRESS_TYPE_HTTP, hostname);
if ( cacheIp == null || TextUtils.isEmpty( cacheIp ) ) {
if (cacheIp == null || TextUtils.isEmpty(cacheIp)) {
return Collections.emptyList();
}
String[] info = cacheIp.split(":");
if (info.length > 1) {
return Arrays.asList( InetAddress.getAllByName( info[0]) );
}else {
return Arrays.asList(InetAddress.getAllByName(info[0]));
} else {
return Arrays.asList(InetAddress.getAllByName(cacheIp));
}
}

View File

@@ -133,6 +133,7 @@ MOGO_MODULES_MVISION_VERSION=2.0.12
MOGO_MODULES_SMALL_MAP=1.0.0
# httpdns
HTTPDNS_TENCENT_VERSION = 2.0.12
HTTPDNS_MOGO_VERSION=2.0.12
HTTPDNS_BASE_VERSION = 2.0.12
HTTPDNS_NOOP_VERSION = 2.0.12