文档中心 API文档 查询时间戳防盗链

查询时间戳防盗链

更新时间:2022-12-02 10:47:24

适用产品

网页加速、下载分发、动态加速、全站加速、点播分发、直播分发、上传加速、移动加速、上网加速、S-P2P、PCDN、应用性能管理、WEB应用防火墙、BotGuard爬虫管理、WSS、DMS、DDoS云清洗、IPv6一体化解决方案、电商安全加速解决方案、金融安全加速解决方案、政企安全加速解决方案、应用安全解决方案、区块链安全加速解决方案、IPv6安全加速解决方案

接口描述

查看时间戳防盗链

推荐使用 Open API在线调试

Open API在线调试功能提供可视化界面在线调试API、支持生成代码示例、快速检索查看API文档等能力。前往调试

请求参数

Path 参数

参数名称类型必填描述
domain-name
String域名名称或域名id,在请求的url后面

返回参数

Body 参数

参数名称类型描述
http status code
Integerhttpstatus=202;   表示成功调用新增域名接口,可使用header中的x-cnc-request-id查看当前新增域名的部署情况
x-cnc-request-id
String唯一标示的id,用于查询每次请求的任务 (适用全部接口)
domain-id
String加速域名ID
domain-name
String加速域名的名称
timestamp-visit-control-rule
QuerytimecontrolServiceResponseTimestampVisitControlRule时间戳防盗链设置 注意: 1、时间戳防盗链分为两部分,一部分是防盗链校验,一部分是时间有效性校验。二者都有效,则防盗链通过,否则不通过。 2、防盗链校验:加密算法为md5sum,按照参与MD5计算的参数及组合顺序进行防盗链加密串的计算,对匹配目录下所有文件的url进行防盗链校验,未匹配到的url,则拒绝访问。 3、时间有效性检验:按照年月日时分秒换算的当前时间,与请求url中所带的名文时间相减,判断是否超过设置的上下限(即前后60s内),时间差小于设置上下限的,系统才会给予正常的响应,否则拒绝请求,返回403 4、日志记录没有带加密串的url 6、需要清空时间戳防盗链规则时,可以只传入节点
path-pattern
String同缓存规则设置中的“path-pattern”,用于URL匹配。对于匹配到的URL进行时间戳防盗链验证;未匹配到的URL,则拒绝。 同缓存规则设置中的“path-pattern”,用于URL匹配。对于匹配到的URL进行时间戳防盗链验证;未匹配到的URL,则拒绝。
protocol-of-path-pattern
String{"en":"Optional values are: http, https, http;https, noprefix, empty. If it is empty, it defaults to "http;https"; if it is noprefix, it means that the protocol prefix of url is not specified, and it only matches according to the regularity of path-pattern. This configuration item only matches with path-pattern. example: 1. Specify protocol-of-path-pattern=https and path-pattern=.* to match all https requests, but not http requests. 2. Specify protocol-of-path-pattern=http;https, path-pattern=.* to match all http and https requests. 3. Specify protocol-of-path-pattern=noprefix and path-pattern=^http://[^/]+/.* to match all http requests but not https requests.", "zh_CN":"可选值为: http、https、http;https、noprefix、空。为空默认为“http;https”;为noprefix表示不指定url的协议前缀,仅按path-pattern的正则匹配。本配置项只与path-pattern(url匹配模式)结合匹配。 例子: 1、指定protocol-of-path-pattern=https,path-pattern=.*,则匹配所有https的请求,不匹配http的请求。 2、指定protocol-of-path-pattern=http;https,path-pattern=.*,则匹配所有http和https的请求。 3、指定protocol-of-path-pattern=noprefix,path-pattern=^http://[^/]+/.*,则匹配所有http的请求,不匹配https的请求。"}
directory
String目录,多个以英文分号隔开。对于匹配到的目录进行时间戳防盗链验证;未匹配到的则拒绝。和path-pattern互斥。
ignore-uri-slash
String防盗链中的$uri是否去掉/,可选值为true、false,默认为false,即包含/。 例如: http://www.test.com/1.flv,则$uri默认为/1.flv,若ignore-uri-slash为true,则$uri为1.flv
ignore-key-and-time-position
String{"en":"Whether key and time are allowed to be interchanged, the optional values are true and false, true is allowed, false is not allowed. By default, the order of key parameters and time parameters must strictly follow the order required by the authentication mode, that is, the default key and time cannot be interchanged. If "true" is selected, the key and time positions can be interchanged and the authentication succeeds.", "zh_CN":"key与time是否允许互换,可选值为true和false,true则允许,false则不允许。默认情况下,密钥参数和时间参数的顺序,必须严格参照鉴权模式要求的顺序,即,默认key和time不能互换位置。如选择“true”,key和time位置可以互换并鉴权成功。"}
except-path-pattern
String例外的url匹配模式,某些URL除外:如abc.jpg,不做防盗链 例外的url匹配模式,某些URL除外:如abc.jpg,不做防盗链
allowed-ips
String例外的IP,支持输入IP或IP段,IP段之间用分号(;)隔开,如1.1.1.0/24;2.2.2.2,某些IP例外,不做防盗链
encrypt-method
String加密算法 当前支持入参:md5sum
multiple-secret-keys
String防盗链加密串,支持多个加密串,多个加密串以分号(;)隔开 示例:abcdef;uvwxyz 注意: 1、支持对url 防盗链设置多个密钥。支持客户任意修改密钥,并做到无缝切换。防盗链等级更高。 2、请求url的key只要跟其中任意一个加密串算出来的key一致就验证通过
time-format
String防盗链加密串时间格式,可多选,以分号(;)分隔 年|月|日|时|分|秒|UNIX时间戳|16进制时间戳:1Y;2m;3d;4H;5M;6S;7s;8x 示例:1Y;2m;3d;4H;5M;6S;7s;8x1Y;2m;3d;4H;5M;7s 注意: 1、必须是英文字母和数字 2、每个值只能出现1次
dst-style
String防盗链回源方式,可选值:1(使用未加密url回源)、2(使用客户请求带加密串url回源) 示例:1 注意: 1、如果URL格式是:http://www.xxx.com/md5/time/uri?参数,则需要下工单给对应客服,让客服在父配置去掉时间戳格式再缓存。
log-format
String 日志记录原始url,可选值:true(日志记录原始url)、false(不开启日志记录原始url)
m3u8
String该配置项用于通过匹配的才进行m3u8改写,可选值:false(不进行m3u8改写)、true(进行m3u8改写) 示例:true
url-key
String用于配置获取url中的key的名称 示例: auth_key
timestamp-control-rules
List时间戳防盗链多条匹配模式 注意:多条配置项如下: 1、url匹配模式的协议: 2、url匹配模式 3、例外url匹配模式的协议 4、例外url匹配模式 5、防盗链生成方式 6、请求url格式 7、通用防盗链取uri对应第几个“/” 8、清空多条配置只传入节点:
data-id
Long添加grid类型标识,表示客户多组配置时,具体某组配置 注意:添加grid类型标识:data-id,每一组配置对应一个data-id:a、如果客户有传data-id,说明指定修改其中一组配置项内容,不需求修改其他组配置内容不需要入参;b、如果客户入参多组配置,其中有些组配置有传data-id,有些没有传,则有传data-id的表示修改具体某组配置,没有传data-id的表示在原来基础上新增一组配置;c、如果客户入参都没有传data-id,表示用本次的配置全量覆盖原先配置;d、如果客户入参没有传任何配置项参数,只传了域名和二级标签,表示清空这个接口对应域名二级服务所有配置。(c、d内容和当前方案实现一致);e、一个gird标签下的入参不能为空,如果,没有具体的配置项,则data-id必填,且值为实际存在的data-id,表示清空这个data-id对应配置项的值;
path-pattern
String
except-path-pattern
String
path-pattern-protocol
String协议,可选值:http|https|http;https|noprefix http:http协议 https:http协议 http;https:http和https协议 noprefix:不加前缀,按path-pattern设置的规则 用法示例: path-pattern:输入.*\jpg$ path-pattern-protocol:选择http,则表示^http://[^/]+/.*\jpg$ ; 选择https,则表示 ^https://[^/]+/ .*\jpg$; 选择http;https,则表示^https?://[^/]+/.*\jpg$; 选择noprefix,则表示.*\jpg$ 注意: 1、为空时,则默认“http和https协议” 2、只与url匹配模式匹配(path-pattern) 3、协议必须跟模式一起,但是模式可以单独存在
except-path-pattern-protocol
String协议,可选值:http|https|http;https|noprefix http:http协议 https:http协议 http;https:http和https协议 noprefix:不加前缀 用法示例: except-path-pattern:输入.*\jpg$ except-path-pattern-protocol:选择http,则表示^http://[^/]+/.*\jpg$ ; 选择https,则表示 ^https://[^/]+/ .*\jpg$; 选择http;https,则表示^https?://[^/]+/.*\jpg$; 选择noprefix,则表示.*\jpg$ 注意: 1、为空时,则默认“http和https协议” 2、只与例外url匹配模式匹配(except-path-pattern) 3、协议必须跟模式一起,但是模式可以单独存在
cipher-combination
String防盗链生成方式,参与MD5计算的参数及组合顺序,仅支持传入以下参数: $uri:介于domain和问号之间的字符串,特殊取值在入参中配置 例如http://cdn.example.com/v0/test.dat?k=v,则URI为/v0/test.dat $ourkey:秘钥,实际秘钥在入参中配置 $time:时间串 $spec_name:文件名 例如:http://cdn.example.com/v0/test.dat?k=v,文件名为 test.dat $args:QUERY_STRING中的某个具体key的值 示例:$uri$ourkey$time$args{k} 注意: 1、$args{k}中的K只允许A-Z大小写字母、数字、下划线、横杠 2、除了$args外,其它参数只允许出现1次 3、可以按照任意组合顺序,拼接各个参数
secret-key
String防盗链加密串的秘钥,只允许传入一个秘钥 示例:abcdef 注意: 1、与客户约定好的秘钥,入参中的某个值可以等于对应的值 2、$ourkey值主要是来自的配置
cipher-param
String防盗链串的参数名称 示例:keyname 注意: 1、如果防盗链加密串是在url问号后的参数中,则防盗链加密串的参数名由的配置决定; 2、如果为空,则默认请求的url中使用key作为参数名
time-param
String时间串的参数名称 示例:tname 注意: 1、如果防盗链时间串是放在url问号后面的参数中,则防盗链时间串的参数名由的配置决定; 2、如果为空,则默认请求的url中使用time作为参数名
lower-limit-expiry-time
String防盗链串的过期时间下限 示例: 200 对应各种场景的配置方式如下: 注意: 1、请求URL中携带的时间戳如果是URL的生成时间,需要加上有效时长才是过期时间,即配置为有效时长。 2、如果URL携带的时间戳是过期时间,则可以配成零。
upper-limit-expiry-time
String防盗链串的过期时间上限 示例: 5000 对应各种场景的配置方式如下: 注意: 1、请求URL中携带的时间戳如果是URL的生成时间,需要加上有效时长才是过期时间,即配置为有效时长。 2、如果URL携带的时间戳是过期时间,则可以配成零。
request-url-style
String防盗链请求url格式,支持两种防盗链方式,即加密串和时间戳放到“?”后面或者是加密串和时间戳放到“host”后面,url格式支持的参数如下: $domain:域名 $uri:不包含域名的url部分 $key:防盗链加密串的MD5值 $time:防盗链时间串 $args:问号后的QUERY_STRING参数 示例:支持以下请求url格式,可替换为https://,url请求协议根据实际使用,如不知道如何正确配置,请找客户技术支持协助;携带加密串和时间串两个值的参数名“keyname”和“tname”,可替换为实际使用的参数名 http://$domain/$key/$time/$uri?$args http://$domain/$time/$key/$uri?$args http://$domain/$uri?auth_key=$key http://$domain/$uri?keyname=$key&tname=$time http://$domain/$uri?$args&keyname=$key&tname=$time http://$domain/$uri?keyname=$key&tname=$time&$args http://$domain/$uri?$args&keyname=$key&tname=$time&$args http://$domain/$uri?tname=$time&keyname=$key http://$domain/$uri?$args&tname=$time&keyname=$key http://$domain/$uri?tname=$time&keyname=$key&$args http://$domain/$uri?$args&tname=$time&keyname=$key&$args 注意: 1、输入的url必须以“http/https”开头 2、如果加密串和时间戳是放到“?”后面时,keyname和tname必须跟配置的值一致 3、如果没有配置值,则$key对应的参数名默认为key,$time对应的参数名默认为time 4、如果防盗链加密串和时间串在url问号后面的参数中,url中的“keyname”和“tname”,对应的是cipher-param和 time-param配置的防盗链串和时间串参数名称。
uri-select
String通用防盗链取uri对应第几个“/”,值为数字,多个值,以分号隔开。 配置通用防盗链取uri对应第几个“/”,从配置为0则为正向第一个,-1为逆向第一个,可分频道配置,默认空值。 比如http://a.com/b/c/d/e/f/1.html 那么0;3; 4;-1 就是取/b/e/f/1.html 注意: 1、取值范围:[-100,+100] 2、重复配置生效规则(建议不要配重复) 重复的将会跳过解析: 如http://cdn.example.com/e/0/e2/test.dat?k=v 可以配 2;2;3;3,但只取2;3 URI则为/e2/test.dat;

