MsmhAgnosticServer 1.6.2
dotnet add package MsmhAgnosticServer --version 1.6.2
NuGet\Install-Package MsmhAgnosticServer -Version 1.6.2
<PackageReference Include="MsmhAgnosticServer" Version="1.6.2" />
paket add MsmhAgnosticServer --version 1.6.2
#r "nuget: MsmhAgnosticServer, 1.6.2"
// Install MsmhAgnosticServer as a Cake Addin
#addin nuget:?package=MsmhAgnosticServer&version=1.6.2
// Install MsmhAgnosticServer as a Cake Tool
#tool nuget:?package=MsmhAgnosticServer&version=1.6.2
A DNS and Proxy Server in C# (Class Library .NET 6)
I'm just sharing this library for developers due to recieved requests. It's a multi platform DNS and Proxy Server. Target Platform: Windows. Tested once on Android. You can make it fully compatible with your own target platform.
DNS Servers: DNS-Over-UDP, DNS-Over-TCP, DNS-Over-HTTPS (DoH)
DNS Clients: DNS-Over-UDP, DNS-Over-TCP, DNS-Over-HTTPS (DoH)(https://, h3://), DNS-Over-TLS (DoT), DNSCrypt, Anonymized DNSCrypt.
Proxy Servers:
HTTP (Domain, IPv4, IPv6) (Get, Post, etc)
HTTPS (Domain, IPv4, IPv6) (Post, etc)
SOCKS4 (IPv4) (Connect, Bind)
SOCKS4A (Domain, IPv4) (Connect, Bind)
SOCKS5 (Domain, IPv4, IPv6) (Connect, Bind, UDP)\
DNS Server Features: DNS Records modification, Upstream Proxy, Text based DNS Rules (Block, Fake DNS, Upstream Proxy per domain)
Proxy Server Features: Upstream Proxy, Fragment, Fake SNI, Text based Proxy Rules (Block, Fake DNS, Fake SNI, Custom DNS, Upstream Proxy per domain)\
Smart DNS Server: Supported - You can create an Smart DNS Server using DNS Rules (Just modify all A Records and AAAA Records To Your Proxy Server IP).
Limit DoH By Path: Supported - e.g. https://example.com/UserName/dns-query </br>
Running a DNS and Proxy Server on port 8080 example:
// Create Agnostic Server
MsmhAgnosticServer server = new();
// Request Received Event
server.OnRequestReceived += Server_OnRequestReceived;
// A List Of DNS Servers To Connect To
List<string> dnsServers = new()
{
"sdns://AQMAAAAAAAAAEjEwMy44Ny42OC4xOTQ6ODQ0MyAxXDKkdrOao8ZeLyu7vTnVrT0C7YlPNNf6trdMkje7QR8yLmRuc2NyeXB0LWNlcnQuZG5zLmJlYmFzaWQuY29t",
"tcp://8.8.8.8:53",
"tcp://1.1.1.1:53",
"https://max.rethinkdns.com/dns-query",
"h3://max.rethinkdns.com/dns-query",
"https://45.90.29.204:443/dns-query",
"udp://208.67.222.222:5353"
};
// Create Settings For Server
AgnosticSettings settings = new()
{
Working_Mode = AgnosticSettings.WorkingMode.DnsAndProxy, // Working Mode - Only DNS Or DNS And Proxy
ListenerPort = 8080, // Server Listning Port
DnsTimeoutSec = 10, // DNS Request Timeout In Seconds
ProxyTimeoutSec = 40, // Proxy Request Timeout In Seconds
MaxRequests = 1000000, // Set Number Of Requests To Handle Per Second
KillOnCpuUsage = 40, // Kill All Proxy Requests If CPU Usage Goes Above 40%
DNSs = dnsServers, // Set Our DNS Servers List
BootstrapIpAddress = IPAddress.Parse("8.8.8.8"), // Set Bootstrap IP Address
BootstrapPort = 53, // Set Bootstrap Port
AllowInsecure = false, // Allow Insecure
BlockPort80 = false, // Block Port 80 On Proxy Requests
// CloudflareCleanIP = cfClenIP, // You Can Redirect All Cloudflare IPs To A Clean IP (IPv4 Only)
// UpstreamProxyScheme = $"socks5://{IPAddress.Loopback}:53", // You Can Set Your Upstream Proxy Here
// ApplyUpstreamOnlyToBlockedIps = true // Apply Upstream Proxy Only To Blocked IPs
};
// Enable Fragment For Proxy Requests
AgnosticProgram.Fragment fragment = new();
fragment.Set(AgnosticProgram.Fragment.Mode.Program, 50, AgnosticProgram.Fragment.ChunkMode.SNI, 5, 2, 1);
server.EnableFragment(fragment);
//// Enable DNS Rules
//AgnosticProgram.DnsRules dnsRules = new();
//dnsRules.Set(AgnosticProgram.DnsRules.Mode.File, "File_Path");
//server.EnableDnsRules(dnsRules);
//// Enable Proxy Rules
//AgnosticProgram.ProxyRules proxyRules = new();
//proxyRules.Set(AgnosticProgram.ProxyRules.Mode.File, "File_Path");
//server.EnableProxyRules(proxyRules);
// Enable DNS Limit Program e.g. https://127.0.0.1:8080/dns-query and https://127.0.0.1:8080/UserName/dns-query
AgnosticProgram.DnsLimit dnsLimit = new();
string allowedDohPaths = "dns-query\nUserName";
dnsLimit.Set(true, false, AgnosticProgram.DnsLimit.LimitDoHPathsMode.Text, allowedDohPaths);
server.EnableDnsLimit(dnsLimit);
// Create SSL Settings For Activating DoH And HTTPS Server, Also You Can Change SNI Here (Fake SNI)
AgnosticSettingsSSL settingsSSL = new(true)
{
EnableSSL = true,
//ChangeSni = true,
//DefaultSni = "speedtest.net",
};
await server.EnableSSL(settingsSSL);
// Start Server
server.Start(settings);
// Write To Console
Console.WriteLine($"Msmh Agnostic Server Started On: {settings.ListenerIP}:{settings.ListenerPort}");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- libsodium (>= 1.0.19)
- Microsoft.Diagnostics.Tracing.TraceEvent (>= 3.1.8)
- Microsoft.PowerShell.SDK (>= 7.2.18)
- System.Diagnostics.PerformanceCounter (>= 8.0.0)
- System.DirectoryServices.AccountManagement (>= 8.0.0)
- System.Drawing.Common (>= 8.0.3)
- System.Management (>= 8.0.0)
- System.Management.Automation (>= 7.2.18)
- TaskScheduler (>= 2.10.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.