Service agent method, device, computer-readable storage medium and electronic device

By automatically updating the target list and mapping access address ports, automatic service proxying on the proxy device is realized, solving the problems of high labor costs and missed service processing, and ensuring normal forwarding of services.

CN116112555BActive Publication Date: 2024-11-15HILLSTONE NETWORKS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211711985.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-29
Publication Date
2024-11-15
Estimated Expiration
2042-12-29

AI Technical Summary

Technical Problem

In the prior art, relying on manual addition of proxy address ports on proxy devices leads to high labor costs, and inadequate addition in scenarios with many services, it is prone to errors and leads to missed service processing.

Method used

By obtaining the transmission control protocol connection request of the target client, automatically update the target list, create a connection between the network packet sending and receiving process and the client, map the access address port to the target address port, and send the network packet to the protocol stack to realize the target proxy Process processing and forwarding of data content.

Benefits of technology

It reduces labor costs, avoids the error of adding address ports on the proxy device, realizes automatic proxying for unproxy address port services, and ensures normal forwarding of service processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116112555B_ABST
    Figure CN116112555B_ABST
Patent Text Reader

Abstract

The present invention discloses a service proxy method, device, computer-readable storage medium and electronic device. The method comprises: obtaining a transmission control protocol connection request sent by a target client, determining a first access address port corresponding to the transmission control protocol connection request; if the first access address port does not exist in the first target list, updating the first target list based on the first access address port; if the first access address port exists in the first target list, creating a transmission control protocol connection between a network packet transceiver process and the target client, and obtaining the first network packet sent by the target client; determining a second target network packet based on the first network packet; sending the second target network packet to the protocol stack, so that the target proxy process performs service proxy based on the target data content corresponding to the second target network packet. The present invention solves the technical problem of high labor cost caused by relying on manual addition of proxy address ports on proxy devices in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to a service proxy method, device, computer-readable storage medium and electronic device. Background Art

[0002] It is quite common to set up reverse proxy devices for services (such as web services, etc.), such as doing statistics and threat detection on the proxy devices. The proxy device needs to terminate the client's connection, process it, and then initiate a new connection to the server to forward the client's request data. At present, administrators are generally required to manually add proxy ports on the proxy device. In scenarios with many services, this method of adding is not only labor-intensive and error-prone, but also causes new services to fail to be added in time, resulting in missed business processing.

[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0004] The embodiments of the present invention provide a service proxy method, apparatus, computer-readable storage medium and electronic device to at least solve the technical problem of high labor cost caused by manually adding proxy address ports on proxy devices in the prior art.

[0005] According to one aspect of an embodiment of the present invention, a service proxy method is provided, comprising: obtaining a transmission control protocol connection request sent by a target client, determining a first access address port corresponding to the transmission control protocol connection request, wherein the transmission control protocol connection request is generated when the target client makes a service request to a target server; if the first access address port does not exist in a first target list, updating the first target list based on the first access address port, wherein the first target list is used to record the first target access address port, and the data content corresponding to the first target access address port is the data content that allows the target service in the target proxy process to execute; if the first access address port does not exist in the first target list , then a transmission control protocol connection is created between the network packet receiving and sending process and the target client, and a first network packet sent by the target client through the transmission control protocol connection is obtained; the first access address port in the first network packet is mapped to the target address port corresponding to the target service, the first target network packet is obtained according to the target address port, and the second target network packet is determined based on the first target network packet and the first access address port; the second target network packet is sent to the protocol stack, so that the target proxy process obtains the target data content corresponding to the second target network packet from the protocol stack based on the target address port, executes the target service on the target data content, and forwards the target data content after the target service is executed to the target server.

[0006] Furthermore, the service proxy method also includes: if the first access address port does not exist in the first target list, determining whether the first access address port exists in the preset configuration information, wherein the configuration information is used to record the second target access address port, and the data content corresponding to the second target access address port is the data content that allows other services in the target proxy process to execute; if the first access address port does not exist in the configuration information, and the first access address port can provide Hypertext Transfer Protocol service, then updating the first target list based on the first access address port.

[0007] Furthermore, the service proxy method also includes: if the first access address port does not exist in the configuration information, allowing a transmission control protocol connection to be created between the target client and the target server, and obtaining a second network packet sent by the target client after the transmission control protocol connection is created between the target client and the target server; based on the second network packet and a preset first identification rule, detecting whether the first access address port can provide a hypertext transfer protocol service; and when it is determined that the first access address port can provide a hypertext transfer protocol service, updating the first target list based on the first access address port.

[0008] Furthermore, the protocol stack is used to generate a target structure based on the second target network packet, and associate the target structure with a socket so that the target proxy process obtains target data content from the target structure through the socket, wherein the target structure and the target data content include a first access address port.

[0009] Furthermore, the service proxy method also includes: obtaining a second access address port sent by the target proxy process, wherein the second access address port is an address port that is identified by the target proxy process based on a second identification rule as being unable to provide Hypertext Transfer Protocol service; removing the second access address port from the first target list, and updating the second target list based on the second access address port, wherein the second target list is used to record a third target access address port, and the data content corresponding to the third target access address port is data content that is prohibited from being executed by the target service within the target time.

[0010] Furthermore, the target proxy process is used to identify the data content corresponding to the third network packet based on the second identification rule, and determine whether the address port corresponding to the third network packet can provide Hypertext Transfer Protocol service based on the identification result, wherein the data content of the third network packet is obtained by the target proxy process from the protocol stack.

[0011] Furthermore, the service proxy method also includes: when it is determined that the first access address port can provide Hypertext Transfer Protocol service, determining whether the first access address port exists in the second target list; if the first access address port does not exist in the second target list, updating the first target list based on the first access address port.

[0012] According to another aspect of an embodiment of the present invention, a service proxy device is further provided, including a first acquisition module, used to acquire a transmission control protocol connection request sent by a target client, and determine a first access address port corresponding to the transmission control protocol connection request, wherein the transmission control protocol connection request is generated when the target client makes a service request to the target server; an update module, used to update the first target list based on the first access address port if the first access address port does not exist in the first target list, wherein the first target list is used to record the first target access address port, and the data content corresponding to the first target access address port is the data content that allows the target service in the target proxy process to execute; a creation module, used to update the first target list based on the first access address port if the first access address port does not exist in the first target list The invention relates to a method for generating a first access address port and a second access address port for a target client, wherein the first access address port is a mapping module for mapping the first access address port in the first network packet to the target address port corresponding to the target service, obtaining the first target network packet according to the target address port, and determining the second target network packet based on the first target network packet and the first access address port; the sending module is used to send the second target network packet to the protocol stack, so that the target proxy process obtains the target data content corresponding to the second target network packet from the protocol stack based on the target address port, executes the target service on the target data content, and forwards the target data content after the target service is executed to the target server.

[0013] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the above-mentioned service proxy method when running.

[0014] According to another aspect of an embodiment of the present invention, an electronic device is also provided, which includes one or more processors; a memory for storing one or more programs, so that when the one or more programs are executed by the one or more processors, the one or more processors are implemented to run the programs, wherein the programs are configured to execute the above-mentioned service agent method when running.

[0015] In an embodiment of the present invention, an automatic proxy method is adopted for the service provided by the address port that is not proxied by the target proxy process. By obtaining the transmission control protocol connection request sent by the target client, the first access address port corresponding to the transmission control protocol connection request is determined. Then, if the first access address port does not exist in the first target list, the first target list is updated based on the first access address port. If the first access address port exists in the first target list, a transmission control protocol connection is created between the network packet sending and receiving process and the target client, and the first network packet sent by the target client through the transmission control protocol connection is obtained. Then, the first access address port in the first network packet is mapped to the target address port corresponding to the target service, and the first target network packet is obtained according to the target address port. Based on the first target network packet and the first access address port, the second target network packet is determined, and the second target network packet is sent to the protocol stack, so that the target proxy process obtains the target data content corresponding to the second target network packet from the protocol stack based on the target address port, executes the target service on the target data content, and forwards the target data content after the target service is executed to the target server. Among them, the transmission control protocol connection request is generated when the target client makes a service request to the target server, the first target list is used to record the first target access address port, and the data content corresponding to the first target access address port is the data content that allows the target service in the target proxy process to execute.

