A decentralized containerized management method based on libp2p connections

The decentralized approach using libp2p connections solves the problems of single point of failure, latency, and high cost in containerized management of network-attached storage systems, achieving efficient and secure container management.

CN119088590BActive Publication Date: 2025-10-31CHENGDU YOULE DIGITAL INTELLIGENCE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411113990.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-14
Publication Date
2025-10-31
Estimated Expiration
2044-08-14

AI Technical Summary

Technical Problem

In existing technologies, containerized management of network-attached storage systems relies on a central server, which presents problems such as single point of failure risk, data transmission latency, insufficient security, and high operation and maintenance costs.

Method used

A decentralized containerized management method is implemented using libp2p connections. Data is input through the xterm.js terminal and encapsulated into a byte array, which is then transmitted to the backend server via libp2p stream. The backend server parses and executes container management operations, and the results are returned to the terminal for display via libp2p stream.

Benefits of technology

It enables decentralized data exchange, improves system flexibility and security, reduces latency and maintenance costs, and enhances the real-time performance and responsiveness of management operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119088590B_ABST
    Figure CN119088590B_ABST
Patent Text Reader

Abstract

This invention discloses a decentralized containerized management method based on libp2p connections. Users input operations in the xterm.js terminal, and the received data is processed through xterm.js event listeners. The data is then encapsulated into a byte array and transmitted to the backend server via libp2p streaming. The backend server parses the data, assembles it into a command line, and analyzes user permissions to determine if the command is allowed. If allowed, it calls the Docker API to perform container management operations, and finally returns the execution result to the xterm.js terminal for display via libp2p streaming. This invention utilizes decentralized peer-to-peer communication, allowing direct communication between nodes, eliminating single points of failure, and providing greater fault tolerance and reliability, thus demonstrating good practicality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of container terminal management, specifically relating to a decentralized containerized management method based on libp2p connections. Background Technology

[0002] Network Attached Storage (NAS) systems typically require remote access and management, such as SSH login. Using a web-based terminal emulation can provide faster remote command-line access. Traditional NAS products use HTTP / HTTPS (central server-client model) for front-end and back-end data transmission. For enterprises, this relies on a central server, resulting in higher costs. Decentralized data exchange, which does not depend on a central server, offers faster and more secure network transmission.

[0003] Containers (Docker) are currently widely used, and some network-attached storage products can be managed in a containerized manner. However, the traditional client-server model they use is susceptible to challenges such as poor real-time performance, security, and insufficient management efficiency. Specifically, when a user accesses a containerized application in a browser, the browser sends a WebSocket connection request to a central server; the central server forwards the request to the server-side application, establishing a connection; real-time bidirectional data transmission occurs between the browser and the server-side application via WebSocket. The user enters commands in the xterm.js terminal emulator within the web interface; the server-side application returns the results to the front-end terminal via WebSocket; the user then views the command execution results in the xterm.js terminal. The involved infrastructure includes the xterm.js terminal emulator page, WebSocket, a central server, the server-side application, and the Docker daemon. The specific drawbacks of the above method are as follows:

[0004] ① The current conventional solution uses a server-client architecture that relies on a centralized server, which is prone to creating a single point of failure;

[0005] ② Data needs to be relayed through a central server, which increases latency and affects real-time performance;

[0006] ③ Data transmission security depends on the developer's implementation and configuration, which is prone to errors;

[0007] ④ It requires the maintenance of a central server, which involves high operation and management costs. Summary of the Invention

[0008] The purpose of this invention is to provide a decentralized containerized management method based on libp2p connections, which aims to solve the above-mentioned problems.

[0009] This invention is mainly achieved through the following technical solutions:

[0010] A decentralized containerized management method based on libp2p connections includes the following steps:

[0011] Step S1: The user inputs operations in the xterm.js terminal, processes the received data through the xterm.js event listener, and then encapsulates the data into a byte array and transmits it to the backend server through libp2p stream;

[0012] Step S2: The backend server parses the data and assembles it into a command line. Then, it analyzes the user's permissions to determine whether the command is allowed to be executed. If it is allowed, it calls the Docker API to perform container management operations and finally returns the execution result to the xterm.js terminal for display via libp2p stream.

