Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
e0d9c8b
feat: configurable DNS routing (Direct and Proxy modes)
wiresock Nov 12, 2026
510efc0
fix: never pass local proxy listener replies to the wire; track TCP c…
wiresock Nov 12, 2026
cdebe10
fix: exempt only ProxiFyre's own traffic to a SOCKS5 server from the …
wiresock Nov 12, 2026
d9c1bfa
fix: classify DNS in first fragments only and drop fragmented DNS in …
wiresock Nov 12, 2026
fd64852
fix: reinstall DNS driver filters on every start and fail closed
wiresock Nov 12, 2026
26a3f77
fix: restore override answers whatever source the relay reports
wiresock Nov 12, 2026
f420360
perf: skip lock_ on the UDP listener reply path unless an override is…
wiresock Nov 12, 2026
0fa1e32
perf: evict DNS origin tracker entries by insertion order
wiresock Nov 12, 2026
2592907
docs: make the Direct-mode TCP/53 change prominent for upgrades
wiresock Nov 12, 2026
7c4ae97
fix: state plainly that DNS stays blocked until restart; refuse unkno…
wiresock Nov 12, 2026
c7c45bf
docs: limit the "one warning per cause" claim to drops by the DNS policy
wiresock Nov 12, 2026
abea47c
fix: normalize a blank proxy id to null; reword the other-family warning
wiresock Nov 12, 2026
33c38b0
fix(gui): give the DNS labels tab indices so their mnemonics focus th…
wiresock Nov 12, 2026
6947d7d
test: replace DNS policy tests that restated the implementation
wiresock Nov 12, 2026
8dc1512
fix: fragment-aware listener-reply handling, with visible drop reports
wiresock Nov 12, 2026
5e26002
test: assert DNS origin tracker cost structurally, not by wall-clock …
wiresock Nov 12, 2026
ce386de
fix: let RST take precedence over SYN in TCP redirect tracking
wiresock Nov 12, 2026
f13d019
fix: name DNS filter installation in the engine start-failure message…
wiresock Nov 12, 2026
6d7d3f0
docs: document the residual recursion-guard race on cached connection…
wiresock Nov 12, 2026
7dedf9b
fix: drop listener segments after a reset quietly instead of reportin…
wiresock Nov 12, 2026
e05e77b
fix: exempt UDP to a SOCKS5 server only once a relay on port 53 exists
wiresock Nov 12, 2026
79f8980
test: count every tracker iteration through one helper per container
wiresock Nov 12, 2026
ca74492
fix: read the DNS mode only when a fragment needs it; drop IPv4 TCP l…
wiresock Nov 12, 2026
7c82084
test: catch a reset record being refreshed by later segments
wiresock Nov 12, 2026
e175dbe
docs: state the UDP-sender claim precisely; fix a misplaced doc comment
wiresock Nov 12, 2026
d7e4abf
fix: restore UDP DNS answers to the queried server with or without a …
wiresock Nov 12, 2026
4801548
docs: describe listener-reply and TCP close handling; extend the Wind…
wiresock Nov 12, 2026
fc052ee
fix: restore a tracked DNS answer when the relay header has the other…
wiresock Nov 12, 2026
4588035
docs: correct the answer-restoration statements and three validation …
wiresock Nov 12, 2026
6db1725
docs: name the second kind of unmatched relayed datagram that is dropped
wiresock Nov 12, 2026
022cfa3
build: use wiresock/ndisapi as a submodule instead of a vendored copy
wiresock Nov 12, 2026
84df0b4
refactor: move the SOCKS5 UDP ASSOCIATE client steps into a shared he…
wiresock Nov 13, 2026
26406e0
feat: share one SOCKS5 UDP association for all UDP DNS
wiresock Nov 13, 2026
c61763c
fix(gui): never turn an unrecognized DNS mode into Direct
wiresock Nov 13, 2026
4aca43f
fix: report throttled DNS and listener drop counts within five seconds
wiresock Nov 13, 2026
10e0b65
fix: restart the redirect cleanup threads when the router starts again
wiresock Nov 13, 2026
6cd6f36
chore: name the unreachable DNS fallback accurately; drop a dead IPv6…
wiresock Nov 13, 2026
00c54fd
feat: return oversized UDP DNS answers truncated so Windows retries o…
wiresock Nov 13, 2026
371992b
docs: describe the shared UDP DNS association and truncated large ans…
wiresock Nov 13, 2026
b3790f5
fix(dns relay): keep a working association open; match answers by que…
wiresock Nov 13, 2026
9294724
fix(router): stop the DNS relays first; dedicated DNS client ports
wiresock Nov 13, 2026
20bfaa5
chore: reuse the shared UDP socket buffer size in the per-port UDP proxy
wiresock Nov 13, 2026
beea6fe
docs: match the shared UDP association's behavior after the review fixes
wiresock Nov 13, 2026
e06af8c
fix(dns relay): drop stale queued queries, check query destinations, …
wiresock Nov 13, 2026
584330c
docs: describe the queued-query limit, the listener's destination che…
wiresock Nov 13, 2026
a74fb2b
fix(dns relay): escalate the backoff for silent associations; keep th…
wiresock Nov 13, 2026
345db2d
fix(dns relay): restart the backoff when an association that answered…
wiresock Nov 13, 2026
7304bfa
fix(dns relay): restart the backoff after any working association; wa…
wiresock Nov 13, 2026
1fdfaab
fix(dns relay): accurate unanswered-relay warning; report a flapping …
wiresock Nov 13, 2026
30452c0
fix(dns relay): distinguish an early-ended association in the warning…
wiresock Nov 13, 2026
91e1240
fix(dns relay): report each cause of a failed association once; warn …
wiresock Nov 13, 2026
0eb081c
test, docs: cover closure reports in either order; name both causes o…
wiresock Nov 13, 2026
490af89
test: stop the owner routing tests colliding with the runner's own PID
wiresock Nov 13, 2026
4b10966
fix(config): only fail on a rule id that DNS Proxy mode depends on
wiresock Nov 13, 2026
16c0579
fix(config, gui): review round 12 for the id and dns upgrade handling
wiresock Nov 13, 2026
9cec800
fix(config, gui): review round 13 for id handling; read date-like str…
wiresock Nov 13, 2026
b14a9c0
fix(gui): keep following a rule given a DNS id across edits; review r…
wiresock Nov 13, 2026
f4981ee
fix(config): name the rule a repeated id resolves to in id messages
wiresock Nov 13, 2026
e243699
fix(config): report id or dns keys that differ only in case
wiresock Nov 13, 2026
216bcf6
fix(dns): drop ICMP errors that quote a DNS answer in Proxy mode
wiresock Nov 14, 2026
d26dbba
fix(udp): drop ICMP errors that quote a proxied UDP reply
wiresock Nov 14, 2026
5fddaca
docs: say how long to keep the socket open in validation step 16
wiresock Nov 14, 2026
e0493f9
Merge pull request #192 from wiresock/claude/ecstatic-mccarthy-8tehu6
wiresock Nov 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ProxiFyre/App.config text eol=lf
ProxiFyre/NLog.config text eol=lf
ProxiFyreUI/ProxiFyreUI.exe.config text eol=lf
netlib/test/portable/run-portable-tests.sh text eol=lf
8 changes: 4 additions & 4 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ Create this file in the same directory as `ProxiFyre.exe`:
- `.github/workflows/main.yml`: CI/CD build pipeline

