CN118118210A - CDN parent layer node anti-theft chain method, device, equipment and medium - Google Patents

CDN parent layer node anti-theft chain method, device, equipment and medium Download PDF

Info

Publication number
CN118118210A
CN118118210A CN202311695819.XA CN202311695819A CN118118210A CN 118118210 A CN118118210 A CN 118118210A CN 202311695819 A CN202311695819 A CN 202311695819A CN 118118210 A CN118118210 A CN 118118210A
Authority
CN
China
Prior art keywords
client
request
detection
hotlinking
access request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311695819.XA
Other languages
Chinese (zh)
Inventor
王志刚
谢东雷
黄颖
黄剑榕
吴海华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Telecom Cloud Technology Co Ltd
Original Assignee
China Telecom Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Telecom Cloud Technology Co Ltd filed Critical China Telecom Cloud Technology Co Ltd
Priority to CN202311695819.XA priority Critical patent/CN118118210A/en
Publication of CN118118210A publication Critical patent/CN118118210A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1441Countermeasures against malicious traffic
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1408Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic by monitoring network traffic
    • H04L63/1416Event detection, e.g. attack signature detection

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

本申请提供一种CDN父层节点防盗链方法、装置、设备及介质,该方法包括在可用父层节点接收到建联客户端发起的访问请求时,获取所述建联客户端的客户端I P,并判断所述访问请求是否为探测请求;在所述访问请求为非探测请求时,基于所述客户端I P,验证所述非探测请求是否为盗链行为;在所述非探测请求为非盗链行为时,则通过所述访问请求;在所述非探测请求为盗链行为时,则拒绝所述访问请求。通过判断访问请求是否为探测请求,判断是否需要对访问请求进行防盗链操作;在访问请求为非探测请求时,通过对客户端I P的盗链行为校验,动态调整父层防盗链策略,避免误触发防盗链操作,提高了CDN节点防盗可靠性。

The present application provides a CDN parent node anti-hotlink method, device, equipment and medium, the method includes when an available parent node receives an access request initiated by a connected client, obtaining the client IP of the connected client and determining whether the access request is a detection request; when the access request is a non-detection request, verifying whether the non-detection request is a hotlink behavior based on the client IP; when the non-detection request is a non-hotlink behavior, passing the access request; when the non-detection request is a hotlink behavior, rejecting the access request. By determining whether the access request is a detection request, it is determined whether an anti-hotlink operation is required for the access request; when the access request is a non-detection request, the parent layer anti-hotlink strategy is dynamically adjusted by verifying the hotlink behavior of the client IP to avoid false triggering of the anti-hotlink operation, thereby improving the anti-theft reliability of the CDN node.

Description

CDN父层节点防盗链方法、装置、设备及介质CDN parent node hotlink prevention method, device, equipment and medium

技术领域Technical Field

本申请涉及数据处理技术领域,尤其涉及一种CDN父层节点防盗链方法、装置、设备及介质。The present application relates to the field of data processing technology, and in particular to a CDN parent node anti-hotlink method, device, equipment and medium.

背景技术Background technique

当前CDN(Content Delivery Network,内容分发网络)技术中,会在全球各地部署边缘节点,就近为用户提供高质量、高效率、低时延的网络服务。为提高缓存命中率,降低回源率,CDN采用边缘+父的架构,一般情况下,有配置防盗链的域名只在边缘节点做校验,边缘节点回父层节点都不需要校验,一旦父层IP泄漏,将导致用户不带防盗链参数直接通过访问父层IP拉取到资源内容。如果发生父层盗链事件,一方面容易导致客户投诉,切走流量,造成业务流失,另一方面,父层节点流量是不计费的,对CDN来说也会造成带宽损失。In the current CDN (Content Delivery Network) technology, edge nodes are deployed around the world to provide users with high-quality, high-efficiency, and low-latency network services nearby. In order to improve the cache hit rate and reduce the return rate, CDN adopts an edge + parent architecture. Under normal circumstances, domain names with anti-hotlink configuration are only verified at the edge node, and the edge node does not need to be verified when returning to the parent node. Once the parent IP is leaked, users will directly access the parent IP without anti-hotlink parameters to pull resource content. If a parent hotlink incident occurs, on the one hand, it is easy to cause customer complaints, cut off traffic, and cause business loss. On the other hand, the parent node traffic is not charged, which will also cause bandwidth loss for CDN.

对于上述情况,当前最常用的父层防盗链方法主要是通过设计一个加解密算法,在边缘节点的每一条发往父层节点的请求生都成一个内部鉴权头部,然后在父层节点进行防盗链的校验。但是这种方法存在一些缺陷:For the above situation, the most commonly used parent-layer anti-hotlink method is to design an encryption and decryption algorithm, generate an internal authentication header for each request sent from the edge node to the parent-layer node, and then perform anti-hotlink verification at the parent-layer node. However, this method has some defects:

1)必须确保每一条从边缘节点发往父层节点的请求都会带上内部鉴权头,然而实际生产环境中,边缘缓存节点发往父层节点的请求是很复杂的,因客户不同需求,存在非常多定制化业务,如果考虑不周漏添加鉴权头,将被父层节点拒绝,直接影响客户业务,造成客户投诉。并且部分客户会做回源鉴权,可能因为新增的内部鉴权头导致缓存节点计算的鉴权头与客户的不一致,最终导致回源被拒,影响客户业务。1) It is necessary to ensure that every request sent from the edge node to the parent node will carry an internal authentication header. However, in the actual production environment, the requests sent by the edge cache node to the parent node are very complex. Due to different customer needs, there are many customized services. If the authentication header is not added carefully, it will be rejected by the parent node, directly affecting customer business and causing customer complaints. In addition, some customers will do back-to-source authentication. The newly added internal authentication header may cause the authentication header calculated by the cache node to be inconsistent with that of the customer, which will eventually lead to the rejection of the back-to-source and affect the customer's business.

2)每个直接与父层网关交互的组件也需要进行改造,适配鉴权算法,在相关组件发往父层节点的每个请求都带上内部鉴权头,这样就给各个组件增加了改造成本。2) Each component that directly interacts with the parent-layer gateway also needs to be modified to adapt the authentication algorithm. Each request sent by the relevant component to the parent-layer node must carry an internal authentication header, which increases the modification cost of each component.

3)虽然内部鉴权头是有时效性,但是如果泄漏,还是存在短时盗链风险,异常行为还是可能会产生客户投诉。3) Although the internal authentication header is time-sensitive, if it is leaked, there is still a short-term risk of hotlinking, and abnormal behavior may still lead to customer complaints.

因此,如何提高CDN节点防盗可靠性成为亟待解决的技术问题。Therefore, how to improve the anti-theft reliability of CDN nodes has become a technical problem that needs to be solved urgently.

发明内容Summary of the invention

本申请提供了一种CDN父层节点防盗链方法、装置、设备及存储介质,旨在提高CDN节点防盗可靠性。The present application provides a CDN parent node anti-hotlink method, device, equipment and storage medium, aiming to improve the anti-theft reliability of CDN nodes.

第一方面,本申请提供一种CDN父层节点防盗链方法,所述方法包括:In a first aspect, the present application provides a CDN parent node hotlink protection method, the method comprising:

在可用父层节点接收到建联客户端发起的访问请求时,获取所述建联客户端的客户端IP,并判断所述访问请求是否为探测请求;When the available parent node receives an access request initiated by the association client, it obtains the client IP of the association client and determines whether the access request is a detection request;

在所述访问请求为非探测请求时,基于所述客户端IP,验证所述非探测请求是否为盗链行为;When the access request is a non-detection request, verifying whether the non-detection request is a hotlinking behavior based on the client IP;

在所述非探测请求为非盗链行为时,则通过所述访问请求;When the non-probing request is not a hotlinking behavior, the access request is approved;

在所述非探测请求为盗链行为时,则拒绝所述访问请求。When the non-probing request is a hotlinking behavior, the access request is rejected.