[0013] To better implement the present invention, step S1 further includes the following steps:

[0014] Step S110: Initialize the front-end node at the front end, find the back-end node of the back-end server and initiate a connection; the front-end node establishes a bidirectional protocol stream with the back-end node based on the initialized transmission protocol, and the protocol stream allows bidirectional data communication between the front end and the back-end server.

[0015] Step S120: Construct a simulated terminal page using xterm.js, which serves as the xterm.js terminal for the front end;

[0016] Step S130: The user accesses the xterm.js terminal page through a browser and performs operations;

[0017] Step S140: In the xterm.js terminal, listen for data change events and keyboard input events respectively, and receive the data from the operation; then, the front-end node uses the it-pipe library to write the data to the libp2p stream, and transmits it to the back-end node through the libp2p stream.

[0018] To better implement the present invention, step S110 further includes the following steps:

[0019] Step S111: Create a libp2p instance in the front end, initialize the transmission protocol, encryption module, and stream multiplexing module configuration of the front end libp2p node; after initialization, the front end node enters standby state to prepare for establishing a connection with the back end node.

[0020] Step S112: The front-end node searches for the back-end node through the discovery mechanism of the libp2p node, and the front-end node establishes a connection with the back-end node through the dial method of the libp2p node.

[0021] To better implement the present invention, further, in step S120, keyboard events and paste behavior are configured in the xterm.js terminal to allow paste operations; a one-click fill command button is set in the xterm.js terminal, and by clicking the one-click fill command button, preset commands are pasted into the command line of the xterm.js terminal.

[0022] To better implement the present invention, further, in step S140, when listening for data change events, if the current keyboard operation is detected as modifier key input or pasting a string, it is transmitted to the backend server; when listening for keyboard input events, if the current keyboard operation is detected as character input, no processing is performed; if the current keyboard operation is detected as shortcut key usage, it is determined whether the shortcut key combination is a copy or paste operation. If so, no interference is performed; otherwise, after preventing the browser's default event from being triggered, the shortcut key operation keyboard code is transmitted to the backend server.

[0023] To better realize the present invention, step S2 further includes the following steps:

[0024] Step S210: The backend node receives the characters or strings input by the user in sequence from the libp2p stream, parses the data and assembles it into a command line. The backend server verifies and filters the received command request. Then, it analyzes the user's permissions to determine whether the command is allowed to be executed. If it is allowed to be executed, it proceeds to step S220; otherwise, it directly returns a message indicating insufficient permissions.

[0025] Step S220: Call the Docker API to interact with the Docker daemon, perform specific container management operations, and return the execution results to the xterm.js terminal for display via the libp2p stream.

[0026] To better implement the present invention, in step S210, the backend node integrates and parses the received characters or strings using key characters to assemble them into a command line.

[0027] To better implement the present invention, step S220 further includes the following steps:

[0028] Step S221: Transfer commands to the Docker daemon by calling the Docker API;

[0029] Step S222: The Docker daemon executes the passed-in command and returns the execution result to the backend node;

[0030] Step S223: The backend node receives the result returned by the Docker daemon and transmits the execution result back to the frontend xterm.js terminal via libp2p stream;

[0031] Step S224: The xterm.js terminal receives the result returned by the backend server, renders it, and displays it on the terminal, allowing the user to view the result of the command execution in real time.

[0032] xterm.js is a JavaScript-based terminal emulator that can run in a web browser. It provides a command-line terminal interface that runs within a web page.

[0033] In a peer-to-peer (P2P) network, a node is a network participant, which can be a computer, device, or virtual machine, involved in data transmission and processing. Nodes connect to each other in the network, exchanging data to achieve a decentralized network structure.

[0034] The bidirectional protocol stream is a bidirectional communication channel in libp2p that allows nodes to transmit data using a specific protocol. It is used to establish data transmission channels between nodes, enabling the sending and receiving of data.

[0035] The beneficial effects of this invention are as follows:

