Port forwarding flow management methods, devices, electronic equipment and storage media

By creating port forwarding flow configuration files to automate the management of port forwarding flows in a server cluster, the complexity of multi-machine deployment is solved, and efficient and reliable port forwarding flow management is achieved.

CN115914233BActive Publication Date: 2026-03-13BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-20
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

In existing technologies, the complexity of multi-port forwarding flow deployment on multiple machines leads to a huge workload for manual management, which is prone to errors and has low efficiency and maintainability.

Method used

By creating a port forwarding flow configuration file corresponding to the server cluster, the system responds to user operations to obtain the IP address and port of the source data service, determines the local target port, combines them into a port forwarding flow, and adds it to the configuration file to achieve automated management.

Benefits of technology

It saves workload, avoids errors, improves efficiency and maintainability, ensures the uniqueness of port forwarding flows, and prevents port conflicts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115914233B_ABST
    Figure CN115914233B_ABST
Patent Text Reader

Abstract

This invention provides a port forwarding flow management method, apparatus, electronic device, and storage medium. The method includes: creating a port forwarding flow configuration file corresponding to a server cluster in response to a user's port forwarding flow configuration file creation operation; obtaining the IP address and port of the source data service in response to a user's port forwarding flow addition operation on the port forwarding flow configuration file; determining the local target port of the server cluster based on the IP address and port of the source data service; combining the IP address, port of the source data service, and local target port to obtain a port forwarding flow, and adding it to the port forwarding flow configuration file. This method, where a file server manages the port forwarding flows of the server cluster through a port forwarding flow configuration file, saves workload, avoids errors, and improves efficiency and maintainability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communication technology, and in particular to a port forwarding flow management method, apparatus, electronic device, and storage medium. Background Technology

[0002] Most existing data synchronization solutions are based on the assumption that the target data service and the source data service can communicate directly. However, what if the target data service and the source data service are located on two isolated networks, such as data synchronization between a public cloud and a private cloud? In this case, there are generally two solutions for data synchronization: Solution 1: Establish a connection between the target data service and the source data service; Solution 2: Use a proxy server located at the edge of the two networks for forwarding.

[0003] Option 1 not only increases the cost of dedicated network lines or bandwidth, but also poses a significant challenge to network security control when the target and source data services involve a large number of servers deployed in a dispersed manner. Therefore, compared to Option 1, Option 2 only requires adding a proxy server, with all synchronization traffic forwarded through the proxy server. This is more economical and convenient to implement, and network security control is simpler, requiring only attention to the security policies of the proxy server.

[0004] To implement Solution 2, various port forwarding tools have emerged, such as iptables, socat, and redir commonly found in Linux systems. These tools typically only allow configuration of one port forwarding flow at a time. A typical medium-performance proxy server can support hundreds of port forwarding flows, thus requiring multiple proxy servers when dealing with a large number of flows. Given the complexity of deploying multiple port forwarding flows across multiple machines, manually managing the port forwarding flows on each proxy server is extremely labor-intensive, error-prone, and inefficient and unmaintainable. Summary of the Invention

[0005] To address the aforementioned technical problems arising from the complexity of deploying multiple port forwarding flows across multiple machines, and the fact that manually managing the port forwarding flows on each forwarding proxy server is labor-intensive, error-prone, inefficient, and lacks maintainability, this invention provides a port forwarding flow management method, apparatus, electronic device, and storage medium. The specific technical solution is as follows:

[0006] In a first aspect of the present invention, a port forwarding flow management method is provided, applied to a file server, the method comprising:

[0007] In response to the user's creation of the port forwarding flow configuration file, create the port forwarding flow configuration file corresponding to the server cluster;

[0008] In response to the user's operation of adding a port forwarding flow to the port forwarding flow configuration file, the IP address and port of the source data service are obtained.

[0009] The local target port of the server cluster is determined based on the IP address and port of the source data service.

[0010] The IP address of the source data service, the port of the source data service, and the local target port are combined to obtain a port forwarding flow, which is then added to the port forwarding flow configuration file.

