CN113438336B - Network request method, device, equipment and storage medium - Google Patents

Network request method, device, equipment and storage medium Download PDF

Info

Publication number
CN113438336B
CN113438336B CN202110703062.9A CN202110703062A CN113438336B CN 113438336 B CN113438336 B CN 113438336B CN 202110703062 A CN202110703062 A CN 202110703062A CN 113438336 B CN113438336 B CN 113438336B
Authority
CN
China
Prior art keywords
address
domain name
network request
target
candidate
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.)
Active
Application number
CN202110703062.9A
Other languages
Chinese (zh)
Other versions
CN113438336A (en
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202110703062.9A priority Critical patent/CN113438336B/en
Publication of CN113438336A publication Critical patent/CN113438336A/en
Application granted granted Critical
Publication of CN113438336B publication Critical patent/CN113438336B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0852Delays
    • H04L43/0864Round trip delays
    • 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
    • H04L63/1466Active attacks involving interception, injection, modification, spoofing of data unit addresses, e.g. hijacking, packet injection or TCP sequence number attacks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • H04L67/63Routing a service request depending on the request content or context

Abstract

The application provides a network request method, a device, equipment and a storage medium, wherein the method comprises the following steps: monitoring a trigger event, traversing and pre-storing an IP address corresponding to a candidate domain name, and establishing a test connection through the IP address; updating the connection data of the IP address according to the connection state information; intercepting an original network request sent to a target server and extracting a target domain name from the original network request; if the target domain name is a candidate domain name, acquiring candidate IP addresses of the target domain name, calculating the total weight of each candidate IP address according to a preset rule, IP configuration data corresponding to the target domain name and connection data of the candidate IP addresses, and taking the candidate IP address with the highest total weight as the target IP address; based on the request protocol, updating the original network request according to the target IP address to obtain an updated network request; an updated network request is sent to the target server. By the method and the device, untrusted domain name resolution can be bypassed, data pollution caused by hijacking is reduced, and network speed is optimized.

Description

Network request method, device, equipment and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to a network request method, apparatus, device, and storage medium.
Background
In the process of sending a network request to a specified domain name, firstly, DNS domain name resolution is carried out, the request is sent to a service operator firstly, the service operator resolves a corresponding IP address after certain processing steps according to the domain name address, and then data is requested according to the IP address. However, in an actual network environment, some service operators or malicious network attacks hijack the DNS, and some advertisements or other unnecessary spam information are inserted into data returned to a client, which causes poor user experience, and network viruses are easily spread, which poses a certain threat to the use safety of a user network.
Disclosure of Invention
The method and the device aim to solve the technical problems that in the prior art, a network is easy to be hijacked by a DNS (domain name server) in the process of requesting to resolve a domain name, so that junk information is maliciously transmitted to a user, and the use safety of the network is threatened. The application provides a network request method, a network request device, network request equipment and a storage medium, and mainly aims to bypass untrusted domain name resolution, avoid data pollution caused by hijacking, improve user experience and guarantee network use safety.
In order to achieve the above object, the present application provides a network request method, including:
if a trigger event is monitored, traversing the IP address corresponding to the candidate domain name in the prestored IP configuration data, and establishing test connection through the IP address;
acquiring round-trip time of each traversed IP address for establishing test connection each time to detect whether each IP address successfully establishes the test connection each time and acquire connection state information;
updating the connection data corresponding to the IP address according to the connection state information of each connection establishment test of the IP address;
intercepting an original network request sent to a target server, and extracting a target domain name from the original network request;
if the target domain name is any candidate domain name, acquiring an IP address corresponding to the target domain name as a candidate IP address, calculating the total weight of each candidate IP address according to a preset rule, IP configuration data corresponding to the target domain name and connection data of the candidate IP address, and taking the candidate IP address with the highest total weight as the target IP address;
acquiring a request protocol of an original network request;
based on the request protocol of the original network request, updating the original network request according to the target IP address to obtain an updated network request;
an updated network request is sent to the target server.
In addition, to achieve the above object, the present application further provides a network request apparatus, including:
the connection module is used for traversing the IP address corresponding to the candidate domain name in the pre-stored IP configuration data and establishing test connection through the IP address if a trigger event is monitored;
the detection module is used for acquiring round-trip time of each traversed IP address for establishing test connection each time so as to detect whether each IP address successfully establishes the test connection each time and acquire connection state information;
the data updating module is used for updating the connection data of the corresponding IP address according to the connection state information of the test connection established each time by the IP address;
the intercepting module is used for intercepting an original network request sent to a target server and extracting a target domain name from the original network request;
the calculation module is used for acquiring an IP address corresponding to the target domain name as a candidate IP address if the target domain name is any candidate domain name, calculating the total weight of each candidate IP address according to a preset rule, IP configuration data corresponding to the target domain name and connection data of the candidate IP address, and taking the candidate IP address with the highest total weight as the target IP address;
the request information acquisition module is used for acquiring a request protocol of an original network request;
the request updating module is used for updating the original network request according to the target IP address based on the request protocol of the original network request to obtain an updated network request;
and the sending module is used for sending the updated network request to the target server.
To achieve the above object, the present application further provides a computer device comprising a memory, a processor and computer readable instructions stored on the memory and executable on the processor, the processor executing the computer readable instructions to perform the steps of the network request method according to any one of the preceding claims.
To achieve the above object, the present application further provides a computer readable storage medium having stored thereon computer readable instructions, which, when executed by a processor, cause the processor to execute the steps of the network request method according to any one of the preceding claims.
According to the network request method, the device, the equipment and the storage medium, the IP configuration data corresponding to each candidate domain name is locally stored in the terminal equipment, when the network request sent to the target server is obtained, the network request is intercepted firstly, the corresponding optimal IP address is searched locally in the terminal equipment, and the original network request is rewritten according to the optimal IP address to obtain a new network request for accessing the target server. According to the method and the device, an operator does not need to analyze the domain name any more, so that the analysis of the operator can be bypassed, and the hijacking risk and data pollution caused by the analysis of the domain name by the operator are avoided. According to the method and the device, the domain name is locally resolved, the step of applying for resolving the domain name to an authoritative server is reduced, the domain name resolving speed is optimized, the weight is calculated from a plurality of candidate IP addresses corresponding to the target domain name according to the connection data of each candidate IP address, and the optimal IP address is selected and is the target IP address with the optimal connection state, so that the network request speed can be greatly optimized. According to the method and the device, the network request is processed differently to generate a new network request according to the request protocol, the network request is processed adaptively under different scenes, and the application range of the method and the device is expanded.
Drawings
Fig. 1 is a diagram illustrating an application scenario of a network request method according to an embodiment of the present application;
fig. 2 is a flowchart illustrating a network request method according to an embodiment of the present application;
FIG. 3 is a block diagram of a network request device according to an embodiment of the present invention;
fig. 4 is a block diagram of an internal structure of a computer device according to an embodiment of the present application.
The implementation, functional features and advantages of the object of the present application will be further explained with reference to the embodiments, and with reference to the accompanying drawings.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The network request method provided by the present application can be applied to the application scenario as shown in fig. 1, wherein the terminal device 110 can be but is not limited to various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices. The server side 120 may be implemented by an independent server or a server cluster composed of a plurality of servers. The terminal device 110 and the server side 120 are connected via a network. If the terminal device 110 monitors the trigger event, traversing the IP address corresponding to the candidate domain name in the pre-stored IP configuration data, and establishing a test connection through the IP address; acquiring round-trip time of each traversed IP address for establishing test connection each time to detect whether each IP address successfully establishes the test connection each time and acquire connection state information; updating the connection data corresponding to the IP address according to the connection state information of each connection establishment test of the IP address; intercepting an original network request sent to a target server, and extracting a target domain name from the original network request; if the target domain name is any candidate domain name, acquiring an IP address corresponding to the target domain name as a candidate IP address, calculating the total weight of each candidate IP address according to a preset rule, IP configuration data corresponding to the target domain name and connection data of the candidate IP address, and taking the candidate IP address with the highest total weight as the target IP address; based on the request protocol of the original network request, updating the original network request according to the target IP address to obtain an updated network request; an updated network request is sent to the server side 120.
The target server and the designated server in the present application are both one of the servers in the server side 120. The designated server is used for storing and managing the IP configuration data of the server corresponding to each candidate domain name. The servers and the terminal device 110 can be connected through a network. Terminal device 110 may request a designated server to obtain IP configuration data corresponding to each candidate domain name, and may also initiate a network request to a server corresponding to each domain name.
The local end of the present application is the local end where the terminal device 110 is located, and the local end includes a local disk and/or a local memory of the terminal device 110.
Fig. 2 is a flowchart illustrating a network request method according to an embodiment of the present application. Referring to fig. 2, the method is illustrated as applied to the terminal device in fig. 1. The network request method includes the following steps S100-S700.
S100: and if the trigger event is monitored, traversing the IP address corresponding to the candidate domain name in the pre-stored IP configuration data, and establishing test connection through the IP address.
Specifically, each candidate domain name corresponds to one piece of IP configuration data, and the IP configuration data is stored locally in the terminal device. The candidate domain names are domain names corresponding to all websites (sites) that the user can access through a specific application program or APP installed in the terminal device. For example, the number of the candidate domain names corresponding to one website may also be any number, such as 1, 2, 3, and the like. One candidate domain name corresponds to at least one IP address.
The triggering events include: over a time interval, or a change in network status occurs.
The network state change comprises the following steps: network disconnection, network switching, for example, switching the network from a 4G or 5G network to a wifi network.
A test connection is established over the IP addresses for testing the availability of each IP address. Due to the complexity of the network environment, the availability of IP addresses has uncertainty, and it is possible that at the last time a certain IP address is available and at the next time the IP address is not available. By repeatedly monitoring and recording the availability of each IP address, the optimal target IP address can be screened out in the domain name resolution process.
More specifically, for example, a timer is set in the terminal device, the timer is triggered once every time a time interval (e.g., 1 minute) elapses to generate a trigger event, and all IP addresses are re-traversed and tested once per the above step S100. Meanwhile, the network state change of the terminal equipment system is monitored, and every time the network state changes, the availability of all the IP addresses is traversed again and tested once according to the step S100.
The test connection may specifically be a socket connection.
S200: and acquiring the round trip time of each traversed IP address for establishing the test connection each time so as to detect whether each IP address successfully establishes the test connection each time and acquire the connection state information.
Specifically, since there are a plurality of total IP addresses, it is necessary to establish test connections by IP addresses one by one. When the establishment of a test connection of a current IP address is completed, the round-trip time for establishing the test connection of the current IP address needs to be acquired, and whether the establishment of the test connection of the current IP address is successful or not is established according to the round-trip time. Thus, the current availability of all IP addresses can be traversed and tested in a complete testing process.
The working principle of step S200 is described below with a specific example:
the time for starting to establish the connection is taken as the starting time, the response data received by the server is taken as the ending time, and the difference value between the starting time and the ending time is taken as the round-trip time. Judging whether the test connection is successfully established or not according to the round-trip time, if the round-trip time exceeds a first time threshold (for example, 5 minutes) or the round-trip time is a second time threshold (for example, 0 minute), indicating that the socket interface is overtime or unavailable, judging that the test connection establishment of the IP address fails, recording the number of times of the test connection establishment failure of the IP address once in terminal equipment (for example, in a memory and/or a disk cache), and simultaneously recording the time point of the failure; if the round trip time is not the second time threshold and does not exceed the first time threshold (for example, 5 minutes), it indicates that the test connection is successfully established, and records the number of times that the connection establishment of the IP address is successful once in the terminal device (for example, in a memory and/or a disk cache), and simultaneously records the time point when the connection establishment is successful. Regardless of whether the connection is successfully established, the round trip time synchronization is maintained, and the record with the time as the second time threshold (e.g., 0 minutes) is rewritten to the first time threshold (e.g., 5 minutes) for subsequent calculations. The server of this embodiment may be a target server or other servers.
S300: and updating the connection data corresponding to the IP address according to the connection state information of the test connection established each time by the IP address.
Specifically, the connection state information is some connection information of the test connection, and includes, for example, whether the connection is successful or not, a time point of the successful connection or a time point of the connection failure, a start time, an expiration time, and the like of the connection. The connection data of an IP address is a statistic of relevant information for all test connections of that IP address.
S400: intercepting an original network request sent to a target server, and extracting a target domain name from the original network request.
Specifically, the original network request is generated by the terminal device according to a user instruction acting on a specific application program or APP or a webpage, the target server is a server that the user wants to access, when the terminal device initiates any network request to the target server, the terminal device firstly intercepts the request, and the original network request carries a target domain name.
S500: if the target domain name is any candidate domain name, acquiring an IP address corresponding to the target domain name as a candidate IP address, calculating the total weight of each candidate IP address according to a preset rule, IP configuration data corresponding to the target domain name and connection data of the candidate IP address, and taking the candidate IP address with the highest total weight as the target IP address.
Specifically, the terminal device obtains a target domain name in the original network request, and determines whether the target domain name can be directly converted into an IP address for transmission by determining whether the target domain name is a candidate target. If the target domain name is the candidate domain name, the target domain name can be directly converted into the IP address, and then the next searching processing is carried out. The next searching process specifically comprises the following steps: and searching whether target IP configuration data corresponding to the target domain name exists in IP configuration data prestored in the terminal equipment. The target IP configuration data includes at least one candidate IP address, and therefore, when the number of the candidate IP addresses is greater than or equal to 2, one target IP address needs to be determined according to the weight of each candidate IP address. The weight of the IP address is related to the IP configuration data, the connection data of the IP address. The weight of the IP address can be determined from multiple dimensions according to the IP configuration data and the connection data of the IP address, and the obtained total weight has more reference significance. The highest total weight indicates that the target IP address is the currently optimal IP address in the candidate IP addresses. The target domain name may be resolved to the target IP address.
S600: and updating the original network request according to the target IP address based on the request protocol of the original network request to obtain an updated network request.
Specifically, different request protocols have different processing modes for the original network request after domain name resolution.
In a specific embodiment, step S600 specifically includes: and if the request protocol is an http protocol, performing first processing on the network request according to the target IP address to obtain a first network request, and taking the first network request as an updated network request. And if the request protocol is an https protocol, performing second processing on the network request according to the target IP address to obtain a second network request, and taking the second network request as an updated network request.
S700: an updated network request is sent to the target server.
Specifically, the terminal device may request data from the target server according to the updated network request.
The IP configuration data corresponding to each candidate domain name is locally stored in the terminal equipment, when a network request sent to a target server is obtained, the network request is intercepted first, a corresponding optimal IP address is searched locally in the terminal equipment, and the original network request is rewritten according to the optimal IP address to obtain a new network request for accessing the target server. According to the method and the device, the domain name does not need to be analyzed by the operator any more, so that the analysis of the operator can be bypassed, and the hijacking risk and data pollution brought by the analysis of the domain name by the operator are avoided. According to the method and the device, the domain name is locally resolved, the step of applying for resolving the domain name to an authoritative server is reduced, the domain name resolving speed is optimized, the weight is calculated from a plurality of candidate IP addresses corresponding to the target domain name according to the connection data of each candidate IP address, and the optimal IP address is selected, and the optimal IP address is the IP address with the optimal connection state, so that the network request speed can be greatly optimized. According to the method and the device, the network request is processed differently to generate a new network request according to the request protocol, the network request is processed adaptively under different scenes, and the application range of the method and the device is expanded.
In one embodiment, before step S100, the method further comprises the steps of:
requesting to obtain IP configuration data corresponding to the candidate domain name from a specified server;
and storing and/or updating the IP configuration data returned by the specified server to the local end.
Specifically, the designated server is an operating server or an application server (for example, a website server including a web server or an app operating server) corresponding to a specific application program in the terminal device, or the designated server is a preset trusted server in which a correspondence relationship between a domain name and an internet protocol IP address and other related information are stored.
The designated server stores domain names corresponding to all websites that can be accessed by a specific application in the terminal device 110, and IP configuration data corresponding to each domain name. Wherein, each domain name can correspond to 1, 2, etc. different IP addresses.
After a specific application program in the terminal equipment is started each time, the IP configuration data corresponding to the candidate domain name is requested from a specified server, and each domain name corresponds to one piece of IP configuration data. The IP configuration data at least includes all IP addresses corresponding to the domain name.
In another specific embodiment, the IP configuration data may include at least one of the following in addition to (1) all IP addresses corresponding to the domain name:
(2) service operator information
(3) Expiry time or validity period for each IP address
(4) IP priority of all IP addresses in the domain name
The local end comprises a local disk and/or a local memory of the terminal equipment.
The appointed server returns the IP configuration data to the terminal equipment according to the request of the terminal equipment, and the terminal equipment detects whether a local disk of the terminal equipment has cache records corresponding to an operator and a domain name: if not, directly caching the IP configuration data in a disk; if so, the old stored record is overwritten or updated according to the IP configuration data.
In one embodiment, the method further comprises: caching the acquired IP configuration data in a memory in a mode that the domain name is key and the IP configuration data is value. Therefore, the search can be accelerated, and the search time is saved. For example: key, value is domain name: IP configuration data.
Of course, the IP configuration data in the disk may also be stored in a form that the domain name is key and the IP configuration data is value.
The searching whether the target IP configuration data corresponding to the target domain name exists in the IP configuration data prestored in the terminal device specifically includes: firstly, searching target IP configuration data corresponding to a target domain name in a local memory cache of the terminal equipment, and if the target IP configuration data corresponding to the target domain name does not exist in the local memory cache of the terminal equipment, searching the target IP configuration data corresponding to the target domain name in a local disk of the terminal equipment.
In one embodiment, after step S400, the method further comprises: and if any candidate domain name cannot be found to be matched with the target domain name, or the target domain name is any candidate domain name but any corresponding candidate IP address cannot be found, sending an original network request to the target server.
Specifically, if the target domain name is not a candidate domain name, the target domain name cannot be directly converted into an IP address, and the original network request is directly sent to the target server. Or, if the target domain name is a candidate domain name, but there is no corresponding IP address in the IP configuration data of the candidate domain name (i.e. the IP address is null) or there is no candidate IP address or there is no target IP address matched with the candidate IP address, the target domain name cannot be converted into any IP address at this time, and at this time, the original network request is also directly sent to the target server. At this time, the domain name resolution in the original network request is not the local resolution of the terminal device, but the domain name resolution is resolved by an authoritative domain name resolution server in the network, which is the prior art and is not described herein again.
In one embodiment, the method further comprises: if any candidate domain name is not matched with the target domain name or any corresponding IP address is not searched, requesting a designated server to acquire target IP configuration data corresponding to the target domain name;
and storing and/or updating target IP configuration data returned by the specified server to the local end.
Specifically, when the network is not good or other operating environments are not good, the requested acquired IP configuration data may be incomplete, and therefore, a candidate domain name that matches the target domain name may not be found, or a matching candidate domain name may not be found, but the corresponding IP address may not be found. At this time, the original network request has been sent, but in order to facilitate finding the target IP configuration data of the target domain name later, the target IP configuration data of the target domain name may be requested to be acquired from the specified server at this time. The purpose of this is to store the IP configuration information of the target domain name to the local terminal device, so that the target IP configuration data of the target domain name can be conveniently and quickly searched.
In one embodiment, the IP configuration data further comprises: at least one of service operator information, an expiration date of each IP address, a priority of the IP address;
the connection data includes: at least one of success and failure times of establishing the test connection, a round trip time of each establishing of the test connection, and a preset time point of each successful establishing of the test connection.
Specifically, the preset time point is a time when the connection is successful.
In one embodiment, in step S500, the step of calculating the total weight of each candidate IP address according to the preset rule, the IP configuration data corresponding to the target domain name, and the connection data of the candidate IP addresses specifically includes the following steps:
screening out undetermined IP addresses meeting screening conditions from the candidate IP addresses according to IP configuration data corresponding to the target domain name and screening rules in preset rules,
and performing sub-weight setting and weight calculation on each undetermined IP address according to the IP configuration data corresponding to the target domain name, the connection data of each undetermined IP address and a weight calculation rule in a preset rule to obtain the total weight of each undetermined IP address.
In particular, although the target domain name may contain multiple candidate IP addresses, not every candidate IP address is available. For example, the validity period of some candidate IP addresses is expired, or service operators of some candidate IP addresses are different from the current device operator of the current terminal device, and the like, these candidate IP addresses which are very easy to eliminate can be directly screened out, so that unnecessary weight calculation is avoided, only the weight of the pending IP address is calculated, the cost of weight calculation is reduced, and the target IP address is quickly screened out, so as to accelerate the network request speed.
In one embodiment, screening out an undetermined IP address meeting the screening condition from candidate IP addresses according to the IP configuration data corresponding to the target domain name and the screening rule in the preset rule includes:
if the IP configuration data corresponding to the target domain name does not contain service operator information and the valid period of each IP address, taking the candidate IP address as an undetermined IP address;
if the IP configuration data corresponding to the target domain name comprises service operator information, screening out a candidate IP address with the same service operator as the current equipment operator from the candidate IP addresses as an undetermined IP address according to the service operator information corresponding to the target domain name;
if the IP configuration data corresponding to the target domain name comprises the valid time limit of each IP address, screening out candidate IP addresses within the valid time limit from the candidate IP addresses as undetermined IP addresses according to the valid time limit of each candidate IP address corresponding to the target domain name;
and if the IP configuration data corresponding to the target domain name comprises service operator information and the valid period of each IP address, screening out candidate IP addresses which are within the valid period and have the same service operator as the current equipment operator from the candidate IP addresses as undetermined IP addresses according to the service operator information corresponding to the target domain name and the valid period of each candidate IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address according to the IP configuration data corresponding to the target domain name and a weight calculation rule in the preset rule to obtain a total weight of each to-be-determined IP address includes:
if the second subdata in the IP configuration data is empty, if the connection data comprises the success times and the failure times of establishing the test connection, respectively setting a first subdeighting weight for each undetermined IP address according to the success times of establishing the test connection of all the undetermined IP addresses, so that the first subdeighting weight of the undetermined IP addresses with less success times is lower than the first subdeighting weight of the undetermined IP addresses with more success times,
setting a second sub-weight for each undetermined IP address according to the failure times of the test connection establishment of all the undetermined IP addresses, so that the second sub-weight of the undetermined IP address with less failure times is higher than the second sub-weight of the undetermined IP address with more failure times,
and performing data processing on the first sub-weight and the second sub-weight of each undetermined IP address to obtain the total weight of each undetermined IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address according to the IP configuration data corresponding to the target domain name and a weight calculation rule in the preset rule to obtain a total weight of each to-be-determined IP address includes:
if the connection data comprises the round trip time of each time or the latest time of establishing the test connection, respectively setting a third sub-weight for each undetermined IP address according to the round trip time of the latest time of establishing the test connection of all undetermined IP addresses, so that the third sub-weight of the undetermined IP address with less round trip time of the latest time of establishing the test connection is higher than the third sub-weight with more round trip time of the latest time of establishing the test connection,
and taking the third sub-weight of each pending IP address as the total weight of the corresponding pending IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address according to the IP configuration data corresponding to the target domain name and a weight calculation rule in the preset rule to obtain a total weight of each to-be-determined IP address includes:
if the connection data comprises the preset time point for successfully establishing the test connection each time or the latest time, respectively setting a fourth sub-weight for each to-be-determined IP address according to the preset time point for successfully establishing the test connection the latest time of all to-be-determined IP addresses, so that the fourth sub-weight of the to-be-determined IP address at the preset time point for successfully establishing the test connection the latest time is closer to the current moment is higher than the fourth sub-weight at the preset time point for successfully establishing the test connection the latest time is farther from the current moment,
and taking the fourth sub-weight of each undetermined IP address as the total weight of the corresponding undetermined IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address according to the IP configuration data corresponding to the target domain name and a weight calculation rule in the preset rule to obtain a total weight of each to-be-determined IP address includes:
if the connection data comprises the success times and the failure times of establishing the test connection and the round trip time of establishing the test connection for each time or the latest time, respectively setting a first sub-weight for each undetermined IP address according to the success times of establishing the test connection for all the undetermined IP addresses, so that the first sub-weight of the undetermined IP address with less success times is lower than the first sub-weight of the undetermined IP address with more success times,
setting a second sub-weight for each undetermined IP address according to the failure times of establishing the test connection of all the undetermined IP addresses, so that the second sub-weight of the undetermined IP address with less failure times is higher than the second sub-weight of the undetermined IP address with more failure times,
setting a third sub-weight for each undetermined IP address according to the round trip time of the latest established test connection of all the undetermined IP addresses, so that the third sub-weight of the undetermined IP address with less round trip time of the latest established test connection is higher than the third sub-weight with more round trip time of the latest established test connection,
and performing data processing on the first sub-weight, the second sub-weight and the third sub-weight of each undetermined IP address to obtain the total weight of each undetermined IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address is performed according to IP configuration data corresponding to a target domain name and a weight calculation rule in a preset rule to obtain a total weight of each to-be-determined IP address, and the method includes:
if the connection data comprises the success times and the failure times of establishing the test connection and the preset time point of successfully establishing the test connection every time or the latest time, respectively setting a first sub-weight for each undetermined IP address according to the success times of establishing the test connection of all the undetermined IP addresses, so that the first sub-weight of the undetermined IP address with less success times is lower than the first sub-weight of the undetermined IP address with more success times,
setting a second sub-weight for each undetermined IP address according to the failure times of establishing the test connection of all the undetermined IP addresses, so that the second sub-weight of the undetermined IP address with less failure times is higher than the second sub-weight of the undetermined IP address with more failure times,
according to the preset time point of the last successful test connection establishment of all the IP addresses to be determined, respectively setting a fourth sub-weight for each IP address to be determined, so that the fourth sub-weight of the IP address to be determined, which is close to the current moment, of the preset time point of the last successful test connection establishment is higher than the fourth sub-weight of the IP address to be determined, which is far away from the current moment, of the preset time point of the last successful test connection establishment,
and performing data processing on the first sub-weight, the second sub-weight and the fourth sub-weight of each undetermined IP address to obtain the total weight of each undetermined IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address according to the IP configuration data corresponding to the target domain name and a weight calculation rule in the preset rule to obtain a total weight of each to-be-determined IP address includes:
if the connection data comprises round trip time for establishing the test connection each time or the latest time and a preset time point for successfully establishing the test connection each time or the latest time, respectively setting a third sub-weight for each undetermined IP address according to the round trip time for establishing the test connection for the latest time of all undetermined IP addresses, so that the third sub-weight of the undetermined IP address with less round trip time for establishing the test connection the latest time is higher than the third sub-weight with more round trip time for establishing the test connection the latest time,
according to the preset time point of the last successful test connection establishment of all the IP addresses to be determined, respectively setting a fourth sub-weight for each IP address to be determined, so that the fourth sub-weight of the IP address to be determined, which is close to the current moment, of the preset time point of the last successful test connection establishment is higher than the fourth sub-weight of the IP address to be determined, which is far away from the current moment, of the preset time point of the last successful test connection establishment,
and carrying out data processing on the third sub-weight and the fourth sub-weight of each undetermined IP address to obtain the total weight of each undetermined IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address according to the IP configuration data corresponding to the target domain name and a weight calculation rule in the preset rule to obtain a total weight of each to-be-determined IP address includes:
if the connection data comprises the success times and the failure times of establishing the test connection, the round trip time of establishing the test connection for each time or the latest time, and the preset time point of successfully establishing the test connection for each time or the latest time, respectively setting a first sub-weight for each undetermined IP address according to the success times of establishing the test connection for all undetermined IP addresses, so that the first sub-weight of the undetermined IP address with less success times is lower than the first sub-weight of the undetermined IP address with more success times,
setting a second sub-weight for each undetermined IP address according to the failure times of establishing the test connection of all the undetermined IP addresses, so that the second sub-weight of the undetermined IP address with less failure times is higher than the second sub-weight of the undetermined IP address with more failure times,
setting a third sub-weight for each undetermined IP address according to the round trip time of the latest established test connection of all the undetermined IP addresses, so that the third sub-weight of the undetermined IP address with less round trip time of the latest established test connection is higher than the third sub-weight with more round trip time of the latest established test connection,
according to the preset time point of the last successful test connection establishment of all the IP addresses to be determined, respectively setting a fourth sub-weight for each IP address to be determined, so that the fourth sub-weight of the IP address to be determined, which is close to the current moment, of the preset time point of the last successful test connection establishment is higher than the fourth sub-weight of the IP address to be determined, which is far away from the current moment, of the preset time point of the last successful test connection establishment,
and performing data processing on the first sub-weight, the second sub-weight, the third sub-weight and the fourth sub-weight of each undetermined IP address to obtain the total weight of each undetermined IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address according to the IP configuration data corresponding to the target domain name and a weight calculation rule in the preset rule to obtain a total weight of each to-be-determined IP address includes:
if the connection data comprises the success frequency and the failure frequency of establishing the test connection, and the IP configuration data corresponding to the target domain name also comprises the priority of the IP address, respectively setting a first sub-weight for each undetermined IP address according to the success frequency of establishing the test connection of all the undetermined IP addresses, so that the first sub-weight of the undetermined IP address with less success frequency is lower than the first sub-weight of the undetermined IP address with more success frequency,
setting a second sub-weight for each undetermined IP address according to the failure times of establishing the test connection of all the undetermined IP addresses, so that the second sub-weight of the undetermined IP address with less failure times is higher than the second sub-weight of the undetermined IP address with more failure times,
according to the IP priority of all the undetermined IP addresses, a fifth sub-weight is respectively set for each undetermined IP address, so that the fifth sub-weight of the undetermined IP address with high priority is higher than the fifth sub-weight of the undetermined IP address with low priority,
and performing data processing on the first sub-weight, the second sub-weight and the fifth sub-weight of each undetermined IP address to obtain the total weight of each undetermined IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address is performed according to IP configuration data corresponding to a target domain name and a weight calculation rule in a preset rule to obtain a total weight of each to-be-determined IP address, and the method includes:
if the connection data comprises the round trip time of each or the latest established test connection and the IP configuration data corresponding to the target domain name also comprises the priority of the IP address, respectively setting a third sub-weight for each undetermined IP address according to the round trip time of the latest established test connection of all the undetermined IP addresses, so that the third sub-weight of the undetermined IP address with less round trip time of the latest established test connection is higher than the third sub-weight with more round trip time of the latest established test connection,
according to the IP priority of all the undetermined IP addresses, a fifth sub-weight is respectively set for each undetermined IP address, so that the fifth sub-weight of the undetermined IP address with high priority is higher than the fifth sub-weight of the undetermined IP address with low priority,
and carrying out data processing on the third sub-weight and the fifth sub-weight of each undetermined IP address to obtain the total weight of each undetermined IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address according to the IP configuration data corresponding to the target domain name and a weight calculation rule in the preset rule to obtain a total weight of each to-be-determined IP address includes:
if the connection data comprises the preset time point of successfully establishing the test connection every time or the latest time, and the IP configuration data corresponding to the target domain name also comprises the priority of the IP address, respectively setting a fourth sub-weight for each undetermined IP address according to the preset time point of successfully establishing the test connection latest for all the undetermined IP addresses, so that the fourth sub-weight of the undetermined IP address at the preset time point of successfully establishing the test connection latest and close to the current moment is higher than the fourth sub-weight of the preset time point of successfully establishing the test connection latest and far from the current moment,
according to the IP priority of all the undetermined IP addresses, a fifth sub-weight is respectively set for each undetermined IP address, so that the fifth sub-weight of the undetermined IP address with high priority is higher than the fifth sub-weight of the undetermined IP address with low priority,
and carrying out data processing on the fourth sub-weight and the fifth sub-weight of each undetermined IP address to obtain the total weight of each undetermined IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address according to the IP configuration data corresponding to the target domain name and a weight calculation rule in the preset rule to obtain a total weight of each to-be-determined IP address includes:
if the connection data comprises the success times and the failure times of establishing the test connection, the round trip time of establishing the test connection for each time or the latest time, and the IP configuration data corresponding to the target domain name also comprises the priority of the IP address, respectively setting a first sub-weight for each undetermined IP address according to the success times of establishing the test connection for all the undetermined IP addresses, so that the first sub-weight of the undetermined IP address with less success times is lower than the first sub-weight of the undetermined IP address with more success times,
setting a second sub-weight for each undetermined IP address according to the failure times of establishing the test connection of all the undetermined IP addresses, so that the second sub-weight of the undetermined IP address with less failure times is higher than the second sub-weight of the undetermined IP address with more failure times,
setting a third sub-weight for each undetermined IP address according to the round trip time of the latest established test connection of all the undetermined IP addresses, so that the third sub-weight of the undetermined IP address with less round trip time of the latest established test connection is higher than the third sub-weight with more round trip time of the latest established test connection,
according to the IP priority of all the undetermined IP addresses, a fifth sub-weight is respectively set for each undetermined IP address, so that the fifth sub-weight of the undetermined IP address with high priority is higher than the fifth sub-weight of the undetermined IP address with low priority,
and performing data processing on the first sub-weight, the second sub-weight, the third sub-weight and the fifth sub-weight of each undetermined IP address to obtain the total weight of each undetermined IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address according to the IP configuration data corresponding to the target domain name and a weight calculation rule in the preset rule to obtain a total weight of each to-be-determined IP address includes:
if the connection data comprises the success times and the failure times of establishing the test connection, the preset time point of successfully establishing the test connection every time or the latest time, and the IP configuration data corresponding to the target domain name also comprises the priority of the IP address, respectively setting a first sub-weight for each undetermined IP address according to the success times of establishing the test connection of all the undetermined IP addresses, so that the first sub-weight of the undetermined IP address with less success times is lower than the first sub-weight of the undetermined IP address with more success times,
setting a second sub-weight for each undetermined IP address according to the failure times of establishing the test connection of all the undetermined IP addresses, so that the second sub-weight of the undetermined IP address with less failure times is higher than the second sub-weight of the undetermined IP address with more failure times,
according to the preset time point of the last successful test connection establishment of all the IP addresses to be determined, respectively setting a fourth sub-weight for each IP address to be determined, so that the fourth sub-weight of the IP address to be determined, which is close to the current moment, of the preset time point of the last successful test connection establishment is higher than the fourth sub-weight of the IP address to be determined, which is far away from the current moment, of the preset time point of the last successful test connection establishment,
according to the IP priority of all the undetermined IP addresses, a fifth sub-weight is respectively set for each undetermined IP address, so that the fifth sub-weight of the undetermined IP address with high priority is higher than the fifth sub-weight of the undetermined IP address with low priority,
and performing data processing on the first sub-weight, the second sub-weight, the fourth sub-weight and the fifth sub-weight of each undetermined IP address to obtain the total weight of each undetermined IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address according to the IP configuration data corresponding to the target domain name and a weight calculation rule in the preset rule to obtain a total weight of each to-be-determined IP address includes:
if the connection data comprises round trip time for establishing the test connection each time or the latest time, a preset time point for successfully establishing the test connection each time or the latest time, and the IP configuration data corresponding to the target domain name also comprises the priority of the IP address, respectively setting a third sub-weight for each undetermined IP address according to the round trip time for establishing the test connection for the latest time of all the undetermined IP addresses, so that the third sub-weight of the undetermined IP address with less round trip time for establishing the test connection the latest time is higher than the third sub-weight with more round trip time for establishing the test connection the latest time,
according to the preset time point of the last successful test connection establishment of all the IP addresses to be determined, respectively setting a fourth sub-weight for each IP address to be determined, so that the fourth sub-weight of the IP address to be determined, which is close to the current moment, of the preset time point of the last successful test connection establishment is higher than the fourth sub-weight of the IP address to be determined, which is far away from the current moment, of the preset time point of the last successful test connection establishment,
according to the IP priority of all the undetermined IP addresses, a fifth sub-weight is respectively set for each undetermined IP address, so that the fifth sub-weight of the undetermined IP address with high priority is higher than the fifth sub-weight of the undetermined IP address with low priority,
and carrying out data processing on the third sub-weight, the fourth sub-weight and the fifth sub-weight of each undetermined IP address to obtain the total weight of each undetermined IP address.
In one embodiment, the sub-weight setting and weight calculation of each to-be-determined IP address according to the IP configuration data corresponding to the target domain name and a weight calculation rule in the preset rule to obtain a total weight of each to-be-determined IP address includes:
if the connection data comprises the success times and the failure times of establishing the test connection, the round trip time of establishing the test connection for each time or the latest time, the preset time point of successfully establishing the test connection for each time or the latest time, and the IP configuration data corresponding to the target domain name also comprises the priority of the IP address, respectively setting a first sub-weight for each undetermined IP address according to the success times of establishing the test connection for all undetermined IP addresses, so that the first sub-weight of the undetermined IP address with less success times is lower than the first sub-weight of the undetermined IP address with more success times,
setting a second sub-weight for each undetermined IP address according to the failure times of establishing the test connection of all the undetermined IP addresses, so that the second sub-weight of the undetermined IP address with less failure times is higher than the second sub-weight of the undetermined IP address with more failure times,
setting a third sub-weight for each undetermined IP address according to the round trip time of the latest established test connection of all the undetermined IP addresses, so that the third sub-weight of the undetermined IP address with less round trip time of the latest established test connection is higher than the third sub-weight with more round trip time of the latest established test connection,
according to the preset time point of the last successful test connection establishment of all the IP addresses to be determined, respectively setting a fourth sub-weight for each IP address to be determined, so that the fourth sub-weight of the IP address to be determined, which is close to the current moment, of the preset time point of the last successful test connection establishment is higher than the fourth sub-weight of the IP address to be determined, which is far away from the current moment, of the preset time point of the last successful test connection establishment,
according to the IP priority of all the undetermined IP addresses, a fifth sub-weight is respectively set for each undetermined IP address, so that the fifth sub-weight of the undetermined IP address with high priority is higher than the fifth sub-weight of the undetermined IP address with low priority,
and performing data processing on the first sub-weight, the second sub-weight, the third sub-weight, the fourth sub-weight and the fifth sub-weight of each undetermined IP address to obtain the total weight of each undetermined IP address.
More specifically, the data processing may be summing; or may be a weighted sum.
More specifically, the success times of establishing connection of all the undetermined IP addresses are obtained, the first sub-weight of the undetermined IP address with the highest success times is assigned as a first numerical value according to the sequence from high to low, if the connection success times of the next undetermined IP address is the same as the previous connection success times, the first sub-weight of the next IP address is assigned as the previous first sub-weight minus a first difference value; and analogizing to obtain the first sub-weight of each pending IP address.
Acquiring the connection establishing failure times of all the undetermined IP addresses, assigning a second sub weight of the undetermined IP address with the lowest failure time as a second numerical value according to the sequence from low to high, assigning the connection failure time of the next undetermined IP address as the same numerical value if the connection failure time is the same as the previous connection failure time, and otherwise assigning the second sub weight of the next IP address as the previous second sub weight minus a second difference; and analogizing to obtain a second sub-weight of each pending IP address.
The round trip time of all the undetermined IP addresses is obtained, according to the sequence from small to large, the third sub-weight of the undetermined IP address with the minimum round trip time is assigned as a third numerical value, if the round trip time of the next IP address is the same as the previous round trip time, the third sub-weight of the next adjacent undetermined IP address is assigned as the previous third sub-weight, and a third difference value is subtracted from the previous third sub-weight; and analogizing to obtain a third sub-weight of each undetermined IP address.
Acquiring a preset time point at which all the undetermined IP addresses successfully establish the test connection last time, assigning a fourth sub-weight of the undetermined IP address at the latest time point as a fourth numerical value according to the sequence of the preset time points from near to far, assigning the time point at which the next undetermined IP address successfully establishes the connection last time as the previous time point, assigning the time point as the same numerical value, and otherwise, assigning the fourth sub-weight of the next undetermined IP address as the fourth sub-weight of the previous undetermined IP address minus a fourth difference value; and analogizing to obtain a fourth sub-weight of each undetermined IP address.
Acquiring the recommended priorities of servers of all the undetermined IP addresses, assigning a fifth sub-weight of the undetermined IP address corresponding to the highest priority as a fifth numerical value according to the sequence of the priorities from high to low, assigning the fifth sub-weight of the next undetermined IP address as the same numerical value if the priority of the next undetermined IP address is the same as the previous priority, and otherwise, assigning the fifth sub-weight of the next undetermined IP address as the previous fifth sub-weight minus a fifth difference; and analogizing to obtain a fifth sub-weight of each undetermined IP address.
In one embodiment, step S400 specifically includes:
if the original network request does not belong to the request in the player, intercepting the original network request by utilizing a configured URL loading system middle layer;
if the original network request belongs to the request in the player, intercepting a calling network request interface of the player in a HOOK mode to intercept the original network request.
Specifically, the original network requests that do not belong to the request in the player include Native network requests and the network requests sent by H5 in Webview.
In one embodiment, step S600 specifically includes the following steps:
if the request protocol is an http protocol, replacing a target domain name in the original network request with a target IP address, adding a host field in a request header of the original network request to obtain a first network request, and using the first network request as an updated network request, wherein the host field can be used for indicating the target domain name, the host field comprises key-value data, and the key is 'host' and the value is 'target domain name';
if the request protocol is https protocol, if the target server corresponds to a plurality of different domain names including the target domain name, constructing a mapping relation between the target IP address and the target domain name,
replacing a target domain name in the original network request with a target IP address, adding a host field in a request header of the original network request, setting a mapping relation in the original network request to obtain a second network request, and taking the second network request as an updated network request, wherein the host field comprises key-value data, and the key is 'host' and the value is 'target domain name'.
Specifically, if the domain name is the http protocol, after the original network request is updated, the first network request is sent out to complete the direct connection with the target server, so that the resolution of a service operator is bypassed, and data pollution and network threat caused by domain name hijacking are effectively avoided. The mapping relationship between the IP and the domain name may be { domain name }:443: { IP }.
If the https protocol is adopted, the terminal device needs to perform SSL/TSL handshake with the target server. In the handshake process, the terminal device needs to verify whether the target server is a trusted server.
Specifically, the terminal device sends a handshake request to a target server, the target server sends a certificate to the terminal device after receiving the handshake request, the terminal device determines whether the certificate sent by the target server is issued by a trusted authority, the terminal device checks whether a domain name carried in the certificate includes a target domain name in the network request, if the certificate is issued by the trusted authority and includes the target domain name, the target server is determined to be the trusted server, and if the certificate is not issued by the trusted authority or does not include the target domain name, the target server is determined not to be the trusted server.
The target server sends an authentication challenge to the terminal equipment, the terminal equipment receives the authentication challenge, and in the callback of the authentication challenge, the original target domain name is used for authentication and a Credential is constructed and returned to the target server side, so that the target server can verify the validity of the terminal equipment.
If one target server has a plurality of domain names, corresponding different certificates under different domain names, at this time, the terminal device may not be able to distinguish whether the certificate issued by the target server is issued by a trusted authority, and SSL/TSL handshake failure occurs. In this case, the target server may correspond to a plurality of domain names, which may cause misjudgment of the terminal device. Therefore, in order to avoid the occurrence of misjudgment, the mapping relationship between the target IP address and the target domain name needs to be added in the original network request. The mapping relationship is specifically constructed according to libcurl (library).
In an embodiment, the adding the host field to the request header of the original network request specifically includes the following steps:
and decrypting the encrypted target domain name, and adding the decrypted target domain name serving as a value and a host serving as a key to the original network request in a key-value form.
In particular, some terminal devices may audit network requests due to the fact that the installed system is unique. Therefore, the target domain name needs to be stored in plaintext, that is, encrypted, and specifically AES encryption can be used. When the host field is generated by using the target domain name, the encrypted data needs to be decrypted to obtain the target domain name, so that the detection and the verification of a special system can be avoided. The step of encrypting the target domain name may be performed at any stage after the target domain name is extracted from the original network request in step S400.
In one embodiment, the method further comprises the steps of:
if a redirection response returned by the target server is received after an updated network request or an original network request is sent to the target server, request information in the original network request is obtained, wherein the request information comprises a request head, a request body and a request mode;
extracting a redirection domain name from the redirection response;
constructing an input stream object, and generating a third network request by using the input stream object according to request information and a redirection domain name in the original network request;
adding the third network request into the circular queue as a message to be consumed, and waiting for consumption;
intercepting a third network request for consumption, and extracting a redirection domain name from the third network request;
if the redirection domain name is any candidate domain name, acquiring an IP address corresponding to the redirection domain name as a redirection candidate IP address, calculating the total weight of each redirection candidate IP address according to a preset rule, IP configuration data corresponding to the redirection domain name and connection data of the redirection candidate IP address, and taking the redirection candidate IP address with the highest total weight as a redirection target IP address;
based on the request protocol of the third network request, updating the third network request according to the redirection target IP address to obtain a fourth network request;
and sending the fourth network request to a server corresponding to the redirection domain name.
Specifically, redirection (Redirect) is to Redirect various network requests to other locations by various methods (e.g., web page redirection, domain name redirection, and routing change are also a kind of redirection of data messages via paths). If the interface of the target server is configured with redirection logic or codes, the target server returns a redirection response to the terminal after sending the network request to the target server. And the terminal receives the redirection response, which indicates that the network request is redirected. When redirection occurs, the terminal can reacquire the request information in the original network request, and copy the extracted redirection domain name and the request information into the input stream object, and the input stream object regenerates the third network request according to the redirection domain name and the request information. The third network request belongs to a new network request. The third network request is placed in a current system event sequential queue, the system can trigger the request call at a proper time, the retransmitted third network request can be intercepted as the original network request and processed as the original network request, if the redirection domain name is a candidate domain name, the redirection target IP address of the third network request is obtained, the third network request is updated according to the redirection target IP address, a fourth network request is obtained, and the terminal can send the fourth network request to a server corresponding to the redirection domain name.
And if the redirected domain name is not the candidate domain name, or the redirected domain name is any candidate domain name but any corresponding redirected candidate IP address cannot be found, sending a third network request to the server corresponding to the redirected domain name.
For a request method for redirecting the third network request corresponding to the domain name, refer to the request method of the original network request specifically, and are not described herein again.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Fig. 3 is a block diagram of a network request device according to an embodiment of the present application, and referring to fig. 3, the network request device includes:
the connection module 100 is configured to traverse an IP address corresponding to a candidate domain name in pre-stored IP configuration data if a trigger event is monitored, and establish a test connection through the IP address;
the detection module 200 is configured to obtain round-trip time of each traversed IP address for establishing a test connection each time, so as to detect whether each IP address successfully establishes a test connection each time, and obtain connection state information;
a data updating module 300, configured to update connection data of a corresponding IP address according to connection state information of each connection establishment test for the IP address;
an intercepting module 400, configured to intercept an original network request sent to a target server, and extract a target domain name from the original network request;
a calculating module 500, configured to, if the target domain name is any candidate domain name, obtain an IP address corresponding to the target domain name as a candidate IP address, calculate a total weight of each candidate IP address according to a preset rule, IP configuration data corresponding to the target domain name, and connection data of the candidate IP address, and use the candidate IP address with the highest total weight as the target IP address;
a request update module 600, configured to update an original network request according to a target IP address based on a request protocol of the original network request, so as to obtain an updated network request;
a sending module 700, configured to send the updated network request to the target server.
In one embodiment, the apparatus further comprises:
the configuration data request module is used for requesting the appointed server to acquire IP configuration data corresponding to the candidate domain name;
and the storage module is used for storing and/or updating the IP configuration data returned by the specified server to the local end.
In an embodiment, the sending module 700 is further configured to send the original network request if any candidate domain name is not found to match the target domain name, or the target domain name is any candidate domain name but any corresponding candidate IP address is not found.
In one embodiment, the IP configuration data further comprises: at least one of service operator information, an expiration date of each IP address, a priority of the IP address;
the connection data includes: at least one of success and failure times of establishing the test connection, a round trip time of each establishing of the test connection, and a preset time point of each successful establishing of the test connection.
In one embodiment, the calculation module 500 specifically includes:
a screening module used for screening out the undetermined IP address meeting the screening condition from the candidate IP addresses according to the IP configuration data corresponding to the target domain name and the screening rule in the preset rule,
and the weight calculation module is used for performing sub-weight setting and weight calculation on each undetermined IP address according to the IP configuration data corresponding to the target domain name, the connection data of each undetermined IP address and a weight calculation rule in a preset rule to obtain the total weight of each undetermined IP address.
In one embodiment, the intercepting module 400 specifically includes:
the first interception module is used for intercepting the original network request by utilizing a middle layer of a configured URL loading system if the original network request does not belong to the request in the player;
and the second interception module is used for intercepting a calling network request interface of the player in a HOOK mode to intercept the original network request if the original network request belongs to the request in the player.
In one embodiment, the request update module 600 specifically includes:
the first updating module is used for replacing a target domain name in the original network request with a target IP address if the request protocol is an http protocol, adding a host field in a request header of the original network request to obtain a first network request, and taking the first network request as an updated network request, wherein the host field comprises key-value data, and the key is 'host' and the value is 'target domain name';
a first constructing module, configured to construct a mapping relationship between the target IP address and the target domain name if the target server corresponds to a plurality of different domain names including the target domain name if the request protocol is https protocol,
the second updating module is used for replacing the target domain name in the original network request with the target IP address, adding a host field in a request header of the original network request, setting the mapping relation in the original network request to obtain a second network request, and taking the second network request as an updated network request, wherein the host field comprises key-value data, and the key is 'host' and the value is 'target domain name'.
In one embodiment, the apparatus further comprises:
the request information acquisition module is used for acquiring request information in the original network request if a redirection response returned by the target server is received after an updated network request or the original network request is sent to the target server, wherein the request information comprises a request head, a request body and a request mode;
the domain name extraction module is used for extracting a redirection domain name from the redirection response;
the second construction module is used for constructing an input stream object and generating a third network request by using the input stream object according to the request information and the redirection domain name in the original network request;
the enqueue module is used for adding the third network request into the circular queue as a message to be consumed and waiting for consumption;
the re-interception module intercepts a third network request for consumption and extracts a redirection domain name from the third network request;
the calculation module is further used for acquiring the IP address corresponding to the redirection domain name as a redirection candidate IP address if the redirection domain name is any candidate domain name, calculating the total weight of each redirection candidate IP address according to a preset rule, IP configuration data corresponding to the redirection domain name and connection data of the redirection candidate IP address, and taking the redirection candidate IP address with the highest total weight as a redirection target IP address;
the request updating module is also used for updating the third network request according to the redirection target IP address based on the request protocol of the third network request to obtain a fourth network request;
and the sending module is further used for sending a fourth network request to the server corresponding to the redirected domain name.
The network requesting device is generally provided in the terminal device.
Wherein the meaning of "first" and "second" in the above modules/units is only to distinguish different modules/units, and is not used to define which module/unit has higher priority or other defining meaning. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or modules is not necessarily limited to those steps or modules explicitly listed, but may include other steps or modules not explicitly listed or inherent to such process, method, article, or apparatus, and such that a division of modules presented in this application is merely a logical division and may be implemented in a practical application in a further manner.
For specific limitations of the network request device, reference may be made to the above limitations of the network request method, which is not described herein again. The various modules in the network request device described above may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
Fig. 4 is a block diagram of an internal structure of a computer device according to an embodiment of the present application. The computer device may specifically be the terminal device in fig. 1. As shown in fig. 4, the computer apparatus includes a processor, a memory, a network interface, an input device, and a display screen connected through a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory includes a storage medium and an internal memory. The storage medium may be a nonvolatile storage medium or a volatile storage medium. The storage medium stores an operating system and may also store computer readable instructions that, when executed by the processor, may cause the processor to implement the network request method. The internal memory provides an environment for the operating system and execution of computer readable instructions in the storage medium. The internal memory may also have stored therein computer readable instructions that, when executed by the processor, cause the processor to perform a network request method. The network interface of the computer device is used for communicating with an external server through a network connection. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
In one embodiment, a computer device is provided, which includes a memory, a processor, and computer readable instructions (e.g., a computer program) stored on the memory and executable on the processor, and when the processor executes the computer readable instructions, the steps of the network request method in the above embodiments are implemented, for example, steps S100 to S700 shown in fig. 2 and other extensions of the method and related steps. Alternatively, the processor, when executing the computer readable instructions, implements the functions of the modules/units of the network request apparatus in the above embodiments, such as the functions of the modules 100 to 700 shown in fig. 3. To avoid repetition, further description is omitted here.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, the processor being the control center of the computer device and the various interfaces and lines connecting the various parts of the overall computer device.
The memory may be used to store computer readable instructions and/or modules, and the processor may implement various functions of the computer apparatus by executing or executing the computer readable instructions and/or modules stored in the memory and invoking data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, video data, etc.) created according to the use of the cellular phone, etc.
The memory may be integrated in the processor or may be provided separately from the processor.
Those skilled in the art will appreciate that the architecture shown in fig. 4 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer readable storage medium is provided, on which computer readable instructions are stored, which when executed by a processor implement the steps of the network request method in the above embodiments, such as the steps S100 to S700 shown in fig. 2 and extensions of other extensions and related steps of the method. Alternatively, the computer readable instructions, when executed by the processor, implement the functions of the modules/units of the network request apparatus in the above embodiments, such as the functions of the modules 100 to 700 shown in fig. 3. To avoid repetition, further description is omitted here.
It will be understood by those of ordinary skill in the art that all or part of the processes of the methods of the embodiments described above may be implemented by instructing associated hardware to implement computer readable instructions, which may be stored in a computer readable storage medium, and when executed, may include processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), synchronous Link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above-mentioned serial numbers of the embodiments of the present application are merely for description, and do not represent the advantages and disadvantages of the embodiments. Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present application may be substantially or partially embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present application.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are included in the scope of the present application.