第二方面,本申请还提供一种CDN父层节点防盗链装置,所述CDN父层节点防盗链装置包括:In a second aspect, the present application further provides a CDN parent node anti-hotlink device, the CDN parent node anti-hotlink device comprising:

访问请求判断模块,用于在可用父层节点接收到建联客户端发起的访问请求时,获取所述建联客户端的客户端IP,并判断所述访问请求是否为探测请求;An access request judgment module is used to obtain the client IP of the association client when the available parent node receives the access request initiated by the association client, and judge whether the access request is a detection request;

盗链行为验证模块,用于在所述访问请求为非探测请求时,基于所述客户端IP,验证所述非探测请求是否为盗链行为;A hotlink behavior verification module, used for verifying whether the non-probing request is a hotlink behavior based on the client IP when the access request is a non-probing request;

请求通过模块,用于在所述非探测请求为非盗链行为时,则通过所述访问请求;A request passing module, used for passing the access request when the non-probing request is a non-hotlinking behavior;

访问拒绝模块,用于在所述非探测请求为盗链行为时,则拒绝所述访问请求。The access rejection module is used to reject the access request when the non-detection request is a hotlink behavior.

第三方面,本申请还提供一种计算机设备,所述计算机设备包括处理器、存储器、以及存储在所述存储器上并可被所述处理器执行的计算机程序,其中所述计算机程序被所述处理器执行时,实现如上述的CDN父层节点防盗链方法的步骤。In a third aspect, the present application also provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the CDN parent node anti-hotlinking method as described above are implemented.

第四方面,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,其中所述计算机程序被处理器执行时,实现如上述的CDN父层节点防盗链方法的步骤。In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the CDN parent node anti-hotlinking method as described above are implemented.

本申请提供一种CDN父层节点防盗链方法、装置、设备及存储介质,本申请方法包括在可用父层节点接收到建联客户端发起的访问请求时,获取所述建联客户端的客户端IP,并判断所述访问请求是否为探测请求;在所述访问请求为非探测请求时,基于所述客户端IP,验证所述非探测请求是否为盗链行为;在所述非探测请求为非盗链行为时,则通过所述访问请求;在所述非探测请求为盗链行为时,则拒绝所述访问请求。通过上述方式,本申请通过判断建联客户端发起的访问请求是否为探测请求,进而确定是否需要对访问请求进行防盗链操作;在访问请求为非探测请求时,通过对客户端IP的盗链行为校验,判断访问请求是否为盗链行为,进而判断是否通过访问请求,从而实现父层防盗链策略的动态调整,以及对盗链行为的甄别准确性,避免误触发防盗链操作,提高了CDN节点防盗可靠性。The present application provides a CDN parent node anti-hotlink method, device, equipment and storage medium. The method of the present application includes obtaining the client IP of the connected client and judging whether the access request is a detection request when the available parent node receives an access request initiated by the connected client; when the access request is a non-detection request, verifying whether the non-detection request is a hotlink behavior based on the client IP; when the non-detection request is a non-hotlink behavior, passing the access request; and rejecting the access request when the non-detection request is a hotlink behavior. Through the above-mentioned method, the present application determines whether it is necessary to perform an anti-hotlink operation on the access request by judging whether the access request initiated by the connected client is a detection request; when the access request is a non-detection request, judging whether the access request is a hotlink behavior by checking the hotlink behavior of the client IP, and then judging whether to pass the access request, thereby realizing the dynamic adjustment of the parent layer anti-hotlink strategy and the accuracy of identifying hotlink behavior, avoiding the false triggering of anti-hotlink operations, and improving the anti-theft reliability of CDN nodes.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

图1为本申请提供的一种CDN父层节点防盗链方法第一实施例的流程示意图;FIG1 is a flow chart of a first embodiment of a CDN parent node anti-hotlinking method provided by the present application;

图2为本申请实施例提供的对于探测请求的校验流程示意图;FIG2 is a schematic diagram of a verification process for a probe request provided in an embodiment of the present application;

图3为本申请实施例提供的父层防盗链模块对非探测请求的防盗链校验流程示意图;3 is a schematic diagram of the anti-hotlink verification process of the parent layer anti-hotlink module for non-detection requests provided in an embodiment of the present application;

图4为本申请提供的一种CDN父层节点防盗链方法第一实施例的流程示意图;FIG4 is a flow chart of a first embodiment of a CDN parent node anti-hotlinking method provided by the present application;

图5为本申请提供的一种CDN父层节点防盗链方法第二实施例的流程示意图;FIG5 is a flow chart of a second embodiment of a CDN parent node anti-hotlinking method provided by the present application;

图6为本申请提供的一种CDN父层节点防盗链方法第三实施例的流程示意图;FIG6 is a flow chart of a third embodiment of a CDN parent node anti-hotlinking method provided by the present application;

图7是本申请提供的一种CDN父层节点防盗链装置第一实施例的结构示意图;FIG7 is a schematic structural diagram of a first embodiment of a CDN parent node anti-hotlinking device provided by the present application;

图8是本申请实施例提供的一种计算机设备的结构示意性框图。FIG8 is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application.

本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings.

具体实施方式Detailed ways

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

附图中所示的流程图仅是示例说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解、组合或部分合并,因此实际执行的顺序有可能根据实际情况改变。The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations/steps, nor must they be executed in the order described. For example, some operations/steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.

下面结合附图,对本申请的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

请参照图1,图1为本申请提供的一种CDN父层节点防盗链系统的结构示意图。Please refer to Figure 1, which is a structural diagram of a CDN parent layer node anti-hotlink system provided by the present application.

在一实施例中,如图1所示,该系统主要由请求处理模块、探测频次校验模块、探测注册存储模块、父层防盗链模块、客户端设备和服务器组成。In one embodiment, as shown in FIG. 1 , the system is mainly composed of a request processing module, a detection frequency verification module, a detection registration storage module, a parent layer anti-hotlink module, a client device and a server.

在一实施例中,客户端设备可以是笔记本电脑、台式计算机等计算机设备。In one embodiment, the client device may be a computer device such as a laptop computer or a desktop computer.

在一实施例中,服务器可以是一台服务器,也可以是服务器集群。In one embodiment, the server may be a single server or a server cluster.

在一实施例中,请求处理模块用于对客户端设备发起的请求进行数据解析。In one embodiment, the request processing module is used to perform data analysis on the request initiated by the client device.

在一实施例中,探测频次校验模块用于对探测请求的探测频次进行检测和校验。In one embodiment, the detection frequency verification module is used to detect and verify the detection frequency of the detection request.

在一实施例中,探测注册存储模块用于将客户端设备的客户点IP注册、更新至数据库中。In one embodiment, the detection registration storage module is used to register and update the client point IP of the client device into the database.

示例性的,可以采用哈希字典存储方式,负责探测请求建联IP的注册、更新、删除操作,以供父层防盗链模块调用查询。Exemplarily, a hash dictionary storage method may be used to detect registration, update, and deletion operations of the IP address requested for association, so that the parent layer anti-hotlink module can call and query.