[0011] In an optional implementation, determining the local target port of the server cluster based on the IP address and port of the source data service includes:

[0012] Based on the IP address and port of the source data service, determine the pre-allocated local port of the server cluster;

[0013] Query the local ports already in use in the server cluster and determine whether the local ports are consistent with the local ports already in use;

[0014] If the local port does not match the already used local port, the local port will be determined as the local target port of the server cluster.

[0015] In an optional implementation, determining the pre-allocated local port of the server cluster based on the IP address and port of the source data service includes:

[0016] Obtain historical combination records, wherein the historical combination records are combination records of the IP address of the source data service and the port of the source data service and the local port of the server cluster;

[0017] By using the historical combination records, find the local port of the server cluster that is combined with the IP address and port of the source data service;

[0018] The local port of the server cluster, which is a combination of the IP address of the source data service and the port of the source data service, is determined as the pre-allocated local port of the server cluster.

[0019] In an optional implementation, determining the local target port of the server cluster based on the IP address and port of the source data service further includes:

[0020] If the local port is consistent with the used local port, increment the local port by one, and jump to the step of determining whether the local port is consistent with the used local port.

[0021] In an optional implementation, determining whether the local port is consistent with the used local port includes:

[0022] Identify the process corresponding to the used local port, and determine whether the process corresponding to the used local port is running normally;

[0023] If the process corresponding to the used local port is running normally, determine whether the local port is consistent with the used local port;

[0024] If the process corresponding to the used local port is not running normally, then the used local port is removed.

[0025] Determine whether the local port is consistent with the remaining used local ports.

[0026] In an optional implementation, combining the IP address of the source data service, the port of the source data service, and the local destination port to obtain a port forwarding flow includes:

[0027] Obtain the remarks information of the port forwarding flow, and combine the local target port, the IP address of the source data service, the port of the source data service, the remarks information, and preset characters to obtain the port forwarding flow.

[0028] In an optional implementation, the method further includes:

[0029] Create the directory path of the server cluster from the directory path of the file server, and store the port forwarding flow configuration file in the directory path of the server cluster;

[0030] Receive a port forwarding flow configuration file retrieval request sent by the server, and in response to the retrieval request, determine the target server cluster to which the server belongs;

[0031] Locate the target directory path corresponding to the target server cluster from the directory path of the file server;

[0032] Locate the port forwarding flow target configuration file corresponding to the target server cluster from the target directory path;

[0033] The port forwarding flow target configuration file is distributed to the server so that the server updates the local port forwarding flow process according to the port forwarding flow target configuration file.

[0034] In an optional implementation, the step of distributing the port forwarding flow target configuration file to the server, so that the server updates the local port forwarding flow process according to the port forwarding flow target configuration file, includes:

[0035] The port forwarding flow target configuration file is distributed to the server, so that the server performs the following steps:

[0036] Determine the local port forwarding flow list and compare it with the target port forwarding flow in the port forwarding flow target configuration file;

[0037] If the target configuration file for the port forwarding flow does not contain the local port forwarding flow in the local port forwarding flow list, the process corresponding to the local port forwarding flow will be shut down.

[0038] If the target port forwarding flow of the target configuration file is not included in the local port forwarding flow list, a new process corresponding to the target port forwarding flow is created.

[0039] In an optional implementation, determining the local port forwarding flow list includes:

[0040] Determine the type of the local port forwarding tool and the corresponding port forwarding flow acquisition method;

[0041] According to the port forwarding flow acquisition method, obtain the local port forwarding flow, and form a local port forwarding flow list from the local port forwarding flow.

[0042] In a second aspect of the present invention, a port forwarding flow management device is also provided, applied to a file server, the device comprising:

[0043] The file creation module is used to create a port forwarding flow configuration file corresponding to the server cluster in response to the user's port forwarding flow configuration file creation operation;

[0044] The address and port acquisition module is used to obtain the IP address and port of the source data service in response to the user's operation of adding a port forwarding flow to the port forwarding flow configuration file.

[0045] The port determination module is used to determine the local target port of the server cluster based on the IP address of the source data service and the port of the source data service;