Claims (10)

1. A network request method, the method comprising:
if a trigger event is monitored, traversing the IP address corresponding to the candidate domain name in the prestored IP configuration data, and establishing test connection through the IP address;
acquiring round-trip time of each traversed IP address for establishing test connection each time to detect whether each IP address establishes test connection each time successfully, and acquiring connection state information, wherein the connection state information comprises whether the current test connection is successful, the starting time and the ending time of connection, and a preset time point of connection success or failure;
updating connection data corresponding to the IP address according to the connection state information of each test connection establishment of the IP address, wherein the connection data comprises at least one of success times and failure times of the test connection establishment of the corresponding IP address, round-trip time of each test connection establishment, and preset time points of each test connection establishment;
intercepting an original network request sent to a target server, and extracting a target domain name from the original network request;
if the target domain name is any one of the candidate domain names, acquiring an IP address corresponding to the target domain name as a candidate IP address, screening undetermined IP addresses meeting screening conditions from the candidate IP addresses according to IP configuration data corresponding to the target domain name and screening rules in preset rules, performing sub-weight setting and weight calculation on each undetermined IP address according to the IP configuration data corresponding to the target domain name, connection data of each undetermined IP address and weight calculation rules in the preset rules to obtain the total weight of each undetermined IP address, and taking the undetermined IP address with the highest total weight as the target IP address;
based on the request protocol of the original network request, updating the original network request according to the target IP address to obtain an updated network request;
sending the updated network request to the target server.
2. The method according to claim 1, wherein before traversing the IP address corresponding to the candidate domain name in the pre-stored IP configuration data and establishing the test connection through the IP address if the trigger event is monitored, the method further comprises:
requesting to obtain IP configuration data corresponding to the candidate domain name from a specified server;
and storing and/or updating the IP configuration data returned by the specified server to a local end.
3. The method according to claim 1 or 2, wherein after intercepting an original network request sent to a target server and extracting a target domain name from the original network request, the method further comprises:
and if any candidate domain name cannot be found to be matched with the target domain name, or the target domain name is any candidate domain name but any corresponding candidate IP address cannot be found, sending the original network request to the target server.
4. The method according to claim 1, wherein the step of screening out the undetermined IP address meeting the screening condition from the candidate IP addresses according to the IP configuration data corresponding to the target domain name and a screening rule in a preset rule includes:
if the IP configuration data corresponding to the target domain name does not contain service operator information and the valid period of each candidate IP address, taking the candidate IP address as an undetermined IP address;
if the IP configuration data corresponding to the target domain name comprises service operator information, screening out a candidate IP address with the same service operator as the current equipment operator from the candidate IP addresses as an undetermined IP address according to the service operator information corresponding to the target domain name;
if the IP configuration data corresponding to the target domain name comprises the valid period of each candidate IP address, screening out the candidate IP addresses within the valid period from the candidate IP addresses according to the valid period of each candidate IP address to serve as undetermined IP addresses;
if the IP configuration data corresponding to the target domain name comprises service operator information and the valid period of each candidate IP address, screening out candidate IP addresses which are within the valid period and have the same service operator as the current equipment operator from the candidate IP addresses to serve as undetermined IP addresses according to the service operator information corresponding to the target domain name and the valid period of each candidate IP address.
5. The method of claim 1 or 2, wherein intercepting the original network request sent to the target server comprises:
if the original network request does not belong to the request in the player, intercepting the original network request by utilizing a configured URL loading system middle layer;
and if the original network request belongs to the request in the player, intercepting a calling network request interface of the player in a HOOK mode to intercept the original network request.
6. The method according to claim 1 or 2, wherein the updating the original network request according to the target IP address based on the request protocol of the original network request to obtain an updated network request comprises:
if the request protocol is an http protocol, replacing the target domain name in the original network request with the target IP address, adding a host field in a request head of the original network request to obtain a first network request, and taking the first network request as an updated network request;
if the request protocol is an https protocol and the target server corresponds to a plurality of different domain names including the target domain name, constructing a mapping relation between the target IP address and the target domain name, replacing the target domain name in the original network request with the target IP address, adding a host field to a request header of the original network request, setting the mapping relation in the original network request to obtain a second network request, and taking the second network request as an updated network request.
7. The method of claim 3, further comprising:
if a redirection response returned by the target server is received after the updated network request or the original network request is sent to the target server, request information in the original network request is obtained, wherein the request information comprises a request head, a request body and a request mode;
extracting a redirection domain name from the redirection response;
constructing an input stream object, and generating a third network request by using the input stream object according to request information and a redirection domain name in the original network request;
adding the third network request into a circular queue to serve as a message to be consumed, and waiting for consumption;
intercepting a third network request for consumption, and extracting a redirection domain name from the third network request;
if the redirection domain name is any candidate domain name, acquiring an IP address corresponding to the redirection domain name as a redirection candidate IP address, calculating the total weight of each redirection candidate IP address according to a preset rule, IP configuration data corresponding to the redirection domain name and connection data of the redirection candidate IP address, and taking the redirection candidate IP address with the highest total weight as a redirection target IP address;
based on the request protocol of the third network request, updating the third network request according to the redirection target IP address to obtain a fourth network request;
and sending the fourth network request to a server corresponding to the redirection domain name.
8. A network request apparatus, the apparatus comprising:
the connection module is used for traversing the IP address corresponding to the candidate domain name in the pre-stored IP configuration data and establishing test connection through the IP address if a trigger event is monitored;
the detection module is used for acquiring round-trip time of each traversed IP address for establishing test connection each time so as to detect whether each IP address successfully establishes the test connection each time and acquire connection state information, wherein the connection state information comprises whether the current test connection is successful, the starting time and the ending time of the connection, and the preset time point of connection success or failure;
the data updating module is used for updating the connection data of the corresponding IP address according to the connection state information of the test connection established by the IP address each time, wherein the connection data comprises at least one of the success times and the failure times of the test connection established by the corresponding IP address, the round trip time of the test connection established each time and the preset time point of the test connection established each time successfully;
the intercepting module is used for intercepting an original network request sent to a target server and extracting a target domain name from the original network request;
the calculation module is used for acquiring an IP address corresponding to the target domain name as a candidate IP address if the target domain name is any one of the candidate domain names, screening undetermined IP addresses meeting screening conditions from the candidate IP addresses according to IP configuration data corresponding to the target domain name and screening rules in preset rules, performing sub-weight setting and weight calculation on each undetermined IP address according to the IP configuration data corresponding to the target domain name, connection data of each undetermined IP address and weight calculation rules in the preset rules to obtain the total weight of each undetermined IP address, and taking the undetermined IP address with the highest total weight as the target IP address;
a request updating module, configured to update the original network request according to the target IP address based on a request protocol of the original network request, so as to obtain an updated network request;
a sending module, configured to send the updated network request to the target server.
9. A computer device comprising a memory, a processor, and computer readable instructions stored on the memory and executable on the processor, wherein the processor when executing the computer readable instructions performs the steps of the method of any one of claims 1-7.
10. A computer readable storage medium having computer readable instructions stored thereon, which, when executed by a processor, cause the processor to perform the steps of the method of any one of claims 1-7.
CN202110703062.9A 2021-06-24 2021-06-24 Network request method, device, equipment and storage medium Active CN113438336B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110703062.9A CN113438336B (en) 2021-06-24 2021-06-24 Network request method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110703062.9A CN113438336B (en) 2021-06-24 2021-06-24 Network request method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113438336A CN113438336A (en) 2021-09-24
CN113438336B true CN113438336B (en) 2022-07-08