错误码

错误代码(code)描述(message)HTTP状态码语义
InternalErrorWe encountered an internal error. Please try again.500内部错误
InvalidParameterNo domain was specified.400uri中没有指定域名或者域名ID
NoSuchDomainThe specified domain does not exist.404指定的域名不存在
NoSuchServiceTagThe specified service tag dose not exist, tag:{}.400当前服务不支持查询

示例

JSON
XML
JSON
请求示例
复制代码 复制成功
#!/bin/bash
username="example_username"
apiKey="example_apiKey"
date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S GMT"`
password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey -binary | openssl enc -base64`
curl -i --url "https://open.chinanetcenter.com/api/config/timecontrol/a.example.com" \
-X "GET" \
-u "$username:$password" \
-H "Date: $date" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
返回示例
复制代码 复制成功
HTTP/1.1 202 Accepted
Date: Fri, 17 May 2017 06:33:26 GMT
Content-Type: application/xml;charset=utf-8
x-cnc-request-id:c54cbbb4-19fe-407a-930c-3988b62ed2fd
{
    "domain-id":"3791876",
    "domain-name":"www.livestream.1558074757857625.com",
    "timestamp-visit-control-rule":{
        "path-pattern":"/20/*",
        "except-path-pattern":"jhkh sdas",
        "allowed-ips":"1.1.1.0/24;2.2.2.2",
        "multiple-secret-keys":"key1;key2",
        "time-format":"1Y;2m;3d;4H;5M;6S;7s;8x",
        "dst-style":"1",
        "encrypt-method":"md5sum",
        "log-format":"true",
        "m3u8":"true",
        "url-key":"auth_key",
        "timestamp-control-rules":[
            {
                "data-id":31462855,
                "path-pattern":"/*.jpg",
                "except-path-pattern":"/*.png",
                "cipher-combination":"$uri$ourkey$time$args{param1}",
                "secret-key":"abcdef",
                "cipher-param":"keyname",
                "time-param":"tname",
                "lower-limit-expiry-time":"200",
                "upper-limit-expiry-time":"5000",
                "request-url-style":"http://$domain/$uri?$args&keyname=$key&tname=$time",
                "uri-select":"1;-1"
            }
        ]
    }
}
本篇文档内容对您是否有帮助?
有帮助
我要反馈
提交成功!非常感谢您的反馈,我们会继续努力做到更好!