示例性的,请求处理模块、探测频次校验模块、探测注册存储模块流程图如附图2所示。CDN父层网关接收到请求后,请求处理模块根据请求URL和请求头部,区分是否为探测请求,如果是探测请求,先进行建联IP防盗链判断,边缘节点使用发起建联的IP和约定的密钥key通过md5算法生成防盗链串,携带在探测请求的参数signature中,父层节点进行校验建联客户端IP与约定key通过md5算法生成的加密串是否与探测携带参数signature值一致,如果不一致,则进行请求拒绝,不进行建联IP的注册。如果一致,建联IP防盗链通过,同时采用滑动窗口统计探测频次,对于防盗链通过的探测请求,进行探测频次校验,在探测频次规定范围内的,进入探测注册存储模块,进行建联IP的注册更新;对于探测频次不在规定范围内的,认为是非法探测请求,进入探测注册存储模块,进行建联IP的删除操作,并响应403拒绝请求。Exemplarily, the flow chart of the request processing module, the detection frequency verification module, and the detection registration storage module is shown in Figure 2. After the CDN parent layer gateway receives the request, the request processing module distinguishes whether it is a detection request based on the request URL and the request header. If it is a detection request, it first performs the anti-hotlink judgment of the IP connection. The edge node uses the IP that initiates the connection and the agreed key key to generate an anti-hotlink string through the md5 algorithm, which is carried in the parameter signature of the detection request. The parent layer node verifies whether the encrypted string generated by the md5 algorithm of the connection client IP and the agreed key is consistent with the detection carrying parameter signature value. If not, the request is rejected and the registration of the connection IP is not performed. If it is consistent, the connection IP anti-hotlink passes, and the sliding window is used to count the detection frequency. For the detection request that passes the anti-hotlink, the detection frequency is checked. If it is within the specified range of the detection frequency, it enters the detection registration storage module to perform the registration update of the connection IP; for the detection frequency that is not within the specified range, it is considered to be an illegal detection request, and the detection registration storage module is entered to perform the deletion operation of the connection IP, and respond to the 403 rejection request.

在一实施例中,如附图3所示,父层防盗链模块包含三重过滤规则:如果判断客户端IP为本机的请求,进行防盗链放过;如果非本机请求,判断IP是否在哈希字典中且未过期,如果IP存在且未过期,父层防盗链通过;如果不存在或过期,则判断该请求IP或请求域名是否在自定义白名单列表中,如果在白名单列表中,父层防盗链放过,否则对该请求进行防盗链拒绝。In one embodiment, as shown in Figure 3, the parent layer anti-hotlink module includes triple filtering rules: if it is determined that the client IP is a local request, the anti-hotlink is passed; if it is a non-local request, it is determined whether the IP is in the hash dictionary and has not expired. If the IP exists and has not expired, the parent layer anti-hotlink passes; if it does not exist or is expired, it is determined whether the request IP or request domain name is in the custom whitelist. If it is in the whitelist, the parent layer anti-hotlink is passed, otherwise the request is rejected for anti-hotlink.

请参照图4,图4为本申请提供的一种CDN父层节点防盗链方法第一实施例的流程示意图。Please refer to FIG. 4 , which is a flowchart of a first embodiment of a CDN parent node anti-hotlinking method provided by the present application.

如图4所示,该CDN父层节点防盗链方法包括步骤S101至步骤S104。As shown in FIG. 4 , the CDN parent node anti-hotlinking method includes steps S101 to S104 .

S101、在可用父层节点接收到建联客户端发起的访问请求时,获取所述建联客户端的客户端IP,并判断所述访问请求是否为探测请求;S101, when an available parent node receives an access request initiated by a connection client, obtains the client IP of the connection client and determines whether the access request is a detection request;

在一实施例中,CDN父层网关接收到请求后,根据请求URL和请求头部,区分是否为探测请求,如果是探测请求,进行探测注册更新,如果非探测请求,流转进入父层防盗链模块,进行防盗链判断处理。In one embodiment, after receiving the request, the CDN parent layer gateway distinguishes whether it is a detection request based on the request URL and the request header. If it is a detection request, the detection registration is updated. If it is not a detection request, it is transferred to the parent layer anti-hotlink module for anti-hotlink judgment processing.

S102、在所述访问请求为非探测请求时,基于所述客户端IP,验证所述非探测请求是否为盗链行为;S102: When the access request is a non-detection request, verify whether the non-detection request is a hotlinking behavior based on the client IP;

在一实施例中,对于非探测请求,通过对客户端IP的本机IP比对、哈希字典查询以及白名单查询等方式,对客户端IP进行查询和校验,从而验证该非探测请求是否为盗链行为。In one embodiment, for non-probing requests, the client IP is queried and verified by comparing the client IP with the local IP, querying the hash dictionary, and querying the whitelist, so as to verify whether the non-probing request is a hotlinking behavior.

S103、在所述非探测请求为非盗链行为时,则通过所述访问请求;S103: when the non-detection request is not a hotlinking behavior, the access request is approved;

S104、在所述非探测请求为盗链行为时,则拒绝所述访问请求。S104: When the non-detection request is a hotlinking behavior, reject the access request.

在一实施例中,对于盗链行为,可用父层节点的防盗链模块直接拒绝该请求,并如果是伪造探测请求,可以标记为异常并剔除,如果是非探测请求,遇到盗链会直接进行拒绝,不会再进行客户端IP标记为不可信任的IP;而对于非盗链行为,则响应该非探测请求。In one embodiment, for hotlinking behavior, the anti-hotlinking module of the parent node can be used to directly reject the request, and if it is a forged detection request, it can be marked as abnormal and eliminated. If it is a non-detection request, it will be directly rejected when encountering hotlinking, and the client IP will no longer be marked as an untrustworthy IP; and for non-hotlinking behavior, the non-detection request will be responded to.

进一步地,所述在所述非探测请求为非盗链行为时,则通过所述访问请求之后,还包括:Furthermore, when the non-probing request is a non-hotlinking behavior, after the access request is passed, the method further includes:

基于所述访问请求,确定目标业务数据,并查询所述可用父层节点的缓存服务器中是否存在所述目标业务数据;在所述缓存服务器中存在所述目标业务数据时,将所述目标业务数据响应至所述建联客户端;在所述缓存服务器中不存在所述目标业务数据时,执行回源操作,获取所述目标业务数据,并将所述目标业务数据响应至所述所述建联客户端。Based on the access request, determine the target business data, and query whether the target business data exists in the cache server of the available parent node; when the target business data exists in the cache server, respond the target business data to the established client; when the target business data does not exist in the cache server, perform a back-to-source operation, obtain the target business data, and respond the target business data to the established client.

在一实施例中,父层防盗链通过后,进入实际客户业务逻辑中,父层节点的缓存服务器有缓存的,直接响应给客户端,如果父层节点缓存服务器无对应URL的缓存,则进行回源拉取文件并缓存于当前父层节点中,然后响应给客户端。In one embodiment, after the parent layer anti-hotlink protection passes, it enters the actual customer business logic. If the cache server of the parent layer node has a cache, it will directly respond to the client. If the cache server of the parent layer node does not have a cache of the corresponding URL, it will go back to the source to pull the file and cache it in the current parent layer node, and then respond to the client.

本实施例提供一种CDN父层节点防盗链方法,该方法通过判断建联客户端发起的访问请求是否为探测请求,进而确定是否需要对访问请求进行防盗链操作;在访问请求为非探测请求时,通过对客户端IP的盗链行为校验,判断访问请求是否为盗链行为,进而判断是否通过访问请求,从而实现父层防盗链策略的动态调整,以及对盗链行为的甄别准确性,避免误触发防盗链操作,提高了CDN节点防盗可靠性。This embodiment provides a CDN parent node anti-hotlinking method, which determines whether an access request initiated by a connected client is a detection request, and then determines whether an anti-hotlinking operation is required for the access request; when the access request is not a detection request, the hotlinking behavior of the client IP is verified to determine whether the access request is a hotlinking behavior, and then determines whether the access request is approved, thereby achieving dynamic adjustment of the parent layer anti-hotlinking strategy and the accuracy of hotlinking behavior identification, avoiding false triggering of anti-hotlinking operations, and improving the anti-theft reliability of CDN nodes.

请参照图5,图5为本申请提供的一种CDN父层节点防盗链方法第二实施例的流程示意图。Please refer to FIG. 5 , which is a flow chart of a second embodiment of a CDN parent node anti-hotlinking method provided by the present application.

本实施例中,基于上述图4所示实施例,所述步骤S101,具体包括:In this embodiment, based on the embodiment shown in FIG. 4 , step S101 specifically includes:

