Factory reset of control methods, devices, computer equipment and storage media
By employing multi-level recovery strategies and differentiated recovery paths, the problem of configuration loss caused by factory reset in existing technologies has been solved, enabling flexible and secure device recovery operations and improving operational efficiency and user experience.
Patent Information
- Application Number
- CN202611262744.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-19
- Publication Date
- 2026-11-17
AI Technical Summary
In existing technologies, the single strategy of restoring factory settings results in the indiscriminate deletion of user configuration data, leading to low operation and maintenance efficiency and poor user experience, especially in some scenarios where it can cause the loss of valid configurations.
It provides a multi-level recovery strategy, which determines the target recovery level by parsing the recovery level indication information, and adopts differentiated recovery scope and recovery path according to different levels to achieve multi-level factory reset control for fault recovery, user configuration protection and operator pre-configuration retention.
It enhances the flexibility and security of equipment operation and maintenance management, balances fault recovery efficiency and user configuration protection, avoids unnecessary data loss and secondary configuration workload, and improves the reliability of recovery operations and user experience.
Smart Images

Figure CN123123765A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network equipment operation and maintenance technology, and in particular to a method, apparatus, computer equipment and storage medium for restoring factory control. Background Technology
[0002] In the operation and maintenance management of network devices such as FTTR (Fiber to the Room) gateways and routers, restoring factory settings is a basic and frequently used operation, mainly for scenarios such as equipment failure recovery, service reconfiguration, or equipment decommissioning. Current technologies typically employ a single strategy for factory reset: clearing all user configuration data from the device to completely restore it to its factory state. However, in practical applications, because configuration data comes from various sources and has different uses, indiscriminately performing a full clear can lead to the loss of valid user configurations in some scenarios. Users or maintenance personnel must then reconfigure the data to restore services, reducing operational efficiency and impacting user experience. Summary of the Invention
[0003] This application provides a method, apparatus, computer device, and storage medium for restoring factory control, which can provide a variety of selectable recovery operation types to meet the differentiated needs of different operation and maintenance scenarios.
[0004] This application provides a method for restoring factory control, including: In response to a factory reset control command for a network device, the recovery level indication information contained in the factory reset control command is parsed to determine the target recovery level of the network device; Based on the target recovery level, a corresponding target recovery strategy is determined from a preset set of multi-level recovery strategies; According to the recovery scope and recovery path of the target recovery strategy, the network device is restored to factory settings.
[0005] In this embodiment, by abstracting the factory reset operation into multiple controllable levels, each level corresponds to a different configuration retention strategy, the upper-level management interface can select the appropriate reset level according to business needs through a unified interface; by adopting differentiated recovery scope and recovery path for different levels, multi-level factory reset control is achieved, which takes into account fault recovery efficiency, user configuration protection and operator pre-configuration retention, significantly improving the flexibility and security of equipment operation and maintenance management.
[0006] In one embodiment, parsing the recovery level indication information contained in the factory reset control command to determine the target recovery level of the network device includes: Extract the level type field from the factory reset control command to obtain the string parameter corresponding to the recovery level indication information; Based on the preset mapping relationship between string parameters and enumeration type values, the string parameters corresponding to the recovery level indication information are converted into the corresponding enumeration type values; The target recovery level of the network device is determined based on the enumerated type value.
[0007] In this embodiment, a string parameter is obtained by extracting the level type field from the factory reset control command. Then, according to a preset mapping relationship, the string parameter is converted into an enumeration type value that the device can recognize. Finally, the target recovery level is determined based on the enumeration type value. This achieves accurate parsing of the recovery level indication information and determination of the target recovery level. The string parameter format is intuitive and easy to extend. The centralized management of the mapping relationship makes the parsing logic of the level information clear and controllable, avoiding the maintenance difficulties caused by hard coding and improving the maintainability and scalability of the device.
[0008] In one embodiment, the multi-level recovery strategy set includes first-level, second-level, third-level, and fourth-level recovery strategies; When the target recovery strategy is a first-level recovery strategy, the recovery scope corresponding to the target recovery strategy is to clear all configuration data; When the target recovery strategy is a second-level recovery strategy, the recovery scope corresponding to the target recovery strategy is to retain the first service configuration data and clear the remaining configuration data; When the target recovery strategy is a level 3 recovery strategy, the recovery scope corresponding to the target recovery strategy is to reset the second service configuration data and retain the remaining configuration data; When the target recovery policy is a fourth-level recovery policy, the recovery scope corresponding to the target recovery policy is to retain the second service configuration data and clear the remaining configuration data; wherein, the first service configuration data is service registration configuration data; and the second service configuration data is network access configuration data.
[0009] In this embodiment, by configuring a multi-level recovery strategy set into four levels, each level corresponding to a different configuration retention policy, network devices can select the appropriate recovery scope according to actual operation and maintenance needs. The first level provides a complete reset capability, the second level protects service registration information during reset, the third level implements a lightweight network configuration reset, and the fourth level protects network access configuration during reset. These four levels cover the most common recovery scenarios in device operation and maintenance, ensuring both the thoroughness of fault recovery and avoiding unnecessary data loss and secondary configuration workload.
[0010] In one embodiment, if the target recovery strategy is a first-level, second-level, or fourth-level recovery strategy, then the recovery path corresponding to the target recovery strategy is a safeguard recovery path; the safeguard recovery path includes: If the target recovery strategy is the first-level recovery strategy, then the configuration storage area is erased and the network device is restarted; If the target recovery strategy is a level 2 or level 4 recovery strategy, then the service configuration data to be retained is determined according to the target recovery strategy, the service configuration data to be retained is stored in the backup storage area, and corresponding backup description information is generated. The configuration storage area is erased and the network device is restarted. After restarting, the configuration data to be restored is obtained according to the backup description information, and the integrity of the configuration data to be restored is verified. If the integrity verification passes, the configuration data is restored to the official configuration directory. Wherein, if the target recovery strategy is a second-level recovery strategy, the service configuration data to be retained is the first service configuration data; if the target recovery strategy is a fourth-level recovery strategy, the service configuration data to be retained is the second service configuration data.
[0011] In this embodiment, a safeguard-based recovery path is adopted for the recovery strategies of Level 1, Level 2, and Level 4. Level 1 requires no backup; it directly erases the configuration storage area and restarts, fully restoring the device to its factory state. Levels 2 and 4 back up the service configuration data before erasure and use integrity verification mechanisms such as backup description information, format parsing, and checksum comparison to securely restore the necessary service configuration data to the official configuration directory while erasing the remaining configuration data. This safeguard-based recovery path ensures the thoroughness of the factory reset operation while preventing accidental deletion or restoration damage of important service configuration data, thus improving the reliability and security of the device's factory reset operation.
[0012] In one embodiment, the safeguard recovery path further includes: If the integrity check fails, the configuration data in the backup storage area will be discarded and the recovery operation will be terminated.
[0013] In this embodiment, by setting up a fallback mechanism for data discarding and operation termination in the case of integrity verification failure, the spread of configuration errors caused by backup data corruption or tampering is effectively prevented, thereby improving the security and robustness of the factory reset operation.
[0014] In one embodiment, if the target recovery strategy is a level 3 recovery strategy, then the recovery path corresponding to the target recovery strategy is a lightweight recovery path; the lightweight recovery path includes: Obtain the default configuration data corresponding to the second service configuration data; The default configuration data is validated to obtain the validation result. If the validity check result is successful, the default configuration data will be overwritten in the official configuration directory. Set the reinitialization flag of the subsystem to which the default configuration data belongs, and restart the network device so that the network device executes the complete reinitialization process of the subsystem based on the reinitialization flag after restarting and clears the reinitialization flag.
[0015] In this embodiment, by setting a lightweight recovery path for the third level, a full erase operation of the configuration storage area is not required. Instead, the target subsystem configuration is reset only through precise replacement at the configuration package level, and the re-initialization flag ensures the complete effectiveness of the subsystem parameters. Compared to the guaranteed recovery path of full erase, the lightweight recovery path significantly shortens the execution time of the recovery operation, reduces the service interruption time during the device recovery process, and improves the efficiency of the recovery operation and the user experience.
[0016] In one embodiment, validating the default configuration data includes: Perform syntax validation on the default configuration data and obtain the syntax validation result; Perform semantic validation on the default configuration data and obtain the semantic validation result; The validity check result is determined based on the syntax check result and the semantic check result.
[0017] In this embodiment, by performing dual checks of syntax and semantics before overwriting the default configuration data, it is ensured that the configuration data used for recovery is correct and usable in both format and logic. This effectively avoids secondary failures caused by format errors or logical defects in the default configuration data itself, and improves the reliability of the lightweight recovery path.
[0018] This application provides a factory reset control device, including: The recovery level determination module is used to respond to a factory reset control command for a network device, parse the recovery level indication information contained in the factory reset control command, and determine the target recovery level of the network device; The strategy determination module is used to determine the corresponding target recovery strategy from a preset multi-level recovery strategy set based on the target recovery level. The recovery execution module is used to perform factory reset operations on the network device according to the recovery scope and recovery path of the target recovery strategy.
[0019] This application provides a computer device, including a processor and a memory, wherein, Memory, used to store computer programs; The processor is used to execute the program stored in the memory to implement the above-mentioned factory reset control method.
[0020] This application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described factory reset control method. Attached Figure Description
[0021] Figure 1 This is a flowchart of a factory reset control method provided in an embodiment of this application; Figure 2 yes Figure 1 A flowchart of step S101; Figure 3 This is a flowchart of a guaranteed recovery path provided in an embodiment of this application; Figure 4 This is a flowchart of a lightweight recovery path provided in an embodiment of this application; Figure 5 yes Figure 4 A flowchart of step S402; Figure 6 This is a schematic diagram of the factory reset control device provided in an embodiment of this application; Figure 7 This is a schematic diagram of the structure of a computer device according to one embodiment of this application. Detailed Implementation
[0022] To make the technical problems, technical solutions, and beneficial effects solved by this application clearer, the following detailed description is provided in conjunction with embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0023] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0024] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0025] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0026] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0027] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0029] This application provides a factory reset control method, which is illustrated using a network device as an example. The network device includes, but is not limited to, embedded network devices such as home gateways, optical modems, and routers. The configuration data carried on this network device includes personalized configurations for end users (such as Wi-Fi name and password), pre-configured service configurations by operators or equipment manufacturers (such as VoIP voice parameters and IPTV channel configuration), and inherent network topology parameters of the device (such as Wi-Fi RF calibration data and port mapping relationships). The network device is configured with a multi-level set of recovery strategies, which can select the corresponding recovery scope and recovery path to perform a factory reset operation based on the recovery level indication information passed from the upper-level management system.
[0030] This application provides a method for restoring factory control, such as... Figure 1 As shown, the method includes: S101: In response to a factory reset control command for a network device, parse the recovery level indication information contained in the factory reset control command and determine the target recovery level of the network device; S102: Based on the target recovery level, determine the corresponding target recovery strategy from the preset multi-level recovery strategy set; S103: Perform factory reset on the network equipment according to the recovery scope and recovery path of the target recovery strategy.
[0031] Among them, the factory reset control command refers to the command message issued by the upper-level management system through the unified management interface to trigger the factory reset operation. The recovery level indication information refers to the field value contained in the factory reset control command, used to specify the required recovery level. The target recovery level refers to the level identifier determined by the network device based on the recovery level indication information, used to match the corresponding recovery strategy from a preset set of multi-level recovery strategies.
[0032] As an example, in step S101, the upper-level management system sends a factory reset control command to the network device through a unified management interface. This command carries recovery level indication information, indicating the required recovery level for this operation. Different upper-level management systems can set different recovery level indication information in the command based on their own operational needs or user scenarios to trigger differentiated factory reset operations. For example, operators can issue recovery commands for specific operational scenarios through a remote management platform, users can issue commands for personal configuration recovery needs through a web interface, and after-sales personnel can issue commands for device return-to-factory reset through a local maintenance terminal. After receiving the command through the unified management interface, the network device parses the command, obtains the recovery level indication information, and determines the target recovery level corresponding to this operation based on the recovery level indication information.
[0033] The multi-level recovery strategy set refers to the set of pre-configured mapping relationships in network devices that includes multiple recovery levels and their corresponding recovery ranges and paths. The target recovery strategy refers to the set of configuration information corresponding to the target recovery level, including the recovery range and path.
[0034] As an example, in step S102, the network device queries a preset multi-level recovery policy set based on the determined target recovery level to obtain the target recovery policy uniquely corresponding to that target recovery level. Specifically, the network device uses the target recovery level as an index to match within the multi-level recovery policy set, searching for a recovery policy corresponding to that target recovery level. Upon successful matching, the network device obtains the recovery scope and recovery path defined in the recovery policy, which serves as the basis for subsequent factory reset operations. If no recovery policy matching the target recovery level is found in the multi-level recovery policy set, the network device determines that the current recovery operation request is invalid, refuses to execute the factory reset operation, and returns an error response to the management system.
[0035] The recovery scope refers to the range of configuration data that was cleared or retained during this factory reset operation. The recovery path refers to the specific steps used to perform this factory reset operation.
[0036] As an example, in step S103, the network device performs the corresponding factory reset operation according to the recovery scope and recovery path specified by the determined target recovery strategy. Specifically, the network device determines which configuration data needs to be cleared and which needs to be retained in this recovery operation based on the configuration data processing boundaries defined by the recovery scope, and executes the processing actions of each stage sequentially according to the process steps and order specified by the recovery path. For example, it first performs configuration data backup, then configuration data clearing, and finally configuration data restoration or device restart. After each stage is completed, the network device returns a notification to the upper-level management system that the recovery operation is complete.
[0037] In this embodiment, by abstracting the factory reset operation into multiple controllable levels, each level corresponds to a different configuration retention strategy, the upper-level management interface can select the appropriate reset level according to business needs through a unified interface; by adopting differentiated recovery scope and recovery path for different levels, multi-level factory reset control is achieved, which takes into account fault recovery efficiency, user configuration protection and operator pre-configuration retention, significantly improving the flexibility and security of equipment operation and maintenance management.
[0038] In one embodiment, such as Figure 2 As shown, step S101, which involves parsing the recovery level indication information contained in the factory reset control command and determining the target recovery level of the network device, includes: S201: Extract the level type field from the factory reset control command to obtain the string parameter corresponding to the recovery level indication information; S202: Based on the preset mapping relationship between string parameters and enumeration type values, convert the string parameters corresponding to the recovery level indication information into enumeration type values; S203: Determine the target recovery level of the network device based on the enumerated type value.
[0039] The "Level Type Field" refers to the specific field in the factory reset control command used to carry the recovery level indication information. The "String Parameter" refers to the level identification information carried by the "Level Type Field," expressed as a string.
[0040] As an example, in step S201, the network device parses the received factory reset control command, locates and extracts the level type field from the command according to the data format definition of the command, and obtains the string parameters carried by the field. For example, the network device reads the value of the field from the specified position of the command and obtains string parameters with different values such as "full", "voip-keep", "wifi-only", or "wifi-keep", and different string parameters correspond to different recovery levels.
[0041] Among them, the enumeration type value refers to the integer constant value predefined inside the network device to uniquely identify each recovery level, and there is a one-to-one mapping relationship between each enumeration type value and the string parameter.
[0042] As an example, in step S202, the network device converts the extracted string parameters into corresponding enumeration type values according to the internally preset mapping relationship between string parameters and enumeration type values. This mapping relationship is pre-stored in the network device's configuration rules; for example, "full" maps to enumeration type value 0, "voip-keep" maps to enumeration type value 1, "wifi-only" maps to enumeration type value 2, and "wifi-keep" maps to enumeration type value 3. The network device matches the extracted string parameters with each entry in the mapping relationship, and completes the conversion after finding the corresponding enumeration type value. If no match is found in the mapping relationship for the string parameter, the network device determines that the recovery level indication information is invalid.
[0043] As an example, in step S203, the network device determines the target recovery level corresponding to this recovery operation based on the converted enumeration type value. Specifically, the network device internally defines a correspondence between enumeration type values and recovery levels, with different enumeration type values indicating different recovery levels. The network device determines its corresponding target recovery level based on the converted enumeration type value.
[0044] In this embodiment, a string parameter is obtained by extracting the level type field from the factory reset control command. Then, according to a preset mapping relationship, the string parameter is converted into an enumeration type value that the device can recognize. Finally, the target recovery level is determined based on the enumeration type value. This achieves accurate parsing of the recovery level indication information and determination of the target recovery level. The string parameter format is intuitive and easy to extend. The centralized management of the mapping relationship makes the parsing logic of the level information clear and controllable, avoiding the maintenance difficulties caused by hard coding and improving the maintainability and scalability of the device.
[0045] In one embodiment, the multi-level recovery strategy set includes first-level, second-level, third-level, and fourth-level recovery strategies; When the target recovery strategy is the first-level recovery strategy, the recovery scope corresponding to the target recovery strategy is to clear all configuration data; When the target recovery strategy is the second-level recovery strategy, the recovery scope corresponding to the target recovery strategy is to retain the first service configuration data and clear the remaining configuration data; When the target recovery strategy is the third-level recovery strategy, the recovery scope corresponding to the target recovery strategy is to reset the second service configuration data and retain the remaining configuration data; When the target recovery policy is a level 4 recovery policy, the recovery scope corresponding to the target recovery policy is to retain the second service configuration data and clear the remaining configuration data; wherein, the first service configuration data is service registration configuration data; and the second service configuration data is network access configuration data.
[0046] As an example, when the target recovery strategy is Level 1, the corresponding recovery scope is to clear all configuration data. Specifically, when a network device performs a factory reset, all configuration data in the configuration storage area is erased. This includes user-defined configuration data, service configuration data, network configuration data, and system logs; all data is wiped, leaving no data. This level is suitable for scenarios requiring complete data clearing, such as device factory reset, complete system rebuild, or device decommissioning.
[0047] The first service configuration data refers to service registration configuration data, such as VoIP voice service configuration data, including but not limited to VoIP account, SIP server address, registration password, and call protocol parameters.
[0048] As an example, when the target recovery strategy is Level 2, the corresponding recovery scope is to retain the first service configuration data and clear all other configuration data. Specifically, when the network device performs a factory reset, all other configuration data in the configuration storage area except for the first service configuration data is cleared. For example, user personalized configuration data, network access configuration data, and IPTV channel configuration data are all erased, while the first service configuration data is retained. This level is suitable for remote operation and maintenance scenarios of operators, where it is necessary to retain VoIP registration information while clearing user misconfigurations to avoid the complex process of reconfiguring VoIP services.
[0049] The second service configuration data refers to network access configuration data, such as Wi-Fi wireless configuration data, including but not limited to Wi-Fi name, Wi-Fi password, encryption method, wireless channel, and radio frequency power.
[0050] As an example, when the target recovery strategy is Level 3, the corresponding recovery scope is to reset the second service configuration data while retaining the remaining configuration data. Specifically, when the network device performs a factory reset, it does not perform a full configuration partition erase. Instead, it only restores the second service configuration data to its factory default values. For example, it restores the Wi-Fi name to the default SSID preset at the factory, the Wi-Fi password to an empty or default password, and the encryption method and wireless channel to their factory default settings. Other categories of configuration data remain unchanged. This level is suitable for scenarios where users experience Wi-Fi connectivity issues and need to reset the Wi-Fi configuration, but wish to retain all other configurations.
[0051] As an example, when the target recovery strategy is Level 4, the corresponding recovery scope is to retain the second service configuration data and clear all other configuration data. Specifically, when the network device performs a factory reset, it retains the second service configuration data, such as Wi-Fi name, Wi-Fi password, encryption method, wireless channel, and RF power, which are network access configuration data. All other configuration data in the configuration storage area, except for the second service configuration data, is cleared. For example, user-personalized configurations, VoIP service configurations, and IPTV channel configurations are all erased. This level is suitable for remote operation and maintenance scenarios where user configurations need to be cleared but Wi-Fi settings retained. This avoids the need for all user terminal devices to reconnect to Wi-Fi after recovery, thereby reducing recovery costs on the user side.
[0052] In this embodiment, by configuring a multi-level recovery strategy set into four levels, each level corresponding to a different configuration retention policy, network devices can select the appropriate recovery scope according to actual operation and maintenance needs. The first level provides a complete reset capability, the second level protects service registration information during reset, the third level implements a lightweight network configuration reset, and the fourth level protects network access configuration during reset. These four levels cover the most common recovery scenarios in device operation and maintenance, ensuring both the thoroughness of fault recovery and avoiding unnecessary data loss and secondary configuration workload.
[0053] In one embodiment, such as Figure 3 As shown, if the target recovery strategy is a Level 1, Level 2, or Level 4 recovery strategy, then the recovery path corresponding to the target recovery strategy is a safeguard recovery path; safeguard recovery paths include: S301: If the target recovery policy is the first-level recovery policy, erase the configuration storage area and restart the network device; S302: If the target recovery strategy is a level 2 or level 4 recovery strategy, then determine the service configuration data to be retained according to the target recovery strategy, store the service configuration data to be retained in the backup storage area, generate the corresponding backup description information, erase the configuration storage area and restart the network device. After restarting, obtain the configuration data to be restored according to the backup description information, perform integrity verification on the configuration data to be restored, and if the integrity verification passes, restore the configuration data to the official configuration directory. Specifically, if the target recovery strategy is a second-level recovery strategy, the service configuration data to be retained is the first service configuration data; if the target recovery strategy is a fourth-level recovery strategy, the service configuration data to be retained is the second service configuration data.
[0054] The guaranteed recovery path refers to the recovery path used by a network device when performing a factory reset operation involving a full erase of the configuration storage area. The configuration storage area refers to the storage area in the network device used for persistently storing configuration data.
[0055] As an example, in step S301, when the target recovery policy is the first-level recovery policy, the network device does not need to perform any backup operations. It directly performs an erase operation on the configuration storage area, clearing all configuration data stored in the configuration storage area, and then performs a system restart. After the device restarts, the initialization process regenerates the configuration file from the factory default configuration template, so that the device is completely restored to its factory state.
[0056] The "service configuration data to be retained" refers to the service configuration data that the network device selects from the formal configuration directory according to the target recovery strategy before erasing the configuration storage area. The backup storage area is a designated storage space within the network device for temporarily storing the service configuration data to be retained. It is independent of the configuration storage area to prevent the erasure operation from affecting the backup data. Backup description information refers to the metadata file generated by the network device during the backup process to record the backup data, including but not limited to reset type, backup timestamp, and a list of backup configuration packages. The formal configuration directory is the storage directory where the configuration files actually loaded and used by the network device during runtime are located. The configuration data to be restored refers to the configuration data retrieved from the backup storage area by the network device after restarting and to be restored to the formal configuration directory. This data is the service configuration data to be retained that was saved during the backup phase.
[0057] As an example, in step S302, when the target recovery policy is a second-level recovery policy, the network device first determines the service configuration data to be retained as the first service configuration data according to the target recovery policy. After determining the service configuration data to be retained, the network device copies the first service configuration data from the formal configuration directory to the backup storage area and generates corresponding backup description information. After the backup is completed, the network device performs an erase operation on the configuration storage area, clearing all configuration data, and then performs a system restart. After the device restarts, the restore initialization script calls the configuration restore module. The configuration restore module obtains the configuration data to be restored from the backup storage area according to the backup description information and performs integrity verification on it. Specifically, the configuration restore module parses the format of the obtained configuration data and compares the verification value of the data with the verification value recorded in the backup description information. If the two are consistent and the format parsing is normal, the integrity verification is determined to be passed. If the two are inconsistent or the format parsing is abnormal, the integrity verification is determined to be failed. When the integrity verification is passed, the configuration data is restored to the formal configuration directory. After the restoration is completed, the network device deletes the remaining backup data in the backup storage area to prevent subsequent repeated restoration.
[0058] When the target recovery policy is Level 4, the network device first determines the service configuration data to be retained as the second service configuration data based on the target recovery policy. After determining the service configuration data to be retained, the network device copies the second service configuration data from the official configuration directory to the backup storage area and generates corresponding backup description information. After the backup is complete, the network device performs an erase operation on the configuration storage area, clearing all configuration data, and then performs a system restart. After the device restarts, the restore initialization script calls the configuration restore module. The configuration restore module retrieves the configuration data to be restored from the backup storage area according to the backup description information and performs integrity verification on it. Specifically, the configuration restore module parses the format of the obtained configuration data and compares the checksum of the data with the checksum recorded in the backup description information. If the two are consistent and the format parsing is normal, the integrity verification is considered successful. If the two are inconsistent or the format parsing is abnormal, the integrity verification is considered unsuccessful. When the integrity verification is successful, the configuration data is restored to the official configuration directory. After the restoration is complete, the network device deletes the remaining backup data in the backup storage area to prevent subsequent duplicate restorations.
[0059] In this embodiment, a safeguard-based recovery path is adopted for the recovery strategies of Level 1, Level 2, and Level 4. Level 1 requires no backup; it directly erases the configuration storage area and restarts, fully restoring the device to its factory state. Levels 2 and 4 back up the service configuration data before erasure and use integrity verification mechanisms such as backup description information, format parsing, and checksum comparison to securely restore the necessary service configuration data to the official configuration directory while erasing the remaining configuration data. This safeguard-based recovery path ensures the thoroughness of the factory reset operation while preventing accidental deletion or restoration damage of important service configuration data, thus improving the reliability and security of the device's factory reset operation.
[0060] In one embodiment, the safeguard recovery path further includes: If the integrity check fails, the configuration data in the backup storage area will be discarded and the recovery operation will be terminated.
[0061] As an example, when integrity verification fails, the network device determines that the backup data is corrupted or tampered with. To ensure the stability and security of the system configuration, it automatically discards the configuration data in the backup storage area, immediately terminates the current recovery operation, logs an error, and returns a verification failure response to the management system. Afterward, the device maintains its current state and does not perform a configuration restore operation to prevent abnormal device operation due to loading corrupted configuration data, thereby ensuring the reliability of the network device.
[0062] In this embodiment, by setting up a fallback mechanism for data discarding and operation termination in the case of integrity verification failure, the spread of configuration errors caused by backup data corruption or tampering is effectively prevented, thereby improving the security and robustness of the factory reset operation.
[0063] In one embodiment, such as Figure 4 As shown, if the target recovery strategy is a level 3 recovery strategy, then the recovery path corresponding to the target recovery strategy is a lightweight recovery path; the lightweight recovery path includes: S401: Obtain the default configuration data corresponding to the second service configuration data; S402: Perform validity verification on the default configuration data and obtain the validity verification result; S403: If the validity check result is successful, the default configuration data will be overwritten in the official configuration directory; S404: Sets the reinitialization flag of the subsystem to which the default configuration data belongs, restarts the network device, so that the network device performs the complete reinitialization process of the subsystem based on the reinitialization flag after restarting and clears the reinitialization flag.
[0064] The lightweight recovery path refers to a recovery path where, when a network device performs a factory reset without fully erasing the configuration storage area, it uses mechanisms such as configuration packet extraction, validity verification, and atomic overwrite to reset the target subsystem configuration while ensuring that other configuration data remains unaffected. Default configuration data refers to the default configuration information pre-configured at the factory by the network device, corresponding to the second service configuration data.
[0065] As an example, in step S401, the network device obtains the default configuration data corresponding to the second service configuration data. Specifically, the network device locates and extracts the configuration package definition block corresponding to the second service configuration data from the factory default configuration template file, obtaining the complete content of the configuration package as the default configuration data. The factory default configuration template file contains default configuration information for multiple configuration packages. The network device performs pattern matching by configuration package name or configuration package identifier to accurately extract the definition block of the target configuration package. For example, the network device extracts the default configuration data corresponding to the Wi-Fi configuration package from the factory default configuration template file, including parameters such as the default Wi-Fi name, default Wi-Fi password, default encryption method, and default wireless channel, as the default configuration data for this recovery operation.
[0066] Among them, the validity verification result refers to the verification conclusion obtained by the network device after verifying the validity of the default configuration data, including whether the verification passed or failed.
[0067] As an example, in step S402, the network device performs a validity check on the extracted default configuration data and obtains the validity check result. If the default configuration data passes the validity check, the validity check result is "validation passed"; if the default configuration data fails the validity check, the validity check result is "validation failed". When the validity check result is "validation failed", the network device terminates the current recovery operation and records the error log.
[0068] As an example, in step S403, if the validity check passes, the network device will overwrite the default configuration data to the official configuration directory. Specifically, the network device first writes the default configuration data to a temporary file, and then replaces the corresponding configuration file in the official configuration directory through an atomic renaming operation to ensure the atomicity of the overwrite operation and data consistency.
[0069] The reinitialization flag refers to the identification information set in the network device to indicate that a specific subsystem needs to perform a complete reinitialization process after a restart.
[0070] As an example, in step S404, the network device sets the reinitialization flag of the subsystem to which the default configuration data belongs in the system configuration, and then performs a system restart. After the device restarts, the initialization process checks the reinitialization flag before initializing the default configuration. If the flag is set, the complete reinitialization process of the subsystem is executed. After the reinitialization is completed, the reinitialization flag is automatically cleared, and the device enters normal operation.
[0071] In this embodiment, by setting a lightweight recovery path for the third level, a full erase operation of the configuration storage area is not required. Instead, the target subsystem configuration is reset only through precise replacement at the configuration package level, and the re-initialization flag ensures the complete effectiveness of the subsystem parameters. Compared to the guaranteed recovery path of full erase, the lightweight recovery path significantly shortens the execution time of the recovery operation, reduces the service interruption time during the device recovery process, and improves the efficiency of the recovery operation and the user experience.
[0072] In one embodiment, such as Figure 5 As shown, step S402, which is to perform a validity check on the default configuration data, includes: S501: Perform syntax validation on the default configuration data and obtain the syntax validation result; S502: Perform semantic validation on the default configuration data and obtain the semantic validation result; S503: Determine the validity check result based on the syntax check result and the semantic check result.
[0073] Syntax validation refers to verifying whether the format of the default configuration data conforms to the system-defined configuration syntax specifications.
[0074] As an example, in step S501, the network device performs syntax validation on the extracted default configuration data, checking whether the format of the default configuration data conforms to the system-defined configuration syntax specifications. For example, it checks whether the configuration items are missing necessary parameters, whether the parameter formats (such as IP address format and MAC address format) are correct, and whether the configuration file conforms to the structure specifications of XML or JSON. If the default configuration data conforms to the system-defined configuration syntax specifications, the syntax validation result is "validation passed"; if the default configuration data does not conform to the system-defined configuration syntax specifications, the syntax validation result is "validation failed".
[0075] Semantic validation refers to verifying whether the content of the default configuration data is logically reasonable.
[0076] As an example, in step S502, the network device performs semantic verification on the extracted default configuration data, checking whether the content of the default configuration data is logically reasonable. For example, it checks whether the configured IP address is within the legal address range, whether the VLAN ID is within the range supported by the device, and whether the port configuration corresponds to the actual hardware. If the content of the default configuration data is logically reasonable, the semantic verification result is verification passed; if the content of the default configuration data is logically unreasonable, the semantic verification result is verification failed.
[0077] As an example, in step S503, after completing the syntax and semantic checks, the network device determines whether the default configuration data passes the validity check based on the syntax and semantic check results. If both the syntax and semantic check results pass, the default configuration data passes the validity check; if either the syntax or semantic check result fails, the default configuration data fails the validity check.
[0078] In this embodiment, by performing dual checks of syntax and semantics before overwriting the default configuration data, it is ensured that the configuration data used for recovery is correct and usable in both format and logic. This effectively avoids secondary failures caused by format errors or logical defects in the default configuration data itself, and improves the reliability of the lightweight recovery path.
[0079] As can be seen from the above, the factory reset control method provided in this application abstracts the factory reset operation into multiple controllable levels, enabling network devices to determine the target recovery level and match the corresponding recovery strategy based on the recovery level indication information. This achieves refined hierarchical control of the factory reset operation, avoiding the problem of indiscriminate erasure of all configuration data under the traditional single strategy. By receiving factory reset control commands through a unified management interface, the coupling between upper-layer systems and maintenance costs are reduced. Differentiated recovery paths are designed for different levels: a safeguard path ensures the secure retention of critical business configuration data, while a lightweight path avoids the impact of full erasure on other configuration data and shortens recovery time. Through integrity verification, validity verification, atomic overwrite, and fallback handling mechanisms for verification failures, the data security and reliability of the recovery process are comprehensively guaranteed. In summary, this application embodiment balances fault recovery efficiency, user configuration protection, and operator pre-configuration retention, significantly improving the flexibility, security, and efficiency of network device operation and maintenance management.
[0080] In one embodiment, a factory reset control device is provided, which corresponds one-to-one with the factory reset control method described in the above embodiments. For example... Figure 6 As shown, the factory reset control device includes a level determination module 601, a strategy determination module 602, and a reset execution module 603.
[0081] The recovery level determination module 601 is used to respond to the factory reset control command for the network device, parse the recovery level indication information contained in the factory reset control command, and determine the target recovery level of the network device. The strategy determination module 602 is used to determine the corresponding target recovery strategy from a preset multi-level recovery strategy set based on the target recovery level. The recovery execution module 603 is used to perform factory reset operations on network devices according to the recovery scope and recovery path of the target recovery strategy.
[0082] Specific limitations regarding the factory reset control device can be found in the limitations of the factory reset control method described above, and will not be repeated here. Each module in the aforementioned factory reset control device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0083] In one embodiment, a computer device is provided, the internal structure of which can be shown as follows: Figure 7As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a factory reset control method.
[0084] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: In response to the factory reset control command for the network device, the recovery level indication information contained in the factory reset control command is parsed to determine the target recovery level of the network device; Based on the target recovery level, the corresponding target recovery strategy is determined from a set of preset multi-level recovery strategies; Perform factory reset operations on network devices according to the recovery scope and recovery path of the target recovery strategy.
[0085] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, performs the following steps: In response to the factory reset control command for the network device, the recovery level indication information contained in the factory reset control command is parsed to determine the target recovery level of the network device; Based on the target recovery level, the corresponding target recovery strategy is determined from a set of preset multi-level recovery strategies; Perform factory reset operations on network devices according to the recovery scope and recovery path of the target recovery strategy.
[0086] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0087] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided by this invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0088] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0089] The above-described 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 the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
[0090] It should be noted that when the above embodiments of the present invention are applied to specific products or technologies, and user-related data is involved, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
Claims
1. A method of restoring factory controls, the method comprising: include: In response to a factory reset control command for a network device, the recovery level indication information contained in the factory reset control command is parsed to determine the target recovery level of the network device; Based on the target recovery level, a corresponding target recovery strategy is determined from a preset set of multi-level recovery strategies; According to the recovery scope and recovery path of the target recovery strategy, the network device is restored to factory settings.
2. The recovery factory control method of claim 1, wherein, The step of parsing the recovery level indication information contained in the factory reset control command to determine the target recovery level of the network device includes: Extract the level type field from the factory reset control command to obtain the string parameter corresponding to the recovery level indication information; Based on the preset mapping relationship between string parameters and enumeration type values, the string parameters corresponding to the recovery level indication information are converted into the corresponding enumeration type values; The target recovery level of the network device is determined based on the enumerated type value.
3. The recovery factory control method of claim 1, wherein, The multi-level recovery strategy set includes recovery strategies at the first, second, third, and fourth levels; When the target recovery strategy is a first-level recovery strategy, the recovery scope corresponding to the target recovery strategy is to clear all configuration data; When the target recovery strategy is a second-level recovery strategy, the recovery scope corresponding to the target recovery strategy is to retain the first service configuration data and clear the remaining configuration data; When the target recovery strategy is a level 3 recovery strategy, the recovery scope corresponding to the target recovery strategy is to reset the second service configuration data and retain the remaining configuration data; When the target recovery policy is a fourth-level recovery policy, the recovery scope corresponding to the target recovery policy is to retain the second service configuration data and clear the remaining configuration data; wherein, the first service configuration data is service registration configuration data; and the second service configuration data is network access configuration data.
4. The recovery factory control method of claim 3, wherein, If the target recovery strategy is a first-level, second-level, or fourth-level recovery strategy, then the recovery path corresponding to the target recovery strategy is a safeguard recovery path; the safeguard recovery path includes: If the target recovery strategy is the first-level recovery strategy, then the configuration storage area is erased and the network device is restarted; If the target recovery strategy is a level 2 or level 4 recovery strategy, then the service configuration data to be retained is determined according to the target recovery strategy, the service configuration data to be retained is stored in the backup storage area, and corresponding backup description information is generated. The configuration storage area is erased and the network device is restarted. After restarting, the configuration data to be restored is obtained according to the backup description information, and the integrity of the configuration data to be restored is verified. If the integrity verification passes, the configuration data is restored to the official configuration directory. Wherein, if the target recovery strategy is a second-level recovery strategy, the service configuration data to be retained is the first service configuration data; if the target recovery strategy is a fourth-level recovery strategy, the service configuration data to be retained is the second service configuration data.
5. The recovery factory control method of claim 4, wherein, The guaranteed recovery path also includes: If the integrity check fails, the configuration data in the backup storage area will be discarded and the recovery operation will be terminated.
6. The recovery factory control method of claim 3, wherein, If the target recovery strategy is a level 3 recovery strategy, then the recovery path corresponding to the target recovery strategy is a lightweight recovery path; The lightweight recovery path includes: Obtain the default configuration data corresponding to the second service configuration data; The default configuration data is validated to obtain the validation result. If the validity check result is successful, the default configuration data will be overwritten in the official configuration directory. Set the reinitialization flag of the subsystem to which the default configuration data belongs, and restart the network device so that the network device executes the complete reinitialization process of the subsystem based on the reinitialization flag after restarting and clears the reinitialization flag.
7. The recovery factory control method according to claim 6, wherein The validation of the default configuration data includes: Perform syntax validation on the default configuration data and obtain the syntax validation result; Perform semantic validation on the default configuration data and obtain the semantic validation result; The validity check result is determined based on the syntax check result and the semantic check result.
8. A recovery factory control device characterized by comprising: include: The recovery level determination module is used to respond to a factory reset control command for a network device, parse the recovery level indication information contained in the factory reset control command, and determine the target recovery level of the network device; The strategy determination module is used to determine the corresponding target recovery strategy from a preset multi-level recovery strategy set based on the target recovery level. The recovery execution module is used to perform factory reset operations on the network device according to the recovery scope and recovery path of the target recovery strategy.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the factory reset control method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 9. When the computer program is executed by the processor, it implements the steps of the factory reset control method as described in any one of claims 1 to 7.