### Include Directories
- `./include/`: Common headers (`Common.h`, `ndisapi.h`)
- `./ndisapi/`: NDIS API implementation
- `./external/ndisapi/`: Git submodule of [wiresock/ndisapi](https://github.com/wiresock/ndisapi) (Windows Packet Filter user-mode API). `include/` holds `Common.h` and `ndisapi.h`; `ndisapi/` holds the implementation. Run `git submodule update --init` after cloning.
- `./ndisapi.lib/`: ProxiFyre's static-library project that builds the submodule sources with the solution's CRT settings
- `./netlib/`: Network utility C++ classes

## Common Tasks
Expand All @@ -228,7 +228,7 @@ Create this file in the same directory as `ProxiFyre.exe`:
```bash
# Root directory listing
ls -la
# Output includes the engine, managed UI, native launcher, tests, MSI, bundle, both setup helpers, socksify, ndisapi.lib, include, netlib, scripts, docs, README.md, and socksify.sln
# Output includes the engine, managed UI, native launcher, tests, MSI, bundle, both setup helpers, socksify, ndisapi.lib, external (ndisapi submodule), netlib, scripts, docs, README.md, and socksify.sln

# Key configuration files
find . -name "*.json" -o -name "*.config" -o -name "packages.config"
Expand All @@ -247,7 +247,7 @@ find . -name "*.cs"

# Find C++ files
find . -name "*.cpp" -o -name "*.h"
# Output: socksify/ and ndisapi/ directories contain C++ implementation
# Output: socksify/, netlib/ and the external/ndisapi/ submodule contain C++ implementation
```

## Limitations
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
uses: actions/checkout@v7
with:
persist-credentials: false
submodules: true

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v3
Expand Down
28 changes: 27 additions & 1 deletion .github/workflows/native-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: 'Native tests'

# Builds and runs the native x64 GoogleTest executable (netlib-tests). This workflow is
# Builds and runs the native x64 GoogleTest executable (netlib-tests) on Windows and the portable
# native tests on Linux. This workflow is
# independent of release packaging and signing: it produces no release artifacts and needs no
# secrets. The commands mirror the local instructions in netlib/README.md.

Expand All @@ -9,6 +10,30 @@ on:
workflow_dispatch:

jobs:
portable-native-tests:
# Platform-independent native tests (DNS routing policy and the real packet-rewriting
# headers it drives); see netlib/README.md#portable-native-tests.
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout from GitHub
uses: actions/checkout@v7
with:
persist-credentials: false
submodules: true

- name: Install compiler and test dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends g++ libgtest-dev libmsgsl-dev

- name: Run portable native tests
run: netlib/test/portable/run-portable-tests.sh

- name: Run portable native tests with sanitizers
run: SANITIZE=1 netlib/test/portable/run-portable-tests.sh

netlib-tests:
strategy:
fail-fast: false
Expand All @@ -22,6 +47,7 @@ jobs:
uses: actions/checkout@v7
with:
persist-credentials: false
submodules: true

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v3
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "external/ndisapi"]
path = external/ndisapi
url = https://github.com/wiresock/ndisapi.git
62 changes: 62 additions & 0 deletions ProxiFyre.Configuration/ConfigurationNormalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,73 @@ public ProxiFyreConfiguration Normalize(ProxiFyreConfiguration configuration)
Excludes = configuration.Excludes == null
? new List<string>()
: configuration.Excludes.Where(value => !string.IsNullOrWhiteSpace(value)).ToList(),
Dns = configuration.Dns == null ? null : NormalizeDns(configuration.Dns),
ExtensionData = CloneExtensionData(configuration.ExtensionData)
};

