Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update ipcheck #454

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions tools/ipcheck/host/build/dotnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ pub fn build() -> std::io::Result<&'static str> {
"../artifacts/dotnet/IPCheck.csproj",
)?;

let output = std::process::Command::new("dotnet").args(&["--version"]).output()?;
let output = std::process::Command::new("dotnet")
.args(&["--version"])
.output()?;

if output.status.success() {
Ok("dotnet run -p ../artifacts/dotnet/IpCheck.csproj")
Ok("dotnet run --project ../artifacts/dotnet/IpCheck.csproj")
} else {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
Expand Down
78 changes: 56 additions & 22 deletions tools/ipcheck/impls/dotnet/IPCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,62 @@ static void Main(string[] args)
var input = args[0];
var addr = IPAddress.Parse(input);

var data = new {
to_ipv4 = addr.MapToIPv4().ToString(),
to_ipv6 = addr.MapToIPv6().ToString(),
is_unspecified = "<unsupported>",
is_loopback = IPAddress.IsLoopback(addr),
is_reserved = "<unsupported>",
is_benchmarking = "<unsupported>",
is_documentation = "<unsupported>",
is_global = "<unsupported>",
is_shared = "<unsupported>",
is_unicast_link_local = addr.IsIPv6LinkLocal,
is_unique_local = "<unsupported>",
mc_scope_admin_local = "<unsupported>",
mc_scope_global = "<unsupported>",
mc_scope_iface_local = "<unsupported>",
mc_scope_link_local = "<unsupported>",
mc_scope_org_local = "<unsupported>",
mc_scope_realm_local = "<unsupported>",
mc_scope_reserved = "<unsupported>",
mc_scope_unassigned = "<unsupported>"
};
if (addr.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{

var data = new
{
to_ipv4 = addr.MapToIPv4().ToString(),
to_ipv6 = addr.MapToIPv6().ToString(),
is_unspecified = "<unsupported>",
is_loopback = IPAddress.IsLoopback(addr),
is_reserved = "<unsupported>",
is_benchmarking = "<unsupported>",
is_documentation = "<unsupported>",
is_global = "<unsupported>",
is_shared = "<unsupported>",
is_unicast_link_local = "<unsupported>",
is_unique_local = "<unsupported>",
mc_scope_admin_local = "<unsupported>",
mc_scope_global = "<unsupported>",
mc_scope_iface_local = "<unsupported>",
mc_scope_link_local = "<unsupported>",
mc_scope_org_local = "<unsupported>",
mc_scope_realm_local = "<unsupported>",
mc_scope_reserved = "<unsupported>",
mc_scope_unassigned = "<unsupported>"
};

Console.WriteLine("{0}", JsonSerializer.Serialize(data));
}
else
{

var data = new
{
to_ipv4 = addr.MapToIPv4().ToString(),
to_ipv6 = addr.MapToIPv6().ToString(),
is_unspecified = "<unsupported>",
is_loopback = IPAddress.IsLoopback(addr),
is_reserved = "<unsupported>",
is_benchmarking = "<unsupported>",
is_documentation = "<unsupported>",
is_global = "<unsupported>",
is_shared = "<unsupported>",
is_unicast_link_local = addr.IsIPv6LinkLocal,
is_unique_local = "<unsupported>",
mc_scope_admin_local = "<unsupported>",
mc_scope_global = "<unsupported>",
mc_scope_iface_local = "<unsupported>",
mc_scope_link_local = "<unsupported>",
mc_scope_org_local = "<unsupported>",
mc_scope_realm_local = "<unsupported>",
mc_scope_reserved = "<unsupported>",
mc_scope_unassigned = "<unsupported>"
};

Console.WriteLine("{0}", JsonSerializer.Serialize(data));
}

Console.WriteLine("{0}", JsonSerializer.Serialize(data));
}
}
2 changes: 1 addition & 1 deletion tools/ipcheck/impls/dotnet/IPCheck.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>9</LangVersion>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion tools/ipcheck/impls/rust_current/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() {
"is_global": addr.is_global(),
"is_unicast_link_local": match addr {
IpAddr::V4(addr) => addr.is_link_local(),
IpAddr::V6(_) => false,
IpAddr::V6(addr) => addr.is_unicast_link_local(),
},
"is_unspecified": addr.is_unspecified(),
"is_unique_local": match addr {
Expand Down