- Behind your provider's shared address, me-web? now shows how its exit hands out ports (kept, one after another, from one block, or at random), the range it gave this device, and how many customers may share the address at most; the estimate sharpens with each check on the same address. - It tests whether two devices behind the same address can reach each other (hairpin), and how long an unused connection stays open: the card says "measuring" for about two minutes after the check, then the answer. - With the test from outside, the publisher's server also traces the route back to your address: your provider's routers and the networks in between appear on the path, with their names. - The provider card says which networks your provider reaches the internet through. - On mobile data, the path shows the operator and the type of network (5G, 4G) read from the phone; on Android 13 and later the phone asks once for permission to read the network type. - The speed card adds the round trip to the publisher's server. - The network data now comes from the publisher's server, refreshed there from open sources: iptoasn.com, DB-IP Lite (CC BY 4.0), the University of Oregon Route Views Project (CC BY 4.0) and the Android Open Source Project's list of mobile operators (Apache 2.0); the release notes list each source's date and checksum. - Source links in the cards wrap instead of being cut off. - New strings, drafted in every language. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012CzABvBkbcFqoHdmi8b9WB
64 lines
2.3 KiB
C#
64 lines
2.3 KiB
C#
using System.IO.Compression;
|
|
using System.Text;
|
|
|
|
namespace MeWeb.Core.Knowledge;
|
|
|
|
public class NetworkInfo
|
|
{
|
|
public uint Number { get; set; }
|
|
public string Organisation { get; set; }
|
|
public List<uint> Upstreams { get; set; } = [];
|
|
}
|
|
|
|
public sealed class NetworkTable
|
|
{
|
|
const uint Magic = 0x324B574D;
|
|
|
|
readonly Dictionary<uint, NetworkInfo> networks = [];
|
|
|
|
public DateTimeOffset BuiltAt { get; private set; }
|
|
|
|
public int Count => networks.Count;
|
|
|
|
public NetworkInfo Find(uint number) => networks.GetValueOrDefault(number);
|
|
|
|
public static NetworkTable Read(Stream compressed)
|
|
{
|
|
using var brotli = new BrotliStream(compressed, CompressionMode.Decompress);
|
|
using var reader = new BinaryReader(brotli, Encoding.UTF8);
|
|
if (reader.ReadUInt32() != Magic) throw new InvalidDataException("not a me-web? network table");
|
|
var table = new NetworkTable { BuiltAt = DateTimeOffset.FromUnixTimeSeconds(reader.ReadInt64()) };
|
|
var count = reader.Read7BitEncodedInt();
|
|
var previous = 0u;
|
|
for (var i = 0; i < count; i++)
|
|
{
|
|
previous += (uint)reader.Read7BitEncodedInt64();
|
|
var info = new NetworkInfo { Number = previous, Organisation = reader.ReadString() };
|
|
var upstreams = reader.Read7BitEncodedInt();
|
|
for (var u = 0; u < upstreams; u++) info.Upstreams.Add((uint)reader.Read7BitEncodedInt64());
|
|
if (info.Organisation.Length == 0) info.Organisation = null;
|
|
table.networks[info.Number] = info;
|
|
}
|
|
return table;
|
|
}
|
|
|
|
public static void Write(Stream output, DateTimeOffset builtAt, IEnumerable<NetworkInfo> networks)
|
|
{
|
|
var list = networks.Where(n => n.Number != 0).OrderBy(n => n.Number).ToList();
|
|
using var brotli = new BrotliStream(output, CompressionLevel.SmallestSize, leaveOpen: true);
|
|
using var writer = new BinaryWriter(brotli, Encoding.UTF8);
|
|
writer.Write(Magic);
|
|
writer.Write(builtAt.ToUnixTimeSeconds());
|
|
writer.Write7BitEncodedInt(list.Count);
|
|
var previous = 0u;
|
|
foreach (var info in list)
|
|
{
|
|
writer.Write7BitEncodedInt64(info.Number - previous);
|
|
writer.Write(info.Organisation ?? "");
|
|
writer.Write7BitEncodedInt(info.Upstreams.Count);
|
|
foreach (var upstream in info.Upstreams) writer.Write7BitEncodedInt64(upstream);
|
|
previous = info.Number;
|
|
}
|
|
}
|
|
}
|