Family

ID=77753829

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110703062.9A Active CN113438336B (en) 2021-06-24 2021-06-24 Network request method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113438336B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114024869B (en) * 2021-11-04 2023-06-02 山东中创软件商用中间件股份有限公司 Method, device, equipment and storage medium for detecting network connection state between terminals
CN115296915B (en) * 2022-08-08 2023-07-18 广州华多网络科技有限公司 Webpage data access method and device, equipment, medium and product thereof

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104065761A (en) * 2011-09-29 2014-09-24 北京奇虎科技有限公司 Application server selecting method and network connection method
CN104158919A (en) * 2014-08-20 2014-11-19 安一恒通(北京)科技有限公司 Webpage access implementation method, server and client
CN110351115A (en) * 2019-05-23 2019-10-18 中国平安财产保险股份有限公司 Reduce method, apparatus, computer equipment and the storage medium of network access time delay

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104901943A (en) * 2012-03-31 2015-09-09 北京奇虎科技有限公司 Method and system for accessing website
US20170207989A1 (en) * 2016-01-14 2017-07-20 Dell Software Inc. Dynamic domain name system destination selection
CN107277025A (en) * 2017-06-28 2017-10-20 维沃移动通信有限公司 A kind of Secure Network Assecc method, mobile terminal and computer-readable recording medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104065761A (en) * 2011-09-29 2014-09-24 北京奇虎科技有限公司 Application server selecting method and network connection method
CN104158919A (en) * 2014-08-20 2014-11-19 安一恒通(北京)科技有限公司 Webpage access implementation method, server and client
CN110351115A (en) * 2019-05-23 2019-10-18 中国平安财产保险股份有限公司 Reduce method, apparatus, computer equipment and the storage medium of network access time delay