[0046] The port forwarding flow component module is used to combine the IP address of the source data service, the port of the source data service, and the local target port to obtain a port forwarding flow, and add it to the port forwarding flow configuration file.

[0047] In a third aspect of the present invention, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus.

[0048] Memory, used to store computer programs;

[0049] When a processor executes a program stored in memory, it implements any of the port forwarding flow management methods described in the first aspect above.

[0050] In a fourth aspect of the present invention, a storage medium is also provided, the storage medium storing instructions that, when run on a computer, cause the computer to execute any of the port forwarding flow management methods described in the first aspect above.

[0051] In a fifth aspect of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the port forwarding flow management methods described above.

[0052] The technical solution provided in this invention, in response to a user's creation operation of a port forwarding flow configuration file, creates a port forwarding flow configuration file corresponding to the server cluster. In response to a user's addition operation of a port forwarding flow to the configuration file, it obtains the IP address and port of the source data service. Based on the IP address and port of the source data service, it determines the local target port of the server cluster. The IP address, port, and local target port of the source data service are combined to obtain a port forwarding flow, which is then added to the port forwarding flow configuration file. By creating a port forwarding flow configuration file corresponding to the server cluster and combining the IP address, port, and local target port of the source data service to obtain a port forwarding flow, which is then added to the forwarding flow configuration file, the file server manages the port forwarding flow of the server cluster through the forwarding flow configuration file. This saves workload, avoids errors, and improves efficiency and maintainability. Attached Figure Description

[0053] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0054] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0055] Figure 1 This is a schematic diagram illustrating an application scenario in an embodiment of the present invention;

[0056] Figure 2 This is a schematic diagram illustrating the implementation process of a port forwarding flow management method in an embodiment of the present invention;

[0057] Figure 3 This is a schematic diagram illustrating the implementation process of another port forwarding flow management method in an embodiment of the present invention;

[0058] Figure 4 This is a schematic diagram illustrating the implementation process of another port forwarding flow management method in an embodiment of the present invention;

[0059] Figure 5 This is a schematic diagram of the directory path of a file server in an embodiment of the present invention;

[0060] Figure 6 This is a schematic diagram of the structure of a port forwarding flow management device shown in an embodiment of the present invention;

[0061] Figure 7 This is a schematic diagram of the structure of another electronic device shown in an embodiment of the present invention. Detailed Implementation

[0062] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0063] In embodiments of the present invention, such as Figure 1As shown, the target data service first accesses the network address (virtual IP or domain name:port) exposed by the Layer 4 load balancer service. Then, the Layer 4 load balancer service distributes the user's access request to a proxy server according to a certain strategy. The proxy server, through the port forwarding service configured on it, sends the access request to the source data service. After receiving and processing the access request, the source data service returns its stored data to the target data service in the form of a response along the reverse path, thus completing a full data synchronization process.

[0064] like Figure 2 The diagram shown illustrates the implementation flow of a port forwarding flow management method according to an embodiment of the present invention. This method is applied to a file server and may specifically include the following steps:

[0065] S201, in response to the user's port forwarding flow configuration file creation operation, creates a port forwarding flow configuration file corresponding to the server cluster.

[0066] In this embodiment of the invention, the port forwarding flow of the server cluster can be managed by the file server through the port forwarding flow configuration file. Here, the server cluster is the server cluster composed of the aforementioned proxy servers.

[0067] Based on this, the server cluster can be identified first, and users can create corresponding port forwarding flow configuration files for that server cluster. In response to the user's port forwarding flow configuration file creation operation, a port forwarding flow configuration file corresponding to the server cluster can be created.

[0068] For example, first determine server cluster 1, and the user creates a corresponding port forwarding flow configuration file for server cluster 1. Thus, in response to the user's port forwarding flow configuration file creation operation, a port forwarding flow configuration file corresponding to server cluster 1 can be created.

[0069] It should be noted that the port forwarding flow configuration file corresponds one-to-one with the server cluster, which means that the servers in the server cluster share the port forwarding flow configuration file, and all servers in the server cluster correspond to the port forwarding flow configuration file. This embodiment of the invention does not limit this.

