A network agent configuration method, apparatus, device, and storage medium

By dynamically updating the host and port number of the proxy server by calling the plugin in the Flutter framework application, the problem of cumbersome configuration when the network environment changes is solved, and the development efficiency and security are improved.

CN116684482BActive Publication Date: 2026-01-20BEIJING SHANGYIN MICRO CORE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310845768.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-11
Publication Date
2026-01-20
Estimated Expiration
2043-07-11

AI Technical Summary

Technical Problem

In existing technologies, applications based on the Flutter framework require rewriting code and installing and configuring network proxies when the network environment changes. This is inflexible, cumbersome, and poses security risks.

Method used

By calling the preset plugin in the application's main function, the host and port number of the proxy server are obtained, updated to the host and port number corresponding to the current IP address, and applied to the global HttpOverrides class to achieve dynamic proxy settings.

Benefits of technology

It enables applications to be repackaged and installed without reinstallation when the network environment changes, improving application development efficiency and flexibility, simplifying operation, and avoiding security risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116684482B_ABST
    Figure CN116684482B_ABST
Patent Text Reader

Abstract

The application discloses a network proxy configuration method and device, equipment and a storage medium, and the method comprises the following steps: in response to the IP address of the proxy server for packet capture changing, calling a preset plug-in in the main function of the application, obtaining the first host of the proxy server and the first port number of the proxy server configured on the device for packet capture through the preset plug-in; the application is developed based on the Flutter framework; a subclass of the HttpOverrides class is included in the plug-in; the first host is changed to the second host corresponding to the current IP address and the first port number is changed to the corresponding second port number through the plug-in; the second host and the second port number are applied to the global HttpOverrides class, so that the packet capture of the application is realized. By configuring the host and the port number of the proxy server, the corresponding proxy server can be freely selected, and the development efficiency and flexibility of the application program are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computers, and in particular to a network proxy configuration method and device, equipment and a storage medium. BACKGROUND

[0002] Flutter is a mobile UI framework open-sourced by Google, which can quickly build high-quality native user interfaces on IOS and Android systems. Therefore, more and more applications are developed using Flutter architecture, but the application developed based on the Flutter framework brings a lot of trouble to testing in the packet capture test phase.

[0003] In the related art, when the code module is initialized, the pre-embedded network proxy IP address and port number are written in the code, and then the network packet capture is realized by configuring the WIFI proxy and combining the Charles software. Although this method can solve the network packet capture problem in the test process, once the APP is packaged and installed, the pre-embedded network proxy IP address and port number are determined, and when the network environment changes and the IP address of the network proxy changes, it is necessary to re-write the code and complete the installation configuration, which is not flexible and cumbersome to operate. SUMMARY

[0004] Based on the above problems, the present application provides a network proxy configuration method, device, equipment and storage medium, which can flexibly select a proxy server according to different networks and environment requirements, and improve the development efficiency and flexibility of the application program.

[0005] The embodiments of the present application disclose the following technical solutions:

[0006] In a first aspect, the embodiments of the present application provide a network proxy configuration method, which comprises:

[0007] In response to the IP address of the proxy server for packet capture changing, a preset plug-in is called in the main function of the application, and a first host of the proxy server configured on the device for packet capture and a first port number of the proxy server are obtained through the preset plug-in; the application is developed based on the Flutter framework; the plug-in includes a subclass of the HttpOverrides class;

[0008] The first host is changed to a second host corresponding to the current IP address through the plug-in, and the first port number is changed to a corresponding second port number;

[0009] The second host and the second port number are applied to the global HttpOverrides class to realize packet capture of the application.

[0010] Optionally, the preset plug-in is called in the main function of the application, and the first host of the proxy server configured on the device under packet capture and the first port number of the proxy server are acquired through the preset plug-in, and the method comprises the following steps of:

[0011] The preset plug-in is called in the main function of the application, the createHttpClient method is added in the subclass, the first host of the proxy server configured on the device under packet capture and the first port number of the proxy server are respectively acquired through the createHttpClient method, and the createHttpClient method returns an instance object of the subclass.

[0012] Optionally, the method further comprises:

[0013] The first host of the proxy server and the first port number of the proxy server are recorded in a first field and a second field of a class member variable respectively.

[0014] Whether the first field and the second field are empty is judged through the findProxyFromEnvironment method in the subclass.

[0015] The first host is changed to a second host corresponding to a current IP address and the first port number is changed to a corresponding second port number through the plug-in, and the method comprises the following steps of:

