change guid byte partition for ipv4 to use only the second and third group of the guid

This commit is contained in:
seroquel 2021-10-08 10:00:28 -07:00
parent 3fc94a336f
commit 0be549b2de
9 changed files with 12 additions and 7 deletions

View File

@ -114,7 +114,8 @@ namespace cloud.insecurity.docker.ipam
if (bytes.Length == 4)
{
bytes = new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}.Concat(bytes).ToArray();
bytes = new byte[] {0, 0, 0, 0}.Concat(bytes).ToArray()
.Concat(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0}).ToArray();
}
//bytes = bytes.Select(b => Convert.ToByte(b ^ prefixLen)).ToArray();
@ -125,17 +126,21 @@ namespace cloud.insecurity.docker.ipam
{
// https://en.wikipedia.org/wiki/Universally_unique_identifier#History
return new Guid(
b.ReadUInt32(),
b.ReadUInt16(),
b.ReadUInt16(),
b.ReadUInt32(), // time low
b.ReadUInt16(), // time mid
b.ReadUInt16(), // time hi and version
b.ReadByte(), // clock seq hi and res?
b.ReadByte(), // clock seq lo?
b.ReadByte(),
b.ReadByte(),
b.ReadByte(),
b.ReadByte(),
b.ReadByte(),
b.ReadByte(),
b.ReadByte(),
b.ReadByte());
b.ReadByte() /* 48-bit node id */);
// however this is RFC4122 (g)UUID and the information
// is definitely not relevant but a nice piece of
// nostalgia.
}
}
}