访问配置接口
更新时间:2023-05-16
设置访问Referer控制
public void setDomainRefererACL(CdnClient client) {
String domain = "my.test.com";
RefererACL acl = new RefererACL()
.addBlackList("http://a.com")
.addBlackList("http://b.com")
.withAllowEmpty(true);
SetDomainRefererACLRequest request = new SetDomainRefererACLRequest()
.withDomain(domain)
.withRefererACL(acl);
client.setDomainRefererACL(request);
}
查询访问Referer控制
public void getDomainRefererACL(CdnClient client) {
String domain = "my.test.com";
GetDomainRefererACLResponse response = client.getDomainRefererACL(domain);
}
设置访问IP控制
public void setDomainIpACL(CdnClient client) {
String domain = "my.test.com";
IpACL acl = new IpACL().addBlackList("1.2.3.4").addBlackList("5.6.7.0/24");
SetDomainIpACLRequest request = new SetDomainIpACLRequest()
.withDomain(domain)
.withIpACL(acl);
client.setDomainIpACL(request);
}
查询访问IP控制
public void getDomainIpACL(CdnClient client){
String domain = "my.test.com";
GetDomainIpACLResponse response = client.getDomainIpACL(domain);
}
设置Cors跨域
public void setCorsConfig(CdnClient client){
String domain = "my.test.com";
Cors cors = new Cors().withAllow("on")
.addOriginList("http://www.baidu.com").addOriginList("http://*.bce.com");
client.setDomainCors(new SetDomainCorsRequest().withDomain(domain).withCors(cors));
}
查询Cors跨域
public void getCorsConfig(CdnClient client){
String domain = "my.test.com";
GetDomainCorsResponse response = client.getDomainCors(domain);
}
设置域名限速
public void setDomainTrafficLimit(CdnClient client) {
String domain = "my.test.com";
TrafficLimit trafficLimit = new TrafficLimit().withEnable(true)
.withLimitRate(10485760).withLimitStartHour(10).withLimitEndHour(19).withLimitRateAfter(0)
.withTrafficLimitArg("rate").withTrafficLimitUnit("m");
SetDomainTrafficLimitRequest request = new SetDomainTrafficLimitRequest().withDomain(domain)
.withTrafficLimit(trafficLimit);
client.setDomainTrafficLimit(request);
}
查询域名限速
public void getDomainTrafficLimit(CdnClient client) {
String domain = "my.test.com";
GetDomainTrafficLimitResponse resp = client.getDomainTrafficLimit(domain);
}
设置访问鉴权
public void setDomainRequestAuth(CdnClient client) {
String domain = "my.test.com";
RequestAuth requestAuth = new RequestAuth().withType("a").withKey1("secretkey1");
SetRequestAuthRequest request = new SetRequestAuthRequest()
.withDomain(domain)
.withRequestAuth(requestAuth);
client.setDomainRequestAuth(request);
}
设置IP访问限频
public void setAccessLimit(CdnClient client){
String domain = "my.test.com";
AccessLimit accessLimit = new AccessLimit().withLimit(200).withEnabled(true);
client.setDomainAccessLimit(new SetDomainAccessLimitRequest()
.withDomain(domain).withAccessLimit(accessLimit));
}
查询IP访问限频
public void getAccessLimit(CdnClient client){
String domain = "my.test.com";
GetDomainAccessLimitResponse response = client.getDomainAccessLimit(domain);
}
设置访问ua控制
public void setDomainUaAcl(CdnClient client){
String domain = "my.test.com";
UaAcl uaAcl = new UaAcl().addBlackList("MQQBrowser/5.3/Mozilla/5.0")
.addBlackList("Mozilla/5.0 (Linux; Android 7.0");
client.setDomainUaAcl(new SetDomainUaAclRequest().withDomain(domain)
.withUaAcl(uaAcl));
}
查询访问ua控制
public void getDomainUaAcl(CdnClient client){
String domain = "my.test.com";
GetDomainUaAclResponse response = client.getDomainUaAcl(domain);
}