[0070] S202, in response to the user's operation of adding a port forwarding flow to the port forwarding flow configuration file, obtains the IP address and port of the source data service.

[0071] S203, determine the local target port of the server cluster based on the IP address and port of the source data service.

[0072] S204 combines the IP address of the source data service, the port of the source data service, and the local target port to obtain a port forwarding flow, and adds it to the port forwarding flow configuration file.

[0073] In this embodiment of the invention, for the port forwarding flow configuration file corresponding to the server cluster, the user can add port forwarding flows to it so as to maintain the port forwarding flows of the server cluster in the port forwarding flow file.

[0074] Based on this, in response to the user's operation of adding a port forwarding flow to the port forwarding flow configuration file, the IP address and port of the source data service can be obtained. Based on the IP address and port of the source data service, the local target port of the server cluster can be determined. The IP address, port of the source data service, and local target port are combined to obtain the port forwarding flow and added to the port forwarding flow configuration file.

[0075] For example, in response to a user's operation to add a port forwarding flow to the port forwarding flow configuration file, the IP address of the source data service (192.168.1.1) and its port (80) are obtained. Then, based on the IP address of the source data service (192.168.1.1) and its port (80), the local target port (80) of the server cluster is determined. The IP address of the source data service (192.168.1.1), its port (80), and its local target port (80) are combined to obtain the port forwarding flow, as shown below. The port forwarding flow may include remarks.

[0076] 80 (local destination port), 192.168.1.1 (IP address of source data service), 80 (port of source data service), just-a-test (remarks).

[0077] It should be noted that, in addition to adding port forwarding flows, the port forwarding flow configuration file can also be modified and deleted, as well as the port forwarding flows in the configuration file. Each line of the port forwarding flow configuration file identifies a port forwarding flow, and each port forwarding flow includes the local target port, the IP address of the source data service, the port of the source data service, and an optional remark. This embodiment of the invention does not limit this.

[0078] Based on the above description of the technical solution provided by the embodiments of the present invention, in response to the user's port forwarding flow configuration file creation operation, a port forwarding flow configuration file corresponding to the server cluster is created. In response to the user's port forwarding flow addition operation on the port forwarding flow configuration file, the IP address and port of the source data service are obtained. Based on the IP address and port of the source data service, the local target port of the server cluster is determined. The IP address, port of the source data service, and local target port are combined to obtain the port forwarding flow and added to the port forwarding flow configuration file.

[0079] By creating a port forwarding flow configuration file corresponding to the server cluster, and combining the IP address of the source data service, the port of the source data service, and the local target port to obtain the port forwarding flow, the file server can manage the port forwarding flow of the server cluster through the port forwarding flow configuration file. This saves workload, avoids errors, and improves efficiency and maintainability.

[0080] like Figure 3 The diagram shown illustrates the implementation flow of another port forwarding flow management method provided in this embodiment of the invention. This method is applied to a file server and may specifically include the following steps:

[0081] S301, in response to the user's port forwarding flow configuration file creation operation, creates a port forwarding flow configuration file corresponding to the server cluster.

[0082] In this embodiment of the invention, this step is similar to step S201 above, and will not be described in detail here.

[0083] S302, in response to the user's operation of adding a port forwarding flow to the port forwarding flow configuration file, obtains the IP address and port of the source data service.

[0084] In this embodiment of the invention, this step is similar to step S202 above, and will not be described in detail here.

[0085] S303 determines the local port of the pre-allocated server cluster based on the IP address and port of the source data service.

[0086] In this embodiment of the invention, for the IP address and port of the source data service, the local port of the pre-allocated server cluster can be determined based on the IP address and port of the source data service.

[0087] This process involves retrieving historical combination records, which are records of combinations of the source data service's IP address and port with the server cluster's local port. By using these historical combination records, the local port of the server cluster that is combined with the source data service's IP address and port is located, and this local port is determined as the pre-allocated local port of the server cluster.