S201、获取所述可用父层节点对应的本机IP,并比对所述客户端IP和所述本机IP;S201, obtaining the local IP corresponding to the available parent node, and comparing the client IP with the local IP;

S202、若所述客户端IP和所述本机IP一致,则确定所述非探测请求为所述非盗链行为。S202: If the client IP is consistent with the local IP, determine that the non-probing request is the non-hotlinking behavior.

在一实施例中,对于父层节点的网关接收到非探测请求,首先判断建联的客户端IP是否为本机IP。如果该客户端IP是本机IP,确认为非盗链,父层防盗链放过。In one embodiment, when the gateway of the parent node receives a non-detection request, it first determines whether the client IP of the connection is the local IP. If the client IP is the local IP, it is confirmed to be non-hotlinking, and the parent layer anti-hotlinking is allowed.

在一实施例中,如果该客户端IP非本机IP,则需要进一步校验。In one embodiment, if the client IP is not the local IP, further verification is required.

进一步地,若所述客户端IP和所述本机IP不一致,则查询预设的哈希字典中是否存在所述客户端IP;若查询到所述哈希字典中存在所述客户端IP,则获取所述客户端IP的生效期限;若所述生效期限当前有效,则确定所述非探测请求为所述非盗链行为。Furthermore, if the client IP and the local IP are inconsistent, the preset hash dictionary is queried to see whether the client IP exists; if the client IP is found to exist in the hash dictionary, the validity period of the client IP is obtained; if the validity period is currently valid, the non-probing request is determined to be the non-hotlinking behavior.

在一实施例中,可以采用哈希字典存储方式存储与父层节点建联的客户端IP,通过哈希字典负责探测请求建联的客户端IP的注册、更新、删除等操作,以供父层防盗链模块调用查询。In one embodiment, a hash dictionary storage method can be used to store the client IP associated with the parent node. The hash dictionary is responsible for detecting the registration, update, deletion and other operations of the client IP requesting the association, so that the parent anti-hotlink module can call and query.

在一实施例中,查询哈希字典中是否已经存储有建联客户端的客户端IP,如果哈希字典中存在该客户端IP且未过期,则父层防盗链通过。In one embodiment, it is queried whether the client IP of the associated client has been stored in the hash dictionary. If the client IP exists in the hash dictionary and has not expired, the parent layer hotlink protection passes.

在一实施例中,如果哈希字典中存在该客户端IP,但是该客户端IP的生效期限已经过期,或者该客户端IP不存在哈希字典中,则进一步对客户端IP进行校验。In one embodiment, if the client IP exists in the hash dictionary, but the validity period of the client IP has expired, or the client IP does not exist in the hash dictionary, the client IP is further verified.

进一步地,若查询到所述哈希字典中不存在所述客户端IP,或者查询到所述哈希字典中存在所述客户端IP且所述客户端IP的所述生效期限当前无效,则获取所述非探测请求的客户端域名;获取预设的白名单,并查询所述白名单中是否存在所述客户端域名和/或所述客户端IP;若查询到所述白名单中存在所述客户端域名和/或所述客户端IP,则确定所述非探测请求为非盗链行为。Furthermore, if it is found that the client IP does not exist in the hash dictionary, or if it is found that the client IP exists in the hash dictionary and the validity period of the client IP is currently invalid, the client domain name of the non-detection request is obtained; a preset whitelist is obtained, and it is queried whether the client domain name and/or the client IP exists in the whitelist; if it is found that the client domain name and/or the client IP exists in the whitelist, it is determined that the non-detection request is a non-hotlinking behavior.

在一实施例中,若在哈希字典中未能查找到发起访问请求的客户端IP,或者该客户端IP存在但已失效,则进一步对该请求的域名和IP进行自定义白名单查询。如果该域名或IP在自定义白名单中,则父层防盗链通过。In one embodiment, if the client IP that initiated the access request cannot be found in the hash dictionary, or the client IP exists but has expired, a custom whitelist query is further performed on the domain name and IP of the request. If the domain name or IP is in the custom whitelist, the parent layer anti-hotlinking passes.

在一实施例中,如果该域名或IP不在自定义白名单中,则判断为盗链行为,进行防盗链拒绝。In one embodiment, if the domain name or IP is not in the custom whitelist, it is determined to be a hotlinking behavior and is rejected for hotlink protection.

本实施例中,对于非探测请求,采用结合自定义白名单方式,对交互组件的域名或IP进行加白,避免交互组件的改造成本,对交互组件进行父层防盗链放行;对其他客户请求,通过请求建联的客户端IP,查询比对哈希字典存储情况,对于不存在或过期的IP,进行父层防盗链拒绝,对于存在且不过期的IP,父层防盗链放行。结合自定义白名单,将与父层网关交互的组件加入自定义白名单中,白名单定时动态加载生效,避免了交互组件的改造成本,也为运维排查线上父层节点问题时,提供一种临时加白客户端IP接入父层节点的方式。In this embodiment, for non-detection requests, the domain name or IP of the interactive component is whitelisted in combination with a custom whitelist method to avoid the modification cost of the interactive component, and the parent layer anti-hotlinking is released for the interactive component; for other customer requests, the client IP that requests the connection is queried and compared with the hash dictionary storage. For non-existent or expired IPs, the parent layer anti-hotlinking is rejected, and for existing and non-expired IPs, the parent layer anti-hotlinking is released. In combination with a custom whitelist, the components that interact with the parent layer gateway are added to the custom whitelist, and the whitelist is dynamically loaded and takes effect at a fixed time, avoiding the modification cost of the interactive component. It also provides a way for the operation and maintenance to temporarily whitelist the client IP to access the parent layer node when troubleshooting problems with the online parent layer node.

请参照图6,图6为本申请提供的一种CDN父层节点防盗链方法第三实施例的流程示意图。Please refer to FIG. 6 , which is a flowchart of a third embodiment of a CDN parent node anti-hotlinking method provided by the present application.

本实施例中,基于上述图4所示实施例,所述步骤S101之后具体包括:In this embodiment, based on the embodiment shown in FIG. 4 , the step S101 and the following steps are specifically performed:

S301、在所述访问请求为探测请求时,验证所述探测请求是否为合法探测请求;S301, when the access request is a detection request, verify whether the detection request is a legal detection request;

在一实施例中,边缘节点会周期性的对父层节点进行存活探测,若是连续多次无响应或响应超时,标记为该父层IP不可用,若是连续多次探测响应200,则标记对应的父层IP可用。同时父层节点复用边缘节点的探测链路,对该请求进行URL和请求头判断,判断该请求是否为合法探测请求。In one embodiment, the edge node periodically performs survival detection on the parent node. If there is no response or response timeout for multiple consecutive times, the parent IP is marked as unavailable. If there are multiple consecutive detection responses of 200, the corresponding parent IP is marked as available. At the same time, the parent node reuses the detection link of the edge node, performs URL and request header judgment on the request, and determines whether the request is a legitimate detection request.

S302、在所述探测请求为合法探测请求时,获取所述探测请求的探测频次,并验证所述探测请求的探测频次是否在合法频次范围内;S302: when the detection request is a legal detection request, obtain the detection frequency of the detection request, and verify whether the detection frequency of the detection request is within a legal frequency range;

S303、在所述探测频次在合法频次范围内时,则对所述客户端IP进行注册或更新操作,并向所述建联客户端发送响应信号,以响应所述访问请求。S303: When the detection frequency is within a legal frequency range, register or update the client IP, and send a response signal to the associated client to respond to the access request.

在一实施例中,对探测请求,先进行建联IP防盗链判断,边缘节点使用发起建联的IP和约定的密钥key通过md5算法生成防盗链串,携带在探测请求的参数signature中,父层节点进行校验建联客户端IP与约定key通过md5算法生成的加密串是否与探测携带参数signature值一致,如果不一致,则进行请求拒绝,不进行建联IP的注册。如果一致,建联IP防盗链通过。In one embodiment, for the detection request, the IP hotlink protection judgment is first performed. The edge node uses the IP that initiates the connection and the agreed key key to generate an anti-hotlink string through the md5 algorithm, which is carried in the parameter signature of the detection request. The parent node verifies whether the encrypted string generated by the md5 algorithm of the connection client IP and the agreed key is consistent with the signature value of the detection parameter. If they are inconsistent, the request is rejected and the registration of the connection IP is not performed. If they are consistent, the IP hotlink protection of the connection is passed.