[0016] In the above process, when the first access address port does not exist in the first target list, the first access address is automatically added to the first target list, thereby realizing dynamic update of the first target list, that is, realizing automatic registration of the address port that is not proxied by the target network process, and when it is determined that the first access address port exists in the first target list, the second target network packet is obtained by combining the first access address port, the first network packet and the target address port, and the second target network packet is sent to the protocol stack, so that the target proxy process can obtain the target data content corresponding to the second target network packet based on the target address port, and forward it to the target server after executing the target service on the target data content, thereby realizing the proxy of the service provided by the first access address port, thereby reducing labor costs and avoiding the high labor cost problem caused by the need to manually add a proxy address port in the proxy device to proxy the service provided by the address port in the related technology. Furthermore, since the second target network packet also includes the first access address port, it is ensured that after the target proxy process obtains the target data content and completes the target service for the target data content, it can successfully forward the target data content to the target server based on the first access address port, thereby ensuring that the business processing is not distorted and the business request is forwarded normally.

[0017] It can be seen that the solution provided in the present application achieves the purpose of automatically proxying the services provided by the address port that is not proxied by the target proxy process, thereby achieving the technical effect of reducing labor costs, and further solving the technical problem of high labor costs caused by relying on manual addition of proxy address ports on proxy devices in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0019] Figure 1 is a schematic diagram of an optional service proxy method according to an embodiment of the present invention;

[0020] Figure 2 is a schematic diagram of an optional service proxy method according to an embodiment of the present invention;

[0021] Figure 3 is a schematic diagram of an optional first access address port transfer process according to an embodiment of the present invention;

[0022] Figure 4 is a schematic diagram of an optional service proxy device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0023] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0025] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.

[0026] Example 1

[0027] According to an embodiment of the present invention, an embodiment of a service proxy method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0028] Figure 1 is a schematic diagram of an optional service proxy method according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:

[0029] Step S101, obtaining a transmission control protocol connection request sent by a target client, and determining a first access address port corresponding to the transmission control protocol connection request, wherein the transmission control protocol connection request is generated when the target client makes a service request to the target server.

[0030] Optionally, in this embodiment, the aforementioned service proxy method is applied to a proxy device, such as Figure 2As shown, the proxy device at least includes a network packet transceiver process and a target proxy process. Specifically, the aforementioned service proxy method is applied to the network packet transceiver process in the proxy device. The network packet transceiver process is responsible for network packet transceiver, session state maintenance, etc. in the proxy device. The aforementioned target proxy process can be a Hyper Text Transfer Protocol (HTTP) proxy process. The target proxy process is used to parse data content, complete specific functions (i.e., specific services), initiate server-side requests and forward request and response data. In this embodiment, the aforementioned proxy device is a transparent proxy device. As a layer 2 device, this proxy device will not modify the source address (IP, Intellectual Property) and source port (Port) of the service request, but will terminate the Transmission Control Protocol (TCP, Transmission Control Protocol) connection, and the client requests the address and port of the server. If you want to proxy the service provided by the address port requested by the client, you need to register the address port on the proxy device. The proxy program (such as apache, nginx) on the proxy device can listen on the internal port corresponding to the aforementioned registered address port and process the request and response data. Among them, the aforementioned proxy device can be a firewall device or other devices.

[0031] In step S101, when the target client wants to send a service request to the target server, the target client first sends a transmission control protocol connection request to the target server. The aforementioned proxy device is arranged between the target server and the target client. During the transmission of the transmission control protocol connection request, the network packet receiving and sending process in the proxy device can obtain the transmission control protocol connection request sent by the target client before the transmission control protocol connection request is sent to the target server. Among them, the transmission control protocol connection request includes the first access address port (also known as the first access IP PORT) that the target client wants to access. The first access address port is the address port on the target server. In the present application, the address port includes both address (IP) information and port (PORT) information.

[0032] Furthermore, after obtaining the transmission control protocol connection request, the network packet receiving and sending process can determine the first access address port that the target client wants to access from the transmission control protocol connection request.

[0033] Step S102, if the first access address port does not exist in the first target list, update the first target list based on the first access address port, wherein the first target list is used to record the first target access address port, and the data content corresponding to the first target access address port is the data content that allows the target service in the target proxy process to execute.

[0034] Optionally, in this embodiment, a default virtual service (i.e., the aforementioned target service) is registered on a certain internal port of the proxy device for managing the business, and the form of the virtual service is similar to the service manually configured by the user. In step S102, after the network packet transceiver process obtains the first access address port, the network packet transceiver process can determine whether the first access address port is the address port of the target proxy process agent. Specifically, if the network packet transceiver process only includes the first target list, the network packet transceiver process can determine whether the first access address port is the address port of the target proxy process agent according to the first target list that is continuously updated in the network packet transceiver process. Optionally, if there is also relevant configuration information pre-configured by the staff in the network packet transceiver process, the network packet transceiver process can determine whether the first access address port is the address port of the target proxy process agent based on the first target list and the relevant configuration information pre-configured by the staff. Among them, the aforementioned configuration information is used to record the corresponding relationship between other services pre-configured in the target proxy process and the address port, and the aforementioned first target list is used to record the corresponding relationship between the default virtual service and the address port in the target proxy process. The services in the proxy device can be statistics of the acquired data, threat detection, etc.

[0035] Furthermore, if the first access address port does not exist in the first target list, the network packet sending and receiving process can automatically add the first access address to the first target list to realize dynamic update of the first target list, that is, to realize automatic registration of the address port that is not proxied by the target network process, so that the network packet sending and receiving process can proxy the service provided by the first access address port when it obtains the transmission control protocol connection request containing the first access address port next time, avoiding the problem of high labor cost caused by the need to manually add the proxy address port in the proxy device to proxy the address port in the related technology.

[0036] Step S103: if the first access address port exists in the first target list, a transmission control protocol connection is created between the network packet receiving and sending process and the target client, and a first network packet sent by the target client through the transmission control protocol connection is obtained.

[0037] In step S103, if the first access address port exists in the first target list, the network packet sending and receiving process determines that the service provided by the first access address port is the service proxied by the proxy device. At this time, the network packet sending and receiving process can automatically create a transmission control protocol connection with the target client, thereby obtaining the first network packet sent by the target client through the transmission control protocol connection, wherein the first network packet is sent by the target client to the target server, the first network packet at least includes a request message for the target client to make a service request to the target server, and the access address port to be accessed by the target client contained in the first network packet is the same as the access address port in the transmission control protocol connection request, that is, the first network packet includes the first access address port.

[0038] Step S104, mapping the first access address port in the first network packet to the target address port corresponding to the target service, obtaining the first target network packet according to the target address port, and determining the second target network packet based on the first target network packet and the first access address port.

[0039] In step S104, the network packet receiving and sending process can automatically map the first access address port in the first network packet to the target address port corresponding to the target service through destination address translation (DNAT), thereby obtaining a new network packet (i.e., the aforementioned first target network packet), wherein the target address port is the address port registered by the target proxy process in the kernel, and the target address port is also the aforementioned internal port.

[0040] Furthermore, if Figure 3 As shown, after determining the first target network packet, the network packet receiving and sending process can attach the first access address port to the memory in front of the first target network packet, thereby obtaining the second target network packet, which includes not only the target address port but also the first access address port.

[0041] It should be noted that, when determining that the first access address port exists in the first target list, the access address port is automatically mapped to the target address port corresponding to the target service in the target proxy process, so that the subsequent target proxy process can implement the proxy of the service provided by the first access address port. By adding the first access address port to the second target network packet, it is ensured that the subsequent target proxy process can successfully forward the content corresponding to the network packet.

[0042] Step S105, sending the second target network packet to the protocol stack, so that the target proxy process obtains the target data content corresponding to the second target network packet from the protocol stack based on the target address port, executes the target service on the target data content, and forwards the target data content after the target service is executed to the target server.

[0043] In step S105, the network packet transceiver process can send the second target network packet to the protocol stack, so that the target proxy process obtains the target data content corresponding to the second target network packet from the protocol stack based on the target address port through the socket, and executes the target service corresponding to the target address port on the target data content. Afterwards, the network packet transceiver process can forward the target data content after the target service is executed to the target server according to the first access address port in the target data content, thereby realizing effective proxy.

[0044] It should be noted that, since the second target network packet includes the target address port, by sending the second target network packet to the protocol stack, the target proxy process can obtain the target data content corresponding to the second target network packet based on the target address port, and forward it to the target server after executing the target service on the target data content, thereby realizing the proxy of the service provided by the first access address port. Furthermore, since the second target network packet also includes the first access address port, it is guaranteed that after the target proxy process obtains the target data content corresponding to the second target network packet and executes the target service, it can successfully forward the target data content to the target server based on the first access address port, thereby ensuring that the business processing is not distorted and the proxy device forwards normally.

[0045] Based on the scheme defined in the above steps S101 to S105, it can be known that in an embodiment of the present invention, an automatic proxy method is adopted for the service provided by the address port that is not proxied by the target proxy process. By obtaining the transmission control protocol connection request sent by the target client, the first access address port corresponding to the transmission control protocol connection request is determined, and then if the first access address port does not exist in the first target list, the first target list is updated based on the first access address port. If the first access address port exists in the first target list, a transmission control protocol connection is created between the network packet sending and receiving process and the target client, and the first network packet sent by the target client through the transmission control protocol connection is obtained. Then, the first access address port in the first network packet is mapped to the target address port corresponding to the target service, and the first target network packet is obtained according to the target address port. Based on the first target network packet and the first access address port, the second target network packet is determined, and the second target network packet is sent to the protocol stack, so that the target proxy process obtains the target data content corresponding to the second target network packet from the protocol stack based on the target address port, executes the target service on the target data content, and forwards the target data content after the target service is executed to the target server. Among them, the transmission control protocol connection request is generated when the target client makes a service request to the target server, the first target list is used to record the first target access address port, and the data content corresponding to the first target access address port is the data content that allows the target service in the target proxy process to execute.

[0046] It is easy to notice that in the above process, by automatically adding the first access address to the first target list when the first access address port does not exist in the first target list, the dynamic update of the first target list is realized, that is, the automatic registration of the address port that is not proxied by the target network process is realized, and by combining the first access address port, the first network packet and the target address port to obtain the second target network packet when determining that the first access address port exists in the first target list, and sending the second target network packet to the protocol stack, the target proxy process can obtain the target data content corresponding to the second target network packet based on the target address port, and forward it to the target server after executing the target service on the target data content, thereby realizing the proxy of the service provided by the first access address port, thereby reducing labor costs and avoiding the high labor cost problem caused by the need to manually add a proxy address port in the proxy device to proxy the service provided by the address port in the related technology. Furthermore, since the second target network packet also includes the first access address port, it is ensured that after the target proxy process obtains the target data content and completes the target service for the target data content, it can successfully forward the target data content to the target server based on the first access address port, thereby ensuring that the business processing is not distorted and the business request is forwarded normally.

[0047] It can be seen that the solution provided in the present application achieves the purpose of automatically proxying the services provided by the address port that is not proxied by the target proxy process, thereby achieving the technical effect of reducing labor costs, and further solving the technical problem of high labor costs caused by relying on manual addition of proxy address ports on proxy devices in the prior art.

[0048] In an optional embodiment, the registration conditions of the network packet receiving and sending process for the first access address port are described. Optionally, if the first access address port does not exist in the first target list, it is determined whether the first access address port exists in the preset configuration information. If the first access address port does not exist in the configuration information, and the first access address port can provide Hypertext Transfer Protocol service, the first target list is updated based on the first access address port. The configuration information is used to record the second target access address port, and the data content corresponding to the second target access address port is the data content that allows other services in the target proxy process to execute.

[0049] Specifically, first, the process of determining whether the first access address port is the address port of the target proxy process by the network packet receiving and sending process is described. In an optional embodiment, the network packet receiving and sending process includes not only the first target list, but also the relevant configuration information pre-configured by the staff, that is, the target proxy process includes not only the target service, but also other services besides the target service, such as Figure 2 Virtual Service 1 and Virtual Service 2 in the target proxy process. Virtual Service 1 and Virtual Service 2 are services pre-configured by the staff in the target proxy process. Virtual Service 1 and Virtual Service 2 are used to process the data content corresponding to the network packet sent to a specific address port. The configuration information records the access address port corresponding to the aforementioned virtual service 1 and the access address port corresponding to virtual service 2. The network packet receiving and sending process is used to map the access address port corresponding to Virtual Service 1 recorded in the configuration information to the service address port corresponding to Virtual Service 1, and to map the access address port corresponding to Virtual Service 2 recorded in the configuration information to the service address port corresponding to Virtual Service 2, so that the target proxy process can obtain relevant data and process it. Among them, the aforementioned service address port is the address port registered by the target proxy process in the kernel, and the aforementioned target address port is equivalent to the service address port corresponding to the target service.

[0050] Furthermore, when the network packet sending and receiving process also includes relevant configuration information, the network packet sending and receiving process can determine whether the first access address port exists in the preset configuration information after determining that the first access address port does not exist in the first target list. If it is determined that the first access address port does not exist in the preset configuration information, it can be determined that the first access address port is an address port that is not proxied by the target proxy process.

[0051] It should be noted that by determining whether the first access address port is the address port of the target proxy process based on the first target list and preset configuration information, accurate judgment of the type of the first access address port is achieved.

[0052] Further, if the first access address port is an address port that is not proxied by the target proxy process, the network packet sending and receiving process can determine whether the first access address port can provide Hypertext Transfer Protocol services, and thus update the first target list based on the first access address port if it is determined that the first access address port can provide Hypertext Transfer Protocol services.

[0053] It should be noted that by only adding the address port that provides HTTP service to the first target list, the registration of the address port that cannot provide HTTP service is avoided, thereby avoiding the data content of the data packet sent to the address port that cannot provide HTTP service to be forwarded to the target proxy process, which may cause the target proxy process to fail to process the data and cause business abnormalities.

[0054] In an optional embodiment, the registration conditions of the network packet receiving and sending process for the first access address port are further described. Optionally, if the first access address port does not exist in the configuration information, a transmission control protocol connection is allowed to be created between the target client and the target server, and a second network packet sent by the target client after the transmission control protocol connection is created between the target client and the target server is obtained, and then based on the second network packet and the preset first identification rule, it is detected whether the first access address port can provide a hypertext transfer protocol service, and when it is determined that the first access address port can provide a hypertext transfer protocol service, the first target list is updated based on the first access address port.

[0055] Specifically, after determining that the first access address port does not exist in the configuration information, the network packet receiving and sending process may allow the target client to create a transmission control protocol connection with the target server, and obtain a second network packet sent by the target client after the transmission control protocol connection is created between the target client and the target server. The second network packet also includes at least a request message for the target client to make a service request to the target server, and the access address port to be accessed by the target client contained in the second network packet is the same as the access address port in the transmission control protocol connection request.

[0056] Furthermore, the network packet receiving and sending process can identify the TCP payload content (i.e., the data block in the second network packet) in the second network packet based on the first identification rule pre-configured by the staff in the network packet receiving and sending process, wherein the first identification rule is used to determine whether the TCP payload content conforms to the format of the Hypertext Transfer Protocol request and response, and when it is determined that the TCP payload content conforms to the format of the Hypertext Transfer Protocol request and response, it is determined that the first access address port in the second network packet can provide the Hypertext Transfer Protocol service, otherwise, if the TCP payload content does not conform to the format of the Hypertext Transfer Protocol request and response, it is determined that the first access address port in the second network packet cannot provide the Hypertext Transfer Protocol service. Optionally, the first identification rule can also be other rules. Among them, when the network packet receiving and sending process can complete the detection of the second network packet, the network packet receiving and sending process directly forwards the second network packet to the target server.

[0057] Furthermore, if the first access address port can provide the Hypertext Transfer Protocol service, the network packet transceiver process can update the first target list based on the first access address port, so that the service provided by the first access address port can be proxied when the next transmission control protocol connection request containing the first access address port is obtained. On the contrary, if the first access address port cannot provide the Hypertext Transfer Protocol service, the network packet transceiver process will not add the first access address port to the first target list, so that Figure 2 As shown, the implementation will send to the server that cannot provide the Hypertext Transfer Protocol service (i.e. Figure 2 The network packets of the access address port of the non-HTTP service in the HTTP protocol are directly forwarded to the target server, that is, the proxy of the access address port is avoided.

[0058] It should be noted that by detecting the second network packet, it is possible to effectively determine whether the first access address port can provide the Hypertext Transfer Protocol service.

[0059] In an optional embodiment, the working process of the network packet transceiving process in the case where the first access address port is determined to be present in the first target list or the preset configuration information is described. Specifically, in the network packet transceiving process, after obtaining the transmission control protocol connection request sent by the target client, the network packet transceiving process can query the first target list and the configuration information. If it is determined that the first access address port is present in the first target list or the preset configuration information, the network packet transceiving process creates a transmission control protocol connection between the network packet transceiving process and the target client. Afterwards, the network packet transceiving process obtains the network packet sent by the target client through the transmission control protocol connection, and then determines the service corresponding to the first access address port based on the content of the first target list or the configuration information record, thereby mapping the first access address port in the aforementioned network packet to the service address port of the corresponding service. For example Figure 2 As shown in , the access address port (1.1.1.1:80) is mapped to the service address port (127.0.0.1:1025) corresponding to virtual service 1, the access address port (1.1.1.2:80) is mapped to the service address port (127.0.0.1:1026) corresponding to virtual service 2, and the access address ports (1.1.1.3:80) and (1.1.1.4:80) are both mapped to the target address port (127.0.0.1:8000). Afterwards, when the first access address port matches the configuration information, the network packet transceiver process directly forwards the mapped network packet to the target proxy process through the protocol stack, or when the first access address port matches the first target list, after generating a second target network packet based on the mapped network packet, the second target network packet is forwarded to the target proxy process.

[0060] In an optional embodiment, after the network packet transceiver process determines the second target network packet, the network packet transceiver process sends the second target network packet to the protocol stack. The protocol stack is used to generate a target structure based on the second target network packet, and associate the target structure with a socket, so that the target proxy process obtains the target data content from the target structure through the socket, wherein the target structure and the target data content include the first access address port.

[0061] Optionally, the target proxy process implements network communication through a socket. Since the network packet receiving and sending process performs DNAT processing on the network packet, the address port obtained by the target proxy process through the socket is not the original one, that is, the address port is not the access address port. In the related art, in order to enable the target proxy process to obtain the original address port (i.e., the first access address port) corresponding to the network packet, the service in the target proxy process is generally set to correspond to the original address port one by one, and the corresponding relationship between the service and the original address port is written into the configuration of the target proxy process for the target proxy process to parse and use in the business processing process. That is, in this embodiment, when the first access address port matches the configuration information, after mapping the first access address port to the port corresponding to the service, the obtained new network packet can be directly forwarded to the target proxy process through the protocol stack.

[0062] In the present application, when the first access address port matches the first target list, since the original address port corresponding to the target service is uncertain, that is, it may change over time, and there may be multiple original address ports corresponding to the target service, the second target network packet can be determined based on the first target network packet and the first access address port by the aforementioned method, so that the target proxy process can effectively obtain the original address port when processing the target data content corresponding to the second target network packet.

[0063] Specifically, in this embodiment, after the protocol stack obtains the second target network packet, the protocol stack assembles the structure sk_buff for describing the network packet based on the second target network packet, that is, assembles the target structure sk_buff. Afterwards, the socket layer in the protocol stack associates sk_buff with the socket, so that the target proxy process can obtain the target data content from the socket through the getsockopt() function and obtain the first access address port. When assembling sk_buff, if Figure 3 As shown, the protocol stack saves the first access address port in the second target network packet to the newly added member in sk_buff, and combines the name of the second target network packet and other data content in the second target network packet to obtain the following Figure 3 The target structure shown in FIG. 1 , the first access address port, name and other data contents in the target structure constitute the aforementioned target data contents. In the aforementioned socket layer receiving data process, as Figure 3 As shown, if it is found that sk_buff contains the first access address port, it is copied to the socket to obtain the following Figure 3 The data structure shown in FIG. 1 and the first access address port, name and other data contents in the socket also constitute the aforementioned target data contents. Figure 3 In the figure, the solid line part is the original workflow or data structure in the related technology, and the dotted line part is the new content in the service proxy method provided in this application.

[0064] It should be noted that, by generating a target structure based on the second target network packet through the protocol stack, and associating the target structure with the socket, the target proxy process can successfully obtain the target data content through the socket, thereby realizing effective proxy.

[0065] In an optional embodiment, the network packet sending and receiving process can also obtain the second access address port sent by the target proxy process, and then remove the second access address port from the first target list, and update the second target list based on the second access address port, wherein the second access address port is the address port that the target proxy process identifies as unable to provide Hypertext Transfer Protocol service based on the second identification rule, and the second target list is used to record the third target access address port, and the data content corresponding to the third target access address port is the data content that is prohibited from being executed by the target service within the target time.

[0066] Among them, the target proxy process is used to identify the data content corresponding to the third network packet based on the second identification rule, and determine whether the address port corresponding to the third network packet can provide Hypertext Transfer Protocol service based on the identification result, wherein the data content of the third network packet is obtained by the target proxy process from the protocol stack.

[0067] Optionally, a second identification rule is preset in the target proxy process. During the operation of the proxy device, the target proxy process can identify the original address port in the data content of the network packet transmitted from the network packet transceiver process based on the second identification rule to identify whether the address port can provide Hypertext Transfer Protocol service. Among them, the data content of the network packet transmitted from the network packet transceiver process is the data content of the aforementioned third network packet. It should be noted that when the network packet transceiver process determines that a certain access address port exists in the first target list, it will no longer detect the network packet containing the access address port sent by the target client based on the first identification rule. Therefore, at this time, the target proxy process can identify the access address port based on the second identification rule to avoid the phenomenon that the address port that originally provided HTTP service is later changed to non-HTTP service, and the network packet transceiver process cannot find it. Among them, the second identification rule can be different from the first identification rule, or it can be the same as the first identification rule.

[0068] Furthermore, after the target proxy process identifies the second access address port, the target proxy process can directly send the second access address port to the network packet transceiver process to notify the network packet transceiver process to temporarily not create a transmission control protocol connection between the network packet transceiver process and the target client the next time it receives a transmission control protocol connection request containing the access address port from the target client, so as to prohibit the data content of the data packet under the transmission control protocol connection from being sent to the target proxy process within the target time. After the network packet transceiver process obtains the second access address port, the network packet transceiver process can remove the second access address port recorded in the first target list and record the second access address port in the second target list.

[0069] Optionally, after the target proxy process identifies the second access address port, the target proxy process may also determine that the target number is greater than a preset number before sending the second access address port to the network packet transceiver process, wherein the target number is obtained by counting the number of network packets that can be used to identify the second access address port by the target proxy process. Specifically, during the proxy process, the target proxy process counts the network packets in the target service that can be used to identify a certain access address port that provides non-HTTP services. When the total amount or proportion of data packets used to identify a certain access address port that provides non-HTTP services reaches a certain threshold, the address port is sent to the network packet transceiver process.

[0070] It should be noted that since an access address port can provide HTTP service and non-HTTP service at the same time, or after a business change, the access address port that originally provided HTTP service is changed to provide non-HTTP service, therefore, the recognition of the access address port by the target proxy process is improved, and the accuracy of the recognition of the access address port is improved, thereby avoiding the situation where after the access address port is added to the first target list, the network packet receiving and sending process no longer recognizes it, resulting in the inability to adapt to the business changes or service diversity of the address port in time, and the target proxy process is unable to handle the business anomalies caused by non-HTTP services, thereby improving the effectiveness of the service agent of this application.

[0071] In an optional embodiment, for the address port recorded in the second target list, the network packet receiving and sending process can count the number of times the access address port can provide Hypertext Transfer Protocol services and the proportion of the number of times the access address port is received when the network packet corresponding to the access address port is obtained again, and when it is determined that the number of times the access address port can provide Hypertext Transfer Protocol services is greater than or equal to the first preset number of times and the proportion of the number of times the access address port is received is greater than the preset proportion, the access address port is removed from the second target list and recorded in the first target list.

[0072] It should be noted that for the access address port removed from the first target list, when the network packet sending and receiving process encounters the access address port again, the conditions for re-adding it to the first target list will be improved, so as to avoid sending non-HTTP services to the address port on the target proxy process as much as possible.

[0073] In an optional embodiment, when it is determined that the first access address port can provide Hypertext Transfer Protocol services, in the process of updating the first target list based on the first access address port, when it is determined that the first access address port can provide Hypertext Transfer Protocol services, it is determined whether the first access address port exists in the second target list; if the first access address port does not exist in the second target list, the first target list is updated based on the first access address port.

[0074] Optionally, if the first access address port can provide Hypertext Transfer Protocol services, the network packet transceiver process also needs to determine whether the first access address port exists in the second target list. If the first access address port does not exist in the second target list, it can be determined that the proxy device has obtained the address port for the first time, so it can be directly registered. On the contrary, if the first access address port exists in the second target list, the network packet transceiver process can first allow the target client and the target server to create a transmission control protocol connection, and count the number of times it can provide Hypertext Transfer Protocol services, until the address port meets the conditions for entering the first target list again, and then register the service provided by the address port for subsequent proxy. In this way, it is possible to avoid non-HTTP services on the address port sent to the target proxy process as much as possible.

[0075] It should be noted that the present application adds the concept of a default virtual service, adds the HTTP service discovery process to the network packet receiving process, and saves the discovered address and port. Subsequently, the network packets under the TCP connection whose address and port can match the first target list are forwarded to the default virtual service registered in the target proxy process through DNAT to achieve effective proxying of related services. The method provided in the present application is applicable to but not limited to scenarios where there are many HTTP services that need to be proxied, and scenarios where the proxy services change frequently. Based on the method provided in the present application, automatic protection of HTTP services in the network can be achieved, and the management cost of HTTP proxy equipment can be reduced.

[0076] It can be seen that the solution provided in the present application achieves the purpose of automatically proxying the services provided by the address port that is not proxied by the target proxy process, thereby achieving the technical effect of reducing labor costs, and further solving the technical problem of high labor costs caused by relying on manual addition of proxy address ports on proxy devices in the prior art.

[0077] Example 2

[0078] According to an embodiment of the present invention, an embodiment of a service proxy device is provided, wherein: Figure 4 is a schematic diagram of an optional service proxy device according to an embodiment of the present invention. Figure 4 As shown, the device comprises:

[0079] The first acquisition module 401 is used to acquire a transmission control protocol connection request sent by a target client and determine a first access address port corresponding to the transmission control protocol connection request, wherein the transmission control protocol connection request is generated when the target client makes a service request to the target server.

[0080] Optionally, in this embodiment, the service proxy device includes a proxy device, such as Figure 2 As shown, the proxy device at least includes a network packet transceiver process and a target proxy process. Specifically, the network packet transceiver process in the proxy device includes a first acquisition module, an update module, a creation module, a mapping module and a sending module. The network packet transceiver process is responsible for network packet transceiver, session state maintenance, etc. in the proxy device. The aforementioned target proxy process can be a Hyper Text Transfer Protocol (HTTP) proxy process. The target proxy process is used to parse data content, complete specific functions (i.e., specific services), initiate server-side requests and forward request and response data. In this embodiment, the aforementioned proxy device is a transparent proxy device. As a layer 2 device, this proxy device will not modify the source address (IP, Intellectual Property) and source port (Port) of the service request, but will terminate the Transmission Control Protocol (TCP, Transmission Control Protocol) connection, and the client requests the address and port of the server. If you want to proxy the service provided by the address port requested by the client, you need to register the address port on the proxy device. The proxy program (such as apache, nginx) on the proxy device can listen on the internal port corresponding to the aforementioned registered address port and process the request and response data. The aforementioned proxy device may be a firewall device or other devices.

[0081] When the target client wants to send a service request to the target server, the target client first sends a transmission control protocol connection request to the target server. The aforementioned proxy device is arranged between the target server and the target client. During the transmission of the transmission control protocol connection request, the network packet receiving and sending process in the proxy device can obtain the transmission control protocol connection request sent by the target client before the transmission control protocol connection request is sent to the target server. Among them, the transmission control protocol connection request includes the first access address port (also known as the first access IP PORT) that the target client wants to access. The first access address port is the address port on the target server. In this application, the address port includes both address (IP) information and port (PORT) information.

[0082] Furthermore, after obtaining the transmission control protocol connection request, the network packet receiving and sending process can determine the first access address port that the target client wants to access from the transmission control protocol connection request.

[0083] Update module 402 is used to update the first target list based on the first access address port if the first access address port does not exist in the first target list, wherein the first target list is used to record the first target access address port, and the data content corresponding to the first target access address port is the data content that allows the target service in the target proxy process to execute.

[0084] Optionally, in this embodiment, a default virtual service (i.e., the aforementioned target service) is registered on a certain internal port of the proxy device for managing the business, and the form of the virtual service is similar to the service manually configured by the user. In step S102, after the network packet transceiver process obtains the first access address port, the network packet transceiver process can determine whether the first access address port is the address port of the target proxy process agent. Specifically, if the network packet transceiver process only includes the first target list, the network packet transceiver process can determine whether the first access address port is the address port of the target proxy process agent according to the first target list that is continuously updated in the network packet transceiver process. Optionally, if there is also relevant configuration information pre-configured by the staff in the network packet transceiver process, the network packet transceiver process can determine whether the first access address port is the address port of the target proxy process agent based on the first target list and the relevant configuration information pre-configured by the staff. Among them, the aforementioned configuration information is used to record the corresponding relationship between other services pre-configured in the target proxy process and the address port, and the aforementioned first target list is used to record the corresponding relationship between the default virtual service and the address port in the target proxy process. The services in the proxy device can be statistics of the acquired data, threat detection, etc.

[0085] Furthermore, if the first access address port does not exist in the first target list, the network packet sending and receiving process can automatically add the first access address to the first target list to realize dynamic update of the first target list, that is, to realize automatic registration of the address port that is not proxied by the target network process, so that the network packet sending and receiving process can proxy the service provided by the first access address port when it obtains the transmission control protocol connection request containing the first access address port next time, avoiding the problem of high labor cost caused by the need to manually add the proxy address port in the proxy device to proxy the address port in the related technology.

[0086] The creation module 403 is used to create a transmission control protocol connection between the network packet receiving and sending process and the target client if the first access address port exists in the first target list, and obtain the first network packet sent by the target client through the transmission control protocol connection.

[0087] Optionally, if the first access address port exists in the first target list, the network packet sending and receiving process determines that the service provided by the first access address port is the service proxied by the proxy device. At this time, the network packet sending and receiving process can automatically create a transmission control protocol connection with the target client, thereby obtaining the first network packet sent by the target client through the transmission control protocol connection, wherein the first network packet is sent by the target client to the target server, the first network packet at least includes a request message for the target client to make a service request to the target server, and the access address port to be accessed by the target client contained in the first network packet is the same as the access address port in the transmission control protocol connection request, that is, the first network packet includes the first access address port.

[0088] The mapping module 404 is used to map the first access address port in the first network packet to the target address port corresponding to the target service, obtain the first target network packet according to the target address port, and determine the second target network packet based on the first target network packet and the first access address port.

[0089] Optionally, the network packet sending and receiving process can automatically map the first access address port in the first network packet to the target address port corresponding to the target service through destination address translation (DNAT), thereby obtaining a new network packet (i.e., the aforementioned first target network packet), wherein the target address port is the address port registered by the target proxy process in the kernel, and the target address port is also the aforementioned internal port.

[0090] Furthermore, if Figure 3As shown, after determining the first target network packet, the network packet receiving and sending process can attach the first access address port to the memory in front of the first target network packet, thereby obtaining the second target network packet, which includes not only the target address port but also the first access address port.

[0091] It should be noted that, when determining that the first access address port exists in the first target list, the access address port is automatically mapped to the target address port corresponding to the target service in the target proxy process, so that the subsequent target proxy process can implement the proxy of the service provided by the first access address port. By adding the first access address port to the second target network packet, it is ensured that the subsequent target proxy process can successfully forward the content corresponding to the network packet.

[0092] The sending module 405 is used to send the second target network packet to the protocol stack so that the target proxy process obtains the target data content corresponding to the second target network packet from the protocol stack based on the target address port, executes the target service on the target data content, and forwards the target data content after the target service is executed to the target server.

[0093] Optionally, the network packet transceiver process may send the second target network packet to the protocol stack, so that the target proxy process obtains the target data content corresponding to the second target network packet from the protocol stack based on the target address port through the socket, and executes the target service corresponding to the target address port on the target data content. Afterwards, the network packet transceiver process may forward the target data content after the target service is executed to the target server according to the first access address port in the target data content, thereby realizing effective proxy.

[0094] It should be noted that, since the second target network packet includes the target address port, by sending the second target network packet to the protocol stack, the target proxy process can obtain the target data content corresponding to the second target network packet based on the target address port, and forward it to the target server after executing the target service on the target data content, thereby realizing the proxy of the service provided by the first access address port. Furthermore, since the second target network packet also includes the first access address port, it is guaranteed that after the target proxy process obtains the target data content corresponding to the second target network packet and executes the target service, it can successfully forward the target data content to the target server based on the first access address port, thereby ensuring that the business processing is not distorted and the proxy device forwards normally.

[0095] In the above process, when the first access address port does not exist in the first target list, the first access address is automatically added to the first target list, thereby realizing dynamic update of the first target list, that is, realizing automatic registration of the address port that is not proxied by the target network process, and when it is determined that the first access address port exists in the first target list, the second target network packet is obtained by combining the first access address port, the first network packet and the target address port, and the second target network packet is sent to the protocol stack, so that the target proxy process can obtain the target data content corresponding to the second target network packet based on the target address port, and forward it to the target server after executing the target service on the target data content, thereby realizing the proxy of the service provided by the first access address port, thereby reducing labor costs and avoiding the high labor cost problem caused by the need to manually add a proxy address port in the proxy device to proxy the service provided by the address port in the related technology. Furthermore, since the second target network packet also includes the first access address port, it is ensured that after the target proxy process obtains the target data content and completes the target service for the target data content, it can successfully forward the target data content to the target server based on the first access address port, thereby ensuring that the business processing is not distorted and the business request is forwarded normally.

[0096] It can be seen that the solution provided in the present application achieves the purpose of automatically proxying the services provided by the address port that is not proxied by the target proxy process, thereby achieving the technical effect of reducing labor costs, and further solving the technical problem of high labor costs caused by relying on manual addition of proxy address ports on proxy devices in the prior art.

[0097] It should be noted that the above-mentioned first acquisition module 401, update module 402, creation module 403, mapping module 404 and sending module 405 correspond to steps S101 to S105 in the above-mentioned embodiment, and the examples and application scenarios implemented by the five modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned embodiment 1.

[0098] Optionally, the update module also includes: a determination unit, used to determine whether the first access address port exists in the preset configuration information if the first access address port does not exist in the first target list, wherein the configuration information is used to record the second target access address port, and the data content corresponding to the second target access address port is the data content that allows other services in the target proxy process to execute; an update unit, used to update the first target list based on the first access address port if the first access address port does not exist in the configuration information and the first access address port can provide Hypertext Transfer Protocol service.

[0099] Specifically, first, the process of determining whether the first access address port is the address port of the target proxy process by the network packet receiving and sending process is described. In an optional embodiment, the network packet receiving and sending process includes not only the first target list, but also the relevant configuration information pre-configured by the staff, that is, the target proxy process includes not only the target service, but also other services besides the target service, such as Figure 2 Virtual Service 1 and Virtual Service 2 in the target proxy process. Virtual Service 1 and Virtual Service 2 are services pre-configured by the staff in the target proxy process. Virtual Service 1 and Virtual Service 2 are used to process the data content corresponding to the network packet sent to a specific address port. The configuration information records the access address port corresponding to the aforementioned virtual service 1 and the access address port corresponding to virtual service 2. The network packet receiving and sending process is used to map the access address port corresponding to Virtual Service 1 recorded in the configuration information to the service address port corresponding to Virtual Service 1, and to map the access address port corresponding to Virtual Service 2 recorded in the configuration information to the service address port corresponding to Virtual Service 2, so that the target proxy process can obtain relevant data and process it. Among them, the aforementioned service address port is the address port registered by the target proxy process in the kernel, and the aforementioned target address port is equivalent to the service address port corresponding to the target service.

[0100] Furthermore, when the network packet sending and receiving process also includes relevant configuration information, the network packet sending and receiving process can determine whether the first access address port exists in the preset configuration information after determining that the first access address port does not exist in the first target list. If it is determined that the first access address port does not exist in the preset configuration information, it can be determined that the first access address port is an address port that is not proxied by the target proxy process.

[0101] It should be noted that by determining whether the first access address port is the address port of the target proxy process based on the first target list and preset configuration information, accurate judgment of the type of the first access address port is achieved.

[0102] Further, if the first access address port is an address port that is not proxied by the target proxy process, the network packet sending and receiving process can determine whether the first access address port can provide Hypertext Transfer Protocol services, and thus update the first target list based on the first access address port if it is determined that the first access address port can provide Hypertext Transfer Protocol services.

[0103] It should be noted that by only adding the address port that provides HTTP service to the first target list, the registration of the address port that cannot provide HTTP service is avoided, thereby avoiding the data content of the data packet sent to the address port that cannot provide HTTP service to be forwarded to the target proxy process, which may cause the target proxy process to fail to process the data and cause business abnormalities.

[0104] Optionally, the update unit also includes: an acquisition sub-module, which is used to allow the target client to create a transmission control protocol connection with the target server if the first access address port does not exist in the configuration information, and to obtain a second network packet sent by the target client after the transmission control protocol connection is created between the target client and the target server; a detection sub-module, which is used to detect whether the first access address port can provide a hypertext transfer protocol service based on the second network packet and a preset first identification rule; and an update sub-module, which is used to update the first target list based on the first access address port when it is determined that the first access address port can provide a hypertext transfer protocol service.

[0105] Specifically, after determining that the first access address port does not exist in the configuration information, the network packet receiving and sending process may allow the target client to create a transmission control protocol connection with the target server, and obtain a second network packet sent by the target client after the transmission control protocol connection is created between the target client and the target server. The second network packet also includes at least a request message for the target client to make a service request to the target server, and the access address port to be accessed by the target client contained in the second network packet is the same as the access address port in the transmission control protocol connection request.

[0106] Furthermore, the network packet receiving and sending process can identify the TCP payload content (i.e., the data block in the second network packet) in the second network packet based on the first identification rule pre-configured by the staff in the network packet receiving and sending process, wherein the first identification rule is used to determine whether the TCP payload content conforms to the format of the Hypertext Transfer Protocol request and response, and when it is determined that the TCP payload content conforms to the format of the Hypertext Transfer Protocol request and response, it is determined that the first access address port in the second network packet can provide the Hypertext Transfer Protocol service, otherwise, if the TCP payload content does not conform to the format of the Hypertext Transfer Protocol request and response, it is determined that the first access address port in the second network packet cannot provide the Hypertext Transfer Protocol service. Optionally, the first identification rule can also be other rules. Among them, when the network packet receiving and sending process can complete the detection of the second network packet, the network packet receiving and sending process directly forwards the second network packet to the target server.

[0107] Furthermore, if the first access address port can provide the Hypertext Transfer Protocol service, the network packet transceiver process can update the first target list based on the first access address port, so that the service provided by the first access address port can be proxied when the next transmission control protocol connection request containing the first access address port is obtained. On the contrary, if the first access address port cannot provide the Hypertext Transfer Protocol service, the network packet transceiver process will not add the first access address port to the first target list, so that Figure 2 As shown, the implementation will send to the server that cannot provide the Hypertext Transfer Protocol service (i.e. Figure 2 The network packets of the access address port of the non-HTTP service in the HTTP protocol are directly forwarded to the target server, that is, the proxy of the access address port is avoided.

[0108] It should be noted that by detecting the second network packet, it is possible to effectively determine whether the first access address port can provide the Hypertext Transfer Protocol service.

[0109] In an optional embodiment, the working process of the network packet transceiving process in the case where the first access address port is determined to be present in the first target list or the preset configuration information is described. Specifically, in the network packet transceiving process, after obtaining the transmission control protocol connection request sent by the target client, the network packet transceiving process can query the first target list and the configuration information. If it is determined that the first access address port is present in the first target list or the preset configuration information, the network packet transceiving process creates a transmission control protocol connection between the network packet transceiving process and the target client. Afterwards, the network packet transceiving process obtains the network packet sent by the target client through the transmission control protocol connection, and then determines the service corresponding to the first access address port based on the content of the first target list or the configuration information record, thereby mapping the first access address port in the aforementioned network packet to the service address port of the corresponding service. For example Figure 2 As shown in , the access address port (1.1.1.1:80) is mapped to the service address port (127.0.0.1:1025) corresponding to virtual service 1, the access address port (1.1.1.2:80) is mapped to the service address port (127.0.0.1:1026) corresponding to virtual service 2, and the access address ports (1.1.1.3:80) and (1.1.1.4:80) are both mapped to the target address port (127.0.0.1:8000). Afterwards, when the first access address port matches the configuration information, the network packet transceiver process directly forwards the mapped network packet to the target proxy process through the protocol stack, or when the first access address port matches the first target list, after generating a second target network packet based on the mapped network packet, the second target network packet is forwarded to the target proxy process.

[0110] In an optional embodiment, after the network packet transceiver process determines the second target network packet, the network packet transceiver process sends the second target network packet to the protocol stack. Optionally, the protocol stack is used to generate a target structure based on the second target network packet, and associate the target structure with a socket, so that the target proxy process obtains the target data content from the target structure through the socket, wherein the target structure and the target data content include the first access address port.

[0111] Optionally, the target proxy process implements network communication through a socket. Since the network packet receiving and sending process performs DNAT processing on the network packet, the address port obtained by the target proxy process through the socket is not the original one, that is, the address port is not the access address port. In the related art, in order to enable the target proxy process to obtain the original address port (i.e., the first access address port) corresponding to the network packet, the service in the target proxy process is generally set to correspond to the original address port one by one, and the corresponding relationship between the service and the original address port is written into the configuration of the target proxy process for the target proxy process to parse and use in the business processing process. That is, in this embodiment, when the first access address port matches the configuration information, after mapping the first access address port to the port corresponding to the service, the obtained new network packet can be directly forwarded to the target proxy process through the protocol stack.

[0112] In the present application, when the first access address port matches the first target list, since the original address port corresponding to the target service is uncertain, that is, it may change over time, and there may be multiple original address ports corresponding to the target service, the second target network packet can be determined based on the first target network packet and the first access address port. Therefore, the target proxy process can effectively obtain the original address port when processing the target data content corresponding to the second target network packet.

[0113] Specifically, in this embodiment, after the protocol stack obtains the second target network packet, the protocol stack assembles the structure sk buff for describing the network packet based on the second target network packet, that is, assembles the target structure sk buff. Afterwards, the socket layer in the protocol stack associates sk_buff with the socket, so that the target proxy process can obtain the target data content from the socket through the getsockopt() function and obtain the first access address port. When assembling sk_buff, if Figure 3 As shown, the protocol stack saves the first access address port in the second target network packet to the newly added member in sk_buff, and combines the name of the second target network packet and other data content in the second target network packet to obtain the following Figure 3The target structure shown in FIG. 1 , the first access address port, name and other data contents in the target structure constitute the aforementioned target data contents. In the aforementioned socket layer receiving data process, as Figure 3 As shown, if it is found that sk_buff contains the first access address port, it is copied to the socket to obtain the following Figure 3 The data structure shown in FIG. 1 and the first access address port, name and other data contents in the socket also constitute the aforementioned target data contents. Figure 3 In the figure, the solid line part is the original workflow or data structure in the related technology, and the dotted line part is the new content in the service proxy method provided in this application.

[0114] It should be noted that, by generating a target structure based on the second target network packet through the protocol stack, and associating the target structure with the socket, the target proxy process can successfully obtain the target data content through the socket, thereby realizing effective proxy.

[0115] Optionally, the service agent device also includes: a second acquisition module, used to acquire a second access address port sent by the target agent process, wherein the second access address port is an address port that is identified by the target agent process based on a second identification rule as being unable to provide Hypertext Transfer Protocol service; a removal module, used to remove the second access address port from the first target list, and update the second target list based on the second access address port, wherein the second target list is used to record a third target access address port, and the data content corresponding to the third target access address port is data content that is prohibited from being executed by the target service within the target time.

[0116] Among them, the target proxy process is used to identify the data content corresponding to the third network packet based on the second identification rule, and determine whether the address port corresponding to the third network packet can provide Hypertext Transfer Protocol service based on the identification result, wherein the data content of the third network packet is obtained by the target proxy process from the protocol stack.

[0117] Optionally, a second identification rule is preset in the target proxy process. During the operation of the proxy device, the target proxy process can identify the original address port in the data content of the network packet transmitted from the network packet transceiver process based on the second identification rule to identify whether the address port can provide Hypertext Transfer Protocol service. Among them, the data content of the network packet transmitted from the network packet transceiver process is the data content of the aforementioned third network packet. It should be noted that when the network packet transceiver process determines that a certain access address port exists in the first target list, it will no longer detect the network packet containing the access address port sent by the target client based on the first identification rule. Therefore, at this time, the target proxy process can identify the access address port based on the second identification rule to avoid the phenomenon that the address port that originally provided HTTP service is later changed to non-HTTP service, and the network packet transceiver process cannot find it. Among them, the second identification rule can be different from the first identification rule, or it can be the same as the first identification rule.

[0118] Furthermore, after the target proxy process identifies the second access address port, the target proxy process can directly send the second access address port to the network packet transceiver process to notify the network packet transceiver process to temporarily not create a transmission control protocol connection between the network packet transceiver process and the target client the next time it receives a transmission control protocol connection request containing the access address port from the target client, so as to prohibit the data content of the data packet under the transmission control protocol connection from being sent to the target proxy process within the target time. After the network packet transceiver process obtains the second access address port, the network packet transceiver process can remove the second access address port recorded in the first target list and record the second access address port in the second target list.

[0119] Optionally, after the target proxy process identifies the second access address port, the target proxy process may also determine that the target number is greater than a preset number before sending the second access address port to the network packet transceiver process, wherein the target number is obtained by counting the number of network packets that can be used to identify the second access address port by the target proxy process. Specifically, during the proxy process, the target proxy process counts the network packets in the target service that can be used to identify a certain access address port that provides non-HTTP services. When the total amount or proportion of data packets used to identify a certain access address port that provides non-HTTP services reaches a certain threshold, the address port is sent to the network packet transceiver process.

[0120] It should be noted that since an access address port can provide HTTP service and non-HTTP service at the same time, or after a business change, the access address port that originally provided HTTP service is changed to provide non-HTTP service, therefore, the recognition of the access address port by the target proxy process is improved, and the accuracy of the recognition of the access address port is improved, thereby avoiding the situation where after the access address port is added to the first target list, the network packet receiving and sending process no longer recognizes it, resulting in the inability to adapt to the business changes or service diversity of the address port in time, and the target proxy process is unable to handle the business anomalies caused by non-HTTP services, thereby improving the effectiveness of the service agent of this application.

[0121] In an optional embodiment, for the address port recorded in the second target list, the network packet receiving and sending process can count the number of times the access address port can provide Hypertext Transfer Protocol services and the proportion of the number of times the access address port is received when the network packet corresponding to the access address port is obtained again, and when it is determined that the number of times the access address port can provide Hypertext Transfer Protocol services is greater than or equal to the first preset number of times and the proportion of the number of times the access address port is received is greater than the preset proportion, the access address port is removed from the second target list and recorded in the first target list.

[0122] It should be noted that for the access address port removed from the first target list, when the network packet sending and receiving process encounters the access address port again, the conditions for re-adding it to the first target list will be improved, so as to avoid sending non-HTTP services to the address port on the target proxy process as much as possible.

[0123] Optionally, the update submodule also includes: a determination subunit, used to determine whether the first access address port exists in the second target list when it is determined that the first access address port can provide Hypertext Transfer Protocol services; an update subunit, used to update the first target list based on the first access address port if the first access address port does not exist in the second target list.

[0124] Optionally, if the first access address port can provide Hypertext Transfer Protocol services, the network packet transceiver process also needs to determine whether the first access address port exists in the second target list. If the first access address port does not exist in the second target list, it can be determined that the proxy device has obtained the address port for the first time, so it can be directly registered. On the contrary, if the first access address port exists in the second target list, the network packet transceiver process can first allow the target client and the target server to create a transmission control protocol connection, and count the number of times it can provide Hypertext Transfer Protocol services, until the address port meets the conditions for entering the first target list again, and then register the service provided by the address port for subsequent proxy. In this way, it is possible to avoid non-HTTP services on the address port sent to the target proxy process as much as possible.

[0125] It should be noted that the present application adds the concept of a default virtual service, adds the HTTP service discovery process to the network packet receiving process, and saves the discovered address and port. Subsequently, the network packets under the TCP connection whose address and port can match the first target list are forwarded to the default virtual service registered in the target proxy process through DNAT to achieve effective proxying of related services. The method provided in the present application is applicable to but not limited to scenarios where there are many HTTP services that need to be proxied, and scenarios where the proxy services change frequently. Based on the method provided in the present application, automatic protection of HTTP services in the network can be achieved, and the management cost of HTTP proxy equipment can be reduced.

[0126] It can be seen that the solution provided in the present application achieves the purpose of automatically proxying the services provided by the address port that is not proxied by the target proxy process, thereby achieving the technical effect of reducing labor costs, and further solving the technical problem of high labor costs caused by relying on manual addition of proxy address ports on proxy devices in the prior art.

[0127] Example 3

[0128] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned service proxy method when running.

[0129] Example 4

[0130] According to another aspect of an embodiment of the present invention, an electronic device is also provided, which includes one or more processors; a memory for storing one or more programs, so that when the one or more programs are executed by the one or more processors, the one or more processors are implemented to run the programs, wherein the programs are configured to execute the above-mentioned service agent method when running.

[0131] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0132] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0133] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0134] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0135] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0136] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0137] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A service proxy method, characterized in that: include: Obtaining a transmission control protocol connection request sent by a target client, and determining a first access address port corresponding to the transmission control protocol connection request, wherein the transmission control protocol connection request is generated when the target client makes a service request to a target server; If the first access address port does not exist in the first target list, updating the first target list based on the first access address port, wherein the first target list is used to record the first target access address port, and the data content corresponding to the first target access address port is the data content that allows the target service in the target proxy process to execute; If the first access address port exists in the first target list, a transmission control protocol connection is created between the network packet receiving and sending process and the target client, and a first network packet sent by the target client through the transmission control protocol connection is obtained; Mapping the first access address port in the first network packet to a target address port corresponding to the target service, obtaining a first target network packet according to the target address port, and determining a second target network packet based on the first target network packet and the first access address port; The second target network packet is sent to the protocol stack so that the target proxy process obtains the target data content corresponding to the second target network packet from the protocol stack based on the target address port, executes the target service on the target data content, and forwards the target data content after the target service is executed to the target server.

2. The method according to claim 1, characterized in that If the first access address port does not exist in the first target list, updating the first target list based on the first access address port includes: If the first access address port does not exist in the first target list, determining whether the first access address port exists in preset configuration information, wherein the configuration information is used to record a second target access address port, and the data content corresponding to the second target access address port is the data content that allows other services in the target proxy process to execute; If the first access address port does not exist in the configuration information, and the first access address port can provide Hypertext Transfer Protocol service, then the first target list is updated based on the first access address port.

3. The method according to claim 2, characterized in that If the first access address port does not exist in the configuration information, and the first access address port can provide a hypertext transfer protocol service, updating the first target list based on the first access address port includes: If the first access address port does not exist in the configuration information, allowing the target client to establish a transmission control protocol connection with the target server, and obtaining a second network packet sent by the target client after the transmission control protocol connection is established between the target client and the target server; Based on the second network packet and a preset first identification rule, detecting whether the first access address port can provide the hypertext transfer protocol service; In a case where it is determined that the first access address port can provide the Hypertext Transfer Protocol service, the first target list is updated based on the first access address port.

4. The method according to claim 1, characterized in that: The protocol stack is used to generate a target structure based on the second target network packet, and associate the target structure with a socket so that the target agent process obtains the target data content from the target structure through the socket, wherein the target structure and the target data content include the first access address port.

5. The method according to claim 3, characterized in that: The method further comprises: Acquire a second access address port sent by the target proxy process, wherein the second access address port is an address port that the target proxy process identifies based on a second identification rule as being unable to provide the Hypertext Transfer Protocol service; The second access address port is removed from the first target list, and the second target list is updated based on the second access address port, wherein the second target list is used to record a third target access address port, and the data content corresponding to the third target access address port is data content that is prohibited from being executed by the target service within the target time.

6. The method according to claim 5, characterized in that The target proxy process is used to identify the data content corresponding to the third network packet based on the second identification rule, and determine whether the address port corresponding to the third network packet can provide the Hypertext Transfer Protocol service based on the identification result, wherein the data content of the third network packet is obtained by the target proxy process from the protocol stack.

7. The method according to claim 5, characterized in that In the case where it is determined that the first access address port can provide the hypertext transfer protocol service, updating the first target list based on the first access address port includes: In the case of determining that the first access address port can provide the hypertext transfer protocol service, determining whether the first access address port exists in the second target list; If the first access address port does not exist in the second target list, the first target list is updated based on the first access address port.

8. A service agent device, characterized in that: include: A first acquisition module is used to acquire a transmission control protocol connection request sent by a target client, and determine a first access address port corresponding to the transmission control protocol connection request, wherein the transmission control protocol connection request is generated when the target client makes a service request to a target server; An updating module, configured to update the first target list based on the first access address port if the first access address port does not exist in the first target list, wherein the first target list is used to record the first target access address port, and the data content corresponding to the first target access address port is the data content that allows the target service in the target proxy process to execute; a creation module, configured to create a transmission control protocol connection between a network packet receiving and sending process and the target client if the first access address port exists in the first target list, and obtain a first network packet sent by the target client through the transmission control protocol connection; a mapping module, configured to map the first access address port in the first network packet to a target address port corresponding to the target service, obtain a first target network packet according to the target address port, and determine a second target network packet based on the first target network packet and the first access address port; A sending module is used to send the second target network packet to the protocol stack, so that the target proxy process obtains the target data content corresponding to the second target network packet from the protocol stack based on the target address port, executes the target service on the target data content, and forwards the target data content after the target service is executed to the target server.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the service agent method according to any one of claims 1 to 7 when running.

10. An electronic device, characterized in that: The electronic device includes one or more processors; A memory for storing one or more programs, which, when executed by the one or more processors, enables the one or more processors to run the programs, wherein the programs are configured to execute the service proxy method described in any one of claims 1 to 7 when run.