[0088] For example, multiple historical combination records are pre-stored, where each historical combination record is a combination record of the IP address of the source data service and the port of the source data service with the local port of the server cluster, as shown in Table 1 below.

[0089]

[0090]

[0091] Table 1

[0092] Based on the historical combination records shown in Table 1 above, the local port 80 of the server cluster that is combined with the source data service's IP address 192.168.1.1 and the source data service's port 80 is found, and the local port 80 of the server cluster that is combined with the source data service's IP address 192.168.1.1 and the source data service's port 80 is determined as the pre-allocated local port of the server cluster.

[0093] It should be noted that by using historical combination records, the local ports of the server cluster that are combined with the IP address and port of the source data service are found, and the local ports of the server cluster that are combined with the IP address and port of the source data service are determined as the pre-allocated local ports of the server cluster. The purpose is to enable the forwarding flow of abnormally closed ports to be quickly restored.

[0094] S304 queries the local ports used in the server cluster and determines whether the local ports are consistent with the used local ports.

[0095] S305 determines the local target port of the server cluster if the local port does not match the local port that is already in use.

[0096] In this embodiment of the invention, for a server cluster, the local ports already in use in the server cluster can be queried to determine whether the pre-allocated local port of the server cluster is consistent with the local port already in use. If the local port of the pre-allocated server cluster is inconsistent with the local port already in use, it means that no port conflict has occurred. At this time, the local port of the pre-allocated server cluster can be determined as the local target port of the server cluster.

[0097] Furthermore, if the local port of the pre-allocated server cluster is the same as the local port already in use in the server cluster, it indicates that a port conflict has occurred. In this case, the local port of the pre-allocated server cluster can be incremented by one, and the process can be skipped to the step of determining whether the local port is the same as the local port already in use, until all local ports of the server cluster have been traversed.

[0098] Before determining whether the local port is consistent with the used local port, it is necessary to identify the process corresponding to the local port already used by the server cluster and determine whether the process corresponding to the local port already used by the server cluster is running normally. If the process corresponding to the local port already used by the server cluster is running normally, it is determined whether the pre-allocated local port of the server cluster is consistent with the local port already used by the server cluster. If the process corresponding to the local port already used by the server cluster is not running normally, it indicates that the used local port should be reclaimed. At this time, the used local port can be removed, and it is determined whether the pre-allocated local port of the server cluster is consistent with the remaining used local ports of the server cluster.

[0099] S306, obtain the remarks information of the port forwarding flow, combine the local target port, the IP address of the source data service, the port of the source data service, the remarks information and the preset characters to obtain the port forwarding flow, and add it to the port forwarding flow configuration file.

[0100] In this embodiment of the invention, the port forwarding stream may include remark information. Therefore, the remark information of the port forwarding stream can be obtained, and the local target port, the IP address of the source data service, the port of the source data service, the remark information and the preset characters are combined to obtain the port forwarding stream and added to the port forwarding stream configuration file.

[0101] The port forwarding flow can be in the form of local target port first, followed by remarks, and the source data service IP address and source data service port in the middle, separated by characters such as commas. This allows the local target port, source data service IP address, source data service port, remarks, and preset characters to be combined to obtain the port forwarding flow.

[0102] It should be noted that steps S302 to S306 above can be performed by a tool. This tool can automatically add a port forwarding flow to the port forwarding flow configuration file, while ensuring that the local ports of the port forwarding flows in the configuration file do not conflict. The tool works by checking whether the pre-allocated port conflicts with the local port based on the IP address and port of the source data service. If a conflict is found, the port number is incremented by one, and then the conflict is checked again until a usable local port is found, or all local ports have been traversed.

[0103] By creating a port forwarding flow configuration file corresponding to the server cluster, the pre-allocated local ports of the server cluster are determined based on the IP address and port of the source data service. If the local port does not match an already used local port, this local port is designated as the local target port of the server cluster. The local target port, the IP address and port of the source data service, remarks, and preset characters are combined to obtain the port forwarding flow, which is then added to the port forwarding flow configuration file. In this way, the file server manages the port forwarding flows of the server cluster through the forwarding flow configuration file, saving workload, avoiding errors, and improving efficiency and maintainability. Furthermore, it can solve the port allocation uniqueness problem, ensuring that port forwarding flows do not encounter port conflicts.