[0036] (1) This invention utilizes libp2p technology to achieve decentralized data exchange and node discovery, enhancing system flexibility. Furthermore, libp2p's security mechanism ensures the security and privacy of management operations, making it particularly suitable for handling sensitive data and deploying containers across multiple cloud service providers. Most importantly, libp2p provides efficient peer-to-peer network communication capabilities, supporting rapid inter-node message passing and state synchronization, thereby improving the real-time performance and responsiveness of management operations. In summary, this invention, by introducing libp2p technology, brings significant innovation to containerized management on network-attached storage devices, optimizing system performance, security, and management efficiency, providing users with an advanced and reliable management solution, and possessing good practicality.

[0037] (2) This invention utilizes libp2p's built-in encryption and authentication mechanisms to ensure data transmission security and privacy protection. It also achieves decentralized data exchange and node discovery, overcoming the limitations of the traditional centralized server model. Eliminating the need for a central server improves system stability and fault tolerance, reduces data transmission latency, and accelerates container management response speed. This invention simulates xterm.js terminal operations, allowing users to perform command-line operations through a regular browser. Compared to traditional SSH login, inputting commands through a graphical interface and obtaining results in real time lowers the operational threshold and learning cost. This invention guides user behavior on the terminal page, ensuring secure operations in the simulated terminal through preset common command lines and monitoring user keyboard and mouse events, effectively controlling the input of unauthorized commands. The backend rigorously verifies and filters received command requests to prevent malicious operations or unexpected security vulnerabilities; simultaneously, the backend analyzes user permissions to achieve user behavior control and refined command permission judgment, effectively solving the problems of poor stability, delayed response speed, and poor user-friendliness and security in traditional container management solutions.

[0038] (3) This invention is a web-based terminal, eliminating the need for users to perform SSH login to the NAS. Furthermore, this invention utilizes decentralized peer-to-peer communication, allowing direct communication between nodes, eliminating single points of failure, and enhancing system fault tolerance and reliability. This invention incorporates end-to-end encryption and authentication mechanisms (such as the Noise protocol), making data transmission more secure and providing stronger privacy protection. Direct communication between nodes reduces intermediate forwarding, lowers latency, and improves real-time performance and responsiveness. This invention eliminates the need to maintain a central server; nodes are self-organizing and self-managing, reducing operational costs. This invention can restrict executable commands, making it highly practical. Attached Figure Description

[0039] Figure 1 The flowchart for initializing the front-end libp2p node in step 2 is as follows;

[0040] Figure 2 The flowchart for implementing event listening in the xterm.js terminal in step 2;

[0041] Figure 3 This is a timing diagram of the decentralized containerized management method based on libp2p connections of the present invention. Detailed Implementation

[0042] Example 1:

[0043] This invention presents a decentralized containerized management method based on libp2p connectivity. On a web-based device connected to Network Attached Storage (NAS), it utilizes xtermjs and libp2p to construct a terminal capable of executing Docker command-line commands. This invention achieves command-line management of Docker on a simulated web terminal by combining xterm.js and libp2p. Applicable to enterprise, home, and personal data management and storage, this invention enables centralized storage, backup, synchronization, sharing, and efficient management of data through command-line operation, containerized management, and remote access.

[0044] First, the user inputs commands in the xterm.js terminal. Through xterm.js event listeners, the received data is processed. The processed data is encapsulated into a byte array and transmitted to the backend server via libp2p. The backend server parses the data, assembles it into a command line, and after checking permissions, calls the Docker API to execute container management operations. Finally, the execution result is returned via libp2p and displayed in the xterm.js terminal, thus achieving efficient and real-time container management.

[0045] Specifically, users access the xterm.js terminal interface through a browser. The frontend uses the libp2p library to initialize a frontend node and configures the necessary transport protocols, encryption modules, stream multiplexing modules, etc. The frontend node finds and connects to the backend node, establishing a bidirectional protocol stream between the frontend and the backend server. When the user enters a command in the xterm.js terminal, the frontend processes the command and transmits the captured command to the backend node via the libp2p stream. After receiving the command, the backend node determines whether the command is allowed to execute, calls the Docker API to interact with the Docker daemon, performs specific container management operations, and returns the result to the frontend. The frontend then displays the result to the user through the xterm.js terminal.

[0046] This invention leverages the powerful features of libp2p, including node discovery, connection management, encryption, and stream multiplexing, to make data transmission more secure and efficient. In this way, users can manage Docker containers in real time via a web terminal, improving the real-time performance and responsiveness of operations.

