-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
新增多个模块的初始化文件,重构缺陷图和自动直方图模块,删除未使用的文件,优化星体检测和颜色校正功能,改进缺陷插值算法
- Loading branch information
Showing
71 changed files
with
7,827 additions
and
2,279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# Network Client Application Documentation | ||
|
||
## Overview | ||
|
||
The `Network Client Application` is a tool designed to send files or messages over TCP or UDP protocols. It uses the `ASIO` library for network communication and `loguru` for logging. The application supports both TCP and UDP modes, allowing users to specify a timeout for TCP connections and optionally send a file. | ||
|
||
## Dependencies | ||
|
||
- **ASIO**: A cross-platform C++ library for network and low-level I/O programming. | ||
- **loguru**: A logging library used for logging operations. | ||
|
||
## Constants | ||
|
||
- **MAX_LENGTH**: The maximum length of the buffer used for reading and sending data. | ||
- **ARG_COUNT_MIN**: The minimum number of command-line arguments required. | ||
- **ARG_COUNT_MAX**: The maximum number of command-line arguments allowed. | ||
- **DEFAULT_TIMEOUT_SECONDS**: The default timeout in seconds for TCP connections. | ||
|
||
## Functions | ||
|
||
### `sendFileTcp(tcp::socket& socket, const std::string& filename)` | ||
|
||
Sends a file over a TCP connection. | ||
|
||
- **Parameters:** | ||
|
||
- `socket`: The TCP socket to send the file through. | ||
- `filename`: The name of the file to send. | ||
|
||
- **Example:** | ||
```cpp | ||
asio::io_context ioContext; | ||
tcp::resolver resolver(ioContext); | ||
auto endpoints = resolver.resolve("localhost", "12345"); | ||
tcp::socket socket(ioContext); | ||
asio::connect(socket, endpoints); | ||
sendFileTcp(socket, "example.txt"); | ||
``` | ||
### `sendFileUdp(udp::socket& socket, const udp::endpoint& endpoint, const std::string& filename)` | ||
Sends a file over a UDP connection. | ||
- **Parameters:** | ||
- `socket`: The UDP socket to send the file through. | ||
- `endpoint`: The endpoint to send the file to. | ||
- `filename`: The name of the file to send. | ||
- **Example:** | ||
```cpp | ||
asio::io_context ioContext; | ||
udp::resolver resolver(ioContext); | ||
udp::resolver::results_type endpoints = resolver.resolve(udp::v4(), "localhost", "12345"); | ||
udp::socket socket(ioContext); | ||
socket.open(udp::v4()); | ||
sendFileUdp(socket, *endpoints.begin(), "example.txt"); | ||
``` | ||
|
||
### `runTcpClient(const std::string& host, const std::string& port, int timeoutSeconds, const std::optional<std::string>& filename = std::nullopt)` | ||
|
||
Runs the TCP client mode. | ||
|
||
- **Parameters:** | ||
|
||
- `host`: The host to connect to. | ||
- `port`: The port to connect to. | ||
- `timeoutSeconds`: The timeout in seconds for the TCP connection. | ||
- `filename`: An optional filename to send over the TCP connection. | ||
|
||
- **Example:** | ||
```cpp | ||
runTcpClient("localhost", "12345", 10, "example.txt"); | ||
``` | ||
### `runUdpClient(const std::string& host, const std::string& port, const std::optional<std::string>& filename = std::nullopt)` | ||
Runs the UDP client mode. | ||
- **Parameters:** | ||
- `host`: The host to connect to. | ||
- `port`: The port to connect to. | ||
- `filename`: An optional filename to send over the UDP connection. | ||
- **Example:** | ||
```cpp | ||
runUdpClient("localhost", "12345", "example.txt"); | ||
``` | ||
|
||
### `main(int argc, char* argv[]) -> int` | ||
|
||
The main function that initializes the application, parses command-line arguments, and starts the appropriate client mode. | ||
|
||
- **Parameters:** | ||
|
||
- `argc`: The number of command-line arguments. | ||
- `argv`: The array of command-line arguments. | ||
|
||
- **Returns:** An integer representing the exit status. | ||
|
||
- **Example:** | ||
```bash | ||
./nc tcp localhost 12345 10 example.txt | ||
``` | ||
|
||
## Notes | ||
|
||
- The application supports both TCP and UDP protocols. | ||
- Users can specify a timeout for TCP connections. | ||
- The application can optionally send a file over the network. | ||
- Logging is used extensively to provide detailed information about the operations being performed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
# NetworkProxy Class Documentation | ||
|
||
## Overview | ||
|
||
The `NetworkProxy` class is designed to manage network proxy settings on both Windows and Linux operating systems. It provides functionalities to set, disable, and retrieve proxy settings, install and uninstall certificates, and manage the hosts file. The class is part of the `lithium::cxxtools` namespace and leverages platform-specific implementations to handle proxy-related operations. | ||
|
||
## Class Methods | ||
|
||
### `setProxy(const std::string& proxy, NetworkProxy::ProxyMode mode, const std::string& listenIP, const std::string& dns) -> bool` | ||
|
||
Sets the network proxy with the specified parameters. | ||
|
||
- **Parameters:** | ||
|
||
- `proxy`: The proxy server address. | ||
- `mode`: The proxy mode (e.g., Hosts, PAC, System). | ||
- `listenIP`: The IP address to listen on. | ||
- `dns`: The DNS server address. | ||
|
||
- **Returns:** `true` if the proxy was set successfully, `false` otherwise. | ||
|
||
### `disableProxy() const -> bool` | ||
|
||
Disables the network proxy. | ||
|
||
- **Returns:** `true` if the proxy was disabled successfully, `false` otherwise. | ||
|
||
### `getCurrentProxy() -> std::string` | ||
|
||
Retrieves the current proxy settings. | ||
|
||
- **Returns:** A string representing the current proxy server address. | ||
|
||
### `installCertificate(const std::string& certPath) const -> bool` | ||
|
||
Installs a certificate from the specified path. | ||
|
||
- **Parameters:** | ||
|
||
- `certPath`: The path to the certificate file. | ||
|
||
- **Returns:** `true` if the certificate was installed successfully, `false` otherwise. | ||
|
||
### `uninstallCertificate(const std::string& certName) const -> bool` | ||
|
||
Uninstalls a certificate by its name. | ||
|
||
- **Parameters:** | ||
|
||
- `certName`: The name of the certificate to uninstall. | ||
|
||
- **Returns:** `true` if the certificate was uninstalled successfully, `false` otherwise. | ||
|
||
### `viewCertificateInfo(const std::string& certName) const -> std::string` | ||
|
||
Retrieves information about a certificate by its name. | ||
|
||
- **Parameters:** | ||
|
||
- `certName`: The name of the certificate. | ||
|
||
- **Returns:** A string containing the certificate information. | ||
|
||
### `editHostsFile(const std::vector<std::pair<std::string, std::string>>& hostsEntries)` | ||
|
||
Edits the hosts file with the specified entries. | ||
|
||
- **Parameters:** | ||
- `hostsEntries`: A vector of pairs where each pair represents an IP address and a hostname. | ||
|
||
### `resetHostsFile()` | ||
|
||
Resets the hosts file to its default state. | ||
|
||
### `enableHttpToHttpsRedirect(bool enable)` | ||
|
||
Enables or disables HTTP to HTTPS redirection. | ||
|
||
- **Parameters:** | ||
- `enable`: `true` to enable redirection, `false` to disable. | ||
|
||
### `setCustomDoH(const std::string& dohUrl)` | ||
|
||
Sets a custom DNS-over-HTTPS (DoH) URL. | ||
|
||
- **Parameters:** | ||
- `dohUrl`: The DoH URL to set. | ||
|
||
### `getProxyModeName(ProxyMode mode) -> std::string` | ||
|
||
Returns the name of the specified proxy mode. | ||
|
||
- **Parameters:** | ||
|
||
- `mode`: The proxy mode. | ||
|
||
- **Returns:** A string representing the name of the proxy mode. | ||
|
||
## Platform-Specific Implementations | ||
|
||
### Windows | ||
|
||
#### `setWindowsProxy(const std::string& proxy) const -> bool` | ||
|
||
Sets the proxy settings on a Windows system using the Windows Registry. | ||
|
||
#### `disableWindowsProxy() const -> bool` | ||
|
||
Disables the proxy settings on a Windows system using the Windows Registry. | ||
|
||
#### `getWindowsCurrentProxy() const -> std::string` | ||
|
||
Retrieves the current proxy settings from the Windows Registry. | ||
|
||
#### `installWindowsCertificate(const std::string& certPath) const -> bool` | ||
|
||
Installs a certificate on a Windows system using the `certutil` command. | ||
|
||
#### `uninstallWindowsCertificate(const std::string& certName) const -> bool` | ||
|
||
Uninstalls a certificate on a Windows system using the `certutil` command. | ||
|
||
#### `viewWindowsCertificateInfo(const std::string& certName) const -> std::string` | ||
|
||
Retrieves information about a certificate on a Windows system using the `certutil` command. | ||
|
||
#### `editWindowsHostsFile(const std::vector<std::pair<std::string, std::string>>& hostsEntries) const` | ||
|
||
Edits the Windows hosts file with the specified entries. | ||
|
||
#### `resetWindowsHostsFile() const` | ||
|
||
Resets the Windows hosts file to its default state. | ||
|
||
### Linux | ||
|
||
#### `setLinuxProxy(const std::string& proxy) const -> bool` | ||
|
||
Sets the proxy settings on a Linux system using environment variables. | ||
|
||
#### `disableLinuxProxy() -> bool` | ||
|
||
Disables the proxy settings on a Linux system by unsetting environment variables. | ||
|
||
#### `getLinuxCurrentProxy() -> std::string` | ||
|
||
Retrieves the current proxy settings from the Linux environment variables. | ||
|
||
#### `installLinuxCertificate(const std::string& certPath) -> bool` | ||
|
||
Installs a certificate on a Linux system using the `update-ca-certificates` command. | ||
|
||
#### `uninstallLinuxCertificate(const std::string& certName) -> bool` | ||
|
||
Uninstalls a certificate on a Linux system using the `update-ca-certificates` command. | ||
|
||
#### `viewLinuxCertificateInfo(const std::string& certName) -> std::string` | ||
|
||
Retrieves information about a certificate on a Linux system using the `openssl` command. | ||
|
||
#### `editLinuxHostsFile(const std::vector<std::pair<std::string, std::string>>& hostsEntries) const` | ||
|
||
Edits the Linux hosts file with the specified entries. | ||
|
||
#### `resetLinuxHostsFile() const` | ||
|
||
Resets the Linux hosts file to its default state. | ||
|
||
## Dependencies | ||
|
||
- **loguru**: A logging library used for logging operations. | ||
- **atom/system/command.hpp**: A utility for executing system commands. | ||
|
||
## Usage Example | ||
|
||
```cpp | ||
#include "proxy.hpp" | ||
|
||
int main() { | ||
lithium::cxxtools::NetworkProxy proxy; | ||
|
||
// Set proxy | ||
proxy.setProxy("http://proxy.example.com:8080", lithium::cxxtools::NetworkProxy::ProxyMode::System, "0.0.0.0", "8.8.8.8"); | ||
|
||
// Disable proxy | ||
proxy.disableProxy(); | ||
|
||
// Install certificate | ||
proxy.installCertificate("path/to/certificate.crt"); | ||
|
||
// Uninstall certificate | ||
proxy.uninstallCertificate("certificate.crt"); | ||
|
||
// Edit hosts file | ||
std::vector<std::pair<std::string, std::string>> hostsEntries = { | ||
{"127.0.0.1", "localhost"}, | ||
{"192.168.1.1", "example.com"} | ||
}; | ||
proxy.editHostsFile(hostsEntries); | ||
|
||
// Reset hosts file | ||
proxy.resetHostsFile(); | ||
|
||
return 0; | ||
} | ||
``` | ||
|
||
## Notes | ||
|
||
- The class uses platform-specific code to handle proxy settings, certificate management, and hosts file operations. | ||
- Logging is used extensively to provide detailed information about the operations being performed. | ||
- The class is designed to be cross-platform, with separate implementations for Windows and Linux. |
Oops, something went wrong.