[0104] In this embodiment of the invention, port forwarding flow configuration files for each server cluster are maintained on a file server. This allows each server in the cluster to maintain its local port forwarding flow based on the file server's configuration file. Specifically, a daemon can be run on each server in the cluster to achieve the goal of maintaining local port forwarding flows based on the file server's configuration file.

[0105] Based on this, such as Figure 4 The diagram shown illustrates the implementation flow of another port forwarding flow management method provided in this embodiment of the invention. This method is applied to a file server and may specifically include the following steps:

[0106] S401 creates the directory path of the server cluster from the directory path of the file server and stores the port forwarding flow configuration file in the directory path of the server cluster.

[0107] In this embodiment of the invention, a port forwarding flow configuration file corresponding to the server cluster is created, and the corresponding port forwarding flow is added to it. This allows the directory path of the server cluster to be created from the directory path of the file server, and the port forwarding flow configuration file to be stored in the directory path of the server cluster.

[0108] It should be noted that, within the root directory of the file server, each server cluster creates its own independent directory path, thereby enabling separate storage of port forwarding flow configuration files for each server cluster, such as... Figure 5 As shown.

[0109] S402 receives a port forwarding stream configuration file retrieval request sent by the server and responds to the retrieval request to determine the target server cluster to which the server belongs.

[0110] S403: Locate the target directory path corresponding to the target server cluster from the directory path of the file server.

[0111] S404: Locate the target configuration file for the port forwarding flow corresponding to the target server cluster in the target directory path.

[0112] S405 sends the port forwarding flow target configuration file to the server so that the server can update the local port forwarding flow process according to the port forwarding flow target configuration file.

[0113] In this embodiment of the invention, for a server in a server cluster, a port forwarding flow configuration file retrieval request can be sent to the file server. The file server can then receive the port forwarding flow configuration file retrieval request sent by the server and, in response to the retrieval request, determine the target server cluster to which the server belongs.

[0114] From the directory path of the file server, find the target directory path corresponding to the target server cluster. From the target directory path, find the port forwarding flow target configuration file corresponding to the target server cluster. Send the port forwarding flow target configuration file to the server so that the server can update the local port forwarding flow process according to the port forwarding flow target configuration file.

[0115] For example, receiving a port forwarding stream configuration file retrieval request from the server and responding to the request, determining the target server cluster to which the server belongs, for example, server cluster 1, and searching for the target directory path corresponding to server cluster 1 from the file server's directory path, such as... Figure 5 As shown, the target configuration file for the port forwarding flow corresponding to server cluster 1 is located in the target directory path. This file is then distributed to the server so that the server can update its local port forwarding flow processes based on the configuration file. In addition, the server can also obtain the load balancing file for server cluster 1 from the file server.

[0116] Specifically, the port forwarding flow target configuration file can be distributed to the server, causing the server to perform the following steps: determine the local port forwarding flow list and compare it with the target port forwarding flow in the port forwarding flow target configuration file; if the port forwarding flow target configuration file does not contain the local port forwarding flow in the local port forwarding flow list, close the process corresponding to the local port forwarding flow; if the local port forwarding flow list does not contain the target port forwarding flow in the port forwarding flow target configuration file, create a new process corresponding to the target port forwarding flow.

[0117] It should be noted that during the process of obtaining the target configuration file for the port forwarding flow, the load balancing configuration file of the target server cluster can also be obtained from the file server. Thus, when the process corresponding to the local port forwarding flow is closed, the load balancing configuration of the process corresponding to the local port forwarding flow can also be deleted. Therefore, when the process corresponding to the target port forwarding flow is created, the load balancing configuration of the process corresponding to the target port forwarding flow is also created.

[0118] In this embodiment of the invention, the method for determining the local port forwarding flow list is related to the port forwarding tool used. For example, process-based port forwarding tools such as redir or socat can obtain local port forwarding flows by viewing the process list in the system, thereby forming a local port forwarding flow list. Port forwarding tools based on the operating system's netfilter network processing architecture, such as iptables, can obtain local port forwarding flows by querying the iptables NAT translation table, thereby forming a local port forwarding flow list.