[0047] Example 2:

[0048] A decentralized containerized management method based on libp2p connections, such as Figure 3 As shown, the specific steps are as follows:

[0049] 1) Initialize the front-end libp2p node, such as... Figure 1As shown, the libp2p instance is created sequentially, the transport protocol is configured, the encryption module (such as NOISE) is configured, and the stream multiplexing module (such as Yamux) is configured. After initialization, the front-end node enters standby mode, ready to establish a connection with the back-end node.

[0050] 2) The front-end node finds the back-end node through libp2p's node discovery mechanism (dht) and establishes a connection with the back-end node through the libp2p node's dial method.

[0051] 3) After a successful connection, the front-end node creates a bidirectional protocol stream with the target back-end node based on the transport protocol set by the initialization node. This protocol stream allows bidirectional data communication between the front-end and back-end servers.

[0052] 4) Construct a simulated terminal page using xterm.js, configure keyboard events and paste behavior to allow paste operations. Add an extra one-click command fill button; clicking the button pastes a preset command into the command line, avoiding errors and the tedious process of manually entering commands. Simultaneously, set up a terminal listener to display the execution results from step 14 on the terminal.

[0053] 5) Users operate and enter commands in the web-based simulated terminal implemented by xterm.js.

[0054] 6) such as Figure 2 As shown, add a keyboard input event listener. Determine whether the current keyboard operation is a shortcut key usage or character input by checking the state of various modifier keys (Alt, AltGraph, Ctrl, Meta).

[0055] 7) Character input operation: No processing is performed to prevent data transmission duplication during data change event listening.

[0056] 8) Shortcut key operation: Determine whether the shortcut key combination is a copy and paste operation. If it is a copy and paste operation, do not interfere with it here. If it is not a copy and paste operation, after blocking the browser's default operation, transmit the shortcut key operation keyboard code to the backend server and continue execution from step 10.

[0057] 9) such as Figure 2 As shown, add a data change event listener. Listen for keyboard and pasted characters, then continue to step 10.

[0058] 10) Use the it-pipe library to write data to the libp2p stream. This step writes the data to the libp2p stream block by block, thus achieving data transfer.

[0059] 11) The backend node receives user input characters or strings sequentially from the libp2p stream, and integrates the received characters or strings using key characters (such as the keyboard key represented by Enter).

[0060] 12) The backend server parses and processes these commands, verifies and filters user input, judges user permissions, and only allows the execution of operations within the user's corresponding permissions. Other commands directly return a permission insufficient prompt to ensure security.

[0061] 13) The backend server transmits commands to the Docker daemon by calling the Docker API.

[0062] 14) The Docker daemon executes the passed-in commands (such as starting, stopping, or deleting containers). Then, it returns the execution results to the backend nodes.

[0063] 15) The backend node receives the results returned by the Docker daemon. It then transmits the execution results back to the frontend xterm.js terminal via a libp2p stream.

[0064] 16) The xterm.js terminal receives the results returned from the backend. It renders and displays them on the terminal, allowing users to view the results of command execution in real time.

[0065] This invention uses the libp2p protocol to achieve peer-to-peer communication between the browser-based xterm.js terminal and a Docker container on a NAS device, ensuring real-time bidirectional data transmission. This invention leverages libp2p's built-in encryption and authentication mechanisms to enhance data transmission security, while simultaneously improving system reliability and flexibility through adaptive networking and multi-protocol support.

[0066] This invention is a web-based terminal, eliminating the need for users to log in to the NAS via SSH. Furthermore, it utilizes decentralized peer-to-peer communication, allowing direct communication between nodes, eliminating single points of failure and enhancing system fault tolerance and reliability. This invention incorporates end-to-end encryption and authentication mechanisms (such as the Noise protocol), resulting in more secure data transmission and stronger privacy protection. Direct communication between nodes reduces intermediate forwarding, lowers latency, and improves real-time performance and responsiveness. This invention eliminates the need for a central server, enabling self-organization and self-management of nodes, thus reducing operational costs. This invention can restrict executable commands, making it highly practical.

