Clean nullable warnings in traffic router

This commit is contained in:
MaxFan
2026-05-11 21:25:14 +03:30
parent a51bcbdadd
commit 247c59c563
3 changed files with 7 additions and 5 deletions
@@ -121,7 +121,7 @@ public partial class TrafficRouterService
for (int hop = 0; hop < 8 && current > 4; hop++) for (int hop = 0; hop < 8 && current > 4; hop++)
{ {
var name = GetProcessNameByPid(current); var name = GetProcessNameByPid(current);
if (IsExecutableTargeted(name)) if (!string.IsNullOrWhiteSpace(name) && IsExecutableTargeted(name))
{ {
_pidTargetOwnerCache[pid] = name; _pidTargetOwnerCache[pid] = name;
return name; return name;
@@ -75,7 +75,7 @@ public partial class TrafficRouterService
if (TryParseConnectionTuple(buffer, readLen, out var tuple)) if (TryParseConnectionTuple(buffer, readLen, out var tuple))
{ {
var processName = connectionCache.GetProcessName(tuple); var processName = connectionCache.GetProcessName(tuple);
if (IsExecutableTargeted(processName)) if (!string.IsNullOrWhiteSpace(processName) && IsExecutableTargeted(processName))
{ {
shouldRedirect = true; shouldRedirect = true;
matchedProcess = processName; matchedProcess = processName;
@@ -99,7 +99,9 @@ public partial class TrafficRouterService
} }
isBlockedProc = !_fullRouteEnabled && IsExecutableBlocked(packetProc); isBlockedProc = !_fullRouteEnabled && IsExecutableBlocked(packetProc);
if (!shouldRoute && !isBlockedProc && IsExecutableTargeted(packetProc)) if (!shouldRoute && !isBlockedProc &&
!string.IsNullOrWhiteSpace(packetProc) &&
IsExecutableTargeted(packetProc))
{ {
shouldRoute = true; shouldRoute = true;
_ipToProcess[dstNbo] = packetProc; _ipToProcess[dstNbo] = packetProc;
@@ -202,7 +204,7 @@ public partial class TrafficRouterService
dnsProc = connCache.GetProcessName(tuple2); dnsProc = connCache.GetProcessName(tuple2);
} }
if (IsExecutableTargeted(dnsProc)) if (!string.IsNullOrWhiteSpace(dnsProc) && IsExecutableTargeted(dnsProc))
{ {
uint publicDnsNbo = _dnsRedirectIpNbo; uint publicDnsNbo = _dnsRedirectIpNbo;
@@ -275,7 +277,7 @@ public partial class TrafficRouterService
} }
// Check if source app is in target tunnel apps // Check if source app is in target tunnel apps
if (IsExecutableTargeted(procName)) if (!string.IsNullOrWhiteSpace(procName) && IsExecutableTargeted(procName))
{ {
shouldRoute = true; shouldRoute = true;
} }