[0119] Based on this, the type of local port forwarding tool can be determined, and the port forwarding flow acquisition method corresponding to the type can be determined; according to the port forwarding flow acquisition method, the local port forwarding flow is acquired, and the local port forwarding flow is composed of the local port forwarding flow list.

[0120] In this way, the servers in the server cluster can obtain the port forwarding flow configuration file of their local machine from the file server in real time through the API interface. Then, they check whether the port forwarding flow exists on the local machine one by one. If it does not exist, a new port forwarding flow is created. At the same time, the servers obtain the port forwarding flows that are running on the local machine. If the port forwarding flow does not exist in the port forwarding flow configuration file, the port forwarding flow is deleted to keep the port forwarding flow configured on the local machine consistent with the port forwarding flow in the port forwarding flow configuration file.

[0121] Corresponding to the above method embodiments, this invention also provides a port forwarding flow management device, such as... Figure 6 As shown, the device may include: a file creation module 610, an address and port acquisition module 620, a port determination module 630, and a port forwarding stream composition module 640.

[0122] The file creation module 610 is used to create a port forwarding flow configuration file corresponding to the server cluster in response to the user's port forwarding flow configuration file creation operation.

[0123] The address and port acquisition module 620 is used to acquire the IP address and port of the source data service in response to the user's port forwarding flow addition operation for the port forwarding flow configuration file.

[0124] The port determination module 630 is used to determine the local target port of the server cluster based on the IP address of the source data service and the port of the source data service.

[0125] The port forwarding flow composition module 640 is used to combine the IP address of the source data service, the port of the source data service, and the local target port to obtain a port forwarding flow, and add it to the port forwarding flow configuration file.

[0126] This invention also provides an electronic device, such as... Figure 7 As shown, it includes a processor 71, a communication interface 72, a memory 73, and a communication bus 74. The processor 71, the communication interface 72, and the memory 73 communicate with each other through the communication bus 74.

[0127] Memory 73 is used to store computer programs;

[0128] When processor 71 executes the program stored in memory 73, it performs the following steps:

[0129] In response to the user's creation operation of the port forwarding flow configuration file, a port forwarding flow configuration file corresponding to the server cluster is created; in response to the user's addition operation of the port forwarding flow in the port forwarding flow configuration file, the IP address and port of the source data service are obtained; based on the IP address and port of the source data service, the local target port of the server cluster is determined; the IP address, port of the source data service, and local target port are combined to obtain the port forwarding flow, and added to the port forwarding flow configuration file.

[0130] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not indicate that there is only one bus or one type of bus.

[0131] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0132] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0133] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0134] In another embodiment of the present invention, a storage medium is also provided, which stores instructions that, when run on a computer, cause the computer to execute any of the port forwarding flow management methods described in the above embodiments.

[0135] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the port forwarding flow management methods described in the above embodiments.

[0136] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a storage medium or transmitted from one storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).

[0137] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0138] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0139] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A method of port forwarding flow management, the method comprising: Applied to a file server, the method comprises: In response to a user's port forwarding stream profile creation operation, creating a port forwarding stream profile corresponding to a server cluster, wherein the port forwarding stream profile corresponds one-to-one to the service cluster; In response to a user's port forwarding stream addition operation for the port forwarding stream profile, obtaining an IP address of a source data service and a port of the source data service; According to the IP address of the source data service and the port of the source data service, determining a local target port of the server cluster; Combining the IP address of the source data service, the port of the source data service, and the local target port to obtain a port forwarding stream, and adding it to the port forwarding stream profile; Wherein, according to the IP address of the source data service and the port of the source data service, determining the local target port of the server cluster, comprising: According to the IP address of the source data service and the port of the source data service, determining a pre-allocated local port of the server cluster, comprising: obtaining a historical combination record, wherein the historical combination record is a combination record of the IP address of the source data service and the port of the source data service and the local port of the server cluster; through the historical combination record, find the local port of the server cluster combined with the IP address of the source data service and the port of the source data service; the local port of the server cluster combined with the IP address of the source data service and the port of the source data service is determined as the pre-allocated local port of the server cluster; Querying the used local port in the server cluster, and judging whether the local port is consistent with the used local port; In the case where the local port is not consistent with the used local port, the local port is determined as the local target port of the server cluster.

