42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
![]() |
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Diagnostics;
|
||
|
using cloud.insecurity.docker.network.IPRoute;
|
||
|
using System.IO;
|
||
|
using Newtonsoft.Json;
|
||
|
|
||
|
namespace cloud.insecurity.docker.network
|
||
|
{
|
||
|
public static class IProute
|
||
|
{
|
||
|
public static IEnumerable<Addr> Addresses()
|
||
|
{
|
||
|
var data = Process
|
||
|
.Start(new ProcessStartInfo()
|
||
|
{
|
||
|
FileName = @"/sbin/ip",
|
||
|
Arguments = "-j",
|
||
|
RedirectStandardOutput = true
|
||
|
})?.StandardOutput.ReadToEnd();
|
||
|
|
||
|
var addresses = JsonConvert.DeserializeObject<IEnumerable<Addr>>(data);
|
||
|
|
||
|
if (addresses == null) throw new ArgumentNullException();
|
||
|
|
||
|
foreach (Addr address in addresses)
|
||
|
{
|
||
|
yield return address;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static IEnumerable<Link> Links()
|
||
|
{
|
||
|
throw new NotImplementedException();
|
||
|
}
|
||
|
|
||
|
public static IEnumerable<Route> Routes()
|
||
|
{
|
||
|
throw new NotImplementedException();
|
||
|
}
|
||
|
}
|
||
|
}
|