在一实施例中,对于探测请求,进行探测任务的建联IP防盗链校验和探测频次校验,如果建联IP防盗链校验通过且探测频次校验在合法范围内,则进行探测建联客户端IP的注册或更新,写入或更新该IP的过期时间,存储于哈希字典中,探测请求响应200告知客户端父层状态正常。In one embodiment, for the detection request, the detection task's connected IP anti-hotlink check and detection frequency check are performed. If the connected IP anti-hotlink check passes and the detection frequency check is within the legal range, the detection connection client IP is registered or updated, and the expiration time of the IP is written or updated and stored in the hash dictionary. The detection request response 200 informs the client that the parent layer status is normal.

进一步地,在所述探测频次不在所述合法频次范围内时,则删除预设数据库中存储的所述客户端IP,并向所述建联客户端发送请求拒绝信号,以拒绝所述访问请求。Furthermore, when the detection frequency is not within the legal frequency range, the client IP stored in the preset database is deleted, and a request rejection signal is sent to the associated client to reject the access request.

在一实施例中,如果该探测请求建联IP防盗链校验失败,则不进行建联客户端IP的注册,并直接响应403拒绝该请求。如果该探测请求建联IP防盗链校验通过,但是频次校验超限,则删除哈希字典中对应的客户端IP,并直接响应403拒绝该请求。In one embodiment, if the detection request fails to establish an IP hotlink protection check, the client IP will not be registered, and the request will be directly rejected with a 403 response. If the detection request passes the IP hotlink protection check, but the frequency check exceeds the limit, the corresponding client IP in the hash dictionary will be deleted, and the request will be directly rejected with a 403 response.

在一实施例中,通过复用边缘节点探测链路,鉴别探测请求和非探测请求,对探测请求进行建联IP防盗链校验和探测频次的双重校验,探测防盗链通过且探测频次符合规定,为有效探测请求,将探测请求的客户端IP加入哈希字典存储,更新IP过期时间;如果探测防盗链失败,则不加入哈希字典存储;如果探测防盗链通过,但探测频次不符合,则拒绝请求并剔除哈希字典存储的客户端IP。In one embodiment, by multiplexing the edge node detection link, distinguishing between detection requests and non-detection requests, and performing a double check of the IP anti-hotlink verification and the detection frequency on the detection request, if the detection anti-hotlink passes and the detection frequency meets the requirements, it is a valid detection request, and the client IP of the detection request is added to the hash dictionary storage and the IP expiration time is updated; if the detection anti-hotlink fails, it is not added to the hash dictionary storage; if the detection anti-hotlink passes, but the detection frequency does not meet the requirements, the request is rejected and the client IP stored in the hash dictionary is removed.

本实施例中,复用边缘节点探测链路,父层节点将探测建联的客户端IP进行注册存储,用以进行是否盗链的识别,减少父层对每条链路请求的鉴权头依赖,防止了业务代码鉴权头漏添加导致合法客户业务请求被拒绝。减少因新增鉴权头而引入业务逻辑与客户要求不同的风险,同时也避免了内部鉴权头泄漏引起短暂盗链。并且能够随着边缘节点规划的调整进行边缘节点IP列表的动态更新。对探测请求进行建联IP防盗链和探测频次双重校验,防止非法探测请求的接入导致非边缘节点的IP注册成功,利用探测请求的单一可控性与准确性,完全剥离父层防盗链体系与客户请求业务逻辑的耦合,防止因为父层防盗链体系的引入影响到客户业务逻辑,同时确保父层防盗链的准确性。In this embodiment, the edge node detection link is reused, and the parent node registers and stores the client IP of the detection connection to identify whether it is a hotlink, reduce the parent layer's reliance on the authentication header of each link request, and prevent the legitimate customer service request from being rejected due to the omission of the service code authentication header. Reduce the risk of introducing business logic that is different from customer requirements due to the addition of a new authentication header, and also avoid short-term hotlinking caused by internal authentication header leakage. And it can dynamically update the edge node IP list as the edge node planning is adjusted. The detection request is double-checked for IP hotlink protection and detection frequency to prevent the access of illegal detection requests from leading to successful registration of non-edge node IPs. The single controllability and accuracy of the detection request are used to completely strip the coupling of the parent layer anti-hotlink system and the customer request business logic, prevent the introduction of the parent layer anti-hotlink system from affecting the customer business logic, and ensure the accuracy of the parent layer anti-hotlink.

请参阅图7,图7是本申请提供的一种CDN父层节点防盗链装置第一实施例的结构示意图,该CDN父层节点防盗链装置用于执行前述的CDN父层节点防盗链方法。其中,该CDN父层节点防盗链装置可以配置于服务器中。Please refer to Figure 7, which is a schematic diagram of the structure of a first embodiment of a CDN parent node anti-hotlinking device provided by the present application, wherein the CDN parent node anti-hotlinking device is used to execute the aforementioned CDN parent node anti-hotlinking method. The CDN parent node anti-hotlinking device can be configured in a server.

如图7所示,该CDN父层节点防盗链装置400,包括:访问请求判断模块401、盗链行为验证模块402、请求通过模块403和访问拒绝模块404。As shown in FIG. 7 , the CDN parent node anti-hotlinking device 400 includes: an access request judgment module 401 , a hotlinking behavior verification module 402 , a request approval module 403 and an access rejection module 404 .

访问请求判断模块401,用于在可用父层节点接收到建联客户端发起的访问请求时,获取所述建联客户端的客户端IP,并判断所述访问请求是否为探测请求;The access request judgment module 401 is used to obtain the client IP of the association client when the available parent node receives the access request initiated by the association client, and judge whether the access request is a detection request;

盗链行为验证模块402,用于在所述访问请求为非探测请求时,基于所述客户端IP,验证所述非探测请求是否为盗链行为;A hotlinking behavior verification module 402 is used to verify whether the non-probing request is a hotlinking behavior based on the client IP when the access request is a non-probing request;

请求通过模块403,用于在所述非探测请求为非盗链行为时,则通过所述访问请求;A request passing module 403, configured to pass the access request when the non-probing request is not a hotlinking behavior;

访问拒绝模块404,用于在所述非探测请求为盗链行为时,则拒绝所述访问请求。The access rejection module 404 is configured to reject the access request when the non-detection request is a hotlinking behavior.

在一实施例中,所述盗链行为验证模块402包括:In one embodiment, the hotlinking behavior verification module 402 includes:

本机IP获取单元,用于获取所述可用父层节点对应的本机IP,并比对所述客户端IP和所述本机IP;A local IP acquisition unit, used to acquire the local IP corresponding to the available parent node, and compare the client IP with the local IP;

非盗链行为确定第一单元,用于若所述客户端IP和所述本机IP一致,则确定所述非探测请求为所述非盗链行为。The first non-hotlinking behavior determination unit is used to determine that the non-probing request is the non-hotlinking behavior if the client IP and the local IP are consistent.

在一实施例中,所述盗链行为验证模块402还包括:In one embodiment, the hotlinking behavior verification module 402 further includes:

IP查询单元,用于若所述客户端IP和所述本机IP不一致,则查询预设的哈希字典中是否存在所述客户端IP;An IP query unit, configured to query whether the client IP exists in a preset hash dictionary if the client IP is inconsistent with the local IP;

生效期限获取单元,用于若查询到所述哈希字典中存在所述客户端IP,则获取所述客户端IP的生效期限;An effective period obtaining unit, configured to obtain the effective period of the client IP if the client IP is found to exist in the hash dictionary;