[0016] If the first field and the second field are not empty, the first host in the findProxyFromEnvironment method is changed to a second host corresponding to a current IP address and the first port number is changed to a corresponding second port number through the plug-in.

[0017] Optionally, if the first field and the second field are not empty, the first host in the findProxyFromEnvironment method is changed to a second host corresponding to a current IP address and the first port number is changed to a corresponding second port number through the plug-in, and the method comprises the following steps of:

[0018] If the first field and the second field are not empty, an environment parameter http_proxy field or an https_proxy field in the findProxyFromEnvironment method is assigned as a second host: second port number.

[0019] Optionally, if the first field and the second field are empty, the method further comprises:

[0020] Keep the environment parameter http_proxy or https_proxy in the findProxyFromEnvironment method unchanged.

[0021] Optionally, applying the second host and the second port number to the global HttpOverrides class specifically includes:

[0022] Set the global HttpOverrides class as the return value of the createHttpClient method.

[0023] Secondly, embodiments of this application provide a network proxy configuration device, the device comprising:

[0024] Get the module, modify the module, and apply the module;

[0025] The acquisition module is used to respond to a change in the IP address of the proxy server used for packet capture, and to call a preset plugin in the main function of the application to obtain the first host and the first port number of the proxy server configured on the packet capture device; the application is developed based on the Flutter framework; the plugin includes a subclass that inherits from the HttpOverrides class;

[0026] The modification module is used to change the first host to the second host corresponding to the current IP address and change the first port number to the corresponding second port number through the plugin.

[0027] The application module is used to apply the second host and the second port number to the global HttpOverrides class to capture packets of the application.

[0028] Optionally, the acquisition module is specifically used for:

[0029] In the main function of the application, a preset plugin is called, and a createHttpClient method is added to the subclass. The createHttpClient method obtains the first host and the first port number of the proxy server configured on the captured device. The createHttpClient method returns an instance of the subclass.

[0030] Optionally, the device further includes: a determination module;

[0031] The judgment module is used to record the first host of the proxy server and the first port number of the proxy server in the first field and the second field of the class member variable, respectively, and to determine whether the first field and the second field are empty by the findProxyFromEnvironment method in the subclass.

[0032] The modification module is used to change the first host in the findProxyFromEnvironment method to the second host corresponding to the current IP address and change the first port number to the corresponding second port number if the first field and the second field are not empty.

[0033] Optionally, the modification module is specifically used for:

[0034] If neither the first field nor the second field is empty, the environment parameter http_proxy field or https_proxy field in the findProxyFromEnvironment method is assigned the value of the second host: second port number.

[0035] Optionally, if the first field and the second field are empty, the environment parameter http_proxy or https_proxy in the findProxyFromEnvironment method remains unchanged.

[0036] Optionally, the application module is specifically used for:

[0037] Set the global HttpOverrides class as the return value of the createHttpClient method.

[0038] Thirdly, embodiments of this application provide a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it implements the network proxy configuration method as described in any of the first aspects.

[0039] Fourthly, embodiments of this application provide a computer-readable storage medium storing instructions that, when executed on a terminal device, cause the terminal device to perform the network proxy configuration method as described in any of the first aspects.

[0040] First, in response to a change in the IP address of the proxy server used for packet capture, a preset plugin is called in the application's main function to obtain the first host and the first port number of the proxy server configured on the device being captured. The application is developed based on the Flutter framework. The plugin includes a subclass that inherits from the HttpOverrides class. Then, the plugin changes the first host to the second host corresponding to the current IP address and changes the first port number to the corresponding second port number. Finally, the second host and the second port number are applied to the global HttpOverrides class to achieve packet capture of the application.

[0041] Compared with the prior art, this application has the following beneficial effects:

[0042] 1. By calling the plugin, even if the IP address of the proxy server changes, the corresponding proxy server can be freely selected by the host and port number of the proxy server, avoiding the need to repackage and install the APP, thus improving the development efficiency and flexibility of the application.

[0043] 2. Global proxy settings can apply proxy settings uniformly throughout the entire lifecycle of the application, without having to manually set the proxy for each network request. Attached Figure Description

[0044] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 A flowchart illustrating a network proxy configuration method provided in this application embodiment;

[0046] Figure 2 A flowchart illustrating an implementation of the ProxyOverrides proxy class provided for an application review embodiment;

[0047] Figure 3 This is a schematic diagram of the structure of a network proxy configuration device provided in an embodiment of this application;

