Browser plug-in based protocol request forwarding method and device, equipment and medium
Patent Information
- Application Number
- CN202211480778.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-24
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2042-11-24
AI Technical Summary
[0003]现有的协议请求转发方法是指在代码里面修改后端指向的配置文件,并对修改后的配置文件进行重新构建、部署和应用,进而生效,这种请求转发方法不灵活,且流程繁琐费时,导致协议请求转发的效率较低
[0040]In this embodiment of the invention, a browser plugin is constructed through multiple plugin interaction modules. The implementation of the browser plugin is non-intrusive to the project source code, and it is convenient and highly flexible. Based on the interface requests intercepted by the browser plugin, protocol request forwarding is performed using rule updates and full-duplex communication protocol rewriting according to different interface request types, resulting in higher efficiency in protocol request forwarding. Therefore, the protocol request forwarding method, apparatus, electronic device, and storage medium based on browser plugins proposed in this invention can solve the problem of low efficiency in improving protocol request forwarding based on browser plugins.
Smart Images

Figure CN115865885B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer communications, and more particularly to a protocol request forwarding method, apparatus, electronic device, and storage medium based on a browser plugin. Background Technology
[0002] In the development and testing of various projects and products, the forwarding function of Application Programming Interface (API) requests is frequently required. APIs include Hypertext Transfer Protocol (HTTP) and Full-Duplex Protocol (MPTP). Request forwarding is used to allow a frontend in different environments to request a backend in any deployment environment. Therefore, a protocol request forwarding method needs to be proposed.
[0003] The existing protocol request forwarding method involves modifying the configuration file pointed to by the backend in the code, and then rebuilding, deploying and applying the modified configuration file to make it effective. This request forwarding method is inflexible and the process is cumbersome and time-consuming, resulting in low efficiency of protocol request forwarding. Summary of the Invention
[0004] This invention provides a protocol request forwarding method, apparatus, electronic device, and storage medium based on a browser plugin, the main purpose of which is to improve the efficiency of protocol request forwarding.
[0005] To achieve the above objectives, the present invention provides a protocol request forwarding method based on a browser plugin, comprising:
[0006] Browser plugins are created by building modules based on pre-built plugin interaction modules.
[0007] The browser plugin is used to intercept interface requests sent by the browser to which the browser plugin belongs, and the type of the interface request is determined.
[0008] When the interface request is a Hypertext Transfer Protocol request, the request header in the interface request is processed by rule update to obtain a standard update request, and the standard update request is forwarded to the corresponding backend. When the backend receives the standard update request, it determines that the interface request has been forwarded.
[0009] When the interface request is a full-duplex communication protocol request, the defined interface class is obtained according to the interface request, and the defined interface class is logically rewritten to obtain the rewritten interface class;
[0010] The rewritten interface class is used to perform data replacement processing on the interface request. When the data replacement processing is completed, it is determined that the interface request has been forwarded.
[0011] Optionally, the browser plugin is constructed based on a pre-built plugin interaction module, including:
[0012] The pre-built interface framework is initialized using the front-end toolchain to obtain the initial framework;
[0013] Create the plugin component directory and configuration file corresponding to the pre-built plugin interaction module;
[0014] Multiple reference permissions are declared in the configuration file, and the configuration file after declaring multiple reference permissions and the plugin component directory are laid out under the initial framework to obtain the browser plugin.
[0015] Optionally, before performing rule update processing on the request headers in the interface request to obtain a standard update request, the method further includes:
[0016] Locate the request header in the interface request and identify the protocol type in the request header;
[0017] When the protocol type is Hypertext Transfer Protocol, the interface request is determined to be a Hypertext Transfer Protocol request;
[0018] When the protocol type is a full-duplex communication protocol, the interface request is determined to be a full-duplex communication protocol request.
[0019] Optionally, the step of performing rule update processing on the request headers in the interface request to obtain a standard update request includes:
[0020] Obtain a preset rule structure and use the preset rule structure to view the processing rules in the request header;
[0021] The processing rules are updated using an update method to obtain a standard update request.
[0022] Optionally, obtaining the defined interface class according to the interface request includes:
[0023] Identify the full-duplex communication class to which the interface request belongs, and declare the full-duplex communication class that has an inheritance relationship with the full-duplex communication class.
[0024] The defined full-duplex communication class is used as the defined interface class.
[0025] Optionally, the step of logically rewriting the defined interface class to obtain the rewritten interface class includes:
[0026] Receive the Uniform Resource Locator (URL) parameter from the defined interface class, perform character processing on the URL parameter, and obtain the conversion parameter;
[0027] The conversion parameters are passed to a preset interface class using a passing method to obtain a new interface class.
[0028] Optionally, after performing data replacement processing on the interface request using the rewritten interface class, the method further includes:
[0029] The method for replacing data is executed in the script code within the browser plugin.
[0030] To address the aforementioned problems, the present invention also provides a protocol request forwarding device based on a browser plugin, the device comprising:
[0031] The plugin building module is used to build browser plugins based on pre-built plugin interaction modules.
[0032] The rule update module is used to intercept the interface request sent by the browser to which the browser plugin belongs using the browser plugin, determine the type of the interface request, and when the interface request is a Hypertext Transfer Protocol request, perform rule update processing on the request header in the interface request to obtain a standard update request, and forward the standard update request to the corresponding backend. When the backend receives the standard update request, it determines that the interface request has been forwarded.
[0033] The logic rewriting module is used to obtain a defined interface class according to the interface request when the interface request is a full-duplex communication protocol request, and to perform logic rewriting on the defined interface class to obtain a rewritten interface class.
[0034] The data replacement module is used to perform data replacement processing on the interface request using the rewritten interface class. When the data replacement processing is completed, it is determined that the interface request has been forwarded.
[0035] To address the above problems, the present invention also provides an electronic device, the electronic device comprising:
[0036] At least one processor; and,
[0037] A memory communicatively connected to the at least one processor; wherein,
[0038] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the browser plugin-based protocol request forwarding method described above.
[0039] To address the aforementioned problems, the present invention also provides a storage medium storing at least one computer program, which is executed by a processor in an electronic device to implement the browser plugin-based protocol request forwarding method described above.
[0040] In this embodiment of the invention, a browser plugin is constructed through multiple plugin interaction modules. The implementation of the browser plugin is non-intrusive to the project source code, and it is convenient and highly flexible. Based on the interface requests intercepted by the browser plugin, protocol request forwarding is performed using rule updates and full-duplex communication protocol rewriting according to different interface request types, resulting in higher efficiency in protocol request forwarding. Therefore, the protocol request forwarding method, apparatus, electronic device, and storage medium based on browser plugins proposed in this invention can solve the problem of low efficiency in improving protocol request forwarding based on browser plugins. Attached Figure Description
[0041] Figure 1 This is a flowchart illustrating a protocol request forwarding method based on a browser plugin according to an embodiment of the present invention.
[0042] Figure 2 for Figure 1 A detailed implementation flowchart of one of the steps;
[0043] Figure 3 A functional block diagram of a protocol request forwarding device based on a browser plugin provided in an embodiment of the present invention;
[0044] Figure 4 This is a schematic diagram of the structure of an electronic device that implements the browser plugin-based protocol request forwarding method according to an embodiment of the present invention.
[0045] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0046] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0047] This application provides a protocol request forwarding method based on a browser plugin. The execution entity of the browser plugin-based protocol request forwarding method includes, but is not limited to, at least one of the following electronic devices that can be configured to execute the method provided in this application: a server, a terminal, etc. In other words, the browser plugin-based protocol request forwarding method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes, but is not limited to, a single server, a server cluster, a cloud server, or a cloud server cluster. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0048] Reference Figure 1 The diagram shown is a flowchart illustrating a browser plugin-based protocol request forwarding method according to an embodiment of the present invention. In this embodiment, the browser plugin-based protocol request forwarding method includes the following steps S1-S4:
[0049] S1. Module construction is performed based on pre-built plugin interaction modules to obtain browser plugins.
[0050] In this embodiment of the invention, the plugin interaction module includes a background module, a contentScript module, and a popup module, etc.
[0051] Specifically, the background module is the browser plugin's backend module, used for logic processing, such as network interception. The contentScript module contains script code injected into the webpage by the browser plugin, such as WebSocket overriding processing. The popup module is the browser plugin's interactive page, serving as a window that pops up when the user clicks on the plugin.
[0052] Specifically, refer to Figure 2 As shown, the process of building a browser plugin based on a pre-built plugin interaction module includes the following steps S11-S13:
[0053] S11. Use the front-end toolchain to initialize the pre-built interface framework to obtain the initial framework;
[0054] S12. Create the plugin component directory and configuration file corresponding to the pre-built plugin interaction module;
[0055] S13. Declare multiple reference permissions in the configuration file, and lay out the configuration file after declaring multiple reference permissions and the plugin component directory under the initial framework to obtain the browser plugin.
[0056] Specifically, the front-end toolchain refers to the Vite toolchain, which is a next-generation front-end toolchain based on the front-end bundling tool Esbuild and the Esm module. The pre-built UI framework refers to Vue, a JavaScript framework for building user interfaces and one of the most popular development frameworks for web front-end development. This solution uses the Vue 3 framework, which, compared to Vue 2, uses a proxy method at its core, providing higher performance and a composable API.
[0057] The plugin component directories corresponding to the various plugin interaction modules are the background directory, contentScript directory, and popup directory, respectively, and the configuration file is a manifest.json file. The manifest.json file declares several required permissions, namely storage permissions and network request-related permissions, namely declarativeNetRequest and declarativeNetRequestFeedback.
[0058] S2. Use the browser plugin to intercept the interface request sent by the browser to which the browser plugin belongs, and determine the type of the interface request.
[0059] In this embodiment of the invention, the browser plugin is a tool that adds new functions based on the existing functions of the browser. Therefore, it is located on the browser to which the browser plugin belongs, and the browser plugin can intercept the interception interface requests sent by the browser to which it belongs.
[0060] Specifically, it is necessary to determine the type of the interface request sent by the browser to which the browser plugin belongs, and then perform subsequent request forwarding processing based on the type of the interface request.
[0061] S3. When the interface request is a Hypertext Transfer Protocol request, the request header in the interface request is updated with rules to obtain a standard update request, and the standard update request is forwarded to the corresponding backend. When the backend receives the standard update request, it determines that the interface request has been forwarded.
[0062] In this embodiment of the invention, before performing rule update processing on the request headers in the interface request to obtain a standard update request, the method further includes:
[0063] Locate the request header in the interface request and identify the protocol type in the request header;
[0064] When the protocol type is Hypertext Transfer Protocol, the interface request is determined to be a Hypertext Transfer Protocol request;
[0065] When the protocol type is a full-duplex communication protocol, the interface request is determined to be a full-duplex communication protocol request.
[0066] In detail, the purpose of request headers is to tell the server information about the client's environment and the request body, such as browser version, protocol type, or the length of request parameters. The server can also use the client information provided in the request headers to try to provide a better response to the client.
[0067] Preferably, the Hypertext Transfer Protocol (HTTP) refers to HTTP, which is the foundation for data exchange on the Web and is a client-server protocol. The full-duplex communication protocol request refers to a protocol for full-duplex communication over a single TCP connection. In this solution, the full-duplex communication protocol refers to WebSocket. WebSocket simplifies data exchange between the client and server, allowing the server to proactively push data to the client. In the WebSocket API, the browser and server only need to complete a single handshake to establish a persistent connection and perform bidirectional data transmission.
[0068] Further, the step of performing rule update processing on the request headers in the interface request to obtain a standard update request includes:
[0069] Obtain a preset rule structure and use the preset rule structure to view the processing rules in the request header;
[0070] The processing rules are updated using an update method to obtain a standard update request.
[0071] In detail, the preset rule structure is a rule structure. The rule structure can be used to view the rule document and update the processing rules through browser.declarativeNetRequest.updateSessionRules.
[0072] The update processing code can be found below:
[0073]
[0074] Specifically, to clear the rules, you can change the rules array to an empty array and then call browser.declarativeNetRequest.updateSessionRules again to clear the previous proxy rules.
[0075] S4. When the interface request is a full-duplex communication protocol request, obtain the defined interface class according to the interface request, and rewrite the defined interface class to obtain the rewritten interface class.
[0076] In this embodiment of the invention, obtaining the defined interface class according to the interface request includes:
[0077] Identify the full-duplex communication class to which the interface request belongs, and declare the full-duplex communication class that has an inheritance relationship with the full-duplex communication class.
[0078] The defined full-duplex communication class is used as the defined interface class.
[0079] In detail, a proxyWebsocket method needs to be implemented. First, declare a custom MyWebsocket class that inherits from the Websocket class provided by the page.
[0080] Specifically, the step of logically rewriting the defined interface class to obtain the rewritten interface class includes:
[0081] Receive the Uniform Resource Locator (URL) parameter from the defined interface class, perform character processing on the URL parameter, and obtain the conversion parameter;
[0082] The conversion parameters are passed to a preset interface class using a passing method to obtain a new interface class.
[0083] In detail, the Uniform Resource Locator (URL) parameter receives a URL link as a parameter, performs certain character processing on this URL, and passes the processed URL using the class's super method, i.e., super(url).
[0084] S5. Use the rewritten interface class to perform data replacement processing on the interface request. When the data replacement processing is completed, determine that the interface request has been forwarded.
[0085] In this embodiment of the invention, the original full-duplex communication Websocket in the interface request is replaced by the rewritten interface class, that is, the defined MyWebsocket is used to cover the original Websocket of the page, which can be expressed in code as window.Websocket = MyWebsocket.
[0086] Specifically, after performing data replacement processing on the interface request using the rewritten interface class, the method further includes:
[0087] The method for replacing data is executed in the script code within the browser plugin.
[0088] In detail, the browser plugin's script code is `contentScript`. Within `contentScript`, a custom-implemented `proxyWebsocket` method is imported. This code is automatically executed when the page loads, replacing the original Websocket connection. When the page calls `Websocket` to initialize a Websocket connection, the replaced `MyWebsocket` is actually used, thus achieving the forwarding of Websocket request protocols.
[0089] In this embodiment of the invention, a browser plugin is constructed through multiple plugin interaction modules. The implementation of the browser plugin is non-intrusive to the project source code, and it is convenient and highly flexible. Based on the interface requests intercepted by the browser plugin, protocol request forwarding is performed using rule updates and full-duplex communication protocol rewriting according to different interface request types, resulting in higher efficiency in protocol request forwarding. Therefore, the protocol request forwarding method based on browser plugins proposed in this invention can solve the problem of low efficiency in improving protocol request forwarding based on browser plugins.
[0090] like Figure 3 The diagram shown is a functional block diagram of a protocol request forwarding device based on a browser plugin provided in an embodiment of the present invention.
[0091] The browser plugin-based protocol request forwarding device 100 of this invention can be installed in an electronic device. Depending on the functions implemented, the browser plugin-based protocol request forwarding device 100 may include a plugin construction module 101, a rule update module 102, a logic rewriting module 103, and a data replacement module 104. The module described in this invention can also be called a unit, which refers to a series of computer program segments that can be executed by the processor of an electronic device and can perform a fixed function, and which are stored in the memory of the electronic device.
[0092] In this embodiment, the functions of each module / unit are as follows:
[0093] The plugin building module 101 is used to build a browser plugin based on a pre-built plugin interaction module.
[0094] The rule update module 102 is used to intercept the interface request sent by the browser to which the browser plugin belongs using the browser plugin, determine the type of the interface request, and when the interface request is a Hypertext Transfer Protocol request, perform rule update processing on the request header in the interface request to obtain a standard update request, and forward the standard update request to the corresponding backend. When the backend receives the standard update request, it determines that the interface request has been forwarded.
[0095] The logic rewriting module 103 is used to obtain a defined interface class according to the interface request when the interface request is a full-duplex communication protocol request, and to perform logic rewriting on the defined interface class to obtain a rewritten interface class.
[0096] The data replacement module 104 is used to perform data replacement processing on the interface request using the rewritten interface class. When the data replacement processing is completed, it is determined that the interface request has been forwarded.
[0097] In detail, the specific implementation methods of each module of the browser plugin-based protocol request forwarding device 100 are as follows:
[0098] Step 1: Build a module based on the pre-built plugin interaction module to obtain the browser plugin.
[0099] In this embodiment of the invention, the plugin interaction module includes a background module, a contentScript module, and a popup module, etc.
[0100] Specifically, the background module is the browser plugin's backend module, used for logic processing, such as network interception. The contentScript module contains script code injected into the webpage by the browser plugin, such as WebSocket overriding processing. The popup module is the browser plugin's interactive page, serving as a window that pops up when the user clicks on the plugin.
[0101] Specifically, the module construction based on the pre-built plugin interaction module to obtain the browser plugin includes:
[0102] The pre-built interface framework is initialized using the front-end toolchain to obtain the initial framework;
[0103] Create the plugin component directory and configuration file corresponding to the pre-built plugin interaction module;
[0104] Multiple reference permissions are declared in the configuration file, and the configuration file after declaring multiple reference permissions and the plugin component directory are laid out under the initial framework to obtain the browser plugin.
[0105] Specifically, the front-end toolchain refers to the Vite toolchain, which is a next-generation front-end toolchain based on the front-end bundling tool Esbuild and the Esm module. The pre-built UI framework refers to Vue, a JavaScript framework for building user interfaces and one of the most popular development frameworks for web front-end development. This solution uses the Vue 3 framework, which, compared to Vue 2, uses a proxy method at its core, providing higher performance and a composable API.
[0106] The plugin component directories corresponding to the various plugin interaction modules are the background directory, contentScript directory, and popup directory, respectively, and the configuration file is a manifest.json file. The manifest.json file declares several required permissions, namely storage permissions and network request-related permissions, namely declarativeNetRequest and declarativeNetRequestFeedback.
[0107] Step 2: Use the browser plugin to intercept the interface requests sent by the browser to which the browser plugin belongs, and determine the type of the interface request.
[0108] In this embodiment of the invention, the browser plugin is a tool that adds new functions based on the existing functions of the browser. Therefore, it is located on the browser to which the browser plugin belongs, and the browser plugin can intercept the interception interface requests sent by the browser to which it belongs.
[0109] Specifically, it is necessary to determine the type of the interface request sent by the browser to which the browser plugin belongs, and then perform subsequent request forwarding processing based on the type of the interface request.
[0110] Step 3: When the interface request is a Hypertext Transfer Protocol (HTTP) request, perform rule update processing on the request header of the interface request to obtain a standard update request, and forward the standard update request to the corresponding backend. When the backend receives the standard update request, it determines that the interface request has been successfully forwarded. In this embodiment of the invention, before performing rule update processing on the request header of the interface request to obtain the standard update request, the method further includes:
[0111] Locate the request header in the interface request and identify the protocol type in the request header;
[0112] When the protocol type is Hypertext Transfer Protocol, the interface request is determined to be a Hypertext Transfer Protocol request;
[0113] When the protocol type is a full-duplex communication protocol, the interface request is determined to be a full-duplex communication protocol request.
[0114] In detail, the purpose of request headers is to tell the server information about the client's environment and the request body, such as browser version, protocol type, or the length of request parameters. The server can also use the client information provided in the request headers to try to provide a better response to the client.
[0115] Preferably, the Hypertext Transfer Protocol (HTTP) refers to HTTP, which is the foundation for data exchange on the Web and is a client-server protocol. The full-duplex communication protocol request refers to a protocol for full-duplex communication over a single TCP connection. In this solution, the full-duplex communication protocol refers to WebSocket. WebSocket simplifies data exchange between the client and server, allowing the server to proactively push data to the client. In the WebSocket API, the browser and server only need to complete a single handshake to establish a persistent connection and perform bidirectional data transmission.
[0116] Further, the step of performing rule update processing on the request headers in the interface request to obtain a standard update request includes:
[0117] Obtain a preset rule structure and use the preset rule structure to view the processing rules in the request header;
[0118] The processing rules are updated using an update method to obtain a standard update request.
[0119] In detail, the preset rule structure is a rule structure. The rule structure can be used to view the rule document and update the processing rules through browser.declarativeNetRequest.updateSessionRules.
[0120] The update processing code can be found below:
[0121]
[0122] Specifically, to clear the rules, you can change the rules array to an empty array and then call browser.declarativeNetRequest.updateSessionRules again to clear the previous proxy rules.
[0123] Step 4: When the interface request is a full-duplex communication protocol request, obtain the defined interface class according to the interface request, and rewrite the defined interface class to obtain the rewritten interface class.
[0124] In this embodiment of the invention, obtaining the defined interface class according to the interface request includes:
[0125] Identify the full-duplex communication class to which the interface request belongs, and declare the full-duplex communication class that has an inheritance relationship with the full-duplex communication class.
[0126] The defined full-duplex communication class is used as the defined interface class.
[0127] In detail, a proxyWebsocket method needs to be implemented. First, declare a custom MyWebsocket class that inherits from the Websocket class provided by the page.
[0128] Specifically, the step of logically rewriting the defined interface class to obtain the rewritten interface class includes:
[0129] Receive the Uniform Resource Locator (URL) parameter from the defined interface class, perform character processing on the URL parameter, and obtain the conversion parameter;
[0130] The conversion parameters are passed to a preset interface class using a passing method to obtain a new interface class.
[0131] In detail, the Uniform Resource Locator (URL) parameter receives a URL link as a parameter, performs certain character processing on this URL, and passes the processed URL using the class's super method, i.e., super(url).
[0132] Step 5: Use the rewritten interface class to perform data replacement processing on the interface request. When the data replacement processing is completed, determine that the interface request has been forwarded.
[0133] In this embodiment of the invention, the original full-duplex communication Websocket in the interface request is replaced by the rewritten interface class, that is, the defined MyWebsocket is used to cover the original Websocket of the page, which can be expressed in code as window.Websocket = MyWebsocket.
[0134] Specifically, after performing data replacement processing on the interface request using the rewritten interface class, the method further includes:
[0135] The method for replacing data is executed in the script code within the browser plugin.
[0136] In detail, the browser plugin's script code is `contentScript`. Within `contentScript`, a custom-implemented `proxyWebsocket` method is imported. This code is automatically executed when the page loads, replacing the original Websocket connection. When the page calls `Websocket` to initialize a Websocket connection, the replaced `MyWebsocket` is actually used, thus achieving the forwarding of Websocket request protocols.
[0137] In this embodiment of the invention, a browser plugin is constructed through multiple plugin interaction modules. The implementation of the browser plugin is non-intrusive to the project source code, and it is convenient and highly flexible. Based on the interface requests intercepted by the browser plugin, protocol request forwarding is performed using rule updates and full-duplex communication protocol rewriting according to the different types of interface requests, resulting in higher efficiency in protocol request forwarding. Therefore, the browser plugin-based protocol request forwarding device proposed in this invention can solve the problem of low efficiency in improving browser plugin-based protocol request forwarding.
[0138] like Figure 4 The diagram shown is a structural schematic of an electronic device that implements a browser plugin-based protocol request forwarding method according to an embodiment of the present invention.
[0139] The electronic device 1 may include a processor 10, a memory 11, a communication bus 12, and a communication interface 13. It may also include a computer program stored in the memory 11 and capable of running on the processor 10, such as a protocol request forwarding program based on a browser plugin.
[0140] In some embodiments, the processor 10 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control unit of the electronic device, connecting various components of the entire electronic device through various interfaces and lines. It executes programs or modules stored in the memory 11 (e.g., executing a protocol request forwarding program based on a browser plugin) and calls data stored in the memory 11 to perform various functions of the electronic device and process data.
[0141] The memory 11 includes at least one type of readable storage medium, including flash memory, portable hard drive, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of an electronic device, such as a portable hard drive. In other embodiments, the memory 11 can be an external storage device of the electronic device, such as a plug-in portable hard drive, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc. Furthermore, the memory 11 can include both internal and external storage units of the electronic device. The memory 11 can be used not only to store application software and various types of data installed on the electronic device, such as the code of a protocol request forwarding program based on a browser plugin, but also to temporarily store data that has been output or will be output.
[0142] The communication bus 12 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into an address bus, a data bus, a control bus, etc. The bus is configured to enable communication between the memory 11 and at least one processor 10, etc.
[0143] The communication interface 13 is used for communication between the aforementioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a Wi-Fi interface, Bluetooth interface, etc.), typically used to establish communication connections between the electronic device and other electronic devices. The user interface may be a display, an input unit (such as a keyboard), or, optionally, a standard wired or wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen, etc. The display may also be appropriately referred to as a screen or display unit, used to display information processed in the electronic device and to display a visual user interface.
[0144] Figure 4 Only electronic devices with components are shown; those skilled in the art will understand that... Figure 4The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0145] For example, although not shown, the electronic device may also include a power supply (such as a battery) to power the various components. Preferably, the power supply can be logically connected to the at least one processor 10 through a power management device, thereby enabling functions such as charging management, discharging management, and power consumption management. The power supply may also include one or more DC or AC power supplies, recharging devices, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0146] It should be understood that the embodiments described are for illustrative purposes only and are not limited to this structure in the scope of the patent application.
[0147] The browser plugin-based protocol request forwarding program stored in the memory 11 of the electronic device 1 is a combination of multiple instructions, which, when run in the processor 10, can achieve the following:
[0148] Browser plugins are created by building modules based on pre-built plugin interaction modules.
[0149] The browser plugin is used to intercept interface requests sent by the browser to which the browser plugin belongs, and the type of the interface request is determined.
[0150] When the interface request is a Hypertext Transfer Protocol request, the request header in the interface request is processed by rule update to obtain a standard update request, and the standard update request is forwarded to the corresponding backend. When the backend receives the standard update request, it determines that the interface request has been forwarded.
[0151] When the interface request is a full-duplex communication protocol request, the defined interface class is obtained according to the interface request, and the defined interface class is logically rewritten to obtain the rewritten interface class;
[0152] The rewritten interface class is used to perform data replacement processing on the interface request. When the data replacement processing is completed, it is determined that the interface request has been forwarded.
[0153] Specifically, the specific implementation method of the processor 10 for the above instructions can be referred to the description of the relevant steps in the corresponding embodiment of the accompanying drawings, and will not be repeated here.
[0154] Furthermore, if the modules / units integrated in the electronic device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a storage medium. The storage medium can be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, or a read-only memory (ROM).
[0155] The present invention also provides a storage medium storing a computer program, which, when executed by a processor of an electronic device, can perform the following:
[0156] Browser plugins are created by building modules based on pre-built plugin interaction modules.
[0157] The browser plugin is used to intercept interface requests sent by the browser to which the browser plugin belongs, and the type of the interface request is determined.
[0158] When the interface request is a Hypertext Transfer Protocol request, the request header in the interface request is processed by rule update to obtain a standard update request, and the standard update request is forwarded to the corresponding backend. When the backend receives the standard update request, it determines that the interface request has been forwarded.
[0159] When the interface request is a full-duplex communication protocol request, the defined interface class is obtained according to the interface request, and the defined interface class is logically rewritten to obtain the rewritten interface class;
[0160] The rewritten interface class is used to perform data replacement processing on the interface request. When the data replacement processing is completed, it is determined that the interface request has been forwarded.
[0161] In the several embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.
[0162] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0163] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.
[0164] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0165] Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within the invention. No appended diagram markings in the claims should be construed as limiting the scope of the claims.
[0166] The blockchain referred to in this invention is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.
[0167] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0168] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a system claim may also be implemented by a single unit or device through software or hardware. The terms "first," "second," etc., are used to indicate names and do not indicate any specific order.
[0169] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A protocol request forwarding method based on a browser plugin, characterized in that, The method includes: Browser plugins are created by building modules based on pre-built plugin interaction modules. The browser plugin is used to intercept interface requests sent by the browser to which the browser plugin belongs, and the type of the interface request is determined. When the interface request is a Hypertext Transfer Protocol request, the request header in the interface request is processed by rule update to obtain a standard update request, and the standard update request is forwarded to the corresponding backend. When the backend receives the standard update request, it determines that the interface request has been forwarded. When the interface request is a full-duplex communication protocol request, the defined interface class is obtained according to the interface request, and the defined interface class is logically rewritten to obtain the rewritten interface class; The rewritten interface class is used to perform data replacement processing on the interface request. When the data replacement processing is completed, it is determined that the interface request has been forwarded. The step of performing rule update processing on the request header in the interface request to obtain a standard update request includes: obtaining a preset rule structure and using the preset rule structure to view the processing rules in the request header; and using an update method to update the processing rules to obtain a standard update request. The step of obtaining the defined interface class according to the interface request includes: identifying the full-duplex communication class to which the interface request belongs, and declaring a defined full-duplex communication class that has an inheritance relationship with the full-duplex communication class; and using the defined full-duplex communication class as the defined interface class. The step of logically rewriting the defined interface class to obtain a rewritten interface class includes: receiving a Uniform Resource Locator (URL) parameter from the defined interface class; performing character processing on the URL parameter to obtain a conversion parameter; and passing the conversion parameter to a preset interface class using a passing method to obtain the rewritten interface class.
2. The protocol request forwarding method based on browser plugins as described in claim 1, characterized in that, The browser plugin is constructed based on the pre-built plugin interaction module, including: The pre-built interface framework is initialized using the front-end toolchain to obtain the initial framework; Create the plugin component directory and configuration file corresponding to the pre-built plugin interaction module; Multiple reference permissions are declared in the configuration file, and the configuration file after declaring multiple reference permissions and the plugin component directory are laid out under the initial framework to obtain the browser plugin.
3. The protocol request forwarding method based on browser plugins as described in claim 1, characterized in that, Before performing rule update processing on the request headers in the interface request to obtain a standard update request, the method further includes: Locate the request header in the interface request and identify the protocol type in the request header; When the protocol type is Hypertext Transfer Protocol, the interface request is determined to be a Hypertext Transfer Protocol request; When the protocol type is a full-duplex communication protocol, the interface request is determined to be a full-duplex communication protocol request.
4. The protocol request forwarding method based on browser plugins as described in claim 1, characterized in that, After performing data replacement processing on the interface request using the rewritten interface class, the method further includes: The method for replacing data is executed in the script code within the browser plugin.
5. A protocol request forwarding device based on a browser plugin, used to implement the protocol request forwarding method based on a browser plugin as described in any one of claims 1 to 4, characterized in that, The device includes: The plugin building module is used to build browser plugins based on pre-built plugin interaction modules. The rule update module is used to intercept the interface request sent by the browser to which the browser plugin belongs using the browser plugin, determine the type of the interface request, and when the interface request is a Hypertext Transfer Protocol request, perform rule update processing on the request header in the interface request to obtain a standard update request, and forward the standard update request to the corresponding backend. When the backend receives the standard update request, it determines that the interface request has been forwarded. The logic rewriting module is used to obtain a defined interface class according to the interface request when the interface request is a full-duplex communication protocol request, and to perform logic rewriting on the defined interface class to obtain a rewritten interface class. The data replacement module is used to perform data replacement processing on the interface request using the rewritten interface class. When the data replacement processing is completed, it is determined that the interface request has been forwarded.
6. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the browser plugin-based protocol request forwarding method as described in any one of claims 1 to 4.
7. A storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the browser plugin-based protocol request forwarding method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Proxy access method, user equipment, storage medium, device and system
CN110808897A
Web browser plug-in based on WebSocket and data interaction method
CN112486587A