QuerytimecontrolService

Update time: 2026-08-25 10:26:07

Applicable Products

Content Acceleration,Dynamic Web Acceleration

API Description

Query Time anti-theft chain custom configuration item content

Call frequency

Single user trigger frequency: 300/5min

Request parameter(s)

Path Params

NameDescription
*domainString
Domain ID or domain Name.

Response parameter(s)

Response Header

NameDescription
x-cnc-request-idString
Uniquely identified id for querying tasks per request (for all API)

Body Params

NameDescription
domain-idString
Accelerated domain name ID
domain-nameString
Name of accelerated domain name
timestamp-visit-control-ruleObject
Timestamp-based Hotlink Protection Configuration Important Notes: 1. Composition & Workflow: The protection consists of two sequential validations: Hotlink Validation Time Validity Check Access is granted only if both checks pass. Otherwise, the request is denied. 2. Hotlink Validation: Algorithm: md5sum Process: A secure hash is calculated using the specified parameters and their combination sequence. Scope: Applies to all URLs under the matched directory(s). Failure Action: Requests to unmatched URLs or with failed validation are denied. 3. Time Validity Check: Process: The system calculates the difference between the current time (converted to YYYYMMDDHHMMSS format) and the plain-text timestamp in the request URL. Tolerance Window: The request is allowed only if the time difference falls within the configured limit (default is ±60 seconds). Failure Action: Requests outside the tolerance window are rejected with a 403 error. 4. Logging: URLs that lack the encrypted authentication string will be logged. 5.Clearing Rules: To clear all timestamp hotlink protection rules, submit the empty node:
path-patternString
The url matching mode supports fuzzy regularization. If all matches, the input parameters can be configured as: *.Verify the time stamp of the matched URL for anti-leeching; reject URLs that are not matched.
protocol-of-path-patternString
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.
directoryString
Directory, multiple separated by English semicolons. Perform timestamp anti-leech verification for the matched directory; reject the unmatched directory. mutually exclusive with path-pattern.
ignore-uri-slashString
Whether to remove / from $uri in anti-leech, the optional values are true or false, and the default is false, that is, it contains /. For example: http://www.test.com/1.flv, then $uri is /1.flv by default, if ignore-uri-slash is true, then $uri is 1.flv
ignore-key-and-time-positionString
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.
except-path-patternString
Exceptional url matching mode, except for some URLs: such as abc.jpg, do not do anti-theft chain function
allowed-ipsString
Exceptional IP, supports input of IP or IP range, separate IP ranges with semicolons (;), such as 1.1.1.0/24;2.2.2.2, some IP exceptions, no anti-leeching.
encrypt-methodString
Encryption Algorithm. Support value: md5sum
multiple-secret-keysString
Anti-leech encrypted string, multiple encrypted strings are supported, and multiple encrypted strings are separated by semicolons (;) Example: abcdef;uvwxyz Notice: 1. Support setting multiple keys for url anti-leech. Support customers to modify the key at will, and achieve seamless switching. The anti-theft chain level is higher. 2. As long as the key of the requested url is consistent with the key calculated from any of the encrypted strings, the verification will pass
time-formatString
The time format of the anti-leech encryption string, Year|Month|Day|Hour|Minute|Second:1Y;2m;3d;4H;5M;6S UNIX timestamp:7s Millisecond-level UNIX timestamp:7s;9ms Hexadecimal timestamp:8x Notice: The format is fixed; numbers and letters must not be changed, and each value can only appear once.
dst-styleString
Anti-leech back-to-source method, optional values: 1 (use unencrypted url to go back to the source), 2 (use the customer request to return to the source with encrypted string url) Example: 1 Notice: 1. If the URL format is: http://www.xxx.com/md5/time/uri? parameter, please contact your technical support.
log-formatString
Logging original url, optional values: true (logging original url), false (do not enable logging original url)
m3u8String
Used to configure m3u8 Example: true
url-keyString
Used to configure the name of the key in the url Example: auth_key
timestamp-control-rulesList
Timestamp-based hotlink protection - Multiple match patterns Note: The configuration items for multiple rules are as follows: 1. Protocol for URL matching pattern 2. URL matching pattern 3. Protocol for exception URL matching pattern 4. Exception URL matching pattern 5. Hotlink protection generation method 6. Request URL format 7. For generic hotlink protection: which occurrence of "/" in the URI to use 8. To clear all configurations: pass only the node
data-idLong
dataId is to indicate a specific group configuration when the client has multiple groups of configurations.
path-patternString
The url matching mode supports fuzzy regularization. If all matches, the input parameters can be configured as: *.Verify the time stamp of the matched URL for anti-leeching; reject URLs that are not matched.
except-path-patternString
Exceptional url matching mode, except for some URLs: such as abc.jpg, do not do anti-theft chain function
path-pattern-protocolString
Protocol, optional values: http|https|http;https|noprefixhttp: http protocolhttps: http protocolhttp;https: http and https protocolsnoprefix: no prefix, according to the rules set by path-patternUsage example:path-pattern: input .*\jpg$path-pattern-protocol: select http, it means ^http://[^/]+/.*\jpg$;If https is selected, it means ^https://[^/]+/ .*\jpg$;Select http;https, it means ^https?://[^/]+/.*\jpg$;If noprefix is selected, it means .*\jpg$Notice:1. When it is empty, the default "http and https protocol"2. Only match the url matching pattern (path-pattern)3. The protocol must be with the mode, but the mode can exist alone
except-path-pattern-protocolString
Protocol, optional values: http|https|http;https|noprefixhttp: http protocolhttps: http protocolhttp;https: http and https protocolsnoprefix: no prefixUsage example:except-path-pattern: input .*\jpg$except-path-pattern-protocol: select http, it means ^http://[^/]+/.*\jpg$;If https is selected, it means ^https://[^/]+/ .*\jpg$;Select http;https, it means ^https?://[^/]+/.*\jpg$;If noprefix is selected, it means .*\jpg$Notice:1. When it is empty, the default "http and https protocol"2. Only match the exception url matching pattern (except-path-pattern)3. The protocol must be with the mode, but the mode can exist alone
cipher-combinationString
The anti-leech chain generation method, the parameters involved in the MD5 calculation and the combination sequence only support the following parameters:$uri: A string between domain and question mark, special values are configured in the input parameter For example http://cdn.example.com/v0/test.dat?k=v, the URI is /v0/test.dat$ourkey: secret key, the actual secret key is configured in the input parameter $time: time string$spec_name: file nameFor example: http://cdn.example.com/v0/test.dat?k=v, the file name is test.dat$args: the value of a specific key in QUERY_STRINGExample: $uri$ourkey$time$args{k}Notice:1. K in $args{k} only allows A-Z uppercase and lowercase letters, numbers, underscores, and bars2. Except for $args, other parameters are only allowed to appear once3. Each parameter can be spliced according to any combination order
secret-keyString
The key of the anti-leech encryption string, only one key is allowed to be passed inExample: abcdefNotice:1. For the secret key agreed with the customer, a value in can be equal to the corresponding value of 2. The value of $ourkey mainly comes from the configuration of a) If is not a value in multiple-secret-keys>, the value of $ourkey is b) is a value in multiple-secret-keys>, then the value of $ourkey is c) If is not passed or is empty, then the value of $ourkey is
cipher-paramString
Parameter name of the anti-leech stringExample: keynameNotice:1. If the anti-leech encryption string is in the parameter after the question mark in the url, the parameter name of the anti-leech encryption string is determined by the configuration of ;2. If is empty, the key is used as the parameter name in the URL of the default request
time-paramString
Parameter name for time stringExample: tnameNotice:1. If the anti-leech time string is placed in the parameter after the url question mark, the parameter name of the anti-leech time string is determined by the configuration of ;2. If is empty, time is used as the parameter name in the URL of the default request
lower-limit-expiry-timeString
The lower limit of the expiration time of the anti-leech chainExample:200The configuration methods corresponding to various scenarios are as follows:Notice:1. If the timestamp carried in the request URL is the generation time of the URL, the expiration time needs to be added with the effective duration, that is, and are configured as the effective duration .2. If the timestamp carried in the URL is the expiration time, it can be set to zero.
upper-limit-expiry-timeString
The upper limit of the expiration time of the anti-leech chainExample:5000The configuration methods corresponding to various scenarios are as follows:Notice:1. If the timestamp carried in the request URL is the generation time of the URL, the expiration time needs to be added with the effective duration, that is, and are configured as the effective duration .2. If the timestamp carried in the URL is the expiration time, it can be set to zero.
request-url-styleString
The anti-leech request url format supports two anti-leech methods, that is, the encrypted string and timestamp are placed after "?" or the encrypted string and timestamp are placed after "host". The parameters supported by the url format are as follows:$domain: domain name$uri: the url part that does not contain the domain name$key: MD5 value of anti-leech encrypted string$time: Anti-leech time string$args: the QUERY_STRING parameter after the question markExample: The following request url format is supported, which can be replaced with https://. The url request protocol is based on actual use. If you don't know how to configure it correctly, please ask customer technical support for assistance; the parameter name carrying two values of encrypted string and time string" keyname" and "tname", which can be replaced by the actual parameter names usedhttp://$domain/$key/$time/$uri?$argshttp://$domain/$time/$key/$uri?$args http://$domain/$uri?auth_key=$keyhttp://$domain/$uri?keyname=$key&tname=$timehttp://$domain/$uri?$args&keyname=$key&tname=$timehttp://$domain/$uri?keyname=$key&tname=$time&$argshttp://$domain/$uri?$args&keyname=$key&tname=$time&$argshttp://$domain/$uri?tname=$time&keyname=$keyhttp://$domain/$uri?$args&tname=$time&keyname=$keyhttp://$domain/$uri?tname=$time&keyname=$key&$argshttp://$domain/$uri?$args&tname=$time&keyname=$key&$argsNotice:1. The input url must start with "http/https"2. If the encrypted string and timestamp are placed after "?", the keyname and tname must be consistent with the configured values of and 3. If there is no configuration value for and , the parameter name corresponding to $key defaults to key, and the parameter name corresponding to $time defaults to time4. If the anti-leech encryption string and time string are in the parameters behind the question mark in the url, the "keyname" and "tname" in the url correspond to the anti-leech string and time string parameter names configured in cipher-param and time-param.
uri-selectString
The general anti-leech takes the number "/" corresponding to the uri, the value is a number, and multiple values are separated by semicolons.Configure the general anti-leech link to get the number of "/" corresponding to the uri. If the configuration is 0, it is the first one in the forward direction, and -1 is the first one in the reverse direction. It can be configured by channel, and the default value is empty.For example http://a.com/b/c/d/e/f/1.htmlThen 0;3; 4;-1 is to take /b/e/f/1.htmlNotice:1. Value range: [-100,+100]2. Repeat configuration effective rules (it is recommended not to configure duplicates)Duplicates will skip parsing:Such as http://cdn.example.com/e/0/e2/test.dat?k=v 2;2;3;3 can be configured, but only 2;3The URI is /e2/test.dat;
special-encryptionString
Special encryption, values: 1 to enable, or leave blank
effective-timeString
Effective time, unit:s
file-typeString
The file type
custom-file-typeString
The custom file type
except-file-typeString
Exceptional file type, multiple values separated by English semicolons (;), optional values: f4m ico m3u8 wmv jpeg shtml wma ts png zip bmp css html txt gif swf js bootstarp rar xml flv exe jpg htm mp4 mp3 Example: gif;png
except-custom-file-typeString
Exceptional custom file type, multiple values separated by English semicolons (;) Example: wml;apk

Error code

Error code(code)Description(message)HTTP statusSemantic
InternalErrorWe encountered an internal error. Please try again.500We encountered an internal error. Please try again.
InvalidParameterNo domain was specified.400No domain was specified.
NoSuchDomainThe specified domain does not exist.404The specified domain does not exist.
NoSuchServiceTagThe specified service tag dose not exist, tag:{}.400The specified service tag dose not exist, tag:{}.

Example

JSON
XML
JSON
Request example
Copy Copy success
#!/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://{@apiDomain}/api/config/timecontrol/a.example.com" \
-X "GET" \
-u "$username:$password" \
-H "Date: $date" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
Response example
Copy Copy success
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",
        "dst-style":"1",
        "encrypt-method":"md5sum",
        "log-format":"true",
        "m3u8":"true",
        "url-key":"auth_key",
		"special-encryption": "1",
		"effective-time": "10",
        "specify-file-type":"gif;png;bmp",
        "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"
            }
        ]
    }
}