### Domain Configuration Options Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Detailed explanation and usage examples for each domain configuration property. ```APIDOC ## Domain Configuration Options ### DomainConfig Configuration Properties Detailed options and usage examples for each domain. #### DomainConfig Record Type Definition ```csharp public record DomainConfig { // Whether to send SNI (Server Name Indication) during TLS handshake public bool TlsSni { get; init; } // Expression for custom SNI value // @domain - domain variable // @ipaddress - IP address variable // @random - random value variable public string? TlsSniPattern { get; init; } // Whether to ignore server certificate name mismatch // When SNI is not sent, the server might return a certificate with a mismatched name public bool TlsIgnoreNameMismatch { get; init; } // Specify the IP address for the request public IPAddress? IPAddress { get; init; } // Request timeout duration, format: "00:02:00" public TimeSpan? Timeout { get; init; } // Destination, format: relative or absolute URI public Uri? Destination { get; init; } // Custom response (if set, other configurations are ignored) public ResponseConfig? Response { get; init; } } ``` #### Example Usage - JSON Configuration ```json { "FastGithub": { "DomainConfigs": { // Domain to disable SNI "github.com": { "TlsSni": false }, // Ignore certificate name mismatch "*.github.io": { "TlsIgnoreNameMismatch": true }, // Redirect request to another address "fonts.googleapis.com": { "TlsSni": true, "Destination": "https://fonts.geekzu.org/" }, // Block request and return a custom response "blocked.example.com": { "Response": { "StatusCode": 403, "ContentType": "text/plain;charset=utf-8", "ContentValue": "This domain has been blocked" } }, // Specify request timeout "slow.example.com": { "TlsSni": true, "Timeout": "00:05:00" } } } } ``` ``` -------------------------------- ### Launch Windows Desktop Application Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Start the FastGithub UI application directly or via command line. ```bash # 直接双击运行 FastGithub.UI.exe # 或从命令行启动 FastGithub.UI.exe ``` -------------------------------- ### Manage Windows Service Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Install or uninstall FastGithub as a background Windows service. ```bash # 以 Windows 服务安装并启动 fastgithub.exe start # 以 Windows 服务卸载并删除 fastgithub.exe stop ``` -------------------------------- ### Manage Linux systemd Service Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Install or remove FastGithub as a systemd service for background execution. ```bash # 以 systemd 服务安装并启动 sudo ./fastgithub start # 以 systemd 服务卸载并删除 sudo ./fastgithub stop # 生成的服务文件位于 /etc/systemd/system/fastgithub.service # 服务配置示例: # [Unit] # Description=fastgithub # # [Service] # Type=notify # User=root # ExecStart=/path/to/fastgithub # WorkingDirectory=/path/to/fastgithub # # [Install] # WantedBy=multi-user.target ``` -------------------------------- ### Domain Configuration and Options Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Defines the DomainConfig record structure and provides examples for handling SNI, certificate mismatches, redirects, and custom responses. ```csharp // DomainConfig 记录类型定义 public record DomainConfig { // 是否在 TLS 握手时发送 SNI (Server Name Indication) public bool TlsSni { get; init; } // 自定义 SNI 值的表达式 // @domain - 域名变量 // @ipaddress - IP 地址变量 // @random - 随机值变量 public string? TlsSniPattern { get; init; } // 是否忽略服务器证书域名不匹配 // 当不发送 SNI 时服务器可能发回域名不匹配的证书 public bool TlsIgnoreNameMismatch { get; init; } // 指定请求的 IP 地址 public IPAddress? IPAddress { get; init; } // 请求超时时长,格式为 "00:02:00" public TimeSpan? Timeout { get; init; } // 目的地,格式为相对或绝对 URI public Uri? Destination { get; init; } // 自定义响应(设置后其它配置不生效) public ResponseConfig? Response { get; init; } } ``` ```json { "FastGithub": { "DomainConfigs": { // 禁用 SNI 的域名 "github.com": { "TlsSni": false }, // 忽略证书域名不匹配 "*.github.io": { "TlsIgnoreNameMismatch": true }, // 请求重定向到其他地址 "fonts.googleapis.com": { "TlsSni": true, "Destination": "https://fonts.geekzu.org/" }, // 阻断请求并返回自定义响应 "blocked.example.com": { "Response": { "StatusCode": 403, "ContentType": "text/plain;charset=utf-8", "ContentValue": "此域名已被阻断" } }, // 指定请求超时时间 "slow.example.com": { "TlsSni": true, "Timeout": "00:05:00" } } } } ``` -------------------------------- ### GET / (PAC Proxy Auto-Configuration) Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Access the FastGithub proxy address to obtain the automatically generated PAC script for browser proxy configuration. ```APIDOC ## GET / (PAC Proxy Auto-Configuration) ### Description Access the FastGithub proxy address to get the automatically generated PAC script for browser auto-proxy configuration. ### Method GET ### Endpoint `/` ### Response #### Success Response (200) - **PAC Script** (string) - The PAC file content. ### Response Example ```javascript function FindProxyForURL(url, host){ var fastgithub = 'PROXY 127.0.0.1:38457'; if (shExpMatch(host, 'github.com')) return fastgithub; if (shExpMatch(host, '*.github.com')) return fastgithub; if (shExpMatch(host, '*.githubusercontent.com')) return fastgithub; if (shExpMatch(host, '*.githubassets.com')) return fastgithub; return 'DIRECT'; } ``` ``` -------------------------------- ### GET /flowStatistics Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Retrieves current proxy traffic statistics, including total read/write amounts and real-time rates. ```APIDOC ## GET /flowStatistics ### Description Get the current proxy traffic statistics, including total read/write amounts and real-time rates. ### Method GET ### Endpoint `/flowStatistics` ### Response #### Success Response (200) - **TotalRead** (long) - Total upstream traffic (bytes) - **TotalWrite** (long) - Total downstream traffic (bytes) - **ReadRate** (double) - Read rate (bytes/second) - **WriteRate** (double) - Write rate (bytes/second) ### Response Example ```json { "TotalRead": 1048576, "TotalWrite": 524288, "ReadRate": 102400.5, "WriteRate": 51200.25 } ``` ``` -------------------------------- ### Configure appsettings.json Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Main configuration file for defining proxy ports, DNS fallbacks, and domain-specific rules. ```json { "FastGithub": { "HttpProxyPort": 38457, "FallbackDns": [ "8.8.8.8:53", "119.29.29.29:53", "114.114.114.114:53" ], "DomainConfigs": { "*.example.com": { "TlsSni": false, "TlsSniPattern": null, "TlsIgnoreNameMismatch": false, "Timeout": null, "IPAddress": null, "Destination": null, "Response": { "StatusCode": 404, "ContentType": "text/plain;charset=utf-8", "ContentValue": "自定义响应内容" } } } }, "Serilog": { "MinimumLevel": { "Default": "Information", "Override": { "Yarp": "Warning", "System": "Warning", "Microsoft": "Warning" } } } } ``` -------------------------------- ### DNS Client Resolution and Configuration Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Demonstrates the DNS resolution flow and fallback server configuration. ```csharp // DnsClient 域名解析流程 public async IAsyncEnumerable ResolveAsync( DnsEndPoint endPoint, bool fastSort, CancellationToken cancellationToken) { var hashSet = new HashSet(); // 遍历所有 DNS 服务器 await foreach (var dns in GetDnsServersAsync(cancellationToken)) { // 查询并缓存结果 var addresses = await LookupAsync(dns, endPoint, fastSort, cancellationToken); foreach (var address in addresses) { if (hashSet.Add(address)) { yield return address; } } } } ``` ```json { "FastGithub": { "FallbackDns": [ "8.8.8.8:53", // Google DNS "119.29.29.29:53", // DNSPod "114.114.114.114:53" // 114 DNS ] } } ``` -------------------------------- ### Configure appsettings.github.json Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Pre-configured domain rules specifically for GitHub services. ```json { "FastGithub": { "DomainConfigs": { "github.com": { "TlsSni": false }, "api.github.com": { "TlsSni": false }, "githubstatus.com": { "TlsSni": false }, "gist.github.com": { "TlsIgnoreNameMismatch": true }, "vscode-auth.github.com": { "TlsSni": true }, "*.github.com": { "TlsIgnoreNameMismatch": true }, "*.github.io": { "TlsIgnoreNameMismatch": true }, "*.githubapp.com": { "TlsIgnoreNameMismatch": true }, "*.githubassets.com": { "TlsIgnoreNameMismatch": true }, "*.githubusercontent.com": { "TlsIgnoreNameMismatch": true } } } } ``` -------------------------------- ### Manage Domain Configurations with FastGithubConfig Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Dynamically load and update domain configurations, supporting wildcard matching for proxy rules. ```csharp public class FastGithubConfig { public int HttpProxyPort { get; set; } public IPEndPoint[] FallbackDns { get; set; } public bool IsMatch(string domain); public bool TryGetDomainConfig(string domain, out DomainConfig value); public DomainPattern[] GetDomainPatterns(); } ``` ```csharp public class ProxyMiddleware { private readonly FastGithubConfig _config; public ProxyMiddleware(FastGithubConfig config) { _config = config; } public void ProcessRequest(string host) { if (_config.TryGetDomainConfig(host, out var domainConfig)) { Console.WriteLine($"域名 {host} 匹配配置:"); Console.WriteLine($" TlsSni: {domainConfig.TlsSni}"); Console.WriteLine($" TlsIgnoreNameMismatch: {domainConfig.TlsIgnoreNameMismatch}"); if (domainConfig.Destination != null) { Console.WriteLine($" 重定向到: {domainConfig.Destination}"); } } else { Console.WriteLine($"域名 {host} 未配置,使用默认处理"); } } } ``` -------------------------------- ### Configure Git SSL Backend Source: https://github.com/wanggithubuser/fastgithub/blob/main/FastGithub.UI/Resource/issue.html Switch Git to use the Windows schannel backend to resolve local issuer certificate errors. ```bash cmd ``` ```bash git config --global http.sslbackend schannel ``` -------------------------------- ### Google CDN Configuration (appsettings.google.json) Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Configuration to redirect Google CDN resources to domestic mirrors for improved loading of CSS/JS files. ```APIDOC ## Google CDN Configuration (appsettings.google.json) ### Description Redirect Google CDN resources to domestic mirrors to resolve issues with loading CSS/JS files on web pages. ### Request Body ```json { "FastGithub": { "DomainConfigs": { "ajax.googleapis.com": { "TlsSni": true, "Destination": "https://gapis.geekzu.org/ajax/" }, "fonts.googleapis.com": { "TlsSni": true, "Destination": "https://fonts.geekzu.org/" }, "themes.googleusercontent.com": { "TlsSni": true, "Destination": "https://gapis.geekzu.org/g-themes/" }, "fonts.gstatic.com": { "TlsSni": true, "Destination": "https://gapis.geekzu.org/g-fonts/" }, "*.gravatar.com": { "TlsIgnoreNameMismatch": true } } } } ``` ``` -------------------------------- ### Deploy with Docker Compose Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Configuration and commands for running FastGithub in a Docker environment. ```yaml # docker-compose.yaml version: "3.7" services: fastgithub: image: slcnx/fastgithub network_mode: host restart: always volumes: - cacert:/fastgithub/cacert/ sample: depends_on: - fastgithub image: slcnx/ubuntu:18.04 volumes: - cacert:/tmp/cacert - build_data:/build_data working_dir: /build_data restart: on-failure tty: true entrypoint: sh -c 'cp /tmp/cacert/fastgithub.cer /usr/local/share/ca-certificates/fastgithub.crt && update-ca-certificates && git clone https://github.com/kubernetes/kubernetes.git' environment: https_proxy: http://127.0.0.1:38457 http_proxy: http://127.0.0.1:38457 network_mode: host volumes: cacert: {} build_data: {} ``` ```bash # 启动服务 docker-compose up -d # 查看日志 docker-compose logs -f fastgithub ``` -------------------------------- ### Run Linux Terminal Mode Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Execute FastGithub with root privileges and configure system proxy settings. ```bash # 以 root 权限运行 sudo ./fastgithub # 配置系统代理 # 方式1: 设置系统自动代理为 http://127.0.0.1:38457 # 方式2: 手动设置 http/https 代理为 127.0.0.1:38457 export http_proxy=http://127.0.0.1:38457 export https_proxy=http://127.0.0.1:38457 ``` -------------------------------- ### Deploy on macOS Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Commands to bypass developer verification and configure proxy settings on macOS. ```bash # 解决 "cannot be opened because the developer cannot be verified" 问题 sudo xattr -d com.apple.quarantine *.* # 双击运行 fastgithub # 安装证书: # 1. 打开 cacert/fastgithub.cer # 2. 在 Keychain Access 中双击 FastGitHub # 3. 展开 Trust 并选择 Always Trust # 配置代理: # 系统偏好设置 -> 网络 -> 高级 -> 代理 # 自动代理配置: http://127.0.0.1:38457 # 或手动设置 HTTP/HTTPS 代理: 127.0.0.1:38457 ``` -------------------------------- ### Configure Git SSL Backend Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Set Git to use the system's certificate store for trusting FastGithub-generated certificates, or disable SSL verification (not recommended). ```bash # 让 Git 使用系统的证书库(推荐) git config --global http.sslbackend schannel # 或者禁用 SSL 验证(不推荐) git config --global http.sslVerify false # 查看当前配置 git config --global --get http.sslbackend # 使用 FastGithub 后的 git 操作 git clone https://github.com/dotnetcore/FastGithub.git git pull origin main git push origin feature-branch ``` -------------------------------- ### Google CDN Replacement Configuration Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Use this JSON configuration to redirect Google CDN resources to domestic mirrors, resolving CSS/JS loading issues. ```json { "FastGithub": { "DomainConfigs": { "ajax.googleapis.com": { "TlsSni": true, "Destination": "https://gapis.geekzu.org/ajax/" }, "fonts.googleapis.com": { "TlsSni": true, "Destination": "https://fonts.geekzu.org/" }, "themes.googleusercontent.com": { "TlsSni": true, "Destination": "https://gapis.geekzu.org/g-themes/" }, "fonts.gstatic.com": { "TlsSni": true, "Destination": "https://gapis.geekzu.org/g-fonts/" }, "*.gravatar.com": { "TlsIgnoreNameMismatch": true } } } } ``` -------------------------------- ### Configure Kestrel and System Proxy for Linux/macOS Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Use this configuration to enable HTTP proxy mode on non-Windows platforms. Ensure the environment variables are set to route traffic through the specified port. ```csharp // Linux/macOS Kestrel 配置 builder.WebHost.UseKestrel(kestrel => { kestrel.NoLimit(); if (!OperatingSystem.IsWindows()) { // HTTP 代理端口 (默认 38457) kestrel.ListenHttpProxy(); } }); // 系统代理配置 // export http_proxy=http://127.0.0.1:38457 // export https_proxy=http://127.0.0.1:38457 ``` -------------------------------- ### Implement Traffic Analysis with IFlowAnalyzer Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Real-time proxy traffic statistics, supporting read/write separation and rate calculation using the IFlowAnalyzer interface. ```csharp public interface IFlowAnalyzer { void OnFlow(FlowType flowType, int length); FlowStatistics GetFlowStatistics(); } ``` ```csharp public enum FlowType { Read, // 上行流量 Write // 下行流量 } ``` ```csharp public class ProxyStream : Stream { private readonly IFlowAnalyzer _flowAnalyzer; private readonly Stream _innerStream; public override int Read(byte[] buffer, int offset, int count) { var bytesRead = _innerStream.Read(buffer, offset, count); _flowAnalyzer.OnFlow(FlowType.Read, bytesRead); return bytesRead; } public override void Write(byte[] buffer, int offset, int count) { _innerStream.Write(buffer, offset, count); _flowAnalyzer.OnFlow(FlowType.Write, count); } } ``` ```csharp var stats = flowAnalyzer.GetFlowStatistics(); Console.WriteLine($"总上行: {stats.TotalRead / 1024.0:F2} KB"); Console.WriteLine($"总下行: {stats.TotalWrite / 1024.0:F2} KB"); Console.WriteLine($"上行速率: {stats.ReadRate / 1024.0:F2} KB/s"); Console.WriteLine($"下行速率: {stats.WriteRate / 1024.0:F2} KB/s"); ``` -------------------------------- ### FastGithubConfig API Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Manages domain configurations, including proxy settings and pattern matching rules. ```APIDOC ## FastGithubConfig ### Description Handles dynamic loading and updating of domain configurations, supporting wildcard matching. ### Methods - **IsMatch(string domain)** (bool) - Checks if a domain matches the current configuration. - **TryGetDomainConfig(string domain, out DomainConfig value)** (bool) - Attempts to retrieve the configuration for a specific domain. - **GetDomainPatterns()** (DomainPattern[]) - Returns all configured domain patterns. ``` -------------------------------- ### Configure Windows Platform Listening Ports for Reverse Proxy Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Configure Kestrel on Windows to listen on standard ports for transparent proxying of HTTPS, HTTP, SSH, and Git traffic. ```csharp builder.WebHost.UseKestrel(kestrel => { kestrel.NoLimit(); if (OperatingSystem.IsWindows()) { // HTTPS 反向代理 (443) kestrel.ListenHttpsReverseProxy(); // HTTP 反向代理 (80) kestrel.ListenHttpReverseProxy(); // SSH 反向代理 (22 -> github.com:22) kestrel.ListenSshReverseProxy(); // Git 反向代理 (9418 -> github.com:9418) kestrel.ListenGitReverseProxy(); } }); ``` -------------------------------- ### Configure Firefox Enterprise Roots Source: https://github.com/wanggithubuser/fastgithub/blob/main/FastGithub.UI/Resource/issue.html Enable enterprise roots in Firefox to resolve invalid signature errors. ```text about:config ``` ```text security.enterprise_roots.enabled ``` ```text true ``` -------------------------------- ### Generate CA and Server Certificates with CertService Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Use CertService to create and manage CA certificates for secure HTTPS interception and issue domain-specific server certificates. ```csharp public class CertService { public string CaCerFilePath { get; } = "cacert/fastgithub.cer"; public string CaKeyFilePath { get; } = "cacert/fastgithub.key"; public bool CreateCaCertIfNotExists(); public void InstallAndTrustCaCert(); public X509Certificate2 GetOrCreateServerCert(string? domain); } ``` ```csharp var certService = serviceProvider.GetRequiredService(); if (certService.CreateCaCertIfNotExists()) { Console.WriteLine("CA 证书已生成"); } certService.InstallAndTrustCaCert(); var githubCert = certService.GetOrCreateServerCert("github.com"); Console.WriteLine($"证书主题: {githubCert.Subject}"); // 输出: 证书主题: CN=github.com ``` -------------------------------- ### PAC Proxy Configuration Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Retrieve the auto-generated PAC script for browser proxy settings. ```bash # 获取 PAC 文件 curl http://127.0.0.1:38457/ -o proxy.pac # PAC 文件内容示例 function FindProxyForURL(url, host){ var fastgithub = 'PROXY 127.0.0.1:38457'; if (shExpMatch(host, 'github.com')) return fastgithub; if (shExpMatch(host, '*.github.com')) return fastgithub; if (shExpMatch(host, '*.githubusercontent.com')) return fastgithub; if (shExpMatch(host, '*.githubassets.com')) return fastgithub; return 'DIRECT'; } ``` -------------------------------- ### Import FastGithub CA Certificate in Firefox Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Steps to import and trust the FastGithub CA certificate within Firefox browser settings. ```text Firefox 证书导入步骤: 1. 打开 Firefox 设置 2. 搜索 "证书" 或进入 隐私与安全 -> 证书 -> 查看证书 3. 选择 "证书颁发机构" 标签页 4. 点击 "导入" 并选择 cacert/fastgithub.cer 5. 勾选 "信任由此证书颁发机构来标识网站" 6. 点击确定保存 ``` -------------------------------- ### Enable Code Copy Functionality Source: https://github.com/wanggithubuser/fastgithub/blob/main/FastGithub.UI/Resource/issue.html JavaScript snippet to add click-to-copy functionality to code elements on the page. ```javascript var codes = document.getElementsByTagName('code'); for (var i = 0; i < codes.length; i++) { var code = codes[i]; code.setAttribute('title', '点击复制'); code.onclick = function () { window.clipboardData.setData("Text", this.outerText); } } ``` -------------------------------- ### IFlowAnalyzer API Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Provides real-time traffic statistics for proxy operations. ```APIDOC ## IFlowAnalyzer ### Description Interface for recording and retrieving traffic statistics, including read/write counts and rates. ### Methods - **OnFlow(FlowType flowType, int length)** (void) - Records traffic flow. - **GetFlowStatistics()** (FlowStatistics) - Returns the current traffic statistics object. ``` -------------------------------- ### DnsClient DNS Resolution Process Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Supports querying multiple DNS servers, including dnscrypt-proxy encrypted DNS and fallback DNS servers. ```APIDOC ## DnsClient DNS Resolution Process ### Description Supports querying multiple DNS servers, including dnscrypt-proxy encrypted DNS and fallback DNS servers. ### DNS Resolution Flow ```csharp public async IAsyncEnumerable ResolveAsync( DnsEndPoint endPoint, bool fastSort, CancellationToken cancellationToken) { var hashSet = new HashSet(); // Iterate through all DNS servers await foreach (var dns in GetDnsServersAsync(cancellationToken)) { // Query and cache results var addresses = await LookupAsync(dns, endPoint, fastSort, cancellationToken); foreach (var address in addresses) { if (hashSet.Add(address)) { yield return address; } } } } ``` ### DNS Server Configuration ```json { "FastGithub": { "FallbackDns": [ "8.8.8.8:53", // Google DNS "119.29.29.29:53", // DNSPod "114.114.114.114:53" // 114 DNS ] } } ``` ``` -------------------------------- ### IDomainResolver Interface Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Interface responsible for resolving domains and returning a list of optimally sorted IP addresses after speed testing. ```APIDOC ## IDomainResolver Interface ### Description Responsible for resolving domains and returning a list of optimally sorted IP addresses after speed testing. ### Code Example ```csharp // IDomainResolver interface definition public interface IDomainResolver { // Asynchronously resolve domain, returning a stream of IP addresses IAsyncEnumerable ResolveAsync( DnsEndPoint endPoint, CancellationToken cancellationToken); // Test speed for all known nodes Task TestSpeedAsync(CancellationToken cancellationToken); } // Usage Example public class MyService { private readonly IDomainResolver _domainResolver; public MyService(IDomainResolver domainResolver) { _domainResolver = domainResolver; } public async Task ResolveGithubAsync() { var endpoint = new DnsEndPoint("github.com", 443); await foreach (var ip in _domainResolver.ResolveAsync(endpoint, default)) { Console.WriteLine($"Resolved IP: {ip}"); // Output: Resolved IP: 20.205.243.166 } } } ``` ``` -------------------------------- ### Domain Resolver Interface Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Defines the IDomainResolver interface for asynchronous domain resolution and speed testing. ```csharp // IDomainResolver 接口定义 public interface IDomainResolver { // 异步解析域名,返回 IP 地址流 IAsyncEnumerable ResolveAsync( DnsEndPoint endPoint, CancellationToken cancellationToken); // 对所有已知节点进行测速 Task TestSpeedAsync(CancellationToken cancellationToken); } // 使用示例 public class MyService { private readonly IDomainResolver _domainResolver; public MyService(IDomainResolver domainResolver) { _domainResolver = domainResolver; } public async Task ResolveGithubAsync() { var endpoint = new DnsEndPoint("github.com", 443); await foreach (var ip in _domainResolver.ResolveAsync(endpoint, default)) { Console.WriteLine($"Resolved IP: {ip}"); // 输出: Resolved IP: 20.205.243.166 } } } ``` -------------------------------- ### Traffic Statistics API Source: https://context7.com/wanggithubuser/fastgithub/llms.txt Access the traffic statistics endpoint and the corresponding C# data structure. ```bash # 获取流量统计 curl http://127.0.0.1:38457/flowStatistics # 响应示例 { "TotalRead": 1048576, "TotalWrite": 524288, "ReadRate": 102400.5, "WriteRate": 51200.25 } ``` ```csharp // FlowStatistics 数据结构 public record FlowStatistics { // 总上行流量(字节) public long TotalRead { get; init; } // 总下行流量(字节) public long TotalWrite { get; init; } // 读取速率(字节/秒) public double ReadRate { get; init; } // 写入速率(字节/秒) public double WriteRate { get; init; } } ``` -------------------------------- ### CertService API Source: https://context7.com/wanggithubuser/fastgithub/llms.txt The CertService handles the generation of self-signed CA certificates and dynamic issuance of domain certificates for HTTPS man-in-the-middle proxying. ```APIDOC ## CertService ### Description Provides methods to manage CA certificates and generate server-specific certificates for HTTPS interception. ### Methods - **CreateCaCertIfNotExists()** (bool) - Generates a CA certificate if it does not already exist. - **InstallAndTrustCaCert()** (void) - Installs and trusts the CA certificate in the system store. - **GetOrCreateServerCert(string domain)** (X509Certificate2) - Retrieves or creates a server certificate for the specified domain. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.