DropUnusedInvalidProxyIds(result.Proxies, DnsConfiguration.GetNamedProxyId(configuration.Dns));
return result;
}

/// <summary>
/// Removes an invalid id, or a repeat of an earlier rule's id, that dns.proxyId does not
/// name. Such ids have no effect, and dropping them lets a saved configuration clear the
/// warning. An id dns.proxyId names is kept in every mode: in Proxy mode the validator
/// reports it as an error, and in Direct mode the selection must survive a later switch
/// to Proxy mode.
/// </summary>
private static void DropUnusedInvalidProxyIds(IList<ProxyRule> rules, string referencedId)
{
if (rules == null)
return;

var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (var rule in rules)
{
if (rule == null || rule.Id == null)
continue;

var referenced = referencedId != null &&
string.Equals(rule.Id, referencedId, StringComparison.OrdinalIgnoreCase);
if (!DnsConfiguration.IsValidProxyId(rule.Id))
{
if (!referenced)
rule.Id = null;
continue;
}

if (!seen.Add(rule.Id) && !referenced)
rule.Id = null;
}
}

public DnsSettings NormalizeDns(DnsSettings dns)
{
if (dns == null)
throw new ArgumentNullException(nameof(dns));

var mode = dns.Mode == null ? null : dns.Mode.Trim();
DnsRoutingMode parsed;
if (DnsConfiguration.TryGetMode(mode, out parsed))
mode = parsed == DnsRoutingMode.Proxy ? DnsConfiguration.ProxyMode : DnsConfiguration.DirectMode;

return new DnsSettings
{
Mode = mode,
ProxyId = EmptyToNull(dns.ProxyId),
ServerOverride = EmptyToNull(dns.ServerOverride),
ExtensionData = CloneExtensionData(dns.ExtensionData)
};
}

private static string EmptyToNull(string value)
{
if (value == null)
return null;
var trimmed = value.Trim();
return trimmed.Length == 0 ? null : trimmed;
}

