fix: replace broken private IP checker with IPNetwork library
This commit is contained in:
parent
fc7a6357c0
commit
7c37726afb
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -55,6 +55,14 @@ public static class DispatchExt
|
||||
return new StringContent(JsonConvert.SerializeObject(o), Encoding.UTF8, "application/json");
|
||||
}
|
||||
|
||||
private static List<IPNetwork> _privateNetworks = new()
|
||||
{
|
||||
IPNetwork.IANA_ABLK_RESERVED1, // 10/8
|
||||
IPNetwork.IANA_CBLK_RESERVED1, // 192.168/16
|
||||
IPNetwork.Parse("127.0.0.0/8"),
|
||||
IPNetwork.Parse("169.254.0.0/16"),
|
||||
};
|
||||
|
||||
public static async Task<bool> ValidateUri(string url)
|
||||
{
|
||||
IPHostEntry host = null;
|
||||
@ -77,15 +85,7 @@ public static class DispatchExt
|
||||
foreach (var address in host.AddressList.Where(address =>
|
||||
address.AddressFamily is AddressFamily.InterNetwork))
|
||||
{
|
||||
if ((address.Address & 0x7f000000) == 0x7f000000) // 127.0/8
|
||||
return false;
|
||||
if ((address.Address & 0xa000000) == 0xa000000) // 10.0/8
|
||||
return false;
|
||||
if ((address.Address & 0xa9fe0000) == 0xa9fe0000) // 169.254/16
|
||||
return false;
|
||||
if ((address.Address & 0xac100000) == 0xac100000) // 172.16/12
|
||||
return false;
|
||||
if ((address.Address & 0xc0a80000) == 0xc0a80000) // 192.168/16
|
||||
if (_privateNetworks.Any(net => net.Contains(address)))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -16,48 +16,49 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="App.Metrics" Version="4.1.0"/>
|
||||
<PackageReference Include="App.Metrics.Reporting.InfluxDB" Version="4.1.0"/>
|
||||
<PackageReference Include="Autofac" Version="6.0.0"/>
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0"/>
|
||||
<PackageReference Include="Dapper" Version="2.0.35"/>
|
||||
<PackageReference Include="Dapper.Contrib" Version="2.0.35"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.10"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.10"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.10"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="3.1.10"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.10"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.10"/>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.10"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.10"/>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
|
||||
<PackageReference Include="NodaTime" Version="3.0.3"/>
|
||||
<PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.0.0"/>
|
||||
<PackageReference Include="Npgsql" Version="4.1.5"/>
|
||||
<PackageReference Include="Npgsql.NodaTime" Version="4.1.5"/>
|
||||
<PackageReference Include="Serilog" Version="2.10.0"/>
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1"/>
|
||||
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0"/>
|
||||
<PackageReference Include="Serilog.NodaTime" Version="3.0.0"/>
|
||||
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.1-dev-00071"/>
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834"/>
|
||||
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="8.4.1"/>
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0"/>
|
||||
<PackageReference Include="SqlKata" Version="2.3.7"/>
|
||||
<PackageReference Include="SqlKata.Execution" Version="2.3.7"/>
|
||||
<PackageReference Include="System.Interactive.Async" Version="5.0.0"/>
|
||||
<PackageReference Include="App.Metrics" Version="4.1.0" />
|
||||
<PackageReference Include="App.Metrics.Reporting.InfluxDB" Version="4.1.0" />
|
||||
<PackageReference Include="Autofac" Version="6.0.0" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
|
||||
<PackageReference Include="Dapper" Version="2.0.35" />
|
||||
<PackageReference Include="Dapper.Contrib" Version="2.0.35" />
|
||||
<PackageReference Include="ipnetwork2" Version="2.5.381" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="3.1.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.10" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="NodaTime" Version="3.0.3" />
|
||||
<PackageReference Include="NodaTime.Serialization.JsonNet" Version="3.0.0" />
|
||||
<PackageReference Include="Npgsql" Version="4.1.5" />
|
||||
<PackageReference Include="Npgsql.NodaTime" Version="4.1.5" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
|
||||
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
|
||||
<PackageReference Include="Serilog.NodaTime" Version="3.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.1-dev-00071" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0-dev-00834" />
|
||||
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="8.4.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
|
||||
<PackageReference Include="SqlKata" Version="2.3.7" />
|
||||
<PackageReference Include="SqlKata.Execution" Version="2.3.7" />
|
||||
<PackageReference Include="System.Interactive.Async" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Database/**/*.sql"/>
|
||||
<EmbeddedResource Include="Database/**/*.sql" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="SetSourceRevisionId" BeforeTargets="InitializeSourceControlInformation">
|
||||
<Exec Command="git log -1 --format='%H' > ../.version" IgnoreExitCode="False">
|
||||
<Exec Command="git log -1 --format='%H' > ../.version" IgnoreExitCode="False">
|
||||
</Exec>
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\.version" LogicalName="version"/>
|
||||
<EmbeddedResource Include="..\.version" LogicalName="version" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user