[0067] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Any simple modifications or equivalent changes made to the above embodiments based on the technical essence of the present invention shall fall within the protection scope of the present invention.

Claims

1. A decentralized containerized management method based on libp2p connections, characterized in that, Includes the following steps: Step S1: The user inputs operations in the xterm.js terminal, processes the received data through the xterm.js event listener, and then encapsulates the data into a byte array and transmits it to the backend server through libp2p stream; Step S110: Initialize the front-end node at the front end, find the back-end node of the back-end server and initiate a connection; the front-end node establishes a bidirectional protocol stream with the back-end node based on the initialized transmission protocol, and the protocol stream allows bidirectional data communication between the front end and the back-end server. Step S120: Construct a simulated terminal page using xterm.js, which serves as the xterm.js terminal for the front end; Step S130: The user accesses the xterm.js terminal page through a browser and performs operations; Step S140: In the xterm.js terminal, listen for data change events and keyboard input events respectively to receive the data from the operation; then, the front-end node uses the it-pipe library to write the data to the libp2p stream, and transmits it to the back-end node through the libp2p stream; Step S2: The backend server parses the data and assembles it into a command line. Then, it analyzes the user's permissions to determine whether the command is allowed to be executed. If it is allowed, it calls the Docker API to perform container management operations and finally returns the execution result to the xterm.js terminal for display via libp2p stream.

2. The decentralized containerized management method based on libp2p connection according to claim 1, characterized in that, Step S110 includes the following steps: Step S111: Create a libp2p instance in the front end, initialize the transmission protocol, encryption module, and stream multiplexing module configuration of the front end libp2p node; after initialization, the front end node enters standby state to prepare for establishing a connection with the back end node. Step S112: The front-end node searches for the back-end node through the discovery mechanism of the libp2p node, and the front-end node establishes a connection with the back-end node through the dial method of the libp2p node.

3. The decentralized containerized management method based on libp2p connection according to claim 1, characterized in that, In step S120, keyboard events and paste behavior are configured in the xterm.js terminal to allow paste operations; a one-click fill command button is set in the xterm.js terminal, and by clicking the one-click fill command button, preset commands are pasted into the command line of the xterm.js terminal.

4. The decentralized containerized management method based on libp2p connection according to claim 1, characterized in that, In step S140, when listening for data change events, if the current keyboard operation is detected as modifier key input or pasting a string, it is transmitted to the backend server; when listening for keyboard input events, if the current keyboard operation is detected as character input, no processing is performed; if the current keyboard operation is detected as shortcut key usage, it is determined whether the shortcut key combination is a copy or paste operation. If so, no interference is performed; otherwise, after preventing the browser's default event from being triggered, the shortcut key operation keyboard code is transmitted to the backend server.

5. A decentralized containerized management method based on libp2p connections according to any one of claims 1-4, characterized in that, Step S2 includes the following steps: Step S210: The backend node receives the characters or strings input by the user in sequence from the libp2p stream, parses the data and assembles it into a command line. The backend server verifies and filters the received command request. Then, it analyzes the user's permissions to determine whether the command is allowed to be executed. If it is allowed to be executed, it proceeds to step S220; otherwise, it directly returns a message indicating insufficient permissions. Step S220: Call the Docker API to interact with the Docker daemon, perform specific container management operations, and return the execution results to the xterm.js terminal for display via the libp2p stream.

6. The decentralized containerized management method based on libp2p connection according to claim 5, characterized in that, In step S210, the backend node integrates and parses the received characters or strings using key characters to assemble them into a command line.

7. A decentralized containerized management method based on libp2p connections according to claim 5, characterized in that, Step S220 includes the following steps: Step S221: Transfer commands to the Docker daemon by calling the Docker API; Step S222: The Docker daemon executes the passed-in command and returns the execution result to the backend node; Step S223: The backend node receives the result returned by the Docker daemon and transmits the execution result back to the frontend xterm.js terminal via libp2p stream; Step S224: The xterm.js terminal receives the result returned by the backend server, renders it, and displays it on the terminal, allowing the user to view the result of the command execution in real time.

Citation Information

Patent Citations

  • Distributed proxy network

    CN110933197A

  • Visual containerized alliance chain node deployment method and system

    CN114650231A