非盗链行为确定第二单元,用于若所述生效期限当前有效,则确定所述非探测请求为所述非盗链行为。The second non-hotlinking behavior determination unit is configured to determine that the non-probing request is the non-hotlinking behavior if the validity period is currently valid.

在一实施例中,所述盗链行为验证模块402还包括:In one embodiment, the hotlinking behavior verification module 402 further includes:

客户端域名获取单元,用于若查询到所述哈希字典中不存在所述客户端IP,或者查询到所述哈希字典中存在所述客户端IP且所述客户端IP的所述生效期限当前无效,则获取所述非探测请求的客户端域名;A client domain name acquisition unit, configured to acquire the client domain name of the non-detection request if it is found that the client IP does not exist in the hash dictionary, or if it is found that the client IP exists in the hash dictionary and the validity period of the client IP is currently invalid;

白名单获取单元,用于获取预设的白名单,并查询所述白名单中是否存在所述客户端域名和/或所述客户端IP;A whitelist acquisition unit, used to acquire a preset whitelist and query whether the client domain name and/or the client IP exists in the whitelist;

非盗链行为确定第三单元,用于若查询到所述白名单中存在所述客户端域名和/或所述客户端IP,则确定所述非探测请求为非盗链行为。The third non-hotlinking behavior determination unit is configured to determine that the non-probing request is a non-hotlinking behavior if it is found that the client domain name and/or the client IP exists in the whitelist.

在一实施例中,所述CDN父层节点防盗链装置400还包括探测请求验证模块,包括:In one embodiment, the CDN parent node anti-hotlinking device 400 further includes a detection request verification module, including:

探测请求合法验证单元,用于在所述访问请求为探测请求时,验证所述探测请求是否为合法探测请求;A detection request legality verification unit, used for verifying whether the detection request is a legal detection request when the access request is a detection request;

探测频次验证单元,用于在所述探测请求为合法探测请求时,获取所述探测请求的探测频次,并验证所述探测请求的探测频次是否在合法频次范围内;A detection frequency verification unit, used to obtain the detection frequency of the detection request when the detection request is a legal detection request, and verify whether the detection frequency of the detection request is within a legal frequency range;

访问请求响应单元,用于在所述探测频次在合法频次范围内时,则对所述客户端IP进行注册或更新操作,并向所述建联客户端发送响应信号,以响应所述访问请求。The access request response unit is used to register or update the client IP when the detection frequency is within the legal frequency range, and send a response signal to the associated client to respond to the access request.

在一实施例中,所述探测请求验证模块还包括:In one embodiment, the probe request verification module further includes:

访问请求拒绝单元,用于在所述探测频次不在所述合法频次范围内时,则删除预设数据库中存储的所述客户端IP,并向所述建联客户端发送请求拒绝信号,以拒绝所述访问请求。The access request rejection unit is used to delete the client IP stored in the preset database when the detection frequency is not within the legal frequency range, and send a request rejection signal to the associated client to reject the access request.

在一实施例中,所述CDN父层节点防盗链装置400还包括业务数据响应模块,包括:In one embodiment, the CDN parent node anti-hotlinking device 400 further includes a service data response module, including:

目标业务数据确定单元,用于基于所述访问请求,确定目标业务数据,并查询所述可用父层节点的缓存服务器中是否存在所述目标业务数据;A target business data determination unit, configured to determine the target business data based on the access request, and query whether the target business data exists in the cache server of the available parent node;

数据响应第一单元,用于在所述缓存服务器中存在所述目标业务数据时,将所述目标业务数据响应至所述建联客户端;A first data response unit, configured to respond the target service data to the connection client when the target service data exists in the cache server;

数据响应第二单元,用于在所述缓存服务器中不存在所述目标业务数据时,执行回源操作,获取所述目标业务数据,并将所述目标业务数据响应至所述所述建联客户端。The second data response unit is used to perform a back-to-source operation to obtain the target business data and respond the target business data to the association client when the target business data does not exist in the cache server.

需要说明的是,所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的装置和各模块的具体工作过程,可以参考前述CDN父层节点防盗链方法实施例中的对应过程,在此不再赘述。It should be noted that technicians in the relevant field can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described device and each module can refer to the corresponding process in the aforementioned CDN parent layer node anti-hotlink method embodiment, and will not be repeated here.

上述实施例提供的装置可以实现为一种计算机程序的形式,该计算机程序可以在如图8所示的计算机设备上运行。The apparatus provided in the above embodiment may be implemented in the form of a computer program, and the computer program may be run on a computer device as shown in FIG. 8 .

请参阅图8,图8是本申请实施例提供的一种计算机设备的结构示意性框图。该计算机设备可以是服务器。Please refer to Fig. 8, which is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application. The computer device may be a server.

参阅图8,该计算机设备包括通过系统总线连接的处理器、存储器和网络接口,其中,存储器可以包括非易失性存储介质和内存储器。Referring to FIG. 8 , the computer device includes a processor, a memory, and a network interface connected via a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.

非易失性存储介质可存储操作系统和计算机程序。该计算机程序包括程序指令,该程序指令被执行时,可使得处理器执行任意一种CDN父层节点防盗链方法。The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any CDN parent node hotlink protection method.

处理器用于提供计算和控制能力,支撑整个计算机设备的运行。The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.

内存储器为非易失性存储介质中的计算机程序的运行提供环境,该计算机程序被处理器执行时,可使得处理器执行任意一种CDN父层节点防盗链方法。The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any CDN parent node anti-hotlinking method.

该网络接口用于进行网络通信,如发送分配的任务等。本领域技术人员可以理解,图8中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will appreciate that the structure shown in FIG8 is only a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