[0048] Figure 4 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0049] Generally, apps developed using the Flutter framework do not support packet capture. Therefore, some techniques propose hardcoding the pre-installed network proxy IP address and port number in the code during module initialization, and then using a configured Wi-Fi proxy in conjunction with Charles software to capture network packets. While this method solves the network packet capture problem during testing, once the app is packaged and installed, the pre-installed network proxy IP address and port number are fixed. If the network environment changes, causing the network proxy IP address to change, the code needs to be rewritten and the installation and configuration completed, making the process inflexible and cumbersome.

[0050] To address the aforementioned technical problems, the following two solutions are proposed in related technologies:

[0051] One approach is to pre-embed a network proxy management module in the app and activate it via a special method (such as shaking the phone when the app is open). Users can then manually enter the new network proxy IP and port number, and restart the app for the changes to take effect. This eliminates the need for repackaging and adjustments when switching network environments. While this method solves the previous problems of inflexibility and cumbersome operation, it significantly intrudes on the project code and poses certain security risks to the online version. For example, if the network proxy module is removed before deployment, it becomes impossible to locate the problem through packet capture when it occurs online; conversely, if the network proxy module is not removed before deployment, it will lead to online security vulnerabilities.

[0052] Secondly, without modifying the existing app, network proxy packet capture can be achieved by installing a third-party VPN (such as Drony on Android) and performing some configuration. This method is complex and works on Android, but on iOS, due to security restrictions in the Apple App Store, it is not always possible to find VPN software that meets the requirements to achieve network proxy packet capture. This presents problems such as uncertainty on iOS and cumbersome operation with a high learning curve.

[0053] Therefore, the above two solutions introduce new technical drawbacks and are not suitable for adoption. This application proposes a network proxy configuration method. First, in response to a change in the IP address of the proxy server used for packet capture, a preset plugin is called in the application's main function to obtain the first host and first port number of the proxy server configured on the device being captured. The application is developed based on the Flutter framework; the plugin includes a subclass inheriting from the HttpOverrides class. Then, the plugin changes the first host to the second host corresponding to the current IP address and changes the first port number to the corresponding second port number. Finally, the second host and second port number are applied to the global HttpOverrides class to achieve packet capture of the application.

[0054] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.

[0055] Packet capture refers to capturing data during the operation of an app using a computer or dedicated equipment. Apps developed using the Flutter framework are installed on mobile devices such as phones (Android or iOS), tablets (Android or iOS), and computers.

[0056] See Figure 1 The figure is a flowchart of a method for configuring a network proxy provided in an embodiment of this application.

[0057] like Figure 1 As shown, the method includes:

[0058] S101: In response to a change in the IP address of the proxy server used for packet capture, the application's main function calls a preset plugin to obtain the first host and first port number of the proxy server configured on the captured device. The application is developed based on the Flutter framework. The plugin includes a subclass that inherits from the HttpOverrides class.

[0059] The IP address of the proxy server used for packet capture may change for several reasons, including but not limited to the following: First, the device used for packet capture has changed, which in turn leads to a change in the IP address of the proxy server. For example, the device used for packet capture was device A, and now it is device B. Second, the network in which the device used for packet capture is located has changed, which in turn leads to a change in the IP address of the proxy server. For example, the device was originally in network A, and now it is in network B.

[0060] HttpOverrides is a class in the Dart:IO library that helps to override HttpClient using a mock implementation. The implementations in this class default to the actual HttpClient implementation. Therefore, the subclasses described in this embodiment serve the same purpose as the HttpOverrides class, simulating and overriding HttpClient. For ease of description, the "ProxyOverrides class" is used to represent the subclasses.

[0061] As an example, add a static method `createHttpProxy` to the `ProxyOverrides` class. This method returns a `ProxyOverrides` object instance. Inside the `createHttpProxy` method, the proxy server host configured on the current phone is obtained from the native client using `ProxyPlatform.instance.getProxyHost`, and the proxy server port number configured on the current phone is obtained from the native client using `ProxyPlatform.instance.getProxyPort`.

[0062] S102: Change the first host to the second host corresponding to the current IP address through the plugin, and change the first port number to the corresponding second port number.

[0063] As an example, we override the `findProxyFromEnvironment` method of `HttpOverrides`, assuming the current phone is configured with a proxy server host and port number, and assign the `http_proxy` segment in the `environment` parameter to `host:port`. Here, `host` and `port` represent the proxy server and its port number corresponding to the current IP address.

[0064] It is important to note that if the first and second fields are empty, the environment parameter http_proxy or https_proxy field in the findProxyFromEnvironment method must remain unchanged.

