A connection filtering method, system, and readable storage medium for multiple IP clients.
By building a database on the Samba server to identify and reject redundant connections, network errors caused by multiple IP client connections are solved and the normal operation of SMB business is ensured.
Patent Information
- Application Number
- CN202110998146.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-27
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-08-27
AI Technical Summary
In a multi-network card configuration, the multi-IP connection of the Windows client may cause the SMB server to mistake it for multiple clients, causing incorrect operations when the network is temporarily interrupted, affecting the client's access to the same file.
By building two databases on the Samba server to save the client's GUID and NETBIOS host name respectively, when redundant connections are detected, connection requests initiated by new IPs are rejected to prevent redundant connections from affecting the SMB business.
This ensures that multiple IP connections of the same client do not affect the normal use of SMB services and avoids network errors caused by redundant connections.
Smart Images

Figure CN113890893B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a connection filtering method and system for multiple IP clients and a readable storage medium. Background Art
[0002] The Windows client supports multiple network adapters and multiple IP addresses. With multiple network adapters, one network adapter can connect to the public network via the default gateway, while another network adapter can connect to the private network via a different default gateway. Typically, these two networks are independent. However, in some real-world environments, these two networks can be connected to a common SMB server simultaneously through static routing or dynamic routing information protocols.
[0003] From the Samba server's perspective, if it is an SMB multi-channel connection, multiple IPs correspond to the same client GUID identifier, so all these connections will be transferred to the same process for processing.
[0004] If two IP addresses of the same client are automatically switched to another network to initiate an SMB connection due to network problems, the Samba server will treat these two IP addresses as two different clients and assign a separate child process to each client IP address. If the first SMB connection is only a brief network interruption and not completely disconnected, there will be two simultaneous connections between the Windows client and the Samba server. The impact of this is that if the client's operation on the same file is temporarily interrupted and the request is sent to the Samba server through another network path, the server will fail to find the file open information and perform an operation error, affecting client access. Summary of the Invention
[0005] In view of this, the present invention proposes a connection filtering method, system and readable storage medium for multiple IP clients. By identifying and judging the GUID and NETBIOS information of the new IP when multiple IPs of the client initiate SMB connections, the problem of redundant connections on the same client affecting client access is solved, and the normal use of existing SMB services can be guaranteed.
[0006] Based on the above purpose, an embodiment of the present invention provides a connection filtering method for a multi-IP client, which specifically includes the following steps:
[0007] Constructing a first database and a second database, and obtaining the GUID and NETBIOS host name of the IP when receiving an SMB connection request initiated by the client IP for the first time, and saving them to the first database and the second database respectively;
[0008] In response to receiving an SMB connection request initiated by another IP of the client again, obtaining the GUID and NETBIOS host name of the further IP, and determining whether the GUID of the further IP exists in the first database;
[0009] In response to the GUID of the further IP not existing, determining whether the NETBIOS host name of the further IP in the second database exists;
[0010] In response to the existence of the NETBIOS host name of the further IP, the connection request initiated by the further IP is rejected.
[0011] In some embodiments, the first database and the second database each include a plurality of key-value pairs, wherein the key-value pairs include a keyword and a value;
[0012] Obtaining the GUID and NETBIOS host name of the IP and saving them to the first database and the second database respectively includes:
[0013] The GUID and NETBIOS host name of the IP are obtained and saved to the keywords of the first database and the keywords of the second database respectively for retrieval and access.
[0014] In some embodiments, the method further comprises:
[0015] Obtain the client source IP and SMB channel index number of the IP, save the client source IP and the SMB channel index number to the values corresponding to the keyword in the first database, and save the client source IP to the value corresponding to the keyword in the second database.
[0016] In some implementations, rejecting the connection initiated by the further IP includes:
[0017] Put the connection request at the tail of the chain cache queue;
[0018] The main thread of connection filtering based on multiple IP clients builds a rejection response sub-thread;
[0019] Based on the rejection response subthread, read the pending connection request from the head of the chain cache queue;
[0020] Based on the pending connection request, a rejection response message is constructed and sent to the client.
[0021] In some implementations, constructing a rejection response message includes:
[0022] Construct a rejection response data structure, exchange the source IP and destination IP, as well as the source TCP port and destination TCP port in the pending connection request and add them to the rejection response data structure, and add the SMB message type code and rejection status code to the rejection response data structure to generate the rejection response message.
[0023] In some implementations, sending the rejection response message to the client includes:
[0024] The rejection response message is added to an output queue, and the output queue sends the message to the client corresponding to the destination IP in the rejection response message.
[0025] In some embodiments, the method further comprises:
[0026] In response to the existence of the GUID of the further IP, multi-channel logic processing is performed on the further IP.
[0027] In some embodiments, the method further comprises:
[0028] In response to the NETBIOS host name of the further IP not existing, the GUID and the NETBIOS host name of the further IP are saved in the KEYs of the first database and the second database respectively.
[0029] Another aspect of the present invention provides a connection filtering system for multiple IP clients, including:
[0030] A construction module configured to construct a first database and a second database, and upon receiving an SMB connection request initiated by an IP address of a client for the first time, obtain a GUID and a NETBIOS host name of the IP address, and save the obtained GUID and the NETBIOS host name to the first database and the second database, respectively;
[0031] a determination module configured to, in response to receiving an SMB connection request initiated by another IP of the client again, obtain the GUID and NETBIOS host name of the another IP, and determine whether the GUID of the another IP exists in the first database;
[0032] The determination module is further configured to determine whether a NETBIOS host name of another IP in the second database exists in response to the GUID of the another IP not existing;
[0033] A connection rejection module is configured to reject the connection request initiated by the further IP in response to the existence of the NETBIOS host name of the further IP.
[0034] In another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program that, when executed by a processor, implements the following method steps:
[0035] Constructing a first database and a second database, and obtaining the GUID and NETBIOS host name of the IP when receiving an SMB connection request initiated by the client IP for the first time, and saving them to the first database and the second database respectively;
[0036] In response to receiving an SMB connection request initiated by another IP of the client again, obtaining the GUID and NETBIOS host name of the further IP, and determining whether the GUID of the further IP exists in the first database;
[0037] In response to the GUID of the further IP not existing, determining whether the NETBIOS host name of the further IP in the second database exists;
[0038] In response to the existence of the NETBIOS host name of the further IP, rejecting the connection request initiated by the further IP.
[0039] In some embodiments, the first database and the second database each include a plurality of key-value pairs, wherein the key-value pairs include a keyword and a value;
[0040] Obtaining the GUID and NETBIOS host name of the IP and saving them to the first database and the second database respectively includes:
[0041] The GUID and NETBIOS host name of the IP are obtained and saved to the keywords of the first database and the keywords of the second database respectively for retrieval and access.
[0042] In some embodiments, the method steps further include:
[0043] Obtain the client source IP and SMB channel index number of the IP, save the client source IP and the SMB channel index number to the values corresponding to the keyword in the first database, and save the client source IP to the value corresponding to the keyword in the second database.
[0044] In some implementations, rejecting the connection initiated by the further IP includes:
[0045] Put the connection request at the tail of the chain cache queue;
[0046] The main thread of connection filtering based on multiple IP clients builds a rejection response sub-thread;
[0047] Based on the rejection response subthread, read the pending connection request from the head of the chain cache queue;
[0048] Based on the pending connection request, a rejection response message is constructed and sent to the client.
[0049] In some implementations, constructing a rejection response message includes:
[0050] Construct a rejection response data structure, exchange the source IP and destination IP, as well as the source TCP port and destination TCP port in the pending connection request and add them to the rejection response data structure, and add the SMB message type code and rejection status code to the rejection response data structure to generate the rejection response message.
[0051] In some implementations, sending the rejection response message to the client includes:
[0052] The rejection response message is added to an output queue, and the output queue sends the message to the client corresponding to the destination IP in the rejection response message.
[0053] In some embodiments, the method steps further include:
[0054] In response to the existence of the GUID of the further IP, multi-channel logic processing is performed on the further IP.
[0055] In some embodiments, the method steps further include:
[0056] In response to the NETBIOS host name of the further IP not existing, the GUID and the NETBIOS host name of the further IP are saved in the KEYs of the first database and the second database respectively.
[0057] The present invention has the following beneficial technical effects: by constructing a first database and a second database, and saving the IP GUID and NETBIOS host name obtained when the client IP initiates an SMB connection request for the first time, respectively, in the first database and the second database; when a new SMB connection request initiated by the client IP is received again, the new IP GUID and NETBIOS information are identified and judged with the information in the first database and the second database, thereby solving the problem that redundant connections of the same client will affect client access, and ensuring the normal use of existing SMB services. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying any creative work.
[0059] Figure 1 A block diagram of an embodiment of a connection filtering method for multiple IP clients provided by the present invention;
[0060] Figure 2 Schematic diagram of the filtering process of SMB connections of multiple IP clients provided by the present invention;
[0061] Figure 3 A schematic diagram of an embodiment of a connection filtering system for multiple IP clients provided by the present invention;
[0062] Figure 4 This is a schematic structural diagram of an embodiment of a computer-readable storage medium provided by the present invention. DETAILED DESCRIPTION
[0063] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the embodiments of the present invention are further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings.
[0064] It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are for distinguishing two non-identical entities with the same name or non-identical parameters. It can be seen that "first" and "second" are only for the convenience of expression and should not be understood as limitations on the embodiments of the present invention. Subsequent embodiments will not explain this one by one.
[0065] In order to better understand the embodiments of the present invention, relevant technical terms involved in the embodiments of the present invention are first explained.
[0066] SMB: Server Message Block, a shared transmission protocol used between different network nodes.
[0067] Samba: An application that implements the SMB protocol and provides sharing services from a Linux server to a Windows client.
[0068] GUID: Globally Unique Identifier, globally unique identifier.
[0069] NETBIOS: Network Basic Input / Output System, is a session layer protocol. Each Windows host has a separate NETBIOS host name.
[0070] TDB: Trivial database, a database storage format provided by Samba.
[0071] Based on the above purpose, the first aspect of the embodiment of the present invention provides an embodiment of a connection filtering method for multiple IP clients. Figure 1 As shown, it includes the following steps:
[0072] Step S101: construct a first database and a second database, and when an SMB connection request initiated by an IP address of a client is received for the first time, obtain the GUID and NETBIOS host name of the IP address, and save them to the first database and the second database respectively;
[0073] Step S103: in response to receiving an SMB connection request initiated by another IP of the client again, obtaining the GUID and NETBIOS host name of the further IP, and determining whether the GUID of the further IP exists in the first database;
[0074] Step S105: In response to the GUID of the further IP not existing, determining whether the NETBIOS host name of the further IP in the second database exists;
[0075] Step S107: In response to the existence of the NETBIOS host name of the further IP, reject the connection request initiated by the further IP.
[0076] By building two databases on the Samba server, and when the Windows client IP initiates an SMB connection request, the IP's GUID and NETBIOS host name are obtained and saved in the first and second databases respectively. When another IP from the same Windows client initiates a connection request, the new IP's GUID and NETBIOS host name are also obtained. First, it is determined whether the new IP's GUID information already exists in the first database. If it does, it indicates that it is an SMB multi-channel connection, and the normal multi-channel processing logic is directly performed. If it does not, it indicates that it is a new SMB connection. At this time, the Windows client's NETBIOS host name is obtained, and the second database is searched to see if the new IP's NETBIOS host name already exists. If it does, it means that multiple independent SMB connections from the same Windows client have been triggered multiple times, and the current connection needs to be filtered. At this time, a connection rejection message is sent to the multiple IPs of the same Windows client to filter the SMB connections of the new IP.
[0077] When initiating an SMB connection through a new IP of a client, the present invention identifies and judges the GUID and NETBIOS information of the new IP, thereby solving the problem that redundant connections to the same client may affect client access and ensuring the normal use of existing SMB services.
[0078] In some embodiments, the first database and the second database each include a plurality of key-value pairs, wherein the key-value pairs include a keyword and a value;
[0079] Obtaining the GUID and NETBIOS host name of the IP and saving them to the first database and the second database respectively includes:
[0080] The GUID and NETBIOS host name of the IP are obtained and saved to the keywords of the first database and the keywords of the second database respectively for retrieval and access.
[0081] In some embodiments, the method further comprises:
[0082] Obtain the client source IP and SMB channel index number of the IP, save the client source IP and the SMB channel index number to the values corresponding to the keyword in the first database, and save the client source IP to the value corresponding to the keyword in the second database.
[0083] The following describes several embodiments of the present invention through specific examples.
[0084] Build two TDB databases on the Samba server, named smb_guid.tdb and smb_netbios.tdb respectively;
[0085] The SMB connection consists of a negotiation phase and a session establishment phase. During the negotiation phase, when a Windows client initiates a connection request to a Samba server, it assigns itself a client GUID identifier using the GUID algorithm and sends it to the Samba server as part of the negotiation message.
[0086] After receiving the SMB negotiation message, the Samba server obtains the client GUID and saves it as the keyword KEY in the database smb_guid.tdb. The client's source IP and SMB channel index number (multiple channels are numbered starting from 0) are saved as the value VALUE in the database smb_guid.tdb.
[0087] During the session establishment phase, the Windows client sends the NETBIOS host name, domain name, and user information. After receiving the information, the Samba server obtains the NETBIOS host name and uses the NETBIOS host name as the key. The client source IP obtained during the negotiation phase is used as the value and saved in the database smb_netbios.tdb.
[0088] The process of obtaining the client's GUID identifier and NETBIOS name is as follows:
[0089] Because the client GUID is transmitted in network order in segments in the network data stream, each segment needs to be converted to host order when parsing it into host order. The main processing steps are as follows:
[0090] First, find the valid offset position of the SMB data from the TCP message, and then determine the SMB message type. If it is a negotiation type, locate the location of the GUID identifier and read the 16-byte fixed-length data, which includes all the field data of the GUID; the GUID is mainly composed of 5 segments, and the host sequence is converted according to the length of each segment to obtain the complete GUID host sequence data that meets the host sequence; use the client GUID identifier as the keyword KEY, and the client's IP address and index number as the VALUE, and store it in the local database smb_guid.tdb for the next retrieval access.
[0091] After the negotiation process is successful, during the SMB session connection phase, the NETBIOS host name of the Windows client is read based on the offset of the NETBIOS host name in the session. The client NETBIOS name is used as the keyword KEY and the client's source IP address is used as the VALUE. These are stored in the local database smb_netbios.tdb for the next retrieval access.
[0092] When another IP of the client initiates an SMB connection request again, it will trigger the multi-channel connection and the identification of the GUID identifier and NETBIOS host name.
[0093] Extract the client GUID identifier and NETBIOS name corresponding to the new IP when the SMB connection occurs.
[0094] Use the new IP GUID as the key to search the local database smb_guid.tdb. If the same GUID is found, update the SMB multi-channel connection information of the client corresponding to the new IP in the database (increase the current multi-channel number by 1); if the same GUID is not found, enter the NETBIOS check process.
[0095] The local database smb_netbios.tdb is retrieved using the NETBIOS name of the new IP as the KEY. If the same NETBIOS name exists, it means that the current connection is a redundant connection and the connection request initiated by the new IP is rejected. If the same NETBIOS name does not exist, the extracted client GUID identifier is used as the KEY, the client's source IP and SMB channel index number are saved as the VALUE to the database smb_guid.tdb, and the extracted NETBIOS name is used as the KEY and the client's source IP as the VALUE to save the database smb_netbios.tdb.
[0096] like Figure 2 Figure 2 shows a schematic diagram of the filtering process for SMB connections of multiple IP clients.
[0097] exist Figure 2In this example, there are two clients: Windows client 1 and Windows client 2. For Windows client 1, IP addresses IP1a and IP1b use the same GUID1a, so it is processed normally as a multi-channel connection. However, IP address IP1c uses a different GUID1c. Therefore, if an SMB connection for GUID1a already exists on Windows client 1, the Samba child process 1c rejects the extra connection. Windows client 2 uses the same logic as Windows client 1 to determine the connection.
[0098] When initiating an SMB connection through the client's new IP, the GUID and NETBIOS information of the new IP are identified and judged, solving the problem of redundant connections from the same client affecting client access and ensuring the normal use of existing SMB services.
[0099] In some implementations, rejecting the connection initiated by the further IP includes:
[0100] Put the connection request at the tail of the chain cache queue;
[0101] The main thread of connection filtering based on multiple IP clients builds a rejection response sub-thread;
[0102] Based on the rejection response subthread, read the pending connection request from the head of the chain cache queue;
[0103] Based on the pending connection request, a rejection response message is constructed and sent to the client.
[0104] By building a rejection response child thread, the main thread is prevented from spending too much time processing GUID and NETBIOS checks, which affects the subsequent normal SMB business processing.
[0105] In some implementations, constructing a rejection response message includes:
[0106] Construct a rejection response data structure, exchange the source IP and destination IP, as well as the source TCP port and destination TCP port in the pending connection request and add them to the rejection response data structure, and add the SMB message type code and rejection status code to the rejection response data structure to generate the rejection response message.
[0107] In some implementations, sending the rejection response message to the client includes:
[0108] The rejection response message is added to an output queue, and the output queue sends the message to the client corresponding to the destination IP in the rejection response message.
[0109] Specifically, after the rejection response thread takes out the request to be processed from the head of the chain buffer queue, it constructs a rejection response data structure according to the information of the request to be processed to generate a rejection response message.
[0110] Use the source IP and source TCP port in the pending request as the destination IP and destination TCP port in the rejection response data structure; use the destination IP and destination TCP port in the pending request as the source IP and source TCP port in the rejection response data structure; fill in the SMB message type code with the negotiation response type, and fill in the status code with NT_STATUS_DENIED.
[0111] The constructed rejection response message is added to the Samba TCP output queue, and the Samba TCP output queue sends it to the client corresponding to the destination IP in the rejection response message.
[0112] In some embodiments, the method further comprises:
[0113] In response to the existence of the GUID of the further IP, multi-channel logic processing is performed on the further IP.
[0114] In response to the NETBIOS host name of the further IP not existing, the GUID and the NETBIOS host name of the further IP are saved in the KEYs of the first database and the second database respectively.
[0115] Based on the same inventive concept, according to another aspect of the present invention, Figure 3 As shown, an embodiment of the present invention further provides a connection filtering system for multiple IP clients, comprising:
[0116] A construction module 110 is configured to construct a first database and a second database, and obtain the GUID and NETBIOS host name of the IP when an SMB connection request initiated by the IP of the client is received for the first time, and save them to the first database and the second database respectively;
[0117] a determination module 120 configured to, in response to receiving an SMB connection request initiated by another IP of the client again, obtain the GUID and NETBIOS host name of the another IP, and determine whether the GUID of the another IP exists in the first database;
[0118] The determination module 120 is further configured to determine whether a NETBIOS host name of another IP in the second database exists in response to the GUID of the another IP not existing;
[0119] The connection rejection module 130 is configured to reject the connection request initiated by the further IP in response to the existence of the NETBIOS host name of the further IP.
[0120] Based on the same inventive concept, according to another aspect of the present invention, Figure 4 As shown, an embodiment of the present invention further provides a computer-readable storage medium 30, which stores a computer program 310 that performs the following method when executed by a processor:
[0121] Constructing a first database and a second database, and obtaining the GUID and NETBIOS host name of the IP when receiving an SMB connection request initiated by the client IP for the first time, and saving them to the first database and the second database respectively;
[0122] In response to receiving an SMB connection request initiated by another IP of the client again, obtaining the GUID and NETBIOS host name of the further IP, and determining whether the GUID of the further IP exists in the first database;
[0123] In response to the GUID of the further IP not existing, determining whether the NETBIOS host name of the further IP in the second database exists;
[0124] In response to the existence of the NETBIOS host name of the further IP, rejecting the connection request initiated by the further IP.
[0125] In some embodiments, the first database and the second database each include a plurality of key-value pairs, wherein the key-value pairs include a keyword and a value;
[0126] Obtaining the GUID and NETBIOS host name of the IP and saving them to the first database and the second database respectively includes:
[0127] The GUID and NETBIOS host name of the IP are obtained and saved to the keywords of the first database and the keywords of the second database respectively for retrieval and access.
[0128] In some embodiments, the method further comprises:
[0129] Obtain the client source IP and SMB channel index number of the IP, save the client source IP and the SMB channel index number to the values corresponding to the keyword in the first database, and save the client source IP to the value corresponding to the keyword in the second database.
[0130] In some implementations, rejecting the connection initiated by the further IP includes:
[0131] Put the connection request at the tail of the chain cache queue;
[0132] The main thread of connection filtering based on multiple IP clients builds a rejection response sub-thread;
[0133] Based on the rejection response subthread, read the pending connection request from the head of the chain cache queue;
[0134] Based on the pending connection request, a rejection response message is constructed and sent to the client.
[0135] In some implementations, constructing a rejection response message includes:
[0136] Construct a rejection response data structure, exchange the source IP and destination IP, as well as the source TCP port and destination TCP port in the pending connection request and add them to the rejection response data structure, and add the SMB message type code and rejection status code to the rejection response data structure to generate the rejection response message.
[0137] In some implementations, sending the rejection response message to the client includes:
[0138] The rejection response message is added to an output queue, and the output queue sends the message to the client corresponding to the destination IP in the rejection response message.
[0139] In some embodiments, the method further comprises:
[0140] In response to the existence of the GUID of the further IP, multi-channel logic processing is performed on the further IP.
[0141] In some embodiments, the method further comprises:
[0142] In response to the NETBIOS host name of the further IP not existing, the GUID and the NETBIOS host name of the further IP are saved in the KEYs of the first database and the second database respectively.
[0143] Finally, it should be noted that those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium of the program can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM). The above-mentioned computer program embodiments can achieve the same or similar effects as any of the corresponding aforementioned method embodiments.
[0144] It will also be appreciated by those skilled in the art that the various exemplary logic blocks, modules, circuits and algorithmic steps described in conjunction with the disclosure herein can be implemented as electronic hardware, computer software or a combination of the two. In order to clearly illustrate this interchangeability of hardware and software, a general description has been given of the functions of various schematic components, blocks, modules, circuits and steps. Whether this function is implemented as software or hardware depends on specific applications and the design constraints imposed on the entire system. Those skilled in the art can implement the function in various ways for each specific application, but this implementation decision should not be interpreted as causing a departure from the disclosed scope of the embodiments of the present invention.
[0145] The above are exemplary embodiments disclosed in the present invention, but it should be noted that various changes and modifications may be made without departing from the scope of the embodiments disclosed in the claims. The functions, steps and / or actions of the method claims according to the disclosed embodiments described herein do not need to be performed in any particular order. In addition, although the elements disclosed in the embodiments of the present invention may be described or required in individual form, they may also be understood as multiple unless expressly limited to the singular.
[0146] It should be understood that, as used herein, the singular forms "a" and "an" are intended to include the plural forms as well, unless the context clearly supports an exception. It should also be understood that, as used herein, "and / or" is intended to include any and all possible combinations of one or more of the associated listed items.
[0147] The serial numbers of the embodiments disclosed in the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0148] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or may be accomplished by a program instructing the relevant hardware, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk, or an optical disk, etc.
[0149] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the disclosure of the embodiments of the present invention (including the claims) is limited to these examples. Within the spirit of the embodiments of the present invention, the technical features of the above embodiments or different embodiments may be combined, and there are many other variations of different aspects of the above embodiments of the present invention, which are not provided in detail for the sake of simplicity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present invention should be included in the scope of protection of the embodiments of the present invention.
Claims
1. A connection filtering method for multiple IP clients, characterized in that: include: Constructing a first database and a second database, and obtaining the GUID and NETBIOS host name of the IP when receiving an SMB connection request initiated by the IP of the client for the first time, and saving the GUID of the IP to the first database and the NETBIOS host name of the IP to the second database; In response to receiving an SMB connection request initiated by another IP of the client again, obtaining the GUID and NETBIOS host name of the another IP, and determining whether the GUID of the another IP exists in the first database; In response to the GUID of the further IP not existing, determining whether the NETBIOS host name of the further IP in the second database exists; In response to the existence of the NETBIOS host name of the further IP, rejecting the connection request initiated by the further IP.
2. The method according to claim 1, characterized in that The first database and the second database each include a plurality of key-value pairs, wherein the key-value pairs include a keyword and a value; Obtaining the GUID and NETBIOS host name of the IP and saving them to the first database and the second database respectively includes: The GUID and NETBIOS host name of the IP are obtained, and are saved to the keywords of the first database and the keywords of the second database respectively for retrieval access.
3. The method according to claim 2, characterized in that Further including: Obtain the client source IP and SMB channel index number of the IP, save the client source IP and the SMB channel index number to the values corresponding to the keyword in the first database, and save the client source IP to the value corresponding to the keyword in the second database.
4. The method according to claim 1, characterized in that Rejecting the connection initiated by the further IP includes: Put the connection request into the tail of the chain cache queue; Based on the main thread of connection filtering of multiple IP clients, a rejection response sub-thread is constructed; Based on the rejection response subthread, read the pending connection request from the head of the chain cache queue; Based on the pending connection request, a rejection response message is constructed and sent to the client.
5. The method according to claim 4, characterized in that The construction of a rejection response message includes: Construct a rejection response data structure, exchange the source IP and destination IP, as well as the source TCP port and destination TCP port in the connection request to be processed and add them to the rejection response data structure, and add the SMB message type code and the rejection status code to the rejection response data structure to generate the rejection response message.
6. The method according to claim 4, characterized in that Sending the rejection response message to the client includes: The rejection response message is added to an output queue, and the output queue is sent to the client corresponding to the destination IP in the rejection response message.
7. The method according to claim 1, characterized in that Further including: In response to the existence of the GUID of the further IP, multi-channel logic processing is performed on the further IP.
8. The method according to claim 1, characterized in that Further including: In response to the NETBIOS host name of the further IP not existing, the GUID and the NETBIOS host name of the further IP are saved in the KEYs of the first database and the second database respectively.
9. A connection filtering system for multiple IP clients, characterized in that: include: A construction module, wherein the construction module is configured to construct a first database and a second database, and obtain the GUID and NETBIOS host name of the IP when an SMB connection request initiated by the IP of the client is received for the first time, and save the GUID of the IP to the first database and save the NETBIOS host name of the IP to the second database; A judgment module, wherein the judgment module is configured to, in response to receiving an SMB connection request initiated by another IP of the client again, obtain the GUID and NETBIOS host name of the another IP, and judge whether the GUID of the another IP in the first database exists; The determination module is further configured to determine whether a NETBIOS host name of another IP in the second database exists in response to the GUID of the another IP not existing; A connection rejection module, wherein the connection rejection module is configured to reject a connection request initiated by the further IP in response to the existence of the NETBIOS host name of the further IP.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are performed.
Citation Information
Patent Citations
Multi-channel concurrent file permission management method and device, server and medium
CN113032829A
Metadata based file switch and switched file system
US20040133607A1
