ci/woodpecker/push/main-amd64-build Pipeline was successful
Agent, Probe and Backend now start from one static compose.yaml plus a local
.env: the panel (or the release assets, for the very first Backend) provides
the file, the panel's command writes the public values into .env, checks the
file's SHA-256 and runs compose up. Updating is compose pull && compose up -d.
The image is chosen by the CI channel (:latest, or MOSHIRO_VERSION in .env),
not by the panel; the previous one-line script stays as a fallback.
- packaging/compose/{agent,probe,backend}/compose.yaml are the single source,
embedded in the Backend and served at /install/compose/{file}; the root
compose.yaml moved there. Releases also carry them and list them in the
signed SHA256SUMS.
- The container entrypoint defaults the node name to the host name.
- Join token creation returns a compose block (.env, url, hash, per-platform
commands); the admin dialog leads with it.
- Remove code with no references (HotLayer members, LiveHub.SubscriberCount,
QueryService.ParseParams, ReleaseService.Forget, a few constants) and reduce
the install-code lookup to the role it is for.
55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
using System.Buffers.Binary;
|
|
|
|
namespace Fleet.Core;
|
|
|
|
/// <summary>LEB128 变长整数(无符号),以及 zigzag 有符号映射。</summary>
|
|
public static class VarInt
|
|
{
|
|
public const int MaxBytes = 10;
|
|
|
|
public static ulong ZigZag(long value) => (ulong)((value << 1) ^ (value >> 63));
|
|
|
|
public static long UnZigZag(ulong value) => (long)(value >> 1) ^ -(long)(value & 1);
|
|
|
|
public static int Write(Span<byte> destination, ulong value)
|
|
{
|
|
int i = 0;
|
|
while (value >= 0x80)
|
|
{
|
|
destination[i++] = (byte)(value | 0x80);
|
|
value >>= 7;
|
|
}
|
|
|
|
destination[i++] = (byte)value;
|
|
return i;
|
|
}
|
|
|
|
public static void Write(Stream destination, ulong value)
|
|
{
|
|
Span<byte> buffer = stackalloc byte[MaxBytes];
|
|
int n = Write(buffer, value);
|
|
destination.Write(buffer[..n]);
|
|
}
|
|
|
|
/// <summary>读取失败(数据被截断或超过 10 字节)时返回 false。</summary>
|
|
public static bool TryRead(ReadOnlySpan<byte> source, out ulong value, out int consumed)
|
|
{
|
|
value = 0;
|
|
consumed = 0;
|
|
int shift = 0;
|
|
while (consumed < source.Length && consumed < MaxBytes)
|
|
{
|
|
byte b = source[consumed++];
|
|
value |= (ulong)(b & 0x7F) << shift;
|
|
if ((b & 0x80) == 0)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
shift += 7;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|