[0065] S103: Apply the second host and the second port number to the global HttpOverrides class to enable packet capture of the application.

[0066] As an example, assigning a ProxyOverrides class object to an HttpOverrides.global object enables packet capture of the application.

[0067] By assigning a `ProxyOverrides` class object to an `HttpOverrides.global` object, a global HTTP proxy is set up within the application. The key advantage is that with a single line of code, proxy settings can be applied uniformly throughout the application's lifecycle, eliminating the need to manually configure the proxy for each network request. Furthermore, by overriding the `findProxyFromEnvironment` method, the appropriate proxy server is selected based on the proxy server host and its corresponding port number, and the values ​​of the `http_proxy` and `https_proxy` fields in the environment variables are modified as needed. The crucial aspect of this is the implementation of dynamic proxy server settings, allowing flexible selection of proxy servers based on different network and environmental requirements, and automatic updating of relevant environment variables.

[0068] See Figure 2 The figure is a flowchart of an implementation of the ProxyOverrides proxy class provided in an embodiment of this application.

[0069] like Figure 2 As shown, the implementation includes:

[0070] S201: Create a custom ProxyOverrides class that inherits from HttpOverrides.

[0071] S202: Add a static method createHttpProxy to the custom ProxyOverrides class. This method returns a ProxyOverrides object instance.

[0072] S203: The createHttpProxy method retrieves the host of the proxy server currently configured on the mobile phone from the native side using ProxyPlatform.instance.getProxyHost.

[0073] S204: Obtain the proxy server port number configured on the current mobile phone from the native side via ProxyPlatform.instance.getProxyPort.

[0074] S205: Record the obtained host and port number in the class member variables host and port fields.

[0075] S206: Override the findProxyFromEnvironment method of HttpOverrides.

[0076] S2061: Within the findProxyFromEnvironment method, check if the class member variables host and port are empty. (That is, check if a proxy server host and port number are configured on the current phone.)

[0077] S2062: If the host and port fields are not empty, assign the value 'host:port' to the http_proxy section in the environment parameter;

[0078] In addition, if the host and port fields are empty, the environment parameter will not be modified.

[0079] S207: Call the super.findProxyFromEnvironment method and pass in the environment parameter.

[0080] See Figure 3 The figure is a schematic diagram of the structure of a network proxy configuration device provided in an embodiment of this application.

[0081] like Figure 3 As shown, the device includes: an acquisition module 301, a modification module 302, and an application module 303;

[0082] The acquisition module 301 is used to respond to a change in the IP address of the proxy server used for packet capture. In the main function of the application, a preset plugin is called to obtain the first host and the first port number of the proxy server configured on the device being captured. The application is developed based on the Flutter framework. The plugin includes a subclass that inherits from the HttpOverrides class.

[0083] Modify module 302 to change the first host to the second host corresponding to the current IP address and change the first port number to the corresponding second port number via a plugin;

[0084] Application module 303 is used to apply the second host and the second port number to the global HttpOverrides class in order to capture packets of the application.

[0085] Optionally, module 301 is used specifically for:

[0086] In the main function of the application, call the preset plugin, add the createHttpClient method in the subclass, and use the createHttpClient method to obtain the first host and the first port number of the proxy server configured on the captured device; the createHttpClient method returns an instance object of the subclass.

[0087] Optionally, the device further includes: a judgment module;

[0088] The judgment module is used to record the first host and the first port number of the proxy server in the first and second fields of the class member variables, respectively, and to determine whether the first and second fields are empty through the findProxyFromEnvironment method in the subclass;

[0089] Modify module 302 to change the first host in the findProxyFromEnvironment method to the second host corresponding to the current IP address and change the first port number to the corresponding second port number if the first and second fields are not empty.

[0090] Optionally, module 302 can be modified specifically for:

[0091] If the first and second fields are not empty, the environment parameter http_proxy field or https_proxy field in the findProxyFromEnvironment method will be assigned the value of the second host: second port number.

[0092] Optionally, if the first and second fields are empty, the environment parameter http_proxy or https_proxy in the findProxyFromEnvironment method remains unchanged.

[0093] Optionally, application module 203 is specifically used for:

[0094] Set the global HttpOverrides class as the return value of the createHttpClient method.

[0095] This application provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the network proxy configuration method described in this application.

[0096] In practical applications, the computer-readable storage medium can be any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. For example, a computer-readable storage medium can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0097] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.

