修改httpdns解析实现,目前以域名转域名方式访问

This commit is contained in:
tongchenfei
2021-01-18 18:25:02 +08:00
parent 568ae741ee
commit b4c6fb2b84
6 changed files with 52 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ import com.mogo.commons.network.Constants;
import com.mogo.commons.network.ParamsUtil;
import com.mogo.commons.network.X509TrustManagerImpl;
import com.mogo.commons.storage.SpStorage;
import com.mogo.httpdns.HttpDnsConst;
import com.mogo.httpdns.IMogoHttpDns;
import com.mogo.httpdns.MogoHttpDnsHandler;
import com.mogo.utils.ThreadPoolService;
@@ -178,7 +179,16 @@ public abstract class AbsMogoApplication extends Application {
.build();
return chain.proceed( request );
} )
.setHttpDns( dns.dns() )
// 增加域名->域名的转换方式暂时去掉httpdns方式
.addInterceptor(chain -> {
Request request = chain.request();
String path = request.url().encodedPath();
String host = "http://" + dns.syncGetHttpDns(request.url().host().replace("http://", "").replace("https://", ""), HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP, true);
String url = host + path;
Logger.d("DomainExchange", "oriHost: " + request.url().host() + " newHost: " + host+" \r\n newUrl: "+url);
return chain.proceed(request.newBuilder().url(url).build());
})
.setHttpDns( null )
.setLoggable( DebugConfig.isDebug() );
}
}