2. The method of claim 1, wherein, According to the IP address of the source data service and the port of the source data service, determining the local target port of the server cluster, also includes: In the case where the local port is consistent with the used local port, add one to the local port, and jump to the step of judging whether the local port is consistent with the used local port.

3. The method of claims 1-2, wherein, The judgment of whether the local port is consistent with the used local port comprises: Determine the process corresponding to the used local port, and judge whether the process corresponding to the used local port is running normally; In the case where the process corresponding to the used local port is running normally, judge whether the local port is consistent with the used local port; In the case where the process corresponding to the used local port is not running normally, then eliminate the used local port; Judge whether the local port is consistent with the remaining used local port.

4. The method of claim 1, wherein, The combination of the IP address of the source data service, the port of the source data service, and the local target port to obtain a port forwarding stream comprises: The remark information of the port forwarding flow is acquired, the local target port, the IP address of the source data service, the port of the source data service, the remark information and preset characters are combined to obtain a port forwarding flow.

5. The method of claim 1, wherein, The method further comprises: creating a directory path of the server cluster from a directory path of the file server, and storing the port forwarding flow configuration file under the directory path of the server cluster; receiving a port forwarding flow configuration file acquisition request sent by a server, and determining a target server cluster to which the server belongs in response to the acquisition request; finding a target directory path corresponding to the target server cluster from a directory path of the file server; finding a port forwarding flow target configuration file corresponding to the target server cluster from the target directory path; downloading the port forwarding flow target configuration file to the server to enable the server to update a process of a local port forwarding flow according to the port forwarding flow target configuration file.

6. The method of claim 5, wherein, The downloading of the port forwarding flow target configuration file to the server to enable the server to update a process of a local port forwarding flow according to the port forwarding flow target configuration file comprises: downloading the port forwarding flow target configuration file to the server to enable the server to perform the following steps: determining a local port forwarding flow list and comparing it with a target port forwarding flow of the port forwarding flow target configuration file; in a case where the port forwarding flow target configuration file does not contain a local port forwarding flow in the local port forwarding flow list, closing a process corresponding to the local port forwarding flow; in a case where the local port forwarding flow list does not contain a target port forwarding flow of the port forwarding flow target configuration file, newly creating a process corresponding to the target port forwarding flow.

7. The method of claim 6, wherein, The determination of the local port forwarding flow list comprises: determining a type of a local port forwarding tool and determining a port forwarding flow acquisition manner corresponding to the type; acquiring local port forwarding flows according to the port forwarding flow acquisition manner, and composing a local port forwarding flow list from the local port forwarding flows.

8. A port forwarding flow management apparatus characterized by, The apparatus is applied to a file server and comprises: a file creation module configured to create a port forwarding flow configuration file corresponding to a server cluster in response to a user's creation operation of the port forwarding flow configuration file, wherein the port forwarding flow configuration file corresponds to the server cluster in a one-to-one manner; an address and port acquisition module configured to acquire an IP address of a source data service and a port of the source data service in response to a user's port forwarding flow addition operation on the port forwarding flow configuration file; a port determination module configured to determine a local target port of the server cluster according to the IP address of the source data service and the port of the source data service; a port forwarding flow composition module configured to combine the IP address of the source data service, the port of the source data service and the local target port to obtain a port forwarding flow, and add the port forwarding flow to the port forwarding flow configuration file; The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises:

9. An electronic device, comprising: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises:

10. A storage medium having stored thereon a computer program, characterized in that The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source data service and the port of the source data service comprises: The determining the local target port of the server cluster according to the IP address of the source

Citation Information

Patent Citations

  • Load balancing method, device and system

    CN111367662A