[0098] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0099] Computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0100] like Figure 4The diagram shown is a structural schematic of a computer device provided in an embodiment of this application. Figure 4 The computer device 12 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.

[0101] like Figure 4 As shown, the computer device 12 is represented in the form of a general-purpose computing device. The components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and a bus 18 connecting different system components (including system memory 28 and processing unit 16).

[0102] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.

[0103] Computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by computer device 12, including volatile and non-volatile media, removable and non-removable media.

[0104] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 3 Not shown; usually referred to as a "hard drive"). Although Figure 3 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.

[0105] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.

[0106] Computer device 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with the computer device 12, and / or with any device that enables the computer device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed through input / output (I / O) interface 22. Furthermore, computer device 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) through network adapter 20. Figure 3 As shown, network adapter 20 communicates with other modules of computer device 12 via bus 18. It should be understood that, although... Figure 3 As not shown, it can be used in conjunction with computer device 12 with other hardware and / or software modules, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0107] The processor unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the network proxy configuration method provided in the embodiments of this application.

[0108] It should be noted that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiments. The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate. The components indicated as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment solution according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0109] The above description is merely one specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A network agent configuration method, characterized by, The method comprises: In response to the IP address of the proxy server for packet capture changing, calling a preset plug-in in the main function of the application, obtaining the first host of the proxy server configured on the device being packet captured and the first port number of the proxy server through the preset plug-in; the application is developed based on a Flutter framework; the plug-in includes a subclass of an HttpOverrides class; Change the first host to a second host corresponding to the current IP address and change the first port number to a corresponding second port number through the plug-in; Apply the second host and the second port number to the global HttpOverrides class to realize packet capture of the application.

2. The method of claim 1, wherein, The method comprises: In the main function of the application, a preset plug-in is called, and a createHttpClient method is added in the subclass to obtain the first host of the proxy server configured on the device being packet captured and the first port number of the proxy server through the createHttpClient method; the createHttpClient method returns an instance object of the subclass.

3. The method of claim 1, wherein, The method further comprises: Record the first host of the proxy server and the first port number of the proxy server in a first field and a second field of a class member variable, respectively; Determine whether the first field and the second field are empty through a findProxyFromEnvironment method in the subclass; Change the first host to a second host corresponding to the current IP address and change the first port number to a corresponding second port number through the plug-in, specifically comprising: If the first field and the second field are not empty, change the first host in the findProxyFromEnvironment method to a second host corresponding to the current IP address and change the first port number to a corresponding second port number through the plug-in.

4. The method of claim 3, wherein, If the first field and the second field are not empty, assign the environment parameters http_proxy field or https_proxy field in the findProxyFromEnvironment method to the second host: the second port number. If the first field and the second field are empty, the method further comprises:

5. The method of claim 3, wherein, Keep the environment parameters http_proxy field or https_proxy field in the findProxyFromEnvironment method unchanged. ​ 6. The method of claim 1, wherein, The second host and the second port number are applied to a global HttpOverrides class, and the application specifically includes: The global HttpOverrides class is set as a return value of a createHttpClient method.

7. A network proxy configuration apparatus characterized by comprising: The device includes an acquisition module, a changing module, and an application module; The acquisition module is configured to, in response to an IP address of a proxy server for packet capture changing, call a preset plug-in in a main function of an application, and acquire a first host of the proxy server and a first port number of the proxy server configured on a device for packet capture through the preset plug-in; the application is developed based on a Flutter framework; the plug-in includes a subclass of an HttpOverrides class; The changing module is configured to change the first host to a second host corresponding to a current IP address and change the first port number to a second port number corresponding to the current IP address through the plug-in; The application module is configured to apply the second host and the second port number to a global HttpOverrides class, so as to realize packet capture of the application.

8. The apparatus of claim 7, wherein, The acquisition module is specifically configured to: Call a preset plug-in in a main function of an application, add a createHttpClient method in the subclass, and acquire a first host of a proxy server and a first port number of the proxy server configured on a device for packet capture through the createHttpClient method; the createHttpClient method returns an instance object of the subclass.

9. A computer device, comprising: It includes: A memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the computer program, the network proxy configuration method of any one of claims 1 to 6 is implemented.

10. A computer readable storage medium characterized by, The computer readable storage medium stores instructions, and when the instructions run on the terminal device, the terminal device executes the network proxy configuration method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Network parameter configuration method and device and storage medium

    CN113489600A

  • Network connection method and device, computer equipment and storage medium

    CN113872955A