Also Published As

Publication number Publication date
CN113438336A (en) 2021-09-24

Similar Documents

Publication Publication Date Title
US10574698B1 (en) Configuration and deployment of decoy content over a network
US8875220B2 (en) Proxy-based network access protection
CN113438336B (en) Network request method, device, equipment and storage medium
US11689514B2 (en) User authentication in communication systems
CN113381979B (en) Access request proxy method and proxy server
US20220353293A1 (en) Identification of triggering events correlated with dns requests for increased security
US20190114630A1 (en) Transient Transaction Server DNS Strategy
CN111431753A (en) Asset information updating method, device, equipment and storage medium
WO2023045196A1 (en) Access request capturing method and apparatus, computer device, and storage medium
CN113194099B (en) Data proxy method and proxy server
CN114745145B (en) Business data access method, device and equipment and computer storage medium
US10360379B2 (en) Method and apparatus for detecting exploits
CN111541649B (en) Password resetting method and device, server and storage medium
US10841276B2 (en) Method and system for carrying out a sensitive operation in the course of a communication session
CN109587134B (en) Method, apparatus, device and medium for secure authentication of interface bus
CN113709136B (en) Access request verification method and device
US11736528B2 (en) Low latency cloud-assisted network security with local cache
US9787658B2 (en) Login system based on server, login server, and verification method thereof
CN115189897A (en) Access processing method and device for zero trust network, electronic equipment and storage medium
RU2751436C1 (en) Method and system for dynamic global identification of user's environment
KR102286029B1 (en) Method for authentication, user terminal and authentication server for executing the same
CN114143106B (en) Approval method and device, electronic equipment and storage medium
CN117240910B (en) Zero trust verification system and method
US20230216830A1 (en) Client-side firewall
US20230023721A1 (en) Method for processing domain name resolution requests

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
GR01 Patent grant
GR01 Patent grant