Implementation methods and systems for leased line clients based on the Electron framework
By using the Electron framework and nginx reverse proxy technology, client requests are intercepted and rewritten, solving the cross-platform support and resource consumption issues of dedicated line clients, and realizing a high-performance, stable and secure dedicated line client.
Patent Information
- Application Number
- CN202310746428.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-21
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2043-06-21
AI Technical Summary
In existing technologies, leased line clients have weak cross-platform support, high installation and maintenance costs, and the .NET Framework runtime library consumes a lot of hardware resources, failing to guarantee high performance, stability, and security.
The dedicated line client is implemented using the Electron framework. The request is intercepted through the onBeforeRequest method in Electron's session module. Combined with the nginx reverse proxy, the request is rewritten and forwarded to the application server to ensure high performance, stability and security.
It achieves good cross-platform compatibility, reduces installation and maintenance costs, reduces hardware resource consumption, and ensures high performance, stability, and security of requests.
Smart Images

Figure CN116846969B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Electron technology, and more specifically, to a method and system for implementing a leased line client based on the Electron framework. Background Technology
[0002] Currently, dedicated line clients are mainly implemented using .NET technology. However, this technology has the problem of weak cross-platform support because it depends on many frameworks, resulting in high installation and maintenance costs. In addition, users also need to install the corresponding .NET Framework runtime library, which consumes a lot of hardware resources.
[0003] Using Electron technology to implement a leased line client can solve the above problems. Electron clients can run on almost all operating systems, reducing installation and maintenance costs and consuming fewer hardware resources. Therefore, leased line clients based on Electron technology have better cross-platform compatibility and user experience, and can meet the needs of a wider range of users.
[0004] Patent document CN114722366A (application number: CN202111644805.6) discloses a method and system for multi-factor authentication of a cloud desktop client based on the Electron framework. When a client needs to log in to the cloud desktop from the terminal, they first obtain login information from the cloud desktop management terminal through the cloud desktop client. Under high information security requirements, multi-factor authentication is configured on the cloud desktop management terminal, requiring users to authenticate using username and password, as well as facial recognition, or a combination of facial recognition and fingerprint for secondary authentication. However, this patent does not employ a reverse proxy method, thus failing to guarantee the high performance, stability, and security of forwarding requests to the application server. Summary of the Invention
[0005] In view of the shortcomings of the existing technology, the purpose of this invention is to provide a method and system for implementing a leased line client based on the Electron framework.
[0006] The leased line client implementation method based on the Electron framework provided by the present invention includes:
[0007] Step 1: When the client starts, check if there is a configuration file in the same directory as the running exe program. If the configuration file exists, proceed to Step 2 to perform the corresponding operation; otherwise, end the process.
[0008] Step 2: Use the onBeforeRequest method in the Electron framework's session to intercept requests;
[0009] Step 3: Rewrite the original request using the Electron framework;
[0010] Step 4: After receiving the client's request to modify the leased line, the user-side leased line server sends it to the server-side leased line server;
[0011] Step 5: The dedicated server uses nginx reverse proxy to restore the user-side request and send the final request to the corresponding application server;
[0012] Step 6: Return the response result of the final request to the original path and add a cross-domain header to the response.
[0013] Preferably, the original request format is https: / / A.* / $, where A is the domain name, including www or a subdomain; and $ is the part following the request path.
[0014] If the IP address of the leased line server on the user side is 1.1.1.1, then the client will modify the request to http: / / 1.1.1.1 / A / $.
[0015] If the IP address of the dedicated line server on the service side is 2.2.2.2, then the user's request will be http: / / 2.2.2.2 / A / $;
[0016] The user-side request http: / / 2.2.2.2 / A / $ is restored and a request is sent to the corresponding application server. If the address of the corresponding application server is 3.3.3.3, then the final request https: / / 3.3.3.3 / $ is sent.
[0017] Preferably, step 2 includes: when the Electron framework is ready to send a network request, it first attempts to match the callback function of onBeforeRequest registered in the session; if a match is found, the Electron framework pauses the request being processed and passes the request details to the callback function; the request is rewritten in the callback function, and then it decides whether to continue sending the request or abort the request and return a custom response content.
[0018] Preferably, step 3 includes:
[0019] Step 3.1: Rewrite the domain name address part ".*" in the original request with the IP address of the user-side leased line server to get 1.1.1.1;
[0020] Step 3.2: Change the protocol from HTTPS to HTTP to get http: / / 1.1.1.1;
[0021] Step 3.3: According to the agreed rules, append A to the IP address and then add $ to get http: / / 1.1.1.1 / A / $;
[0022] Step 3.4: Set the redirect address to http: / / 1.1.1.1 / A / $ in the callback function, and then send the request.
[0023] Preferably, step 5 includes:
[0024] Step 5.1: Based on the suffix / A, find the corresponding application server address, which is 3.3.3.3;
[0025] Step 5.2: Convert the protocol from HTTP to HTTPS to obtain https: / / 3.3.3.3;
[0026] Step 5.3: Add the $ symbol to get https: / / 3.3.3.3 / $.
[0027] The leased line client implementation system based on the Electron framework provided by the present invention includes:
[0028] Module M1: When the client starts, it checks whether there is a configuration file in the same directory as the running exe program. If there is a configuration file, it triggers module M2 to perform the corresponding operation; otherwise, the process ends.
[0029] Module M2: Uses the onBeforeRequest method in the Electron framework's session to hijack requests;
[0030] Module M3: Rewrites the original request using the Electron framework;
[0031] Module M4: After receiving the client's request to modify the leased line, the user-side leased line server sends it to the server-side leased line server;
[0032] Module M5: The dedicated server uses nginx reverse proxy to restore the user-side request and send the final request to the corresponding application server;
[0033] Module M6: Returns the response result of the final request to the original path and adds a cross-domain header to the response.
[0034] Preferably, the original request format is https: / / A.* / $, where A is the domain name, including www or a subdomain; and $ is the part following the request path.
[0035] If the IP address of the leased line server on the user side is 1.1.1.1, then the client will modify the request to http: / / 1.1.1.1 / A / $.
[0036] If the IP address of the dedicated line server on the service side is 2.2.2.2, then the user's request will be http: / / 2.2.2.2 / A / $;
[0037] The user-side request http: / / 2.2.2.2 / A / $ is restored and a request is sent to the corresponding application server. If the address of the corresponding application server is 3.3.3.3, then the final request https: / / 3.3.3.3 / $ is sent.
[0038] Preferably, module M2 includes: when the Electron framework is preparing to send a network request, it first attempts to match the callback function of onBeforeRequest registered in the session; if a match is found, the Electron framework pauses the request being processed and passes the request details to the callback function; the request is rewritten in the callback function, and then it decides whether to continue sending the request or abort the request and return a custom response content.
[0039] Preferably, the module M3 includes:
[0040] Module M3.1: Rewrites the domain name address part ".*" in the original request with the IP address of the user-side leased line server, resulting in 1.1.1.1;
[0041] Module M3.2: Changes the protocol from HTTPS to HTTP, resulting in http: / / 1.1.1.1;
[0042] Module M3.3: According to the agreed rules, append A to the IP address and then add $ to get http: / / 1.1.1.1 / A / $;
[0043] Module M3.4: Set the redirect address to http: / / 1.1.1.1 / A / $ in the callback function, and then send the request.
[0044] Preferably, the module M5 includes:
[0045] Module M5.1: Based on the suffix / A, find the corresponding application server address, which is 3.3.3.3;
[0046] Module M5.2: Converts the protocol from HTTP to HTTPS, resulting in https: / / 3.3.3.3;
[0047] Module M5.3: Add $ to get https: / / 3.3.3.3 / $.
[0048] Compared with the prior art, the present invention has the following beneficial effects:
[0049] (1) This invention uses the onBeforeRequest method in Electron's session module to intercept client requests, thereby achieving the purpose of modifying requests. Traditional .NET requires additional modules and HTTP handlers, which is more cumbersome to write.
[0050] (2) This invention uses a reverse proxy to forward requests to the application server, thereby enabling the dedicated line server to send requests to the application server. Specifically, it uses nginx reverse proxy, which can guarantee high performance, stability and security, and has strong performance. Attached Figure Description
[0051] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0052] Figure 1 Network link diagram;
[0053] Figure 2 Flowchart for initializing client hijacking. Detailed Implementation
[0054] The present invention will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present invention, but do not limit the invention in any way. It should be noted that those skilled in the art can make several changes and improvements without departing from the concept of the present invention. These all fall within the protection scope of the present invention.
[0055] Example 1:
[0056] This invention provides a method for implementing a leased line client based on the Electron framework. Before sending a request, the Electron client intercepts the request and rewrites it according to specific rules, and then sends it to the leased line server. After receiving the request, the leased line server restores the request according to the pre-set rules and forwards it to the application server. Finally, the leased line server returns the response to the client along the original path, thus completing the entire request-response process.
[0057] Specifically, it includes the following steps:
[0058] Step 1: When the client starts, check if there is a configuration file in the same directory as the running exe program; if there is no configuration file, skip the subsequent steps; if there is a configuration file, proceed to Step 2 to perform the corresponding operations.
[0059] Step 2: Use the `onBeforeRequest` method in Electron's session module to intercept the request. The original request format is `https: / / A.* / $`, where A is the domain name, which can be www or a subdomain; and $ represents the part after the request path.
[0060] Step 2.1: When Electron is ready to send a network request, it first tries to match the onBeforeRequest callback function registered in the session;
[0061] Step 2.2: If a match is found, Electron will pause the request being processed and pass the request details to the callback function;
[0062] Step 2.3: Rewrite the request in the callback function, and then decide whether to continue sending the request or abort the request and return a custom response.
[0063] Step 3: Rewrite the original request using Electron. Assuming the IP address of the user's leased line server is 1.1.1.1, the client will then request http: / / 1.1.1.1 / A / $ after rewriting.
[0064] Step 3 includes the following steps:
[0065] Step 3.1: Rewrite the domain name address part ".*" in the original request with the IP address of the user-side leased line server, i.e., 1.1.1.1;
[0066] Step 3.2: Change the protocol from HTTPS to HTTP, i.e., http: / / 1.1.1.1;
[0067] Step 3.3: According to the agreed rules, append A to the IP address and then add $, i.e., http: / / 1.1.1.1 / A / $;
[0068] Step 3.4: Set the redirect address to http: / / 1.1.1.1 / A / $ in the callback function, and then send the request.
[0069] Step 4: After receiving the modified request from the client, the user-side leased line server sends it to the server-side leased line server. Assuming the server-side leased line server's IP address is 2.2.2.2, the user-side request will be http: / / 2.2.2.2 / A / $.
[0070] Step 5: The dedicated server uses nginx reverse proxy to restore the user's request http: / / 2.2.2.2 / A / $ and send a request to the corresponding application server. Assuming the address of the corresponding application server is 3.3.3.3, then the final request https: / / 3.3.3.3 / $ is sent.
[0071] Step 5 includes the following steps:
[0072] Step 5.1: Locate the corresponding application server address, i.e., 3.3.3.3, based on the suffix / A;
[0073] Step 5.2: Change the protocol from HTTP to HTTPS, i.e., https: / / 3.3.3.3;
[0074] Step 5.3: Add the $ symbol, i.e., https: / / 3.3.3.3 / $;
[0075] Step 6: Return the response result of the final request to the original path and add a cross-domain header to the response.
[0076] like Figure 1 The network link diagram includes the following steps: The user initiates a request; The Electron client intercepts and rewrites the request, sending it to the dedicated line connection server A; Dedicated line connection server A sends the request to dedicated line connection server B through the operator's service; Dedicated line connection server B sends the request to nginx; nginx forwards the request to the final application server; The application server returns a response, and the data returns along the original path of the above link.
[0077] like Figure 2 The client hijacking initialization flowchart includes the following steps: When the client starts, it checks whether a dedicated line is configured. If so, it starts configuring hijacking rules; otherwise, it stops configuring hijacking rules and the program ends. It checks whether an independent domain name is configured in the file. If so, it replaces the default domain name with the domain name and modifies the configuration rules; otherwise, it uses the default domain name, i.e., uses the default configuration rules.
[0078] Example 2:
[0079] The present invention also provides a dedicated line client implementation system based on the Electron framework. The dedicated line client implementation system based on the Electron framework can be implemented by executing the process steps of the dedicated line client implementation method based on the Electron framework. That is, those skilled in the art can understand the dedicated line client implementation method based on the Electron framework as a preferred embodiment of the dedicated line client implementation system based on the Electron framework.
[0080] The dedicated line client implementation system based on the Electron framework provided by the present invention includes: Module M1: When the client starts, it checks whether there is a configuration file located in the same directory as the running exe program. If a configuration file exists, it triggers Module M2 to perform corresponding operations; otherwise, the process ends. Module M2: It uses the onBeforeRequest method in the Electron framework session to intercept requests. Module M3: It rewrites the original request through the Electron framework. Module M4: After receiving the rewritten request from the client, the user-side dedicated line server sends it to the server-side dedicated line server. Module M5: The server-side dedicated line server uses nginx reverse proxy to restore the user-side request and send the final request to the corresponding application server. Module M6: It returns the response result of the final request to the original path and adds a cross-domain header to the response.
[0081] The original request format is https: / / A.* / $, where A is the domain name, including www or a subdomain; $ represents the part after the request path. If the IP address of the user-side leased line server is 1.1.1.1, the client will rewrite the request as http: / / 1.1.1.1 / A / $. If the IP address of the service-side leased line server is 2.2.2.2, the user-side request will be http: / / 2.2.2.2 / A / $. The user-side request http: / / 2.2.2.2 / A / $ will be restored and a request will be sent to the corresponding application server. If the address of the corresponding application server is 3.3.3.3, the final request https: / / 3.3.3.3 / $ will be sent.
[0082] The module M2 includes: when the Electron framework is about to send a network request, it first attempts to match the callback function of onBeforeRequest registered in the session; if a match is found, the Electron framework pauses the request being processed and passes the request details to the callback function; the request is rewritten in the callback function, and then it decides whether to continue sending the request or abort the request and return a custom response content.
[0083] Module M3 includes: Module M3.1: Rewrites the domain name address part ".*" in the original request with the IP address of the user-side leased line server, resulting in 1.1.1.1; Module M3.2: Changes the protocol from HTTPS to HTTP, resulting in http: / / 1.1.1.1; Module M3.3: According to the agreed rules, appends "A" to the IP address and then adds "$", resulting in http: / / 1.1.1.1 / A / $; Module M3.4: Sets the redirect address to http: / / 1.1.1.1 / A / $ in the callback function and then sends the request.
[0084] The module M5 includes: Module M5.1: finds the corresponding application server address based on the suffix / A, and obtains 3.3.3.3; Module M5.2: converts the protocol from http to https, and obtains https: / / 3.3.3.3; Module M5.3: pads with $, and obtains https: / / 3.3.3.3 / $.
[0085] Those skilled in the art will understand that, in addition to implementing the system, apparatus, and their modules provided by this invention in purely computer-readable program code, the same program can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system, apparatus, and their modules provided by this invention can be considered a hardware component, and the modules included therein for implementing various programs can also be considered structures within the hardware component; alternatively, modules for implementing various functions can be considered both software programs implementing the method and structures within the hardware component.
[0086] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.
Claims
1. A method for implementing a private line client based on an Electron framework, comprising: Step 1: When the client is started, check whether there is a configuration file in the same directory as the running exe program, if the configuration file exists, perform step 2 for corresponding operation, otherwise end the process; Step 2: Use the onBeforeRequest method in the session of the Electron framework to hijack the request; Step 3: Rewrite the original request through the Electron framework; Step 4: After the user-side private line server receives the request rewritten by the client, send it to the server-side private line server; Step 5: The server-side private line server uses nginx reverse proxy to restore the user-side request and initiates the final request to the corresponding application server; Step 6: Return the response result of the final request to the original path and add the cross-domain header of the response; The original request format is https: / / A.* / $, where A is the domain name, including www or second-level domain name; $ is the part after the request path; If the IP address of the user-side private line server is 1.1.1.1, the client rewritten request is http: / / 1.1.1.1 / A / $; If the IP address of the server-side private line server is 2.2.2.2, the user-side request is http: / / 2.2.2.2 / A / $; Restore the user-side request http: / / 2.2.2.2 / A / $ and initiate a request to the corresponding application server, if the corresponding application server address is 3.3.3.3, send the final request https: / / 3.3.3.3 / $; The step 3 comprises: Step 3.1: Rewrite the domain name address part.* in the original request to the IP address of the user-side private line server, get 1.1.1.1; Step 3.2: Change the protocol from https to http, get http: / / 1.1.1.1; Step 3.3: According to the agreed rule, concatenate A to the ip, and then supplement $, get http: / / 1.1.1.1 / A / $; Step 3.4: Set the redirection address to http: / / in the callback function 1.1.1.1 / A / $, and then reissue the request. 2.The Electron framework-based private line client implementation method according to claim 1, characterized in that, The step 2 comprises: when the Electron framework is ready to send a network request, first try to match the callback function of onBeforeRequest registered in the session; if it can be matched, the Electron framework pauses the request being processed, and passes the request details to the callback function; in the callback function, the request is rewritten, and then it is decided whether to continue sending the request or to abort the request and return the custom response content. 3.The Electron framework-based private line client implementation method according to claim 1, wherein, The step 5 comprises: Step 5.1: according to the suffix / A, find the corresponding application server address, get 3.3.3.3; Step 5.2: change the protocol from http to https, get https: / / 3.3.3.3; Step 5.3: complete the $, get https: / / 3.3.3.3 / $.
4. A private line client implementation system based on Electron framework, characterized in that, Comprise: Module M1: when the client starts, detect whether there is a configuration file in the same directory as the running exe program, if the configuration file exists, trigger module M2 to perform corresponding operation, otherwise end the process; Module M2: use the onBeforeRequest method in the session of the Electron framework to hijack the request; Module M3: rewrite the original request through the Electron framework; Module M4: after the user-side dedicated server receives the request rewritten by the client, send it to the server-side dedicated server; Module M5: the server-side dedicated server uses nginx reverse proxy to restore the user-side request and initiate the final request to the corresponding application server; Module M6: return the response result of the final request to the original path, and increase the cross-domain header of the response; The original request format is https: / / A.* / $, wherein A is the domain name, including www or secondary domain name; $ is the part after the request path; If the IP address of the user-side dedicated server is 1.1.1.1, the request rewritten by the client is http: / / 1.1.1.1 / A / $; If the IP address of the service-side dedicated server is 2.2.2.2, the user-side request is http: / / 2.2.2.2 / A / $; Restore the user-side request http: / / 2.2.2.2 / A / $ and initiate a request to the corresponding application server, if the address of the corresponding application server is 3.3.3.3, then send the final request https: / / 3.3.3.3 / $; The module M3 comprises: Module M3.1: rewrite the domain name address part.* in the original request to the IP address of the user-side dedicated server, get 1.1.1.1; Module M3.2: change the protocol from https to http, get http: / / 1.1.1.1; Module M3.3: according to the agreed rule, concatenate A to the ip, and then complete the $, get http: / / 1.1.1.1 / A / $; Module M3.4: set the redirection address to http: / / 1.1.1.1 / A / $ in the callback function, and then reissue the request.
5. The Electron framework-based private line client implementation system according to claim 4, wherein, The module M2 comprises: when the Electron framework is ready to send a network request, first try to match the callback function of onBeforeRequest registered in the session; if it can be matched, the Electron framework suspends the request being processed, and passes the request details to the callback function; in the callback function, the request is rewritten, and then it is decided whether to continue sending the request or to abort the request and return the custom response content.
6. The Electron framework-based private line client implementation system according to claim 4, wherein, The module M5 comprises: Module M5.1: find the corresponding application server address according to the suffix / A, and obtain 3.3.3.3; Module M5.2: convert the protocol from http to https, and obtain https: / / 3.3.3.3; Module M5.3: complete the $, and obtain https: / / 3.3.3.3 / $.
Citation Information
Patent Citations
Method and system for realizing multi-factor authentication of cloud desktop client based on Electron framework
CN114722366A
Method and system for maintaining host state in desktop application
CN105955785A
Front-end data simulation implementation method and system
CN106598575A