public ProxyRule NormalizeRule(ProxyRule rule)
{
if (rule == null)
Expand Down Expand Up @@ -64,6 +125,7 @@ public ProxyRule NormalizeRule(ProxyRule rule)
var hasCanonicalTransport = TryGetCanonicalTransport(rule.Socks5Transport, out transport);
return new ProxyRule
{
Id = EmptyToNull(rule.Id),
AppNames = appNames,
Socks5ProxyEndpoint = rule.Socks5ProxyEndpoint == null ? null : rule.Socks5ProxyEndpoint.Trim(),
Username = rule.Username,
Expand Down
88 changes: 87 additions & 1 deletion ProxiFyre.Configuration/ConfigurationSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,25 @@ public ProxiFyreConfiguration Deserialize(string json)
JObject root;
try
{
root = JObject.Parse(json);
// JObject.Parse would turn ISO date-time strings (a password, for example) into
// dates and re-format them; the settings' DateParseHandling does not apply to it.
using (var reader = new JsonTextReader(new StringReader(json)) { DateParseHandling = DateParseHandling.None })
{
root = JObject.Load(reader);
// Like JObject.Parse: only comments may follow the object.
while (reader.Read())
{
}
}
}
catch (JsonException ex)
{
throw new ConfigurationFormatException(
"The configuration is not a valid JSON object.", ex);
}

PrepareKeysEarlierReleasesIgnored(root);

ProxiFyreConfiguration configuration;
try
{
Expand All @@ -91,6 +102,81 @@ public ProxiFyreConfiguration Deserialize(string json)
return configuration;
}

/// <summary>
/// Earlier releases kept a rule "id" and a top-level "dns" property as unknown data and
/// ignored them. A rule id that is an object or array is turned into its JSON text, which
/// the validator then reports as an invalid id (a warning unless DNS uses it), so such a
/// configuration still loads. A "dns" value that is not an object, or a DNS setting that
/// is an object or array, is a configuration error that names the property. So are two
/// "id" (or "dns") keys that differ only in case: earlier releases kept both, and reading
/// one would silently discard the other.
/// </summary>
private static void PrepareKeysEarlierReleasesIgnored(JObject root)
{
RejectCaseVariants(root, "dns", "The configuration");
foreach (var proxies in PropertiesNamed(root, "proxies"))
{
var rules = proxies.Value as JArray;
if (rules == null)
continue;
for (var index = 0; index < rules.Count; index++)
{
var rule = rules[index] as JObject;
if (rule == null)
continue;
RejectCaseVariants(rule, "id", "Proxy rule " + (index + 1));
foreach (var id in PropertiesNamed(rule, "id"))
{
if (id.Value.Type == JTokenType.Object || id.Value.Type == JTokenType.Array)
id.Value = new JValue(id.Value.ToString(Formatting.None));
}
}
}

foreach (var dns in PropertiesNamed(root, "dns"))
{
if (dns.Value.Type == JTokenType.Null)
continue;
var settings = dns.Value as JObject;
if (settings == null)
{
throw new ConfigurationFormatException(
"The '" + dns.Name + "' property must be an object such as " +
"{ \"mode\": \"Proxy\", \"proxyId\": \"office\" }, or be removed to keep DNS Direct.");
}

foreach (var setting in settings.Properties())
{
var known = new[] { "mode", "proxyId", "serverOverride" }.FirstOrDefault(
name => string.Equals(name, setting.Name, StringComparison.OrdinalIgnoreCase));
if (known != null && (setting.Value.Type == JTokenType.Object || setting.Value.Type == JTokenType.Array))
{
throw new ConfigurationFormatException(
"The '" + dns.Name + "." + setting.Name + "' property must be a string.");
}
}
}
}

private static void RejectCaseVariants(JObject parent, string name, string owner)
{
var variants = PropertiesNamed(parent, name);
if (variants.Length > 1)
{
throw new ConfigurationFormatException(
owner + " has more than one '" + name + "' property (" +
string.Join(", ", variants.Select(p => "'" + p.Name + "'")) +
"); names differ only in case. Keep one of them.");
}
}

private static JProperty[] PropertiesNamed(JObject parent, string name)
{
return parent.Properties()
.Where(p => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase))
.ToArray();
}

/// <summary>
/// Creates a lossless editable copy, including credentials and unknown extension fields.
/// Keeping this operation here prevents UI projects from taking a direct JSON dependency.
Expand Down
Loading
Loading