应当理解的是,处理器可以是中央处理单元(CentralProcessingUnit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(DigitalSignalProcessor,DSP)、专用集成电路(ApplicationSpecificIntegratedCircuit,ASIC)、现场可编程门阵列(Field-ProgrammableGateArray,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

其中,在一个实施例中,所述处理器用于运行存储在存储器中的计算机程序,以实现如下步骤:In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:

在可用父层节点接收到建联客户端发起的访问请求时,获取所述建联客户端的客户端IP,并判断所述访问请求是否为探测请求;When the available parent node receives an access request initiated by the association client, it obtains the client IP of the association client and determines whether the access request is a detection request;

在所述访问请求为非探测请求时,基于所述客户端IP,验证所述非探测请求是否为盗链行为;When the access request is a non-detection request, verifying whether the non-detection request is a hotlinking behavior based on the client IP;

在所述非探测请求为非盗链行为时,则通过所述访问请求;When the non-probing request is not a hotlinking behavior, the access request is approved;

在所述非探测请求为盗链行为时,则拒绝所述访问请求。When the non-probing request is a hotlinking behavior, the access request is rejected.

在一实施例中,所述处理器在实现所述基于所述客户端IP,验证所述非探测请求是否为盗链行为时,用于实现:In one embodiment, when the processor implements the verification based on the client IP whether the non-probing request is a hotlinking behavior, it is used to implement:

获取所述可用父层节点对应的本机IP,并比对所述客户端IP和所述本机IP;Obtain the local IP corresponding to the available parent node, and compare the client IP with the local IP;

若所述客户端IP和所述本机IP一致,则确定所述非探测请求为所述非盗链行为。If the client IP is consistent with the local IP, the non-probing request is determined to be the non-hotlinking behavior.

在一实施例中,所述处理器在实现所述获取所述可用父层节点对应的本机IP,并比对所述客户端IP和所述本机IP之后,还用于实现:In one embodiment, after obtaining the local IP corresponding to the available parent node and comparing the client IP with the local IP, the processor is further configured to implement:

若所述客户端IP和所述本机IP不一致,则查询预设的哈希字典中是否存在所述客户端IP;If the client IP is inconsistent with the local IP, query whether the client IP exists in the preset hash dictionary;

若查询到所述哈希字典中存在所述客户端IP,则获取所述客户端IP的生效期限;If the client IP is found in the hash dictionary, the validity period of the client IP is obtained;

若所述生效期限当前有效,则确定所述非探测请求为所述非盗链行为。If the effective period is currently valid, the non-probing request is determined to be the non-hotlinking behavior.

在一实施例中,所述处理器在实现所述若所述客户端IP和所述本机IP不一致,则查询预设的哈希字典中是否存在所述客户端IP之后,还用于实现:In one embodiment, after implementing the querying of whether the client IP exists in a preset hash dictionary if the client IP and the local IP are inconsistent, the processor is further configured to implement:

若查询到所述哈希字典中不存在所述客户端IP,或者查询到所述哈希字典中存在所述客户端IP且所述客户端IP的所述生效期限当前无效,则获取所述非探测请求的客户端域名;If it is found that the client IP does not exist in the hash dictionary, or if it is found that the client IP exists in the hash dictionary and the validity period of the client IP is currently invalid, then obtaining the client domain name of the non-detection request;

获取预设的白名单,并查询所述白名单中是否存在所述客户端域名和/或所述客户端IP;Obtain a preset whitelist, and query whether the client domain name and/or the client IP exists in the whitelist;

若查询到所述白名单中存在所述客户端域名和/或所述客户端IP,则确定所述非探测请求为非盗链行为。If it is found that the client domain name and/or the client IP exists in the whitelist, it is determined that the non-probing request is a non-hotlinking behavior.

在一实施例中,所述处理器在实现所述获取所述建联客户端的客户端IP,并判断所述访问请求是否为探测请求之后,还用于实现:In one embodiment, after obtaining the client IP of the associated client and determining whether the access request is a detection request, the processor is further configured to implement:

在所述访问请求为探测请求时,验证所述探测请求是否为合法探测请求;When the access request is a detection request, verifying whether the detection request is a legitimate detection request;

在所述探测请求为合法探测请求时,获取所述探测请求的探测频次,并验证所述探测请求的探测频次是否在合法频次范围内;When the detection request is a legal detection request, obtaining a detection frequency of the detection request, and verifying whether the detection frequency of the detection request is within a legal frequency range;

在所述探测频次在合法频次范围内时,则对所述客户端IP进行注册或更新操作,并向所述建联客户端发送响应信号,以响应所述访问请求。When the detection frequency is within the legal frequency range, the client IP is registered or updated, and a response signal is sent to the associated client to respond to the access request.

在一实施例中,所述处理器在实现所述在所述探测请求为合法探测请求时,获取所述探测请求的探测频次,并验证所述探测请求的探测频次是否在合法频次范围内之后,还用于实现:In one embodiment, the processor, after obtaining the detection frequency of the detection request when the detection request is a legitimate detection request and verifying whether the detection frequency of the detection request is within a legitimate frequency range, is further configured to implement:

在所述探测频次不在所述合法频次范围内时,则删除预设数据库中存储的所述客户端IP,并向所述建联客户端发送请求拒绝信号,以拒绝所述访问请求。When the detection frequency is not within the legal frequency range, the client IP stored in the preset database is deleted, and a request rejection signal is sent to the associated client to reject the access request.

在一实施例中,所述处理器在实现所述在所述非探测请求为非盗链行为时,则通过所述访问请求之后,还用于实现:In one embodiment, when the non-probing request is a non-hotlinking behavior, the processor is further configured to implement, after passing the access request:

基于所述访问请求,确定目标业务数据,并查询所述可用父层节点的缓存服务器中是否存在所述目标业务数据;Based on the access request, determine the target business data, and query whether the target business data exists in the cache server of the available parent node;

在所述缓存服务器中存在所述目标业务数据时,将所述目标业务数据响应至所述建联客户端;When the target service data exists in the cache server, responding the target service data to the connection client;

在所述缓存服务器中不存在所述目标业务数据时,执行回源操作,获取所述目标业务数据,并将所述目标业务数据响应至所述所述建联客户端。When the target business data does not exist in the cache server, a back-to-source operation is performed to obtain the target business data, and the target business data is responded to the association client.

本申请的实施例中还提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序中包括程序指令,所述处理器执行所述程序指令,实现本申请实施例提供的任一种CDN父层节点防盗链方法。A computer-readable storage medium is also provided in an embodiment of the present application. The computer-readable storage medium stores a computer program. The computer program includes program instructions. The processor executes the program instructions to implement any CDN parent node anti-hotlinking method provided in the embodiment of the present application.

其中,所述计算机可读存储介质可以是前述实施例所述的计算机设备的内部存储单元,例如所述计算机设备的硬盘或内存。所述计算机可读存储介质也可以是所述计算机设备的外部存储设备,例如所述计算机设备上配备的插接式硬盘,智能存储卡(SmartMediaCard,SMC),安全数字(SecureDigital,SD)卡,闪存卡(FlashCard)等。The computer-readable storage medium may be an internal storage unit of the computer device described in the above embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SmartMediaCard, SMC), a secure digital (SecureDigital, SD) card, a flash card (FlashCard), etc. equipped on the computer device.

以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims (10)

1.一种CDN父层节点防盗链方法,其特征在于,所述方法包括:1. A CDN parent node anti-hotlink method, characterized in that the method comprises: 在可用父层节点接收到建联客户端发起的访问请求时,获取所述建联客户端的客户端IP,并判断所述访问请求是否为探测请求;When the available parent node receives an access request initiated by the association client, it obtains the client IP of the association client and determines whether the access request is a detection request; 在所述访问请求为非探测请求时,基于所述客户端IP,验证所述非探测请求是否为盗链行为;When the access request is a non-detection request, verifying whether the non-detection request is a hotlinking behavior based on the client IP; 在所述非探测请求为非盗链行为时,则通过所述访问请求;When the non-probing request is not a hotlinking behavior, the access request is approved; 在所述非探测请求为盗链行为时,则拒绝所述访问请求。When the non-probing request is a hotlinking behavior, the access request is rejected. 2.根据权利要求1所述的CDN父层节点防盗链方法,其特征在于,所述基于所述客户端IP,验证所述非探测请求是否为盗链行为,包括:2. The CDN parent node anti-hotlinking method according to claim 1, characterized in that the step of verifying whether the non-detection request is a hotlinking behavior based on the client IP comprises: 获取所述可用父层节点对应的本机IP,并比对所述客户端IP和所述本机IP;Obtain the local IP corresponding to the available parent node, and compare the client IP with the local IP; 若所述客户端IP和所述本机IP一致,则确定所述非探测请求为所述非盗链行为。If the client IP is consistent with the local IP, the non-probing request is determined to be the non-hotlinking behavior. 3.根据权利要求2所述的CDN父层节点防盗链方法,其特征在于,所述获取所述可用父层节点对应的本机IP,并比对所述客户端IP和所述本机IP之后,还包括:3. The CDN parent node anti-hotlinking method according to claim 2 is characterized in that after obtaining the local IP corresponding to the available parent node and comparing the client IP with the local IP, it also includes: 若所述客户端IP和所述本机IP不一致,则查询预设的哈希字典中是否存在所述客户端IP;If the client IP is inconsistent with the local IP, query whether the client IP exists in the preset hash dictionary; 若查询到所述哈希字典中存在所述客户端IP,则获取所述客户端IP的生效期限;If the client IP is found in the hash dictionary, the validity period of the client IP is obtained; 若所述生效期限当前有效,则确定所述非探测请求为所述非盗链行为。If the effective period is currently valid, the non-probing request is determined to be the non-hotlinking behavior. 4.根据权利要求3所述的CDN父层节点防盗链方法,其特征在于,所述若所述客户端IP和所述本机IP不一致,则查询预设的哈希字典中是否存在所述客户端IP之后,还包括:4. The CDN parent node anti-hotlinking method according to claim 3 is characterized in that if the client IP and the local IP are inconsistent, after querying whether the client IP exists in a preset hash dictionary, it also includes: 若查询到所述哈希字典中不存在所述客户端IP,或者查询到所述哈希字典中存在所述客户端IP且所述客户端IP的所述生效期限当前无效,则获取所述非探测请求的客户端域名;If it is found that the client IP does not exist in the hash dictionary, or if it is found that the client IP exists in the hash dictionary and the validity period of the client IP is currently invalid, then obtaining the client domain name of the non-detection request; 获取预设的白名单,并查询所述白名单中是否存在所述客户端域名和/或所述客户端IP;Obtain a preset whitelist, and query whether the client domain name and/or the client IP exists in the whitelist; 若查询到所述白名单中存在所述客户端域名和/或所述客户端IP,则确定所述非探测请求为非盗链行为。If it is found that the client domain name and/or the client IP exists in the whitelist, it is determined that the non-probing request is a non-hotlinking behavior. 5.根据权利要求1所述的CDN父层节点防盗链方法,其特征在于,所述获取所述建联客户端的客户端IP,并判断所述访问请求是否为探测请求之后,还包括:5. The CDN parent node anti-hotlinking method according to claim 1, characterized in that after obtaining the client IP of the associated client and determining whether the access request is a detection request, it also includes: 在所述访问请求为探测请求时,验证所述探测请求是否为合法探测请求;When the access request is a detection request, verifying whether the detection request is a legitimate detection request; 在所述探测请求为合法探测请求时,获取所述探测请求的探测频次,并验证所述探测请求的探测频次是否在合法频次范围内;When the detection request is a legal detection request, obtaining a detection frequency of the detection request, and verifying whether the detection frequency of the detection request is within a legal frequency range; 在所述探测频次在合法频次范围内时,则对所述客户端IP进行注册或更新操作,并向所述建联客户端发送响应信号,以响应所述访问请求。When the detection frequency is within the legal frequency range, the client IP is registered or updated, and a response signal is sent to the associated client to respond to the access request. 6.根据权利要求5所述的CDN父层节点防盗链方法,其特征在于,所述在所述探测请求为合法探测请求时,获取所述探测请求的探测频次,并验证所述探测请求的探测频次是否在合法频次范围内之后,还包括:6. The CDN parent node anti-hotlinking method according to claim 5, characterized in that when the detection request is a legal detection request, after obtaining the detection frequency of the detection request and verifying whether the detection frequency of the detection request is within a legal frequency range, it also includes: 在所述探测频次不在所述合法频次范围内时,则删除预设数据库中存储的所述客户端IP,并向所述建联客户端发送请求拒绝信号,以拒绝所述访问请求。When the detection frequency is not within the legal frequency range, the client IP stored in the preset database is deleted, and a request rejection signal is sent to the associated client to reject the access request. 7.根据权利要求1-6中任一项所述的CDN父层节点防盗链方法,其特征在于,所述在所述非探测请求为非盗链行为时,则通过所述访问请求之后,还包括:7. The CDN parent node anti-hotlinking method according to any one of claims 1 to 6, characterized in that when the non-detection request is a non-hotlinking behavior, after passing the access request, it also includes: 基于所述访问请求,确定目标业务数据,并查询所述可用父层节点的缓存服务器中是否存在所述目标业务数据;Based on the access request, determine the target business data, and query whether the target business data exists in the cache server of the available parent node; 在所述缓存服务器中存在所述目标业务数据时,将所述目标业务数据响应至所述建联客户端;When the target service data exists in the cache server, responding the target service data to the connection client; 在所述缓存服务器中不存在所述目标业务数据时,执行回源操作,获取所述目标业务数据,并将所述目标业务数据响应至所述所述建联客户端。When the target business data does not exist in the cache server, a back-to-source operation is performed to obtain the target business data, and the target business data is responded to the association client. 8.一种CDN父层节点防盗链装置,其特征在于,所述CDN父层节点防盗链装置包括:8. A CDN parent node anti-hotlink device, characterized in that the CDN parent node anti-hotlink device comprises: 访问请求判断模块,用于在可用父层节点接收到建联客户端发起的访问请求时,获取所述建联客户端的客户端IP,并判断所述访问请求是否为探测请求;An access request judgment module is used to obtain the client IP of the association client when the available parent node receives the access request initiated by the association client, and judge whether the access request is a detection request; 盗链行为验证模块,用于在所述访问请求为非探测请求时,基于所述客户端IP,验证所述非探测请求是否为盗链行为;A hotlink behavior verification module, used for verifying whether the non-probing request is a hotlink behavior based on the client IP when the access request is a non-probing request; 请求通过模块,用于在所述非探测请求为非盗链行为时,则通过所述访问请求;A request passing module, used for passing the access request when the non-probing request is a non-hotlinking behavior; 访问拒绝模块,用于在所述非探测请求为盗链行为时,则拒绝所述访问请求。The access rejection module is used to reject the access request when the non-detection request is a hotlink behavior. 9.一种计算机设备,其特征在于,所述计算机设备包括处理器、存储器、以及存储在所述存储器上并可被所述处理器执行的计算机程序,其中所述计算机程序被所述处理器执行时,实现如权利要求1至7中任一项所述的CDN父层节点防盗链方法的步骤。9. A computer device, characterized in that the computer device includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the CDN parent node anti-hotlinking method as described in any one of claims 1 to 7 are implemented. 10.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,其中所述计算机程序被处理器执行时,实现如权利要求1至7中任一项所述的CDN父层节点防盗链方法的步骤。10. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, wherein when the computer program is executed by a processor, the steps of the CDN parent node anti-hotlinking method according to any one of claims 1 to 7 are implemented.
CN202311695819.XA 2023-12-11 2023-12-11 CDN parent layer node anti-theft chain method, device, equipment and medium Pending CN118118210A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311695819.XA CN118118210A (en) 2023-12-11 2023-12-11 CDN parent layer node anti-theft chain method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311695819.XA CN118118210A (en) 2023-12-11 2023-12-11 CDN parent layer node anti-theft chain method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN118118210A true CN118118210A (en) 2024-05-31

Family

ID=91215049

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311695819.XA Pending CN118118210A (en) 2023-12-11 2023-12-11 CDN parent layer node anti-theft chain method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN118118210A (en)

Similar Documents

Publication Publication Date Title
CN111868689B (en) Runtime self-correction of blockchain ledgers
US11831609B2 (en) Network security system with enhanced traffic analysis based on feedback loop
US10862870B2 (en) Privacy as a service by offloading user identification and network protection to a third party
US7996713B2 (en) Server-to-server integrity checking
US7447755B1 (en) Method and apparatus for policy management in a network device
US20070016914A1 (en) Kernel validation layer
US20090113528A1 (en) Techniques for authentication via network connections
US20110131635A1 (en) Client-side prevention of cross-site request forgeries
CN113179271A (en) Intranet security policy detection method and device
CN113569285A (en) Identity authentication and authorization method, device, system, equipment and storage medium
CN111083093B (en) Method, device, electronic device and storage medium for calling end capability
CN112511565B (en) Request response method and device, computer readable storage medium and electronic equipment
WO2023040453A1 (en) Transaction information processing method and apparatus
US9998495B2 (en) Apparatus and method for verifying detection rule
CN118118210A (en) CDN parent layer node anti-theft chain method, device, equipment and medium
CN112769731B (en) Process control method, device, server and storage medium
CN111770093B (en) Transaction monitoring decision method, device, equipment and computer readable storage medium
CN116318858A (en) Northbound interface security guarantee method, architecture and electronic equipment
US20210400083A1 (en) Method and system for privacy and security policy delivery
CN113709136A (en) Access request verification method and device
CN113592645A (en) Data verification method and device
CN111400328A (en) Data updating method and device and node server
US20240163296A1 (en) Detection of unknown applications
US11704403B2 (en) Detecting and preventing unauthorized command injection
AU2012101560A4 (en) Transaction verification

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination