Client information transparent transmission method, device, equipment and storage medium under seven-layer proxy
By writing client information in the kernel state of the seven-layer proxy server, the problem that the seven-layer proxy protocol cannot transparently transmit client information is solved, transparent transmission and flexible configuration of client information are realized, and statistics and security of the origin site are supported. Function.
Patent Information
- Application Number
- CN202311655315.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-05
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-12-05
AI Technical Summary
The existing seven-layer proxy protocol cannot transparently transmit client information to the origin site, resulting in the inability to obtain the client's original IP address and port information in some application scenarios.
In the kernel mode of the seven-layer proxy server, through the interactive interface between the user mode and the kernel mode, a transparent transmission matching table is constructed and written to match and write the client information in the forwarded message, so that the origin station can obtain the client's IP address and port number.
It realizes the transparent transmission of client information to the origin site in a seven-layer proxy environment, supports flexible configuration of forwarded message processing, avoids waste of resources, and supports the origin site for statistics, monitoring and security protection.
Smart Images

Figure CN117354368B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a method, device, equipment and storage medium for transparent transmission of client information under a seven-layer proxy. Background Art
[0002] When accessing a server through the Internet, due to considerations such as load balancing, security, and transmission efficiency, the server (source site) storing the original data is sometimes not exposed to the client. Instead, a proxy server is used to allow the client to access the proxy server, which then forwards the request to the source site, obtains the data from the source site, and then transmits it to the client.
[0003] In the prior art, a seven-layer proxy is used to forward messages. By establishing connections with the source station and the client respectively, after the original request from the client reaches the proxy server, the proxy server parses the application layer protocol and then forwards the application layer request to the source station to implement the proxy. This method is more flexible and can implement additional functions such as caching, SSL offloading, and security auditing. However, in some application scenarios, the source station needs to obtain the original IP address and port information of the client, and the existing seven-layer proxy cannot be applied to these application scenarios.
[0004] How to solve the problem that the seven-layer proxy protocol in the existing technology cannot transparently transmit client information to the source station is an urgent problem to be solved. Summary of the invention
[0005] To solve the problems in the prior art, the embodiments of this specification provide a method, device, equipment and storage medium for transparent transmission of client information under a seven-layer proxy, which solves the problem in the prior art that client information cannot be transparently transmitted under a seven-layer proxy.
[0006] The embodiment of this specification provides a method for transparent transmission of client information under a seven-layer proxy, which is applied to a seven-layer proxy server, including:
[0007] In user mode, receive and parse the original message from the client and construct the forwarding message;
[0008] In kernel state, writing the forwarding message matching the transparent transmission matching table into the client information of the client;
[0009] The forwarding message in the kernel state is sent according to the forwarding quintuple of the forwarding message.
[0010] As a further aspect of this specification, in the user state, receiving and parsing the original message of the client, and constructing the forwarding message further includes:
[0011] The forwarding message is constructed according to the parsed information of the original message and the forwarding quintuple information of the forwarding message.
[0012] As a further aspect of the present specification, the forwarding five-tuple information includes the IP address and port number of the seven-layer proxy server, the IP address and port number of the target source server, and the communication protocol.
[0013] As another further aspect of this specification, in the user state, receiving and parsing the original message of the client, and constructing the forwarding message further includes:
[0014] The transparent transmission matching table in the kernel state is updated through the interactive interface between the user state and the kernel state.
[0015] As another further aspect of the present specification, the interaction interface between the user state and the kernel state includes at least one of the following or a combination thereof: a system call interface, a shared memory, and a system file IO interface.
[0016] As another further aspect of the present specification, in the kernel state, writing the forwarding message matching the transparent transmission matching table into the client information of the client further includes:
[0017] Acquire client information in a transparent transmission matching table according to at least part of the information of the forwarded message;
[0018] The client information of the client is written into the forwarded message that matches successfully.
[0019] As another further aspect of the present specification, the transparent transmission matching table includes at least part of the information of the forwarded message and the client information.
[0020] As another further aspect of the present specification, in the user state, a matching rule is obtained according to the domain name of the target source server;
[0021] In the kernel state, the forwarded message is matched in the transparent transmission matching table according to the matching rule, wherein the matching rule includes an exact match or a fuzzy match.
[0022] As another further aspect of the present specification, matching in the transparent transmission matching table according to the matching rule further includes:
[0023] When the matching rule is an exact match, the IP address and port number of the seven-layer proxy server of the forwarded message, the IP address, port number and communication protocol of the target source server are used to match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message.
[0024] As another further aspect of the present specification, matching is performed in the transparent transmission matching table according to the matching rule, and obtaining the client information corresponding to the forwarded message further includes:
[0025] When the matching rule is a fuzzy match, at least the IP address of the seven-layer proxy server of the forwarded message is used to match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message; or
[0026] At least use the IP address of the target source server of the forwarded message to match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message; or,
[0027] The IP address and port number of the target source server of the forwarded message are used to match the client information corresponding to the forwarded message in the transparent transmission matching table.
[0028] As another further aspect of the present specification, in the user state, according to the domain name of the target source server, obtaining the matching rule also includes:
[0029] Generate an origin station configuration table according to the configuration of each origin station server, including the characteristics of the forwarded message configured by the origin station server that need to be written with the client information;
[0030] Matching the information of the original message in the source station configuration table;
[0031] The forwarding five-tuple information, client information and matching rules of the forwarding message generated successfully corresponding to the original message are transmitted to the transparent transmission matching table in the kernel state for updating.
[0032] As another further aspect of the present specification, in the kernel state, writing at least part of the forwarded message into the client information of the client further includes:
[0033] The client information includes the IP address and / or port number of the client.
[0034] As another further aspect of the present specification, in the kernel state, writing at least part of the forwarded message into the client information of the client further includes:
[0035] The client information is written into an option of a TCP message header of the at least partially forwarded message.
[0036] The embodiment of this specification also provides a device for transparent transmission of client information under a seven-layer proxy, including:
[0037] A user-mode forwarding message construction unit, used to receive and parse the client's message in the user mode and construct a forwarding message;
[0038] A kernel state client information writing unit, used for writing a forwarding message matching the transparent transmission matching table into the client information of the client in the kernel state;
[0039] A sending unit is used to send the forwarding message in the kernel state according to the forwarding quintuple of the forwarding message.
[0040] The embodiments of the present specification also provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method when executing the computer program.
[0041] The embodiments of this specification also provide a computer-readable storage medium on which computer instructions are stored. When the computer instructions are executed by a processor, the above method is implemented.
[0042] By using the embodiments of the present specification, in the kernel state of the seven-layer proxy server, a kernel-state client information writing unit is added to write client information into at least part of the forwarded messages, so that the client information can be transparently transmitted to the source server in the seven-layer proxy environment; and it is also possible to flexibly configure the processing of the forwarded messages to avoid wasting the resources of the seven-layer proxy server. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 The diagram shows a schematic diagram of a network structure based on a seven-layer proxy according to an embodiment of the present specification;
[0045] Figure 2 It is a flowchart of a method for transparently transmitting client information under a seven-layer proxy according to an embodiment of this specification;
[0046] Figure 3 The data flow diagram of client information transparent transmission under a seven-layer proxy in an embodiment of this specification is shown;
[0047] Figure 4 The flowchart of the embodiment of this specification for matching forwarded messages according to matching rules is shown;
[0048] Figure 5It is a schematic diagram of the structure of a device for transparent transmission of client information under a seven-layer proxy according to an embodiment of this specification;
[0049] Figure 6 The figure shows a computer device provided by an embodiment of this specification.
[0050] [Description of Reference Numerals]
[0051] 101. Client;
[0052] 102. Layer 7 proxy server;
[0053] 103. Origin server;
[0054] 501, user mode forwarding message construction unit;
[0055] 502, kernel state client information writing unit;
[0056] 503, sending unit;
[0057] 602. Computer equipment;
[0058] 604, processor;
[0059] 606. Memory;
[0060] 608, driving mechanism;
[0061] 610, input / output module;
[0062] 612. Input devices;
[0063] 614. Output device;
[0064] 616. Presentation equipment;
[0065] 618. Graphical user interface;
[0066] 620, network interface;
[0067] 622, communication link;
[0068] 624. Communication bus. DETAILED DESCRIPTION
[0069] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0070] like Figure 1The diagram shows a schematic diagram of a network structure based on a seven-layer proxy according to an embodiment of the present specification. In this diagram, multiple clients 101, a seven-layer proxy server 102, and multiple source station servers 103 are described.
[0071] The client 101 includes but is not limited to electronic devices such as self-service terminal devices, desktop computers, tablet computers, laptop computers, smart wearable devices, etc. Optionally, the operating system running on the electronic device may include but is not limited to Android system, IOS system, Linux, Windows, etc. Of course, the client 101 is not limited to the above-mentioned electronic devices with certain entities, and it can also be software running in the above-mentioned electronic devices.
[0072] The seven-layer proxy server 102 and the multiple source station servers 103 can be independent physical servers, or a server cluster or distributed system composed of multiple physical servers. They can also be cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms.
[0073] The client 101 initiates an original access request message according to the domain name of the source station server 103. The source IP address and port number of the original access request message are the IP address and port number of the client 101, and the destination IP address and port number are the first IP address and the first port number of the seven-layer proxy server 102. After receiving the original access request message, the seven-layer proxy server 102 parses the original access request message and reconstructs a forwarding message corresponding to the original message. In this process, the seven-layer proxy server 102 can implement additional functions such as caching, SSL offloading (secure socket protocol offloading, the process of unloading SSL encrypted data streams into non-encrypted format data streams), security auditing, etc., and implements in the user state of the seven-layer proxy server 102, such as Nginx, Apache, HAProxy, etc. The source IP address and port number of the forwarding message are the second IP address and the second port number of the seven-layer proxy server 102, and the destination address is the IP address and port number of the target source station server 103. In an embodiment of the present specification, the seven-layer proxy server 102 also calls the kernel-mode client information writing unit in the kernel mode to write the information of the client 101, such as the client IP address and port number, into the option field of the forwarding message sent to the target source station server 103, so that the target source station server 103 can obtain the client information for statistical or analysis purposes.
[0074] like Figure 2The flowchart of the method for transparent transmission of client information under a seven-layer proxy in the embodiment of this specification is shown. Figure 1 The seven-layer proxy server of the network architecture adds client information to the forwarding message specified by the source server while implementing the proxy forwarding message, so that the source server can perform other application statistics and other functions according to the client information. The method specifically includes:
[0075] Step 201, in user mode, receiving and parsing the original message from the client, and constructing a forwarding message;
[0076] Step 202: In kernel mode, write the forwarding message that matches the transparent transmission matching table into the client information of the client;
[0077] Step 203: Send the forwarding message in the kernel state according to the forwarding quintuple of the forwarding message.
[0078] Through the method of the above-mentioned embodiment of this specification, in the kernel state of the seven-layer proxy server, by adding a kernel-state client information writing unit to write client information to at least part of the forwarded messages, the client information can be transparently transmitted to the source server in the seven-layer proxy environment.
[0079] As an embodiment of the present specification, in the user state, receiving and parsing the original message of the client, and constructing the forwarding message further includes:
[0080] The forwarding message is constructed according to the parsed original message information and the forwarding quintuple information.
[0081] In this embodiment, the seven-layer proxy server parses the original message sent by the client in the user state, obtains the data content in the original message, performs additional functions such as caching, SSL offloading, and security auditing, constructs a forwarding message corresponding to the original message sent by the client, and sends the forwarding message to the kernel state for encapsulation.
[0082] The user state may include, for example, application programs running on an application layer above an operating system, and the kernel state may include, for example, kernel operations at an operating system layer.
[0083] In this embodiment, the forwarding quintuple information includes the IP address and port number of the seven-layer proxy server (as the source IP address and port number of the forwarded message), the IP address and port number of the target source server (as the target IP address and port number of the forwarded message) and the communication protocol.
[0084] As an embodiment of the present specification, in the user state, receiving and parsing the original message of the client, and constructing the forwarding message further includes:
[0085] The transparent transmission matching table in the kernel state is updated through the interactive interface between the user state and the kernel state.
[0086] In this embodiment, a module capable of writing client information to the option field of the TCP header of the forwarded message in the kernel of the operating system is constructed through the hook node of the operating system in the kernel state, that is, the kernel state client information writing unit in this embodiment. In the user state, according to the conditions pre-set by the source station server, the original message information is obtained in the original message, such as the domain name or URL of the source station server accessed by the client, and when the pre-set conditions are met, at least part of the information (all or part of the forwarding five-tuple information) and the client information of the forwarded message obtained by the user state through the interactive interface are sent to the transparent transmission matching table of the kernel state to update the transparent transmission matching table. Information such as matching rules can also be sent through the interactive interface to notify the kernel state client information writing unit which matching rule to use to match the forwarded message with the record in the transparent transmission matching table. Wherein, updating the transparent transmission matching table means adding a new record in the transparent transmission matching table, or modifying the original record in the transparent transmission matching table.
[0087] As an embodiment of the present specification, the interaction interface between the user state and the kernel state includes at least one of the following or a combination thereof: a system call interface, a shared memory and system file IO interface, or other interfaces provided by the operating system, such as a network communication interface (Socket interface) for transmitting and forwarding messages between the user state and the kernel state.
[0088] As an embodiment of the present specification, in the kernel state, writing the forwarding message matching the transparent transmission matching table into the client information of the client further includes:
[0089] Acquire client information in a transparent transmission matching table according to at least part of the information of the forwarded message;
[0090] The client information of the client is written into the forwarded message that matches successfully.
[0091] In this embodiment, the transparent transmission matching table includes at least part of the information of the forwarded message and the client information, wherein, for example, the forwarding five-tuple information of the forwarded message composed of the IP address and port number of the destination source station server of the forwarded message, the IP address and port number of the seven-layer proxy server, and the communication protocol can be matched in the transparent transmission matching table in the kernel state, and the transparent transmission matching table records the option fields of the TCP packet headers of the forwarded messages into which the client information is to be added. For example, when the forwarding five-tuple information of the forwarded message matches the forwarding five-tuple information recorded in the transparent transmission matching table, the corresponding client information in the transparent transmission matching table can be obtained, and the client information is added to the option field of the TCP packet header of the corresponding forwarded message by using the kernel state client information writing unit; the transparent transmission matching table can also include matching rules. When the match is successful, the matching rules can also be obtained, so that different matching rules are used to compare the forwarded message in the kernel state with the records in the transparent transmission matching table, such as the exact matching rules and fuzzy matching rules described later.
[0092] As an embodiment of the present specification, before obtaining the client information in the transparent transmission matching table according to at least part of the information of the forwarded message, the method further includes:
[0093] In the user state, a matching rule is obtained according to the domain name of the target source server;
[0094] In the kernel state, the forwarded message is matched in the transparent transmission matching table according to the matching rule, wherein the matching rule includes an exact match or a fuzzy match.
[0095] In this embodiment, the kernel-mode client information writing unit in the kernel mode of the seven-layer proxy server can use all the information of the forwarding five-tuple in the forwarding message to match in the transparent transmission matching table, or can use part of the information of the forwarding five-tuple in the forwarding message to match in the transparent transmission matching table, or can use the target source station server IP address or port number in the forwarding message to match in the transparent transmission matching table. Which matching rule to use can be determined when the client sends the message, for example, the matching rule can be determined according to the domain name of the target source station server for the client to request resources, or the matching rule can be determined according to the IP address and / or port number of the target source station server. The matching rule can be set in advance in the seven-layer proxy server by the source station server, such as the source station URL to be accessed in the original message. When the source station URL in the original message matches the set value, the corresponding matching rule is used.
[0096] As an embodiment of the present specification, matching in the transparent transmission matching table according to the matching rule further includes:
[0097] When the matching rule is an exact match, the IP address and port number of the seven-layer proxy server of the forwarded message, the IP address, port number and communication protocol of the target source server are used to match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message.
[0098] In this embodiment, the exact match may be performed using the forwarding quintuple information of the forwarded message, for example, the entire information of the forwarding quintuple is used for matching.
[0099] As an embodiment of the present specification, matching in the transparent transmission matching table according to the matching rule further includes:
[0100] When the matching rule is a fuzzy match, at least the IP address of the seven-layer proxy server of the forwarded message is used to match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message; or
[0101] At least use the IP address of the target source server of the forwarded message to match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message; or,
[0102] The IP address and port number of the target source server of the forwarded message are used to match the client information corresponding to the forwarded message in the transparent transmission matching table.
[0103] In this embodiment, the IP address of the seven-layer proxy server of the forwarding message can be used for matching in fuzzy matching, and a part of the information in the forwarding five-tuple can also be used for matching, for example, the IP address and port number of the target source server. The IP address of the seven-layer proxy server of the forwarding message, the IP address, port number and communication protocol of the target source server can also be used to match in the transparent transmission matching table to obtain the client information corresponding to the forwarding message. In other embodiments, the information combination in the forwarding five-tuple information of the forwarding message can be used for matching, which is not limited to the above-mentioned methods, and can also include, for example, matching only the IP address of the seven-layer proxy server, or matching the IP address and communication protocol of the seven-layer proxy server, etc., and the arrangement and combination of a part of the information in the forwarding five-tuple information.
[0104] As an embodiment of the present specification, in the user state, according to the domain name of the target source server, obtaining the matching rule further includes:
[0105] Generate a source station configuration table according to the configuration of each source station server, wherein the source station configuration table includes features of forwarding messages configured by the source station server that need to be written with client information;
[0106] Matching the information of the original message in the source station configuration table;
[0107] The forwarding five-tuple information, client information and matching rules of the forwarding message generated successfully corresponding to the original message are transmitted to the transparent transmission matching table in the kernel state for updating.
[0108] In this embodiment, the proxy application in the user state of the seven-layer proxy server provides an interface for communicating with each source station server. Through this interface, each source station server can configure on the proxy application which forwarding messages are to carry client information. For example, when the target source station server IP address or port number of the forwarding message is a specified IP address or port number, the forwarding five-tuple information, client information and matching rules of the forwarding message need to be sent to the transparent transmission matching table in the kernel state through the interactive interface between the user state and the kernel state for updating, so as to facilitate screening and modification when the forwarding message is encapsulated in the kernel state, and write the client information into the forwarding message that matches at least part of the forwarding five-tuple information in the transparent transmission matching table according to the matching rules.
[0109] As an embodiment of the present specification, in the kernel state, writing at least part of the forwarded message into the client information of the client further includes:
[0110] The client information is written into an option of a TCP message header of the at least partially forwarded message.
[0111] In this embodiment, since the kernel-state client information writing unit in the kernel state of the seven-layer proxy server matches the forwarding message in the transparent transmission matching table according to the matching rules, and writes the client information into the forwarding message according to the configuration information of the target source station server, some forwarding messages have the client information written into them, while some forwarding messages do not have the client information written into them. In this way, it is possible to flexibly configure whether to include the client information in the forwarding message according to the needs of the source station server. For the forwarding messages that do not need to be counted, no additional processing is required, thereby saving the computing resources and memory consumption of the seven-layer proxy server.
[0112] As an embodiment of the present specification, in the kernel state, after writing at least part of the forwarded message into the client information of the client, further comprising:
[0113] Update the checksum field of the forwarded message that contains the client information.
[0114] In this embodiment, after writing the client information into the option field of the TCP packet header of the forwarded message, the IP check field and TCP check field of the original forwarded message will be wrong, and the check field needs to be updated. That is to say, the check field generation algorithm in the prior art is used to generate a new check field in combination with the content of the forwarded message, and the newly generated check field replaces the check field of the original forwarded message.
[0115] Through the method of the embodiment of the present specification, in the kernel state of the seven-layer proxy server, by adding a kernel state client information writing unit to write client information to at least part of the forwarded message, the client information can be transparently transmitted to the source server in the seven-layer proxy environment; and it is also possible to flexibly configure the processing of the forwarded message to avoid wasting the resources of the seven-layer proxy server. The source server can perform statistics, monitoring, security protection and other processing based on the client information, count the number of visits, monitor the access behavior and trace back the client, and protect the client from malicious access and attack behavior.
[0116] like Figure 3 The figure shows a data flow diagram of client information transparent transmission under a seven-layer proxy in an embodiment of the present specification. In this figure, data flow of a client, a seven-layer proxy server and a target source server in a system under a seven-layer proxy is described. In this embodiment, the seven-layer proxy server includes a user state and a kernel state. A session consisting of a client, a seven-layer proxy server and a target source server includes multiple data packets. The client's message is sent to the network interface of the seven-layer proxy server through the network, and the message is transmitted to the user-state proxy application through the kernel state of the seven-layer proxy server. The proxy application obtains information about the original message sent by the client, performs various pre-defined parsing and processing on the message, and constructs it into a forwarding message and sends it to the kernel state. The kernel state client information writing unit in the kernel state matches according to the matching rules and the transparent transmission matching table, determines which forwarding messages need to be written with client information, and writes the client information in the option field of the TCP packet header of the forwarding message where the client information needs to be written, and sends it to the target source server. The specific process includes:
[0117] Step 301: The client sends an original message to the layer-7 proxy server.
[0118] In this step, the original message quintuple sent by the client includes the client IP address and port number (IP_A, Port_A), the seven-layer proxy server IP address and port number (IP_B1, Port_B1), and the communication protocol. Among them, the source IP address and port number of the original message are the client IP address and port number (IP_A, Port_A), and the target IP address and port number are the seven-layer proxy server IP address and port number (IP_B1, Port_B1).
[0119] The original message sent by the client reaches the network interface of the seven-layer proxy server through the network, and the kernel state of the seven-layer proxy server transmits the original message to the proxy application in the user state.
[0120] Step 302: The proxy application constructs a forwarding message based on the original message.
[0121] In this step, the proxy application can perform statistics, processing and other operations on the received original message, and can also obtain the information of the original message, such as the domain name, URL, IP address and port number of the target source server, client information and other information. According to the information of the original message and the forwarding five-tuple information, a forwarding message is constructed, and the forwarding message is sent to the kernel state through the Socket interface to process the forwarding message to the target source server. Among them, the proxy application can also connect and communicate with the target source server through the Socket, so as to obtain the IP address and port number of the target source server, and the forwarding five-tuple information includes the seven-layer proxy server IP address and port number (IP_B2, Port_B2), the target source server IP address and port number (IP_C, Port_C), and the communication protocol. Among them, the source IP address and port number of the forwarding message are the seven-layer proxy server IP address and port number (IP_B2, Port_B2), and the target IP address and port number are the target source server IP address and port number (IP_C, Port_C).
[0122] Furthermore, as shown by the dotted line in the figure, through the interface provided by the proxy application, the source station server can also pre-set its own matching rules and configuration information. The proxy application can also generate a source station configuration table for each source station server, which records the configuration information of each source station server, that is, for which forwarding messages the client information is written. For example, after parsing the original message, the target source station server IP address in the original message information obtained is a specified IP address (that is, the source station server IP address), or the port number of the target source station server is a specified port number (that is, the source station server port number), or the URL to be accessed in the original message information belongs to a domain name specified by the target source station server, then the client information corresponding to the forwarding message needs to be sent to the target source station server, and what kind of matching rules are used for the forwarding messages that meet the requirements.
[0123] The proxy application queries whether there is a corresponding record in the source station configuration table based on the information of the original message, for example, the domain name of the target source station server in the original message information. If there is a corresponding record, it indicates that the target source station requires the seven-layer proxy server to carry client information in the forwarding message. The proxy application sends the forwarding quintuple information and client information of the forwarding message corresponding to the original message to the kernel state transparent transmission matching table through the interactive interface for update.
[0124] Among them, the proxy application determines which source station server to establish a Socket connection with based on the domain name of the target source station server accessed by the client obtained by parsing the message, and can also determine the matching rules pre-set by the target source station based on the domain name of the target source station server, including fuzzy matching and exact matching. The proxy application can also send the matching rules to the kernel-mode client information writing unit through the interactive interface.
[0125] Step 303: The proxy application sends the forwarding five-tuple information of the forwarded message and the client information to the transparent transmission matching table in the kernel state for updating.
[0126] In this step, the proxy application sends the forwarding five-tuple information of the forwarded message and the client information to the transparent transmission matching table of the kernel state through the interactive interface between the user state and the kernel state, such as the interactive interface formed by shared memory, system call, etc.
[0127] As another embodiment, the matching rules may also be sent to the transparent matching table in the kernel state through the interactive interface for updating.
[0128] After the transparent transmission matching table is updated, when the proxy application of the seven-layer proxy server receives other messages of the same session of the client, it will no longer match the source station configuration table, but directly match the transparent transmission matching table in the kernel state, and then add the client information to the message according to the matching result and send it to the target source station server, or do not perform additional processing on the forwarded message and send it directly to the target source station server.
[0129] Step 304: the kernel-mode client information writing unit matches the forwarding message in the transparent transmission matching table according to the matching rule.
[0130] In this step, the data recorded in the transparent transmission matching table can be aged according to time or access frequency. For example, when the existence time of the data in the transparent transmission matching table exceeds a predetermined threshold value (at this time, each data in the transparent transmission matching table also needs to have a data field of a timestamp for recording the time when the record is written), the data can be deleted. Alternatively, when the access frequency of the data in the transparent transmission matching table is lower than a certain threshold value (at this time, each record in the transparent transmission matching table also needs to have a field for recording the number of accesses), the data can be deleted.
[0131] You can refer to Figure 4 The flowchart of the forwarding message matching according to the matching rules in the embodiment of this specification is shown. In this figure, it is described that the kernel state client information writing unit filters all received forwarding messages and matches the forwarding messages in the transparent transmission matching table. If no match is successful, no additional operation is performed on the forwarding message, which specifically includes:
[0132] Step 401, determine the matching rule.
[0133] In this step, if the matching rule is an exact match, the process proceeds to step 405 ; if the matching rule is a fuzzy match, the process proceeds to step 402 .
[0134] Step 402, when fuzzy matching is the first matching rule, the IP address and port number (IP_C, Port_C) of the target source server of the forwarded message are used to match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message.
[0135] Step 403, when fuzzy matching is the second matching rule, the IP address (IP_C) of the target source server of the forwarded message is used to match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message.
[0136] Step 404, when the fuzzy match is the third matching rule, the IP address (IP_B2) of the seven-layer proxy server of the forwarded message, the IP address and port number (IP_C, Port_C) of the target source server are used to match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message.
[0137] The fuzzy matching matching rules may also have other combinations, such as using the IP address (IP_B2) of the seven-layer proxy server that forwards the message to match in the transparent transmission matching table, etc., which will not be described in detail here.
[0138] Step 405, when the matching rule is an exact match, the IP address and port number (IP_B2, Port_B2) of the seven-layer proxy server of the forwarded message, the IP address and port number (IP_C, Port_C) of the target source server and the communication protocol are used to match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message.
[0139] Step 305: The kernel-mode client information writing unit writes the client information into the forwarded message.
[0140] In this step, when the information of the forwarding message matches the forwarding message information in the transparent transmission matching table, the kernel state client information writing unit writes the client information into the option field of the TCP header of the forwarding message and updates the check field of the forwarding message.
[0141] Step 306: The kernel state of the seven-layer proxy server sends the forwarding message to the target source server through the network interface.
[0142] In this step, the forwarding message includes the forwarding message with the client information written in it and the forwarding message without the client information written in it. The kernel state of the seven-layer proxy server sends all the forwarding messages to the corresponding target source server through the network interface.
[0143] like Figure 5 The figure shows a schematic diagram of the structure of a device for transparent transmission of client information under a seven-layer proxy according to an embodiment of the present specification. In this figure, the structure of a seven-layer proxy server is described, wherein each unit can be implemented by software or by a general chip with a specific processing logic written therein. The device specifically includes a user-mode forwarding message construction unit 501, a kernel-mode client information writing unit 502, and a sending unit 503 in the kernel mode:
[0144] A user-mode forwarding message construction unit 501 is used to receive and parse the client's message in the user mode to construct a forwarding message;
[0145] A kernel state client information writing unit 502, used to write the forwarding message matching the transparent transmission matching table into the client information of the client in the kernel state;
[0146] The sending unit 503 is used to send the forwarding message in the kernel state according to the forwarding quintuple of the forwarding message.
[0147] like Figure 6A computer device provided in an embodiment of this specification is shown. The method for implementing client information transparent transmission under a seven-layer proxy in an embodiment of this specification can be run on the computer device in this embodiment to execute the above method of this specification. The computer device 602 may include one or more processors 604, such as one or more central processing units (CPUs), and each processing unit may implement one or more hardware threads. The computer device 602 may also include any memory 606, which is used to store any kind of information such as code, settings, data, etc. Non-limiting, for example, the memory 606 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory can use any technology to store information. Further, any memory can provide volatile or non-volatile retention of information. Further, any memory can represent a fixed or removable component of the computer device 602. In one case, when the processor 604 executes an associated instruction stored in any memory or a combination of memories, the computer device 602 can perform any operation of the associated instruction. The computer device 602 also includes one or more drive mechanisms 608 for interacting with any storage, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.
[0148] The computer device 602 may also include an input / output module 610 (I / O) for receiving various inputs (via input devices 612) and for providing various outputs (via output devices 614). A specific output mechanism may include a presentation device 616 and an associated graphical user interface (GUI) 618. In other embodiments, the input / output module 610 (I / O), the input device 612, and the output device 614 may not be included, and the computer device 602 may be used as a computer device in a network. The computer device 602 may also include one or more network interfaces 620 for exchanging data with other devices via one or more communication links 622. One or more communication buses 624 couple the components described above together.
[0149] The communication link 622 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 622 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.
[0150] The embodiment of the present specification also provides a computer-readable instruction, wherein when a processor executes the instruction, the program therein causes the processor to execute the method as described above.
[0151] It should be understood that in the various embodiments of this specification, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this specification.
[0152] It should also be understood that in the embodiments of this specification, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this specification generally indicates that the associated objects before and after are in an "or" relationship.
[0153] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this specification can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this specification.
[0154] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0155] In the several embodiments provided in this specification, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.
[0156] 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 on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of this specification.
[0157] In addition, each functional unit in each embodiment of this specification 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 integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0158] 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 this specification is essentially 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. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of this specification. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0159] Specific embodiments are used in this specification to illustrate the principles and implementation methods of this specification. The description of the above embodiments is only used to help understand the methods and core ideas of this specification. At the same time, for those skilled in the art, according to the ideas of this specification, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on this specification.
Claims
1. A method for transparent transmission of client information under a seven-layer proxy, characterized in that: Applicable to seven-layer proxy servers, including: In user mode, receiving and parsing the original message of the client, and constructing a forwarding message; wherein the source IP address and port number of the forwarding message are respectively the IP address and port number of the seven-layer proxy server, and the target IP address and port number of the forwarding message are respectively the IP address and port number of the target source station server; In kernel state, writing the client information of the client into the option of the TCP message header of the forwarding message matching the transparent transmission matching table; Sending the forwarding message in the kernel state according to the forwarding quintuple of the forwarding message; In the kernel state, the client information of the client written into the option option of the TCP message header of the forwarding message matching the transparent transmission matching table further includes: Acquire client information in a transparent transmission matching table according to at least part of the information of the forwarded message; Writing the client information of the client into the option of the TCP message header of the successfully matched forwarded message; Before obtaining the client information in the transparent transmission matching table according to at least part of the information of the forwarded message, the method further includes: In the user state, obtaining a matching rule; In the kernel state, the forwarded message is matched in the transparent transmission matching table according to the matching rule, wherein the matching rule includes an exact match or a fuzzy match.
2. The method for transparent transmission of client information under a seven-layer proxy according to claim 1 is characterized in that: In user mode, the original message from the client is received and parsed, and the forwarding message is constructed, further including: The forwarding message is constructed according to the parsed information of the original message and the forwarding quintuple information of the forwarding message.
3. The method for transparent transmission of client information under a seven-layer proxy according to claim 2 is characterized in that: In user mode, the original message from the client is received and parsed, and the forwarding message is constructed, further including: The transparent transmission matching table in the kernel state is updated through the interactive interface between the user state and the kernel state.
4. The method for transparent transmission of client information under a seven-layer proxy according to claim 3 is characterized in that: The interaction interface between the user state and the kernel state includes at least one of the following or a combination thereof: a system call interface, a shared memory, and a system file IO interface.
5. The method for transparent transmission of client information under a seven-layer proxy according to claim 1 is characterized in that: The transparent transmission matching table includes at least part of the information of the forwarded message and the client information.
6. The method for transparent transmission of client information under a seven-layer proxy according to claim 1 is characterized in that: Matching in the transparent transmission matching table according to the matching rule further includes: When the matching rule is an exact match, the IP address and port number of the seven-layer proxy server of the forwarded message, the IP address, port number and communication protocol of the target source server are used to match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message.
7. The method for transparent transmission of client information under a seven-layer proxy according to claim 1 is characterized in that: Matching in the transparent transmission matching table according to the matching rule, obtaining the client information corresponding to the forwarded message further includes: When the matching rule is fuzzy matching, at least the IP address of the seven-layer proxy server of the forwarded message is used to match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message; or, At least the IP address of the target source server of the forwarded message is used to perform a match in the transparent transmission matching table to obtain the client information corresponding to the forwarded message.
8. The method for transparent transmission of client information under a seven-layer proxy according to claim 1 is characterized in that: In the user state, according to the domain name of the target source server, the matching rules are also obtained, Generate an origin station configuration table according to the configuration of each origin station server, including the characteristics of the forwarded message configured by the origin station server that need to be written with the client information; Matching the information of the original message in the source station configuration table; The forwarding five-tuple information, client information and matching rules of the forwarding message generated successfully corresponding to the original message are transmitted to the transparent transmission matching table in the kernel state for updating.
9. The method for transparent transmission of client information under a seven-layer proxy according to claim 1 is characterized in that: The client information includes the IP address and / or port number of the client.
10. A device for transparent transmission of client information under a seven-layer proxy, characterized in that include, A user-state forwarding message construction unit is used to receive and parse the client's message in the user state to construct a forwarding message; wherein the source IP address and port number of the forwarding message are respectively the IP address and port number of the seven-layer proxy server, and the target IP address and port number of the forwarding message are respectively the IP address and port number of the target source station server; in the user state, a matching rule is obtained; A kernel state client information writing unit is used to write the client information of the client in the option option of the TCP message header of the forwarded message that matches the transparent transmission matching table in the kernel state; match the forwarded message in the transparent transmission matching table according to the matching rule, wherein the matching rule includes obtaining the client information by exact matching or fuzzy matching, and write the client information of the client in the option option of the TCP message header of the forwarded message that successfully matches; A sending unit is used to send the forwarding message in the kernel state according to the forwarding quintuple of the forwarding message.
11. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 9 is implemented.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method of any one of claims 1 to 9 is executed.
