mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 13:08:24 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
1 changed files with 768360 additions and 0 deletions
|
|
@ -0,0 +1,34 @@
|
|||
using System.Buffers.Binary;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Brutal.RakNetApi;
|
||||
|
||||
public partial struct SystemAddress
|
||||
{
|
||||
public SystemAddress()
|
||||
{
|
||||
// All other fields should be initialised to their default values, which will be 0.
|
||||
Address.Addr4.SinFamily = (ushort)AddressFamily.InterNetwork;
|
||||
SystemIndex = unchecked((ushort)(-1));
|
||||
DebugPort = 0;
|
||||
}
|
||||
|
||||
[Pure]
|
||||
public string ToString(bool includePort = false, char portDelimiter = ':')
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (byte* b = &Address.Addr4.SinAddr.SUn.SUnB.SB1)
|
||||
{
|
||||
var ip = new IPAddress(new ReadOnlySpan<byte>(b, sizeof(SUnBSUnInAddr)));
|
||||
var port = BinaryPrimitives.ReverseEndianness(Address.Addr4.SinPort);
|
||||
return ip + (includePort ? $"{portDelimiter}{port}" : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly SystemAddress UNASSIGNED_SYSTEM_ADDRESS = new();
|
||||
}
|
||||
Loading…
Reference in a new issue