Network equipment access method and system based on browser and server
By accessing network devices in the browser, using FRP reverse proxy technology and OAuth 2.0 authentication, the complexity and security problems of cross-domain access in the existing technology are solved, and simple and fast device access and flexible users are realized. Experience.
Patent Information
- Application Number
- CN202411479345.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-01-07
AI Technical Summary
When the prior art realizes cross-domain network equipment access, there are problems such as complex configuration, high security risks, and difficult to adapt to changing network environments and user needs.
Adopting a browser access method based on FRP reverse proxy technology, establishing access connections with intelligent network devices through proxy servers, using OAuth2.0 security authentication mechanism, supports multiple access methods, including web, mobile applications and applet platforms, avoiding The dependence of specific clients and software simplifies the configuration process and overcomes cross-domain access restrictions through switching between public web pages and device web pages.
It realizes simple and fast access to network equipment, enhances security and flexibility, supports diverse user needs, and ensures the user-friendliness and long-term availability of services.
Smart Images

Figure CN119276592A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of network technology, and in particular relates to a browser-based network device access method, system and server. Background Art
[0002] With the rapid development of computer technology and the application of more and more intelligent network devices, users usually need to monitor and manage network devices distributed in different geographical locations. Cross-domain access usually relies on VPN (virtual private network), remote access or dedicated management software. Although these methods can achieve remote access management, the configuration is complex and has certain requirements for the end user's device and network environment. With the development of Web technology, cross-domain access through browsers has become a convenient way, but it still faces challenges such as cross-origin resource sharing (CORS) restrictions, network security and compatibility.
[0003] In the prior art, as shown in the patent: Cross-domain access control method and electronic device, storage medium (publication number CN114282240A), a technical solution is proposed to solve the problem that the legality verification cannot be performed during cross-domain access, resulting in inaccessibility. A new address is generated by encoding and sent to the browser. When the browser subsequently requests a cross-domain resource, the new address can be decoded and verified, thereby achieving access to cross-domain resources.
[0004] However, the above technologies have obvious defects: they need to rely on specific clients or software, and the configuration process is cumbersome; they are restricted by Web security policies such as CORS, which can easily lead to limited cross-domain access; devices directly exposed to the Internet may be subject to unauthorized access or attacks, resulting in greater security risks; they are not easy to adapt to changing network environments and diverse user needs, resulting in a lack of flexibility.
[0005] Therefore, there is an urgent need for a technical solution to enable browsers to access network devices, which can solve the above problems. Summary of the invention
[0006] In order to address the deficiencies of the prior art, the present application provides a browser-based network device access method, system and server. The method is based on FRP reverse proxy technology to establish an access connection between a proxy server and an intelligent network device. It has no specific technical requirements for the access end that provides browser access, and can be applied to multiple access methods such as web, mobile application, and mini-program platforms. The security of the access connection is guaranteed by the OAuth2.0 security authentication mechanism, and the interface services provided by the integrated network devices can meet diverse user needs.
[0007] The technical effects to be achieved by this application are achieved through the following solutions: According to a first aspect of the present application, a browser-based network device access method is provided, comprising the following steps: Step 1: After the network device is started, a long connection is established with the device server; Step 2: The access end uses a browser to access the public web page of the proxy server for authentication; Step 3: After authentication, the proxy server queries the device server to see whether the network device meets the access conditions; Step 4: When the access conditions are met, the proxy server loads the device web page of the network device; Step 5: The access end loads the device web page and uses the local resources and functional services of the network device through the relative address and interface.
[0008] Preferably, in step 1, after the network device is started, the frp client service is started, and a frp remote access service channel is established with the device server.
[0009] Preferably, in step 2, different Oauth2.0 account authentication systems are used according to different functions and permissions.
[0010] Preferably, in step 3, querying whether the network device meets the access conditions specifically includes: querying whether the network device is powered on and connected to the device server; querying whether an frp remote access service channel is established between the network device and the device server.
[0011] Preferably, if the network device is not powered on, the public network web page of the proxy server provides a page prompt and guides the operation; When the network device is powered on but the frp remote access service channel is not established, the proxy server sends an instruction to establish the frp connection channel to the network device through the device server, and the network device establishes the frp remote access service channel according to the random subdomain address in the instruction.
[0012] Preferably, in step 4, the proxy server loads the device web page of the network device by loading the device web page of the network device through an iframe or page redirection, and the address of the device web page is a concatenation of the random subdomain name and the page relative address.
[0013] Preferably, after the access terminal loads the device web page, it detects the frp original factory access service channel and Oauth2.0 account authentication through polling logic.
[0014] Preferably, in step 5, after the access end loads the device web page, no access behavior occurs and the cumulative time reaches a set threshold, the network device actively disconnects the frp remote access service channel; After the device web page detects that the frp remote access service channel is disconnected, it prompts the access end.
[0015] According to a second aspect of the present application, a network device access system using the above-mentioned browser-based network device access method is provided, including an access terminal, a proxy server, a device server and a network device, wherein: The proxy server is used to provide access to the authentication web page and receive the HTTP request from the access terminal; The device server is used to establish a long connection and signaling interaction with the network device, and to connect and interact with the proxy server; The network device is installed with a frp client service for providing local resources and functional services.
[0016] According to a third aspect of the present application, there is provided a server, comprising: a memory and at least one processor; The memory stores a computer program, and the at least one processor executes the computer program stored in the memory to implement the above-mentioned browser-based network device access method.
[0017] According to one embodiment of the present application, the beneficial effects of the browser-based network device access method of the present application are: Using a browser as the access method and a proxy server as the central access control server, there is no need to rely on specific clients or software, avoiding the cumbersome configuration process and making access simple and fast; The authentication mechanism based on OAuth2.0 token expands the business control deficiency of frp remote access mechanism; The switching between the public web page of the proxy server and the device web page on the device side overcomes the cross-domain access restriction while ensuring the user-friendliness and functional availability of the service. The provision of the device web page can support the browser to access the device resources through the local interface of the device; When the frp channel is disconnected, account authentication fails, or there is no access for a long time, relevant resources are recovered in a timely manner, which effectively improves the rationality of resource use and ensures the long-term availability of services. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present application or the existing technical solutions, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0019] Figure 1 This is a flowchart of a browser-based network device access method in one embodiment of the present application; Figure 2 This is a structural block diagram of a browser-based network device access system in an embodiment of the present application; Figure 3 This is a structural block diagram of a server in an embodiment of the present application. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0021] like Figure 1 As shown, a browser-based network device access method in one embodiment of the present application includes the following steps: Step 1: After the network device is started, a long connection is established with the device server; In this step, after the network device is powered on and the internal system is started, a long connection is established with the device server in a timely manner so that it can respond to various instructions issued by the device server at any time.
[0022] At the same time, the frp client service is started in advance, and a frp remote access service channel is established with the device server. The advantage of using the frp remote access service channel is that the access end does not need to use VPN and other functions. This situation is more suitable for lightweight browser access needs, and has fewer requirements for ordinary visitors and network environment. In addition, the frp technology also includes security mechanisms to ensure information security.
[0023] When a network device establishes a long connection with a device server, the relevant information of the network device is registered in the device server at the same time. The relevant information includes at least device model information, deviceId, and SN. The device server monitors the status of the network device in real time, and records the connection status, as well as the establishment and disconnection time of the long connection. When a network device is disconnected from the long connection with the device server, the device server updates the network device to a disconnected state.
[0024] Step 2: The access end uses a browser to access the public web page of the proxy server for authentication; In this step, the public network web page unifies the account login page, and the access terminal enters the account and password for login authentication.
[0025] In order to expand the business control deficiency of the frp remote access mechanism, the Oauth2.0 account authentication system can be used according to different functions and permissions. Bring the Oauth2.0 account authentication information and device information when accessing. After passing the authentication, the user identity can be determined, thereby verifying the legitimacy of the management device. According to business needs, in addition to the Oauth2.0 account information, a sharing code with a limited scope of use can also be designed to give other visitors limited permissions. For example, the address of a certain network device is made into a sharing code, and other users who obtain the sharing code can operate and can only operate the network device corresponding to the sharing code.
[0026] When the access end accesses a public web page, the corresponding network devices are displayed according to the logged-in account. For example, if the account is a primary user account, there will be a list of multiple network devices under the account, that is, it has all access permissions, and the user selects the corresponding network device to access; if the account is logged in through the link in the sharing code, only the network device corresponding to the current sharing code will be displayed.
[0027] The owner of the network device logs in to the management account through the access terminal and enjoys all access rights to the network device. If the account password is lost, it can be retrieved through mobile phone, email, etc.
[0028] Step 3: After authentication, the proxy server queries the device server to see whether the network device meets the access conditions; In this step, after the access end passes the Oauth2.0 authentication, the proxy server's public network web page queries the device server for information about the network device that the access end needs to use to determine whether the network device meets the access conditions, such as whether it is powered on and connected to the device server, whether a frp remote access service channel has been established with the device server, etc.
[0029] If the network device is not powered on, the public web page of the proxy server will provide page prompts and guide operations. For example, it will prompt the accessing user that the device is offline or offline, and the page will prompt and guide the user on how to perform offline operations to power on the device and connect to the network, so that the overall service can be available. When the network device is powered on but the FRP remote access service channel is not established, the proxy server sends an instruction to establish a FRP connection channel to the network device through the device server. At the same time, the public web page of the proxy server polls to check whether the subdomain address in the instruction can be accessed normally. After the address can be accessed normally, the network device establishes the FRP remote access service channel according to the random subdomain address in the instruction.
[0030] The proxy server sends the instruction of establishing the frp connection channel to the network device through the device server in json or other ways; the server needs to create a random subdomain address according to the device information, such as creating a corresponding random string in the database according to the deviceId (device unique identification code), and then concatenate the string with the server and send it to the terminal device. You can also directly concatenate the deviceId of the device to the address, for example: A third-level domain name server address test.demo.com, based on this address and a random string abcdefxxx (can be of any length, 32-bit or 64-bit random string is recommended) generates a subdomain, and finally determines the device's frp remote access address https: / / abcdefxxx.test.demo.com; After determining the address, specify the service port configured by the terminal device frp client program, assuming it is 8443. Then, after establishing the frp remote access service channel, the access end can access the terminal device through the address https: / / abcdefxxx.test.demo.com:8443 / , and then deploy the corresponding local Http service according to the different terminal device systems and connect it to the access of the frp port.
[0031] If the terminal system is Android, then you can deploy local Http services through a framework like NanoHttp. Services generally provide relevant business interfaces. Suppose there is a getDeviceInfo interface to read device information. Then the final access end can access the corresponding interface service of the terminal device through https: / / abcdefxxx.test.demo.com:8443 / getDeviceInfo.
[0032] Different business configurations have different service names. In addition, when accessing, you can refer to the standard network communication protocol. The request parameters can include header and body. The request method also supports get and post, etc., which is equivalent to treating the terminal device as a server that provides services. Web resources can also be deployed on the terminal device for external access.
[0033] Step 4: When the access conditions are met, the proxy server loads the device web page of the network device; In this step, the proxy server loads the device web page of the network device specifically by loading the device web page of the network device through an iframe or page redirection, and the address of the device web page is a concatenation of the random subdomain name and the page relative address.
[0034] After the device web page is successfully loaded, the frp connection and Oauth2.0 authentication are detected through polling logic. The frp connection is checked regularly to ensure service availability. When a network disconnection is detected (the network line is disconnected or the connection is disconnected due to server reasons), a friendly prompt is given to the user in a timely manner to avoid the access end waiting without knowing the reason. Polling Oauth2.0 authentication can timely guarantee user rights and interests. When the device sharing permission is revoked, etc., the purpose of reasonably controlling the device access rights can be achieved.
[0035] When the public web page of the access end detects that the account authentication fails, it will kindly prompt the user to log in again or re-purchase the corresponding benefits.
[0036] Step 5: The access end loads the device web page and uses the local resources and functional services of the network device through the relative address and interface.
[0037] In this step, the local resources and functional services of the network device are used through relative addresses and interfaces to achieve device file access, download files from the device and upload files to the network device, and apply the computing resources of the network device and specific hardware devices.
[0038] After the access end loads the device web page, if no access behavior occurs and the cumulative time reaches the set threshold, the network device actively disconnects the frp remote access service channel to facilitate the device server to recover resources; after the device web page detects that the frp remote access service channel is disconnected, it gives a friendly prompt to the access end, prompting the user whether to continue using the function. If the user agrees, the above steps are performed again to connect. If the user refuses, the web page returns to the initial state of the proxy server public network web page.
[0039] like Figure 2 As shown, in one embodiment of the present application, a network device access system using the above-mentioned browser-based network device access method includes an access terminal, a proxy server, a device server, and a network device, wherein: The access terminal is a terminal with browser access function, such as a smart phone, tablet computer, microcomputer and other devices that can connect to the Internet.
[0040] The proxy server is located on the public network and has the ability to access the public network, and is used to provide access to the authentication web page and receive the HTTP request from the access terminal; The device server is located on the public network and has public network access capability, and is used to establish long connections and signaling interactions with network devices, and to connect and interact with the proxy server; in some embodiments, the device server and the proxy server can be combined to reduce device costs.
[0041] The network device is a terminal device with HTTP interface capability and long connection capability, including the function of Frp remote proxy access. It can be a smart phone, smart TV, smart speaker, smart printer, which is used to provide local resources and functional services.
[0042] In the above system, the access end accesses the public web page of the proxy server. After checking the visitor's access rights and the status of the accessed device, the public web page is redirected to the device web page of the network device. At this time, the access end accesses the content and services of the network device through the FRP remote access channel.
[0043] like Figure 3 As shown, the server in one embodiment of the present application includes: a memory and at least one processor; The memory stores a computer program, and the at least one processor executes the computer program stored in the memory to implement the above-mentioned browser-based network device access method.
[0044] The beneficial effects of adopting the above-mentioned browser-based network device access method are: The provision of device web pages for network devices can support browsers to access device resources through the local interface of the device; using browsers as access means and proxy servers as central access control servers, there is no need to rely on specific clients or software, avoiding the cumbersome configuration process and making access simple and fast; The authentication mechanism based on OAuth2.0 token expands the business control deficiency of frp remote access mechanism; The switching between the public web page of the proxy server and the device web page on the device side overcomes the cross-domain access restriction while ensuring the user-friendliness and functional availability of the service. The provision of the device web page can support the browser to access the device resources through the local interface of the device; When the frp channel is disconnected, account authentication fails, or there is no access for a long time, relevant resources are recovered in a timely manner, which effectively improves the rationality of resource use and ensures the long-term availability of services.
[0045] It should be noted that the above detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the art to which the present application belongs.
[0046] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should also be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0047] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein.
[0048] In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or inherent to these processes, methods, products, or apparatuses.
[0049] For ease of description, spatially relative terms, such as "above", "above", "on the upper surface of", "above", etc., may be used herein to describe the spatial positional relationship between a device or feature and other devices or features as shown in the figure. It should be understood that spatially relative terms are intended to include different orientations of the device in use or operation in addition to the orientation described in the figure. For example, if the device in the accompanying drawings is inverted, the device described as "above other devices or structures" or "above other devices or structures" will be positioned as "below other devices or structures" or "below other devices or structures". Thus, the exemplary term "above" may include both "above" and "below". The device may also be positioned in other different ways, such as rotated 90 degrees or in other orientations, and the spatially relative descriptions used herein are interpreted accordingly.
[0050] In the above detailed description, reference is made to the accompanying drawings, which form a part of this document. In the accompanying drawings, similar symbols typically identify similar components unless the context indicates otherwise. The illustrated embodiments described in the detailed description, drawings, and claims are not meant to be limiting. Other embodiments may be used, and other changes may be made, without departing from the spirit or scope of the subject matter presented herein.
[0051] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A browser-based network device access method, characterized in that: The steps include: Step 1: After the network device is started, a long connection is established with the device server; Step 2: The access end uses a browser to access the public web page of the proxy server for authentication; Step 3: After authentication, the proxy server queries the device server to see whether the network device meets the access conditions; Step 4: When the access conditions are met, the proxy server loads the device web page of the network device; Step 5: The access end loads the device web page and uses the local resources and functional services of the network device through the relative address and interface.
2. The browser-based network device access method according to claim 1, characterized in that: In step 1, after the network device is started, the frp client service is started and a frp remote access service channel is established with the device server.
3. The browser-based network device access method according to claim 2, characterized in that: In step 2, different Oauth2.0 account authentication systems are used according to different functions and permissions.
4. The browser-based network device access method according to claim 3, characterized in that: In step 3, querying whether the network device meets the access conditions specifically includes: querying whether the network device is powered on and connected to the device server; querying whether an frp remote access service channel is established between the network device and the device server.
5. The browser-based network device access method according to claim 4, characterized in that: If the network device is not powered on, the public web page of the proxy server will provide page prompts and guide the operation; When the network device is powered on but the frp remote access service channel is not established, the proxy server sends an instruction to establish the frp connection channel to the network device through the device server, and the network device establishes the frp remote access service channel according to the random subdomain address in the instruction.
6. The browser-based network device access method according to claim 5, characterized in that: In step 4, the proxy server loads the device web page of the network device by loading the device web page of the network device through an iframe or page redirection, and the address of the device web page is a concatenation of the random subdomain name and the page relative address.
7. The browser-based network device access method according to claim 6, characterized in that: After the access end loads the device web page, it detects the frp remote access service channel and Oauth2.0 account authentication through polling logic.
8. The browser-based network device access method according to claim 1, characterized in that: In step 5, after the access end loads the device web page, if no access behavior occurs and the cumulative time reaches the set threshold, the network device actively disconnects the frp remote access service channel; After the device web page detects that the frp remote access service channel is disconnected, it prompts the access end.
9. A network device access system using the browser-based network device access method according to any one of claims 1 to 8, characterized in that: It includes access terminals, proxy servers, device servers and network devices, including: The proxy server is used to provide access to the authentication web page and receive the HTTP request from the access terminal; The device server is used to establish a long connection and signaling interaction with the network device, and to connect and interact with the proxy server; The network device is installed with a frp client service for providing local resources and functional services.
10. A server, characterized in that: include: memory and at least one processor; The memory stores a computer program, and the at least one processor executes the computer program stored in the memory to implement the browser-based network device access method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Cross-domain access control method, electronic equipment and storage medium
CN114282240A