@omnibuf/node 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/bin/conformance-es.d.ts +3 -0
- package/dist/bin/conformance-es.d.ts.map +1 -0
- package/dist/bin/conformance-es.js +29 -0
- package/dist/bin/conformance-es.js.map +1 -0
- package/dist/conformance.d.ts +49 -0
- package/dist/conformance.d.ts.map +1 -0
- package/dist/conformance.js +505 -0
- package/dist/conformance.js.map +1 -0
- package/dist/gen/peer_omnibuf.pb.d.ts +109 -0
- package/dist/gen/peer_omnibuf.pb.d.ts.map +1 -0
- package/dist/gen/peer_omnibuf.pb.js +1596 -0
- package/dist/gen/peer_omnibuf.pb.js.map +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +323 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -3
- package/README.md +0 -3
|
@@ -0,0 +1,1596 @@
|
|
|
1
|
+
// Code generated by protoc-gen-omnibuf-es. DO NOT EDIT.
|
|
2
|
+
// source: peer.proto
|
|
3
|
+
import { Encoder, MaxNestingDepth, appendStringArrBody, appendUint32ArrBody, countSubMsgArrElems, decodeSchemaMeta, decodeUTF8, decodeVarintAuto, decodeVarintBigInt, decodeZigZag, defineMessage, float32FromBits, readBool, readFloat32, readFloat64, readFloat64At, readInt, readLenSlice, readString, readStringArr, readSubMsgArrDecoded, readSubMsgMerged, readUint, readUint32Arr, readUintAuto, roundFloat32Shortest, spliceFields, validateValue, writeField0SchemaMeta, } from '@omnibuf/core';
|
|
4
|
+
export const LocationSchema = defineMessage('omnibuf.bench.Location', {
|
|
5
|
+
region: { fieldNum: 1, type: 'string' },
|
|
6
|
+
datacenter: { fieldNum: 2, type: 'string' },
|
|
7
|
+
city: { fieldNum: 3, type: 'string' },
|
|
8
|
+
rack: { fieldNum: 4, type: 'uint32' },
|
|
9
|
+
latitude: { fieldNum: 5, type: 'float32' },
|
|
10
|
+
longitude: { fieldNum: 6, type: 'float32' },
|
|
11
|
+
});
|
|
12
|
+
class LocationMsg {
|
|
13
|
+
region = '';
|
|
14
|
+
datacenter = '';
|
|
15
|
+
city = '';
|
|
16
|
+
rack = 0;
|
|
17
|
+
latitude = 0;
|
|
18
|
+
longitude = 0;
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(LocationMsg.prototype, '$typeName', {
|
|
21
|
+
value: 'omnibuf.bench.Location',
|
|
22
|
+
enumerable: false,
|
|
23
|
+
writable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
});
|
|
26
|
+
export function createLocation(init) {
|
|
27
|
+
if (init === undefined)
|
|
28
|
+
return new LocationMsg();
|
|
29
|
+
return LocationSchema.create(init);
|
|
30
|
+
}
|
|
31
|
+
export function encodeLocation(enc, msg, options) {
|
|
32
|
+
enc.writeString(1, msg.region ?? '');
|
|
33
|
+
enc.writeString(2, msg.datacenter ?? '');
|
|
34
|
+
enc.writeString(3, msg.city ?? '');
|
|
35
|
+
enc.writeUint(4, msg.rack ?? 0);
|
|
36
|
+
enc.writeFloat32(5, msg.latitude ?? 0);
|
|
37
|
+
enc.writeFloat32(6, msg.longitude ?? 0);
|
|
38
|
+
if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
|
|
39
|
+
for (const uf of msg.$unknown) {
|
|
40
|
+
enc.writeTag(uf.no, uf.wireType);
|
|
41
|
+
enc.writeRaw(uf.data);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function marshalLocationOmniBuf(msg, options) {
|
|
46
|
+
const enc = new Encoder(256);
|
|
47
|
+
if (options?.selfDescribing) {
|
|
48
|
+
writeField0SchemaMeta(enc, LocationSchema.getSchemaMeta(0, msg), Boolean(options.deterministic));
|
|
49
|
+
}
|
|
50
|
+
encodeLocation(enc, msg, options);
|
|
51
|
+
return enc.finish();
|
|
52
|
+
}
|
|
53
|
+
export function decodeLocation(buf, target, depth = 0, options, startPos = 0, endPos = buf.length) {
|
|
54
|
+
const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
|
|
55
|
+
const readUnknown = options?.readUnknownFields ?? true;
|
|
56
|
+
if (depth > maxDepth) {
|
|
57
|
+
throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
|
|
58
|
+
}
|
|
59
|
+
const out = target ?? new LocationMsg();
|
|
60
|
+
const n = endPos;
|
|
61
|
+
let pos = startPos;
|
|
62
|
+
let unknownFields = Array.isArray(out.$unknown)
|
|
63
|
+
? out.$unknown
|
|
64
|
+
: null;
|
|
65
|
+
while (pos < n) {
|
|
66
|
+
let tag = 0;
|
|
67
|
+
const b0 = buf[pos];
|
|
68
|
+
if ((b0 & 1) !== 0) {
|
|
69
|
+
tag = b0 >>> 1;
|
|
70
|
+
pos += 1;
|
|
71
|
+
}
|
|
72
|
+
else if ((b0 & 2) !== 0) {
|
|
73
|
+
if (pos + 2 > n)
|
|
74
|
+
throw new Error('omnibuf: truncated tag');
|
|
75
|
+
tag = ((b0 | (buf[pos + 1] << 8)) >>> 2) >>> 0;
|
|
76
|
+
pos += 2;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const [t64, tn] = decodeVarintBigInt(buf, pos);
|
|
80
|
+
if (tn === 0 || pos + tn > n || t64 >> 4n > 0xffffffffn)
|
|
81
|
+
throw new Error('omnibuf: invalid tag');
|
|
82
|
+
tag = Number(t64);
|
|
83
|
+
pos += tn;
|
|
84
|
+
}
|
|
85
|
+
const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
|
|
86
|
+
const wt = tag & 0x0f;
|
|
87
|
+
if (fieldNum === 0) {
|
|
88
|
+
if (wt !== 5)
|
|
89
|
+
throw new Error('omnibuf: invalid Field #0 wire type');
|
|
90
|
+
const [meta, nextPos] = readLenSlice(buf.subarray(0, n), pos, 0);
|
|
91
|
+
decodeSchemaMeta(meta, depth + 1, maxDepth);
|
|
92
|
+
pos = nextPos;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
switch (fieldNum) {
|
|
96
|
+
case 1: {
|
|
97
|
+
if (wt !== 3) {
|
|
98
|
+
const valStart = pos;
|
|
99
|
+
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
100
|
+
if (readUnknown) {
|
|
101
|
+
if (!unknownFields)
|
|
102
|
+
unknownFields = [];
|
|
103
|
+
unknownFields.push({
|
|
104
|
+
no: fieldNum,
|
|
105
|
+
wireType: wt,
|
|
106
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
if (pos >= n)
|
|
112
|
+
throw new Error('omnibuf: truncated string');
|
|
113
|
+
const sb = buf[pos];
|
|
114
|
+
if ((sb & 1) !== 0) {
|
|
115
|
+
const sLen = sb >>> 1;
|
|
116
|
+
pos += 1;
|
|
117
|
+
if (pos + sLen > n)
|
|
118
|
+
throw new Error('omnibuf: truncated string');
|
|
119
|
+
out.region = decodeUTF8(buf, pos, pos + sLen);
|
|
120
|
+
pos += sLen;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const [s, nextPos] = readLenSlice(buf.subarray(0, n), pos, 0);
|
|
124
|
+
out.region = decodeUTF8(s);
|
|
125
|
+
pos = nextPos;
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
case 2: {
|
|
130
|
+
if (wt !== 3) {
|
|
131
|
+
const valStart = pos;
|
|
132
|
+
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
133
|
+
if (readUnknown) {
|
|
134
|
+
if (!unknownFields)
|
|
135
|
+
unknownFields = [];
|
|
136
|
+
unknownFields.push({
|
|
137
|
+
no: fieldNum,
|
|
138
|
+
wireType: wt,
|
|
139
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
if (pos >= n)
|
|
145
|
+
throw new Error('omnibuf: truncated string');
|
|
146
|
+
const sb = buf[pos];
|
|
147
|
+
if ((sb & 1) !== 0) {
|
|
148
|
+
const sLen = sb >>> 1;
|
|
149
|
+
pos += 1;
|
|
150
|
+
if (pos + sLen > n)
|
|
151
|
+
throw new Error('omnibuf: truncated string');
|
|
152
|
+
out.datacenter = decodeUTF8(buf, pos, pos + sLen);
|
|
153
|
+
pos += sLen;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const [s, nextPos] = readLenSlice(buf.subarray(0, n), pos, 0);
|
|
157
|
+
out.datacenter = decodeUTF8(s);
|
|
158
|
+
pos = nextPos;
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case 3: {
|
|
163
|
+
if (wt !== 3) {
|
|
164
|
+
const valStart = pos;
|
|
165
|
+
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
166
|
+
if (readUnknown) {
|
|
167
|
+
if (!unknownFields)
|
|
168
|
+
unknownFields = [];
|
|
169
|
+
unknownFields.push({
|
|
170
|
+
no: fieldNum,
|
|
171
|
+
wireType: wt,
|
|
172
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
if (pos >= n)
|
|
178
|
+
throw new Error('omnibuf: truncated string');
|
|
179
|
+
const sb = buf[pos];
|
|
180
|
+
if ((sb & 1) !== 0) {
|
|
181
|
+
const sLen = sb >>> 1;
|
|
182
|
+
pos += 1;
|
|
183
|
+
if (pos + sLen > n)
|
|
184
|
+
throw new Error('omnibuf: truncated string');
|
|
185
|
+
out.city = decodeUTF8(buf, pos, pos + sLen);
|
|
186
|
+
pos += sLen;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
const [s, nextPos] = readLenSlice(buf.subarray(0, n), pos, 0);
|
|
190
|
+
out.city = decodeUTF8(s);
|
|
191
|
+
pos = nextPos;
|
|
192
|
+
}
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
case 4: {
|
|
196
|
+
if (wt !== 0) {
|
|
197
|
+
const valStart = pos;
|
|
198
|
+
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
199
|
+
if (readUnknown) {
|
|
200
|
+
if (!unknownFields)
|
|
201
|
+
unknownFields = [];
|
|
202
|
+
unknownFields.push({
|
|
203
|
+
no: fieldNum,
|
|
204
|
+
wireType: wt,
|
|
205
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
if (pos >= n)
|
|
211
|
+
throw new Error('omnibuf: truncated uint32');
|
|
212
|
+
const vb = buf[pos];
|
|
213
|
+
if ((vb & 1) !== 0) {
|
|
214
|
+
out.rack = vb >>> 1;
|
|
215
|
+
pos += 1;
|
|
216
|
+
}
|
|
217
|
+
else if ((vb & 2) !== 0) {
|
|
218
|
+
if (pos + 2 > n)
|
|
219
|
+
throw new Error('omnibuf: truncated uint32');
|
|
220
|
+
out.rack = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
221
|
+
pos += 2;
|
|
222
|
+
}
|
|
223
|
+
else if ((vb & 4) !== 0) {
|
|
224
|
+
if (pos + 4 > n)
|
|
225
|
+
throw new Error('omnibuf: truncated uint32');
|
|
226
|
+
const u32 = (vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
|
|
227
|
+
out.rack = u32 >>> 3;
|
|
228
|
+
pos += 4;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
if (pos + 9 > n)
|
|
232
|
+
throw new Error('omnibuf: truncated uint32');
|
|
233
|
+
out.rack =
|
|
234
|
+
(buf[pos + 1] |
|
|
235
|
+
(buf[pos + 2] << 8) |
|
|
236
|
+
(buf[pos + 3] << 16) |
|
|
237
|
+
(buf[pos + 4] << 24)) >>>
|
|
238
|
+
0;
|
|
239
|
+
pos += 9;
|
|
240
|
+
}
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
case 5: {
|
|
244
|
+
if (wt !== 10) {
|
|
245
|
+
const valStart = pos;
|
|
246
|
+
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
247
|
+
if (readUnknown) {
|
|
248
|
+
if (!unknownFields)
|
|
249
|
+
unknownFields = [];
|
|
250
|
+
unknownFields.push({
|
|
251
|
+
no: fieldNum,
|
|
252
|
+
wireType: wt,
|
|
253
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
if (n - pos < 4)
|
|
259
|
+
throw new Error('omnibuf: truncated float32');
|
|
260
|
+
const bits = (buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
|
|
261
|
+
out.latitude = roundFloat32Shortest(float32FromBits(bits));
|
|
262
|
+
pos += 4;
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
case 6: {
|
|
266
|
+
if (wt !== 10) {
|
|
267
|
+
const valStart = pos;
|
|
268
|
+
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
269
|
+
if (readUnknown) {
|
|
270
|
+
if (!unknownFields)
|
|
271
|
+
unknownFields = [];
|
|
272
|
+
unknownFields.push({
|
|
273
|
+
no: fieldNum,
|
|
274
|
+
wireType: wt,
|
|
275
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
if (n - pos < 4)
|
|
281
|
+
throw new Error('omnibuf: truncated float32');
|
|
282
|
+
const bits = (buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
|
|
283
|
+
out.longitude = roundFloat32Shortest(float32FromBits(bits));
|
|
284
|
+
pos += 4;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
default: {
|
|
288
|
+
const valStart = pos;
|
|
289
|
+
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
290
|
+
if (readUnknown) {
|
|
291
|
+
if (!unknownFields)
|
|
292
|
+
unknownFields = [];
|
|
293
|
+
unknownFields.push({
|
|
294
|
+
no: fieldNum,
|
|
295
|
+
wireType: wt,
|
|
296
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (unknownFields && unknownFields.length > 0 && !('$unknown' in out)) {
|
|
304
|
+
Object.defineProperty(out, '$unknown', {
|
|
305
|
+
value: unknownFields,
|
|
306
|
+
enumerable: false,
|
|
307
|
+
writable: true,
|
|
308
|
+
configurable: true,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
return out;
|
|
312
|
+
}
|
|
313
|
+
export function unmarshalLocationOmniBuf(buf, options) {
|
|
314
|
+
return decodeLocation(buf, undefined, 0, options);
|
|
315
|
+
}
|
|
316
|
+
LocationSchema.setGeneratedCodec({
|
|
317
|
+
create: () => new LocationMsg(),
|
|
318
|
+
encode: encodeLocation,
|
|
319
|
+
decode: decodeLocation,
|
|
320
|
+
});
|
|
321
|
+
export const NeighborSchema = defineMessage('omnibuf.bench.Neighbor', {
|
|
322
|
+
peerAsn: { fieldNum: 1, name: 'peer_asn', type: 'uint32' },
|
|
323
|
+
router: { fieldNum: 2, type: 'string' },
|
|
324
|
+
latencyUs: { fieldNum: 3, name: 'latency_us', type: 'uint32' },
|
|
325
|
+
established: { fieldNum: 4, type: 'bool' },
|
|
326
|
+
});
|
|
327
|
+
class NeighborMsg {
|
|
328
|
+
peerAsn = 0;
|
|
329
|
+
router = '';
|
|
330
|
+
latencyUs = 0;
|
|
331
|
+
established = false;
|
|
332
|
+
get peer_asn() {
|
|
333
|
+
return this.peerAsn;
|
|
334
|
+
}
|
|
335
|
+
set peer_asn(v) {
|
|
336
|
+
this.peerAsn = v;
|
|
337
|
+
}
|
|
338
|
+
get latency_us() {
|
|
339
|
+
return this.latencyUs;
|
|
340
|
+
}
|
|
341
|
+
set latency_us(v) {
|
|
342
|
+
this.latencyUs = v;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
Object.defineProperty(NeighborMsg.prototype, '$typeName', {
|
|
346
|
+
value: 'omnibuf.bench.Neighbor',
|
|
347
|
+
enumerable: false,
|
|
348
|
+
writable: true,
|
|
349
|
+
configurable: true,
|
|
350
|
+
});
|
|
351
|
+
export function createNeighbor(init) {
|
|
352
|
+
if (init === undefined)
|
|
353
|
+
return new NeighborMsg();
|
|
354
|
+
return NeighborSchema.create(init);
|
|
355
|
+
}
|
|
356
|
+
export function encodeNeighbor(enc, msg, options) {
|
|
357
|
+
enc.writeUint(1, msg.peerAsn ?? msg.peer_asn ?? 0);
|
|
358
|
+
enc.writeString(2, msg.router ?? '');
|
|
359
|
+
enc.writeUint(3, msg.latencyUs ?? msg.latency_us ?? 0);
|
|
360
|
+
enc.writeBool(4, Boolean(msg.established));
|
|
361
|
+
if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
|
|
362
|
+
for (const uf of msg.$unknown) {
|
|
363
|
+
enc.writeTag(uf.no, uf.wireType);
|
|
364
|
+
enc.writeRaw(uf.data);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
export function marshalNeighborOmniBuf(msg, options) {
|
|
369
|
+
const enc = new Encoder(256);
|
|
370
|
+
if (options?.selfDescribing) {
|
|
371
|
+
writeField0SchemaMeta(enc, NeighborSchema.getSchemaMeta(0, msg), Boolean(options.deterministic));
|
|
372
|
+
}
|
|
373
|
+
encodeNeighbor(enc, msg, options);
|
|
374
|
+
return enc.finish();
|
|
375
|
+
}
|
|
376
|
+
export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, endPos = buf.length) {
|
|
377
|
+
const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
|
|
378
|
+
const readUnknown = options?.readUnknownFields ?? true;
|
|
379
|
+
if (depth > maxDepth) {
|
|
380
|
+
throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
|
|
381
|
+
}
|
|
382
|
+
const out = target ?? new NeighborMsg();
|
|
383
|
+
const n = endPos;
|
|
384
|
+
let pos = startPos;
|
|
385
|
+
let unknownFields = Array.isArray(out.$unknown)
|
|
386
|
+
? out.$unknown
|
|
387
|
+
: null;
|
|
388
|
+
while (pos < n) {
|
|
389
|
+
let tag = 0;
|
|
390
|
+
const b0 = buf[pos];
|
|
391
|
+
if ((b0 & 1) !== 0) {
|
|
392
|
+
tag = b0 >>> 1;
|
|
393
|
+
pos += 1;
|
|
394
|
+
}
|
|
395
|
+
else if ((b0 & 2) !== 0) {
|
|
396
|
+
if (pos + 2 > n)
|
|
397
|
+
throw new Error('omnibuf: truncated tag');
|
|
398
|
+
tag = ((b0 | (buf[pos + 1] << 8)) >>> 2) >>> 0;
|
|
399
|
+
pos += 2;
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
const [t64, tn] = decodeVarintBigInt(buf, pos);
|
|
403
|
+
if (tn === 0 || pos + tn > n || t64 >> 4n > 0xffffffffn)
|
|
404
|
+
throw new Error('omnibuf: invalid tag');
|
|
405
|
+
tag = Number(t64);
|
|
406
|
+
pos += tn;
|
|
407
|
+
}
|
|
408
|
+
const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
|
|
409
|
+
const wt = tag & 0x0f;
|
|
410
|
+
if (fieldNum === 0) {
|
|
411
|
+
if (wt !== 5)
|
|
412
|
+
throw new Error('omnibuf: invalid Field #0 wire type');
|
|
413
|
+
const [meta, nextPos] = readLenSlice(buf.subarray(0, n), pos, 0);
|
|
414
|
+
decodeSchemaMeta(meta, depth + 1, maxDepth);
|
|
415
|
+
pos = nextPos;
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
switch (fieldNum) {
|
|
419
|
+
case 1: {
|
|
420
|
+
if (wt !== 0) {
|
|
421
|
+
const valStart = pos;
|
|
422
|
+
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
423
|
+
if (readUnknown) {
|
|
424
|
+
if (!unknownFields)
|
|
425
|
+
unknownFields = [];
|
|
426
|
+
unknownFields.push({
|
|
427
|
+
no: fieldNum,
|
|
428
|
+
wireType: wt,
|
|
429
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
if (pos >= n)
|
|
435
|
+
throw new Error('omnibuf: truncated uint32');
|
|
436
|
+
const vb = buf[pos];
|
|
437
|
+
if ((vb & 1) !== 0) {
|
|
438
|
+
out.peerAsn = vb >>> 1;
|
|
439
|
+
pos += 1;
|
|
440
|
+
}
|
|
441
|
+
else if ((vb & 2) !== 0) {
|
|
442
|
+
if (pos + 2 > n)
|
|
443
|
+
throw new Error('omnibuf: truncated uint32');
|
|
444
|
+
out.peerAsn = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
445
|
+
pos += 2;
|
|
446
|
+
}
|
|
447
|
+
else if ((vb & 4) !== 0) {
|
|
448
|
+
if (pos + 4 > n)
|
|
449
|
+
throw new Error('omnibuf: truncated uint32');
|
|
450
|
+
const u32 = (vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
|
|
451
|
+
out.peerAsn = u32 >>> 3;
|
|
452
|
+
pos += 4;
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
if (pos + 9 > n)
|
|
456
|
+
throw new Error('omnibuf: truncated uint32');
|
|
457
|
+
out.peerAsn =
|
|
458
|
+
(buf[pos + 1] |
|
|
459
|
+
(buf[pos + 2] << 8) |
|
|
460
|
+
(buf[pos + 3] << 16) |
|
|
461
|
+
(buf[pos + 4] << 24)) >>>
|
|
462
|
+
0;
|
|
463
|
+
pos += 9;
|
|
464
|
+
}
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
case 2: {
|
|
468
|
+
if (wt !== 3) {
|
|
469
|
+
const valStart = pos;
|
|
470
|
+
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
471
|
+
if (readUnknown) {
|
|
472
|
+
if (!unknownFields)
|
|
473
|
+
unknownFields = [];
|
|
474
|
+
unknownFields.push({
|
|
475
|
+
no: fieldNum,
|
|
476
|
+
wireType: wt,
|
|
477
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
if (pos >= n)
|
|
483
|
+
throw new Error('omnibuf: truncated string');
|
|
484
|
+
const sb = buf[pos];
|
|
485
|
+
if ((sb & 1) !== 0) {
|
|
486
|
+
const sLen = sb >>> 1;
|
|
487
|
+
pos += 1;
|
|
488
|
+
if (pos + sLen > n)
|
|
489
|
+
throw new Error('omnibuf: truncated string');
|
|
490
|
+
out.router = decodeUTF8(buf, pos, pos + sLen);
|
|
491
|
+
pos += sLen;
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
const [s, nextPos] = readLenSlice(buf.subarray(0, n), pos, 0);
|
|
495
|
+
out.router = decodeUTF8(s);
|
|
496
|
+
pos = nextPos;
|
|
497
|
+
}
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
case 3: {
|
|
501
|
+
if (wt !== 0) {
|
|
502
|
+
const valStart = pos;
|
|
503
|
+
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
504
|
+
if (readUnknown) {
|
|
505
|
+
if (!unknownFields)
|
|
506
|
+
unknownFields = [];
|
|
507
|
+
unknownFields.push({
|
|
508
|
+
no: fieldNum,
|
|
509
|
+
wireType: wt,
|
|
510
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
515
|
+
if (pos >= n)
|
|
516
|
+
throw new Error('omnibuf: truncated uint32');
|
|
517
|
+
const vb = buf[pos];
|
|
518
|
+
if ((vb & 1) !== 0) {
|
|
519
|
+
out.latencyUs = vb >>> 1;
|
|
520
|
+
pos += 1;
|
|
521
|
+
}
|
|
522
|
+
else if ((vb & 2) !== 0) {
|
|
523
|
+
if (pos + 2 > n)
|
|
524
|
+
throw new Error('omnibuf: truncated uint32');
|
|
525
|
+
out.latencyUs = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
526
|
+
pos += 2;
|
|
527
|
+
}
|
|
528
|
+
else if ((vb & 4) !== 0) {
|
|
529
|
+
if (pos + 4 > n)
|
|
530
|
+
throw new Error('omnibuf: truncated uint32');
|
|
531
|
+
const u32 = (vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
|
|
532
|
+
out.latencyUs = u32 >>> 3;
|
|
533
|
+
pos += 4;
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
if (pos + 9 > n)
|
|
537
|
+
throw new Error('omnibuf: truncated uint32');
|
|
538
|
+
out.latencyUs =
|
|
539
|
+
(buf[pos + 1] |
|
|
540
|
+
(buf[pos + 2] << 8) |
|
|
541
|
+
(buf[pos + 3] << 16) |
|
|
542
|
+
(buf[pos + 4] << 24)) >>>
|
|
543
|
+
0;
|
|
544
|
+
pos += 9;
|
|
545
|
+
}
|
|
546
|
+
break;
|
|
547
|
+
}
|
|
548
|
+
case 4: {
|
|
549
|
+
if (wt !== 1 && wt !== 2) {
|
|
550
|
+
const valStart = pos;
|
|
551
|
+
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
552
|
+
if (readUnknown) {
|
|
553
|
+
if (!unknownFields)
|
|
554
|
+
unknownFields = [];
|
|
555
|
+
unknownFields.push({
|
|
556
|
+
no: fieldNum,
|
|
557
|
+
wireType: wt,
|
|
558
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
563
|
+
out.established = wt === 2;
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
default: {
|
|
567
|
+
const valStart = pos;
|
|
568
|
+
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
569
|
+
if (readUnknown) {
|
|
570
|
+
if (!unknownFields)
|
|
571
|
+
unknownFields = [];
|
|
572
|
+
unknownFields.push({
|
|
573
|
+
no: fieldNum,
|
|
574
|
+
wireType: wt,
|
|
575
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (unknownFields && unknownFields.length > 0 && !('$unknown' in out)) {
|
|
583
|
+
Object.defineProperty(out, '$unknown', {
|
|
584
|
+
value: unknownFields,
|
|
585
|
+
enumerable: false,
|
|
586
|
+
writable: true,
|
|
587
|
+
configurable: true,
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
return out;
|
|
591
|
+
}
|
|
592
|
+
export function unmarshalNeighborOmniBuf(buf, options) {
|
|
593
|
+
return decodeNeighbor(buf, undefined, 0, options);
|
|
594
|
+
}
|
|
595
|
+
NeighborSchema.setGeneratedCodec({
|
|
596
|
+
create: () => new NeighborMsg(),
|
|
597
|
+
encode: encodeNeighbor,
|
|
598
|
+
decode: decodeNeighbor,
|
|
599
|
+
});
|
|
600
|
+
export const PeerUpdateSchema = defineMessage('omnibuf.bench.PeerUpdate', {
|
|
601
|
+
asn: { fieldNum: 1, type: 'uint32' },
|
|
602
|
+
routerId: { fieldNum: 2, name: 'router_id', type: 'string' },
|
|
603
|
+
active: { fieldNum: 3, type: 'bool' },
|
|
604
|
+
uptimeSec: { fieldNum: 4, name: 'uptime_sec', type: 'uint64' },
|
|
605
|
+
rssiDbm: { fieldNum: 5, name: 'rssi_dbm', type: 'sint32' },
|
|
606
|
+
cpuLoad: { fieldNum: 6, name: 'cpu_load', type: 'float64' },
|
|
607
|
+
tags: { fieldNum: 7, type: 'string[]' },
|
|
608
|
+
prefixes: { fieldNum: 8, type: 'uint32[]' },
|
|
609
|
+
location: { fieldNum: 9, type: 'submsg', optional: false, subSchema: () => LocationSchema },
|
|
610
|
+
neighbors: { fieldNum: 10, type: 'submsg[]', subSchema: () => NeighborSchema },
|
|
611
|
+
sequence: { fieldNum: 11, type: 'uint64' },
|
|
612
|
+
});
|
|
613
|
+
class PeerUpdateMsg {
|
|
614
|
+
asn = 0;
|
|
615
|
+
routerId = '';
|
|
616
|
+
active = false;
|
|
617
|
+
uptimeSec = 0;
|
|
618
|
+
rssiDbm = 0;
|
|
619
|
+
cpuLoad = 0;
|
|
620
|
+
tags = [];
|
|
621
|
+
prefixes = [];
|
|
622
|
+
location = new LocationMsg();
|
|
623
|
+
neighbors = [];
|
|
624
|
+
sequence = 0;
|
|
625
|
+
get router_id() {
|
|
626
|
+
return this.routerId;
|
|
627
|
+
}
|
|
628
|
+
set router_id(v) {
|
|
629
|
+
this.routerId = v;
|
|
630
|
+
}
|
|
631
|
+
get uptime_sec() {
|
|
632
|
+
return this.uptimeSec;
|
|
633
|
+
}
|
|
634
|
+
set uptime_sec(v) {
|
|
635
|
+
this.uptimeSec = v;
|
|
636
|
+
}
|
|
637
|
+
get rssi_dbm() {
|
|
638
|
+
return this.rssiDbm;
|
|
639
|
+
}
|
|
640
|
+
set rssi_dbm(v) {
|
|
641
|
+
this.rssiDbm = v;
|
|
642
|
+
}
|
|
643
|
+
get cpu_load() {
|
|
644
|
+
return this.cpuLoad;
|
|
645
|
+
}
|
|
646
|
+
set cpu_load(v) {
|
|
647
|
+
this.cpuLoad = v;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
Object.defineProperty(PeerUpdateMsg.prototype, '$typeName', {
|
|
651
|
+
value: 'omnibuf.bench.PeerUpdate',
|
|
652
|
+
enumerable: false,
|
|
653
|
+
writable: true,
|
|
654
|
+
configurable: true,
|
|
655
|
+
});
|
|
656
|
+
export function createPeerUpdate(init) {
|
|
657
|
+
if (init === undefined)
|
|
658
|
+
return new PeerUpdateMsg();
|
|
659
|
+
return PeerUpdateSchema.create(init);
|
|
660
|
+
}
|
|
661
|
+
export function encodePeerUpdate(enc, msg, options) {
|
|
662
|
+
enc.writeUint(1, msg.asn ?? 0);
|
|
663
|
+
enc.writeString(2, msg.routerId ?? msg.router_id ?? '');
|
|
664
|
+
enc.writeBool(3, Boolean(msg.active));
|
|
665
|
+
enc.writeUint(4, msg.uptimeSec ?? msg.uptime_sec ?? 0);
|
|
666
|
+
enc.writeInt(5, msg.rssiDbm ?? msg.rssi_dbm ?? 0);
|
|
667
|
+
enc.writeFloat64(6, msg.cpuLoad ?? msg.cpu_load ?? 0);
|
|
668
|
+
enc.writeStringArr(7, msg.tags ?? []);
|
|
669
|
+
enc.writeUint32Arr(8, msg.prefixes ?? []);
|
|
670
|
+
enc.beginSubMsg(9);
|
|
671
|
+
encodeLocation(enc, msg.location ?? createLocation(), options);
|
|
672
|
+
enc.endSubMsg();
|
|
673
|
+
{
|
|
674
|
+
const arr = msg.neighbors ?? [];
|
|
675
|
+
enc.beginSubMsgArr(10);
|
|
676
|
+
for (let i = 0; i < arr.length; i++) {
|
|
677
|
+
enc.beginSubMsgElem();
|
|
678
|
+
encodeNeighbor(enc, arr[i], options);
|
|
679
|
+
enc.endSubMsgElem();
|
|
680
|
+
}
|
|
681
|
+
enc.endSubMsgArr();
|
|
682
|
+
}
|
|
683
|
+
enc.writeUint(11, msg.sequence ?? 0);
|
|
684
|
+
if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
|
|
685
|
+
for (const uf of msg.$unknown) {
|
|
686
|
+
enc.writeTag(uf.no, uf.wireType);
|
|
687
|
+
enc.writeRaw(uf.data);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
export function marshalPeerUpdateOmniBuf(msg, options) {
|
|
692
|
+
const enc = new Encoder(256);
|
|
693
|
+
if (options?.selfDescribing) {
|
|
694
|
+
writeField0SchemaMeta(enc, PeerUpdateSchema.getSchemaMeta(0, msg), Boolean(options.deterministic));
|
|
695
|
+
}
|
|
696
|
+
encodePeerUpdate(enc, msg, options);
|
|
697
|
+
return enc.finish();
|
|
698
|
+
}
|
|
699
|
+
export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
700
|
+
const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
|
|
701
|
+
const readUnknown = options?.readUnknownFields ?? true;
|
|
702
|
+
if (depth > maxDepth) {
|
|
703
|
+
throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
|
|
704
|
+
}
|
|
705
|
+
const out = target ?? new PeerUpdateMsg();
|
|
706
|
+
const n = buf.length;
|
|
707
|
+
let pos = 0;
|
|
708
|
+
let seenMask = 0;
|
|
709
|
+
let unknownFields = Array.isArray(out.$unknown)
|
|
710
|
+
? out.$unknown
|
|
711
|
+
: null;
|
|
712
|
+
while (pos < n) {
|
|
713
|
+
let tag = 0;
|
|
714
|
+
const b0 = buf[pos];
|
|
715
|
+
if ((b0 & 1) !== 0) {
|
|
716
|
+
tag = b0 >>> 1;
|
|
717
|
+
pos += 1;
|
|
718
|
+
}
|
|
719
|
+
else if ((b0 & 2) !== 0) {
|
|
720
|
+
if (pos + 2 > n)
|
|
721
|
+
throw new Error('omnibuf: truncated tag');
|
|
722
|
+
tag = ((b0 | (buf[pos + 1] << 8)) >>> 2) >>> 0;
|
|
723
|
+
pos += 2;
|
|
724
|
+
}
|
|
725
|
+
else {
|
|
726
|
+
const [t64, tn] = decodeVarintBigInt(buf, pos);
|
|
727
|
+
if (tn === 0 || t64 >> 4n > 0xffffffffn)
|
|
728
|
+
throw new Error('omnibuf: invalid tag');
|
|
729
|
+
tag = Number(t64);
|
|
730
|
+
pos += tn;
|
|
731
|
+
}
|
|
732
|
+
const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
|
|
733
|
+
const wt = tag & 0x0f;
|
|
734
|
+
if (fieldNum === 0) {
|
|
735
|
+
if (wt !== 5)
|
|
736
|
+
throw new Error('omnibuf: invalid Field #0 wire type');
|
|
737
|
+
const [meta, nextPos] = readLenSlice(buf, pos, 0);
|
|
738
|
+
decodeSchemaMeta(meta, depth + 1, maxDepth);
|
|
739
|
+
pos = nextPos;
|
|
740
|
+
continue;
|
|
741
|
+
}
|
|
742
|
+
const bit = fieldNum <= 30 ? 1 << fieldNum : 0;
|
|
743
|
+
const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
|
|
744
|
+
switch (fieldNum) {
|
|
745
|
+
case 1: {
|
|
746
|
+
if (wt !== 0) {
|
|
747
|
+
const valStart = pos;
|
|
748
|
+
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
749
|
+
if (readUnknown) {
|
|
750
|
+
if (!unknownFields)
|
|
751
|
+
unknownFields = [];
|
|
752
|
+
unknownFields.push({
|
|
753
|
+
no: fieldNum,
|
|
754
|
+
wireType: wt,
|
|
755
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
seenMask |= bit;
|
|
761
|
+
if (pos >= n)
|
|
762
|
+
throw new Error('omnibuf: truncated uint32');
|
|
763
|
+
const vb = buf[pos];
|
|
764
|
+
if ((vb & 1) !== 0) {
|
|
765
|
+
out.asn = vb >>> 1;
|
|
766
|
+
pos += 1;
|
|
767
|
+
}
|
|
768
|
+
else if ((vb & 2) !== 0) {
|
|
769
|
+
if (pos + 2 > n)
|
|
770
|
+
throw new Error('omnibuf: truncated uint32');
|
|
771
|
+
out.asn = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
772
|
+
pos += 2;
|
|
773
|
+
}
|
|
774
|
+
else if ((vb & 4) !== 0) {
|
|
775
|
+
if (pos + 4 > n)
|
|
776
|
+
throw new Error('omnibuf: truncated uint32');
|
|
777
|
+
const u32 = (vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
|
|
778
|
+
out.asn = u32 >>> 3;
|
|
779
|
+
pos += 4;
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
if (pos + 9 > n)
|
|
783
|
+
throw new Error('omnibuf: truncated uint32');
|
|
784
|
+
out.asn =
|
|
785
|
+
(buf[pos + 1] |
|
|
786
|
+
(buf[pos + 2] << 8) |
|
|
787
|
+
(buf[pos + 3] << 16) |
|
|
788
|
+
(buf[pos + 4] << 24)) >>>
|
|
789
|
+
0;
|
|
790
|
+
pos += 9;
|
|
791
|
+
}
|
|
792
|
+
break;
|
|
793
|
+
}
|
|
794
|
+
case 2: {
|
|
795
|
+
if (wt !== 3) {
|
|
796
|
+
const valStart = pos;
|
|
797
|
+
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
798
|
+
if (readUnknown) {
|
|
799
|
+
if (!unknownFields)
|
|
800
|
+
unknownFields = [];
|
|
801
|
+
unknownFields.push({
|
|
802
|
+
no: fieldNum,
|
|
803
|
+
wireType: wt,
|
|
804
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
break;
|
|
808
|
+
}
|
|
809
|
+
seenMask |= bit;
|
|
810
|
+
if (pos >= n)
|
|
811
|
+
throw new Error('omnibuf: truncated string');
|
|
812
|
+
const sb = buf[pos];
|
|
813
|
+
if ((sb & 1) !== 0) {
|
|
814
|
+
const sLen = sb >>> 1;
|
|
815
|
+
pos += 1;
|
|
816
|
+
if (pos + sLen > n)
|
|
817
|
+
throw new Error('omnibuf: truncated string');
|
|
818
|
+
out.routerId = decodeUTF8(buf, pos, pos + sLen);
|
|
819
|
+
pos += sLen;
|
|
820
|
+
}
|
|
821
|
+
else {
|
|
822
|
+
const [s, nextPos] = readLenSlice(buf, pos, 0);
|
|
823
|
+
out.routerId = decodeUTF8(s);
|
|
824
|
+
pos = nextPos;
|
|
825
|
+
}
|
|
826
|
+
break;
|
|
827
|
+
}
|
|
828
|
+
case 3: {
|
|
829
|
+
if (wt !== 1 && wt !== 2) {
|
|
830
|
+
const valStart = pos;
|
|
831
|
+
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
832
|
+
if (readUnknown) {
|
|
833
|
+
if (!unknownFields)
|
|
834
|
+
unknownFields = [];
|
|
835
|
+
unknownFields.push({
|
|
836
|
+
no: fieldNum,
|
|
837
|
+
wireType: wt,
|
|
838
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
break;
|
|
842
|
+
}
|
|
843
|
+
seenMask |= bit;
|
|
844
|
+
out.active = wt === 2;
|
|
845
|
+
break;
|
|
846
|
+
}
|
|
847
|
+
case 4: {
|
|
848
|
+
if (wt !== 0) {
|
|
849
|
+
const valStart = pos;
|
|
850
|
+
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
851
|
+
if (readUnknown) {
|
|
852
|
+
if (!unknownFields)
|
|
853
|
+
unknownFields = [];
|
|
854
|
+
unknownFields.push({
|
|
855
|
+
no: fieldNum,
|
|
856
|
+
wireType: wt,
|
|
857
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
seenMask |= bit;
|
|
863
|
+
if (pos >= n)
|
|
864
|
+
throw new Error('omnibuf: truncated uint64');
|
|
865
|
+
const vb = buf[pos];
|
|
866
|
+
if ((vb & 1) !== 0) {
|
|
867
|
+
out.uptimeSec = vb >>> 1;
|
|
868
|
+
pos += 1;
|
|
869
|
+
}
|
|
870
|
+
else if ((vb & 2) !== 0) {
|
|
871
|
+
if (pos + 2 > n)
|
|
872
|
+
throw new Error('omnibuf: truncated uint64');
|
|
873
|
+
out.uptimeSec = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
874
|
+
pos += 2;
|
|
875
|
+
}
|
|
876
|
+
else if ((vb & 4) !== 0) {
|
|
877
|
+
if (pos + 4 > n)
|
|
878
|
+
throw new Error('omnibuf: truncated uint64');
|
|
879
|
+
const u32 = (vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
|
|
880
|
+
out.uptimeSec = u32 >>> 3;
|
|
881
|
+
pos += 4;
|
|
882
|
+
}
|
|
883
|
+
else {
|
|
884
|
+
const [v, vn] = decodeVarintAuto(buf, pos);
|
|
885
|
+
if (vn === 0)
|
|
886
|
+
throw new Error('omnibuf: truncated uint64');
|
|
887
|
+
out.uptimeSec = v;
|
|
888
|
+
pos += vn;
|
|
889
|
+
}
|
|
890
|
+
break;
|
|
891
|
+
}
|
|
892
|
+
case 5: {
|
|
893
|
+
if (wt !== 12) {
|
|
894
|
+
const valStart = pos;
|
|
895
|
+
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
896
|
+
if (readUnknown) {
|
|
897
|
+
if (!unknownFields)
|
|
898
|
+
unknownFields = [];
|
|
899
|
+
unknownFields.push({
|
|
900
|
+
no: fieldNum,
|
|
901
|
+
wireType: wt,
|
|
902
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
break;
|
|
906
|
+
}
|
|
907
|
+
seenMask |= bit;
|
|
908
|
+
if (pos >= n)
|
|
909
|
+
throw new Error('omnibuf: truncated int32');
|
|
910
|
+
const vb = buf[pos];
|
|
911
|
+
if ((vb & 1) !== 0) {
|
|
912
|
+
const u = vb >>> 1;
|
|
913
|
+
out.rssiDbm = (u >>> 1) ^ -(u & 1);
|
|
914
|
+
pos += 1;
|
|
915
|
+
}
|
|
916
|
+
else if ((vb & 2) !== 0) {
|
|
917
|
+
if (pos + 2 > n)
|
|
918
|
+
throw new Error('omnibuf: truncated int32');
|
|
919
|
+
const u = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
920
|
+
out.rssiDbm = (u >>> 1) ^ -(u & 1);
|
|
921
|
+
pos += 2;
|
|
922
|
+
}
|
|
923
|
+
else if ((vb & 4) !== 0) {
|
|
924
|
+
if (pos + 4 > n)
|
|
925
|
+
throw new Error('omnibuf: truncated int32');
|
|
926
|
+
const u = ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
|
|
927
|
+
0;
|
|
928
|
+
out.rssiDbm = (u >>> 1) ^ -(u & 1);
|
|
929
|
+
pos += 4;
|
|
930
|
+
}
|
|
931
|
+
else {
|
|
932
|
+
const [v, vn] = decodeVarintBigInt(buf, pos);
|
|
933
|
+
if (vn === 0)
|
|
934
|
+
throw new Error('omnibuf: truncated int32');
|
|
935
|
+
out.rssiDbm = decodeZigZag(v) | 0;
|
|
936
|
+
pos += vn;
|
|
937
|
+
}
|
|
938
|
+
break;
|
|
939
|
+
}
|
|
940
|
+
case 6: {
|
|
941
|
+
if (wt !== 11) {
|
|
942
|
+
const valStart = pos;
|
|
943
|
+
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
944
|
+
if (readUnknown) {
|
|
945
|
+
if (!unknownFields)
|
|
946
|
+
unknownFields = [];
|
|
947
|
+
unknownFields.push({
|
|
948
|
+
no: fieldNum,
|
|
949
|
+
wireType: wt,
|
|
950
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
break;
|
|
954
|
+
}
|
|
955
|
+
seenMask |= bit;
|
|
956
|
+
if (n - pos < 8)
|
|
957
|
+
throw new Error('omnibuf: truncated float64');
|
|
958
|
+
out.cpuLoad = readFloat64At(buf, pos);
|
|
959
|
+
pos += 8;
|
|
960
|
+
break;
|
|
961
|
+
}
|
|
962
|
+
case 7: {
|
|
963
|
+
if (wt !== 6) {
|
|
964
|
+
const valStart = pos;
|
|
965
|
+
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
966
|
+
if (readUnknown) {
|
|
967
|
+
if (!unknownFields)
|
|
968
|
+
unknownFields = [];
|
|
969
|
+
unknownFields.push({
|
|
970
|
+
no: fieldNum,
|
|
971
|
+
wireType: wt,
|
|
972
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
break;
|
|
976
|
+
}
|
|
977
|
+
seenMask |= bit;
|
|
978
|
+
if (pos >= n)
|
|
979
|
+
throw new Error('omnibuf: invalid string array');
|
|
980
|
+
const lb = buf[pos];
|
|
981
|
+
let bodyLen = 0;
|
|
982
|
+
if ((lb & 2) !== 0) {
|
|
983
|
+
if (pos + 2 > n)
|
|
984
|
+
throw new Error('omnibuf: invalid string array');
|
|
985
|
+
bodyLen = (lb | (buf[pos + 1] << 8)) >>> 2;
|
|
986
|
+
pos += 2;
|
|
987
|
+
}
|
|
988
|
+
else if ((lb & 1) !== 0) {
|
|
989
|
+
bodyLen = lb >>> 1;
|
|
990
|
+
pos += 1;
|
|
991
|
+
}
|
|
992
|
+
else {
|
|
993
|
+
const [body, nextPos] = readLenSlice(buf, pos, 1);
|
|
994
|
+
const prev = alreadySeen && Array.isArray(out.tags) ? out.tags : [];
|
|
995
|
+
const [arr, ok] = appendStringArrBody(prev, body);
|
|
996
|
+
if (!ok)
|
|
997
|
+
throw new Error('omnibuf: invalid string array');
|
|
998
|
+
out.tags = arr;
|
|
999
|
+
pos = nextPos;
|
|
1000
|
+
break;
|
|
1001
|
+
}
|
|
1002
|
+
const bodyEnd = pos + bodyLen;
|
|
1003
|
+
if (bodyLen < 1 || bodyEnd > n)
|
|
1004
|
+
throw new Error('omnibuf: invalid string array');
|
|
1005
|
+
const cb0 = buf[pos];
|
|
1006
|
+
if ((cb0 & 1) !== 0) {
|
|
1007
|
+
const count = cb0 >>> 1;
|
|
1008
|
+
let p = pos + 1;
|
|
1009
|
+
if (count > bodyEnd - p)
|
|
1010
|
+
throw new Error('omnibuf: invalid string array');
|
|
1011
|
+
let dst = out.tags;
|
|
1012
|
+
if (!Array.isArray(dst)) {
|
|
1013
|
+
dst = [];
|
|
1014
|
+
out.tags = dst;
|
|
1015
|
+
}
|
|
1016
|
+
else if (!alreadySeen) {
|
|
1017
|
+
dst.length = 0;
|
|
1018
|
+
}
|
|
1019
|
+
for (let i = 0; i < count; i++) {
|
|
1020
|
+
if (p >= bodyEnd)
|
|
1021
|
+
throw new Error('omnibuf: invalid string array');
|
|
1022
|
+
const sb = buf[p];
|
|
1023
|
+
if ((sb & 1) !== 0) {
|
|
1024
|
+
const sLen = sb >>> 1;
|
|
1025
|
+
p += 1;
|
|
1026
|
+
if (p + sLen > bodyEnd)
|
|
1027
|
+
throw new Error('omnibuf: invalid string array');
|
|
1028
|
+
dst.push(decodeUTF8(buf, p, p + sLen));
|
|
1029
|
+
p += sLen;
|
|
1030
|
+
}
|
|
1031
|
+
else {
|
|
1032
|
+
const [sLen, sn] = decodeVarintBigInt(buf, p);
|
|
1033
|
+
if (sn === 0 || sLen > BigInt(bodyEnd - (p + sn))) {
|
|
1034
|
+
throw new Error('omnibuf: invalid string array');
|
|
1035
|
+
}
|
|
1036
|
+
p += sn;
|
|
1037
|
+
const sLenNum = Number(sLen);
|
|
1038
|
+
dst.push(decodeUTF8(buf, p, p + sLenNum));
|
|
1039
|
+
p += sLenNum;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
if (p !== bodyEnd)
|
|
1043
|
+
throw new Error('omnibuf: invalid string array');
|
|
1044
|
+
pos = bodyEnd;
|
|
1045
|
+
break;
|
|
1046
|
+
}
|
|
1047
|
+
const prev = alreadySeen && Array.isArray(out.tags) ? out.tags : [];
|
|
1048
|
+
const [arr, ok] = appendStringArrBody(prev, buf.subarray(pos, bodyEnd));
|
|
1049
|
+
if (!ok)
|
|
1050
|
+
throw new Error('omnibuf: invalid string array');
|
|
1051
|
+
out.tags = arr;
|
|
1052
|
+
pos = bodyEnd;
|
|
1053
|
+
break;
|
|
1054
|
+
}
|
|
1055
|
+
case 8: {
|
|
1056
|
+
if (wt !== 7) {
|
|
1057
|
+
const valStart = pos;
|
|
1058
|
+
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1059
|
+
if (readUnknown) {
|
|
1060
|
+
if (!unknownFields)
|
|
1061
|
+
unknownFields = [];
|
|
1062
|
+
unknownFields.push({
|
|
1063
|
+
no: fieldNum,
|
|
1064
|
+
wireType: wt,
|
|
1065
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
break;
|
|
1069
|
+
}
|
|
1070
|
+
seenMask |= bit;
|
|
1071
|
+
if (pos >= n)
|
|
1072
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1073
|
+
const lb = buf[pos];
|
|
1074
|
+
let bodyLen = 0;
|
|
1075
|
+
if ((lb & 2) !== 0) {
|
|
1076
|
+
if (pos + 2 > n)
|
|
1077
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1078
|
+
bodyLen = (lb | (buf[pos + 1] << 8)) >>> 2;
|
|
1079
|
+
pos += 2;
|
|
1080
|
+
}
|
|
1081
|
+
else if ((lb & 1) !== 0) {
|
|
1082
|
+
bodyLen = lb >>> 1;
|
|
1083
|
+
pos += 1;
|
|
1084
|
+
}
|
|
1085
|
+
else {
|
|
1086
|
+
const [body, nextPos] = readLenSlice(buf, pos, 1);
|
|
1087
|
+
const prev = alreadySeen && Array.isArray(out.prefixes) ? out.prefixes : [];
|
|
1088
|
+
const [arr, ok] = appendUint32ArrBody(prev, body);
|
|
1089
|
+
if (!ok)
|
|
1090
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1091
|
+
out.prefixes = arr;
|
|
1092
|
+
pos = nextPos;
|
|
1093
|
+
break;
|
|
1094
|
+
}
|
|
1095
|
+
const bodyEnd = pos + bodyLen;
|
|
1096
|
+
if (bodyLen < 1 || bodyEnd > n)
|
|
1097
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1098
|
+
const cb0 = buf[pos];
|
|
1099
|
+
if ((cb0 & 1) !== 0) {
|
|
1100
|
+
const count = cb0 >>> 1;
|
|
1101
|
+
let p = pos + 1;
|
|
1102
|
+
if (count > bodyEnd - p)
|
|
1103
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1104
|
+
let dst = out.prefixes;
|
|
1105
|
+
if (!Array.isArray(dst)) {
|
|
1106
|
+
dst = [];
|
|
1107
|
+
out.prefixes = dst;
|
|
1108
|
+
}
|
|
1109
|
+
else if (!alreadySeen) {
|
|
1110
|
+
dst.length = 0;
|
|
1111
|
+
}
|
|
1112
|
+
for (let i = 0; i < count; i++) {
|
|
1113
|
+
if (p >= bodyEnd)
|
|
1114
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1115
|
+
const vb = buf[p];
|
|
1116
|
+
if ((vb & 1) !== 0) {
|
|
1117
|
+
dst.push(vb >>> 1);
|
|
1118
|
+
p += 1;
|
|
1119
|
+
}
|
|
1120
|
+
else if ((vb & 2) !== 0) {
|
|
1121
|
+
if (p + 2 > bodyEnd)
|
|
1122
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1123
|
+
dst.push((vb | (buf[p + 1] << 8)) >>> 2);
|
|
1124
|
+
p += 2;
|
|
1125
|
+
}
|
|
1126
|
+
else if ((vb & 4) !== 0) {
|
|
1127
|
+
if (p + 4 > bodyEnd)
|
|
1128
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1129
|
+
const u32 = (vb | (buf[p + 1] << 8) | (buf[p + 2] << 16) | (buf[p + 3] << 24)) >>> 0;
|
|
1130
|
+
dst.push(u32 >>> 3);
|
|
1131
|
+
p += 4;
|
|
1132
|
+
}
|
|
1133
|
+
else {
|
|
1134
|
+
if (p + 9 > bodyEnd)
|
|
1135
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1136
|
+
const lo = (buf[p + 1] | (buf[p + 2] << 8) | (buf[p + 3] << 16) | (buf[p + 4] << 24)) >>>
|
|
1137
|
+
0;
|
|
1138
|
+
dst.push(lo);
|
|
1139
|
+
p += 9;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
if (p !== bodyEnd)
|
|
1143
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1144
|
+
pos = bodyEnd;
|
|
1145
|
+
break;
|
|
1146
|
+
}
|
|
1147
|
+
const prev = alreadySeen && Array.isArray(out.prefixes) ? out.prefixes : [];
|
|
1148
|
+
const [arr, ok] = appendUint32ArrBody(prev, buf.subarray(pos, bodyEnd));
|
|
1149
|
+
if (!ok)
|
|
1150
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1151
|
+
out.prefixes = arr;
|
|
1152
|
+
pos = bodyEnd;
|
|
1153
|
+
break;
|
|
1154
|
+
}
|
|
1155
|
+
case 9: {
|
|
1156
|
+
if (wt !== 5) {
|
|
1157
|
+
const valStart = pos;
|
|
1158
|
+
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1159
|
+
if (readUnknown) {
|
|
1160
|
+
if (!unknownFields)
|
|
1161
|
+
unknownFields = [];
|
|
1162
|
+
unknownFields.push({
|
|
1163
|
+
no: fieldNum,
|
|
1164
|
+
wireType: wt,
|
|
1165
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
break;
|
|
1169
|
+
}
|
|
1170
|
+
seenMask |= bit;
|
|
1171
|
+
if (pos >= n)
|
|
1172
|
+
throw new Error('omnibuf: truncated submsg');
|
|
1173
|
+
let subLen = 0;
|
|
1174
|
+
const lb = buf[pos];
|
|
1175
|
+
if ((lb & 2) !== 0) {
|
|
1176
|
+
if (pos + 2 > n)
|
|
1177
|
+
throw new Error('omnibuf: truncated submsg');
|
|
1178
|
+
subLen = (lb | (buf[pos + 1] << 8)) >>> 2;
|
|
1179
|
+
pos += 2;
|
|
1180
|
+
}
|
|
1181
|
+
else if ((lb & 1) !== 0) {
|
|
1182
|
+
subLen = lb >>> 1;
|
|
1183
|
+
pos += 1;
|
|
1184
|
+
}
|
|
1185
|
+
else {
|
|
1186
|
+
const [subBytes, nextPos] = readLenSlice(buf, pos, 0);
|
|
1187
|
+
out.location = decodeLocation(subBytes, out.location ?? undefined, depth + 1, alreadySeen ? { ...options, merge: true } : options);
|
|
1188
|
+
pos = nextPos;
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
if (pos + subLen > n)
|
|
1192
|
+
throw new Error('omnibuf: truncated submsg');
|
|
1193
|
+
out.location = decodeLocation(buf, out.location ?? undefined, depth + 1, alreadySeen ? { ...options, merge: true } : options, pos, pos + subLen);
|
|
1194
|
+
pos += subLen;
|
|
1195
|
+
break;
|
|
1196
|
+
}
|
|
1197
|
+
case 10: {
|
|
1198
|
+
if (wt !== 8) {
|
|
1199
|
+
const valStart = pos;
|
|
1200
|
+
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1201
|
+
if (readUnknown) {
|
|
1202
|
+
if (!unknownFields)
|
|
1203
|
+
unknownFields = [];
|
|
1204
|
+
unknownFields.push({
|
|
1205
|
+
no: fieldNum,
|
|
1206
|
+
wireType: wt,
|
|
1207
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
break;
|
|
1211
|
+
}
|
|
1212
|
+
seenMask |= bit;
|
|
1213
|
+
if (pos >= n)
|
|
1214
|
+
throw new Error('omnibuf: truncated submsg array');
|
|
1215
|
+
let arrLen = 0;
|
|
1216
|
+
const lb = buf[pos];
|
|
1217
|
+
if ((lb & 2) !== 0) {
|
|
1218
|
+
if (pos + 2 > n)
|
|
1219
|
+
throw new Error('omnibuf: truncated submsg array');
|
|
1220
|
+
arrLen = (lb | (buf[pos + 1] << 8)) >>> 2;
|
|
1221
|
+
pos += 2;
|
|
1222
|
+
}
|
|
1223
|
+
else if ((lb & 1) !== 0) {
|
|
1224
|
+
arrLen = lb >>> 1;
|
|
1225
|
+
pos += 1;
|
|
1226
|
+
}
|
|
1227
|
+
else {
|
|
1228
|
+
const [arrPayload, nextPos] = readLenSlice(buf, pos, 0);
|
|
1229
|
+
const [elemCount, ok] = countSubMsgArrElems(arrPayload);
|
|
1230
|
+
if (!ok)
|
|
1231
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1232
|
+
const elems = alreadySeen && Array.isArray(out.neighbors) ? out.neighbors : [];
|
|
1233
|
+
let p = 0;
|
|
1234
|
+
for (let i = 0; i < elemCount; i++) {
|
|
1235
|
+
const [el, en] = decodeVarintBigInt(arrPayload, p);
|
|
1236
|
+
p += en;
|
|
1237
|
+
const elNum = Number(el);
|
|
1238
|
+
elems.push(decodeNeighbor(arrPayload, undefined, depth + 1, options, p, p + elNum));
|
|
1239
|
+
p += elNum;
|
|
1240
|
+
}
|
|
1241
|
+
out.neighbors = elems;
|
|
1242
|
+
pos = nextPos;
|
|
1243
|
+
break;
|
|
1244
|
+
}
|
|
1245
|
+
const arrEnd = pos + arrLen;
|
|
1246
|
+
if (arrEnd > n)
|
|
1247
|
+
throw new Error('omnibuf: truncated submsg array');
|
|
1248
|
+
let elems = out.neighbors;
|
|
1249
|
+
if (!Array.isArray(elems)) {
|
|
1250
|
+
elems = [];
|
|
1251
|
+
out.neighbors = elems;
|
|
1252
|
+
}
|
|
1253
|
+
else if (!alreadySeen) {
|
|
1254
|
+
elems.length = 0;
|
|
1255
|
+
}
|
|
1256
|
+
let p = pos;
|
|
1257
|
+
while (p < arrEnd) {
|
|
1258
|
+
let elNum = 0;
|
|
1259
|
+
const eb0 = buf[p];
|
|
1260
|
+
if ((eb0 & 2) !== 0) {
|
|
1261
|
+
if (p + 2 > arrEnd)
|
|
1262
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1263
|
+
elNum = (eb0 | (buf[p + 1] << 8)) >>> 2;
|
|
1264
|
+
p += 2;
|
|
1265
|
+
}
|
|
1266
|
+
else if ((eb0 & 1) !== 0) {
|
|
1267
|
+
elNum = eb0 >>> 1;
|
|
1268
|
+
p += 1;
|
|
1269
|
+
}
|
|
1270
|
+
else {
|
|
1271
|
+
const [el, en] = decodeVarintBigInt(buf, p);
|
|
1272
|
+
if (en === 0 || el > BigInt(arrEnd - (p + en))) {
|
|
1273
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1274
|
+
}
|
|
1275
|
+
p += en;
|
|
1276
|
+
elNum = Number(el);
|
|
1277
|
+
}
|
|
1278
|
+
if (p + elNum > arrEnd)
|
|
1279
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1280
|
+
elems.push(decodeNeighbor(buf, undefined, depth + 1, options, p, p + elNum));
|
|
1281
|
+
p += elNum;
|
|
1282
|
+
}
|
|
1283
|
+
pos = arrEnd;
|
|
1284
|
+
break;
|
|
1285
|
+
}
|
|
1286
|
+
case 11: {
|
|
1287
|
+
if (wt !== 0) {
|
|
1288
|
+
const valStart = pos;
|
|
1289
|
+
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1290
|
+
if (readUnknown) {
|
|
1291
|
+
if (!unknownFields)
|
|
1292
|
+
unknownFields = [];
|
|
1293
|
+
unknownFields.push({
|
|
1294
|
+
no: fieldNum,
|
|
1295
|
+
wireType: wt,
|
|
1296
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
break;
|
|
1300
|
+
}
|
|
1301
|
+
seenMask |= bit;
|
|
1302
|
+
if (pos >= n)
|
|
1303
|
+
throw new Error('omnibuf: truncated uint64');
|
|
1304
|
+
const vb = buf[pos];
|
|
1305
|
+
if ((vb & 1) !== 0) {
|
|
1306
|
+
out.sequence = vb >>> 1;
|
|
1307
|
+
pos += 1;
|
|
1308
|
+
}
|
|
1309
|
+
else if ((vb & 2) !== 0) {
|
|
1310
|
+
if (pos + 2 > n)
|
|
1311
|
+
throw new Error('omnibuf: truncated uint64');
|
|
1312
|
+
out.sequence = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
1313
|
+
pos += 2;
|
|
1314
|
+
}
|
|
1315
|
+
else if ((vb & 4) !== 0) {
|
|
1316
|
+
if (pos + 4 > n)
|
|
1317
|
+
throw new Error('omnibuf: truncated uint64');
|
|
1318
|
+
const u32 = (vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
|
|
1319
|
+
out.sequence = u32 >>> 3;
|
|
1320
|
+
pos += 4;
|
|
1321
|
+
}
|
|
1322
|
+
else {
|
|
1323
|
+
if (pos + 9 > n)
|
|
1324
|
+
throw new Error('omnibuf: truncated uint64');
|
|
1325
|
+
const lo = (buf[pos + 1] |
|
|
1326
|
+
(buf[pos + 2] << 8) |
|
|
1327
|
+
(buf[pos + 3] << 16) |
|
|
1328
|
+
(buf[pos + 4] << 24)) >>>
|
|
1329
|
+
0;
|
|
1330
|
+
const hi = (buf[pos + 5] |
|
|
1331
|
+
(buf[pos + 6] << 8) |
|
|
1332
|
+
(buf[pos + 7] << 16) |
|
|
1333
|
+
(buf[pos + 8] << 24)) >>>
|
|
1334
|
+
0;
|
|
1335
|
+
out.sequence = hi <= 0x1fffff ? hi * 0x100000000 + lo : (BigInt(hi) << 32n) | BigInt(lo);
|
|
1336
|
+
pos += 9;
|
|
1337
|
+
}
|
|
1338
|
+
break;
|
|
1339
|
+
}
|
|
1340
|
+
default: {
|
|
1341
|
+
const valStart = pos;
|
|
1342
|
+
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1343
|
+
if (readUnknown) {
|
|
1344
|
+
if (!unknownFields)
|
|
1345
|
+
unknownFields = [];
|
|
1346
|
+
unknownFields.push({
|
|
1347
|
+
no: fieldNum,
|
|
1348
|
+
wireType: wt,
|
|
1349
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
break;
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
if (unknownFields && unknownFields.length > 0 && !('$unknown' in out)) {
|
|
1357
|
+
Object.defineProperty(out, '$unknown', {
|
|
1358
|
+
value: unknownFields,
|
|
1359
|
+
enumerable: false,
|
|
1360
|
+
writable: true,
|
|
1361
|
+
configurable: true,
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
return out;
|
|
1365
|
+
}
|
|
1366
|
+
export function unmarshalPeerUpdateOmniBuf(buf, options) {
|
|
1367
|
+
return decodePeerUpdate(buf, undefined, 0, options);
|
|
1368
|
+
}
|
|
1369
|
+
PeerUpdateSchema.setGeneratedCodec({
|
|
1370
|
+
create: () => new PeerUpdateMsg(),
|
|
1371
|
+
encode: encodePeerUpdate,
|
|
1372
|
+
decode: decodePeerUpdate,
|
|
1373
|
+
});
|
|
1374
|
+
export class OpaquePeerUpdate {
|
|
1375
|
+
_raw;
|
|
1376
|
+
_dirtyMask = 0;
|
|
1377
|
+
_asn;
|
|
1378
|
+
_routerId;
|
|
1379
|
+
_active;
|
|
1380
|
+
_uptimeSec;
|
|
1381
|
+
_rssiDbm;
|
|
1382
|
+
_cpuLoad;
|
|
1383
|
+
_tags;
|
|
1384
|
+
_prefixes;
|
|
1385
|
+
_location;
|
|
1386
|
+
_neighbors;
|
|
1387
|
+
_sequence;
|
|
1388
|
+
constructor(raw) {
|
|
1389
|
+
this._raw = raw;
|
|
1390
|
+
}
|
|
1391
|
+
raw() {
|
|
1392
|
+
return this._raw;
|
|
1393
|
+
}
|
|
1394
|
+
asn() {
|
|
1395
|
+
if ((this._dirtyMask & (1 << 1)) !== 0)
|
|
1396
|
+
return this._asn;
|
|
1397
|
+
return readUint(this._raw, 1)[0];
|
|
1398
|
+
}
|
|
1399
|
+
getAsn() {
|
|
1400
|
+
return this.asn();
|
|
1401
|
+
}
|
|
1402
|
+
setAsn(val) {
|
|
1403
|
+
this._asn = val;
|
|
1404
|
+
this._dirtyMask |= 1 << 1;
|
|
1405
|
+
}
|
|
1406
|
+
routerId() {
|
|
1407
|
+
if ((this._dirtyMask & (1 << 2)) !== 0)
|
|
1408
|
+
return this._routerId;
|
|
1409
|
+
return readString(this._raw, 2)[0];
|
|
1410
|
+
}
|
|
1411
|
+
getRouterId() {
|
|
1412
|
+
return this.routerId();
|
|
1413
|
+
}
|
|
1414
|
+
router_id() {
|
|
1415
|
+
return this.routerId();
|
|
1416
|
+
}
|
|
1417
|
+
setRouterId(val) {
|
|
1418
|
+
this._routerId = val;
|
|
1419
|
+
this._dirtyMask |= 1 << 2;
|
|
1420
|
+
}
|
|
1421
|
+
active() {
|
|
1422
|
+
if ((this._dirtyMask & (1 << 3)) !== 0)
|
|
1423
|
+
return this._active;
|
|
1424
|
+
return readBool(this._raw, 3)[0];
|
|
1425
|
+
}
|
|
1426
|
+
getActive() {
|
|
1427
|
+
return this.active();
|
|
1428
|
+
}
|
|
1429
|
+
setActive(val) {
|
|
1430
|
+
this._active = val;
|
|
1431
|
+
this._dirtyMask |= 1 << 3;
|
|
1432
|
+
}
|
|
1433
|
+
uptimeSec() {
|
|
1434
|
+
if ((this._dirtyMask & (1 << 4)) !== 0)
|
|
1435
|
+
return this._uptimeSec;
|
|
1436
|
+
return readUintAuto(this._raw, 4)[0];
|
|
1437
|
+
}
|
|
1438
|
+
getUptimeSec() {
|
|
1439
|
+
return this.uptimeSec();
|
|
1440
|
+
}
|
|
1441
|
+
uptime_sec() {
|
|
1442
|
+
return this.uptimeSec();
|
|
1443
|
+
}
|
|
1444
|
+
setUptimeSec(val) {
|
|
1445
|
+
this._uptimeSec = val;
|
|
1446
|
+
this._dirtyMask |= 1 << 4;
|
|
1447
|
+
}
|
|
1448
|
+
rssiDbm() {
|
|
1449
|
+
if ((this._dirtyMask & (1 << 5)) !== 0)
|
|
1450
|
+
return this._rssiDbm;
|
|
1451
|
+
return readInt(this._raw, 5)[0];
|
|
1452
|
+
}
|
|
1453
|
+
getRssiDbm() {
|
|
1454
|
+
return this.rssiDbm();
|
|
1455
|
+
}
|
|
1456
|
+
rssi_dbm() {
|
|
1457
|
+
return this.rssiDbm();
|
|
1458
|
+
}
|
|
1459
|
+
setRssiDbm(val) {
|
|
1460
|
+
this._rssiDbm = val;
|
|
1461
|
+
this._dirtyMask |= 1 << 5;
|
|
1462
|
+
}
|
|
1463
|
+
cpuLoad() {
|
|
1464
|
+
if ((this._dirtyMask & (1 << 6)) !== 0)
|
|
1465
|
+
return this._cpuLoad;
|
|
1466
|
+
return readFloat64(this._raw, 6)[0];
|
|
1467
|
+
}
|
|
1468
|
+
getCpuLoad() {
|
|
1469
|
+
return this.cpuLoad();
|
|
1470
|
+
}
|
|
1471
|
+
cpu_load() {
|
|
1472
|
+
return this.cpuLoad();
|
|
1473
|
+
}
|
|
1474
|
+
setCpuLoad(val) {
|
|
1475
|
+
this._cpuLoad = val;
|
|
1476
|
+
this._dirtyMask |= 1 << 6;
|
|
1477
|
+
}
|
|
1478
|
+
tags() {
|
|
1479
|
+
if ((this._dirtyMask & (1 << 7)) !== 0)
|
|
1480
|
+
return this._tags;
|
|
1481
|
+
return readStringArr(this._raw, 7)[0];
|
|
1482
|
+
}
|
|
1483
|
+
getTags() {
|
|
1484
|
+
return this.tags();
|
|
1485
|
+
}
|
|
1486
|
+
setTags(val) {
|
|
1487
|
+
this._tags = val;
|
|
1488
|
+
this._dirtyMask |= 1 << 7;
|
|
1489
|
+
}
|
|
1490
|
+
prefixes() {
|
|
1491
|
+
if ((this._dirtyMask & (1 << 8)) !== 0)
|
|
1492
|
+
return this._prefixes;
|
|
1493
|
+
return readUint32Arr(this._raw, 8)[0];
|
|
1494
|
+
}
|
|
1495
|
+
getPrefixes() {
|
|
1496
|
+
return this.prefixes();
|
|
1497
|
+
}
|
|
1498
|
+
setPrefixes(val) {
|
|
1499
|
+
this._prefixes = val;
|
|
1500
|
+
this._dirtyMask |= 1 << 8;
|
|
1501
|
+
}
|
|
1502
|
+
location() {
|
|
1503
|
+
if ((this._dirtyMask & (1 << 9)) !== 0)
|
|
1504
|
+
return this._location;
|
|
1505
|
+
return readSubMsgMerged(this._raw, 9, (sub, target, merge) => decodeLocation(sub, target, 0, { merge }))[0];
|
|
1506
|
+
}
|
|
1507
|
+
getLocation() {
|
|
1508
|
+
return this.location();
|
|
1509
|
+
}
|
|
1510
|
+
setLocation(val) {
|
|
1511
|
+
this._location = val;
|
|
1512
|
+
this._dirtyMask |= 1 << 9;
|
|
1513
|
+
}
|
|
1514
|
+
neighbors() {
|
|
1515
|
+
if ((this._dirtyMask & (1 << 10)) !== 0)
|
|
1516
|
+
return this._neighbors;
|
|
1517
|
+
return readSubMsgArrDecoded(this._raw, 10, (sub) => decodeNeighbor(sub))[0];
|
|
1518
|
+
}
|
|
1519
|
+
getNeighbors() {
|
|
1520
|
+
return this.neighbors();
|
|
1521
|
+
}
|
|
1522
|
+
setNeighbors(val) {
|
|
1523
|
+
this._neighbors = val;
|
|
1524
|
+
this._dirtyMask |= 1 << 10;
|
|
1525
|
+
}
|
|
1526
|
+
sequence() {
|
|
1527
|
+
if ((this._dirtyMask & (1 << 11)) !== 0)
|
|
1528
|
+
return this._sequence;
|
|
1529
|
+
return readUintAuto(this._raw, 11)[0];
|
|
1530
|
+
}
|
|
1531
|
+
getSequence() {
|
|
1532
|
+
return this.sequence();
|
|
1533
|
+
}
|
|
1534
|
+
setSequence(val) {
|
|
1535
|
+
this._sequence = val;
|
|
1536
|
+
this._dirtyMask |= 1 << 11;
|
|
1537
|
+
}
|
|
1538
|
+
marshal(options) {
|
|
1539
|
+
if (this._dirtyMask === 0) {
|
|
1540
|
+
return this._raw;
|
|
1541
|
+
}
|
|
1542
|
+
this._raw = spliceFields(this._raw, this._dirtyMask, 11, (enc, fnum) => {
|
|
1543
|
+
switch (fnum) {
|
|
1544
|
+
case 1:
|
|
1545
|
+
enc.writeUint(1, this._asn ?? 0);
|
|
1546
|
+
break;
|
|
1547
|
+
case 2:
|
|
1548
|
+
enc.writeString(2, this._routerId ?? '');
|
|
1549
|
+
break;
|
|
1550
|
+
case 3:
|
|
1551
|
+
enc.writeBool(3, Boolean(this._active));
|
|
1552
|
+
break;
|
|
1553
|
+
case 4:
|
|
1554
|
+
enc.writeUint(4, this._uptimeSec ?? 0);
|
|
1555
|
+
break;
|
|
1556
|
+
case 5:
|
|
1557
|
+
enc.writeInt(5, this._rssiDbm ?? 0);
|
|
1558
|
+
break;
|
|
1559
|
+
case 6:
|
|
1560
|
+
enc.writeFloat64(6, this._cpuLoad ?? 0);
|
|
1561
|
+
break;
|
|
1562
|
+
case 7:
|
|
1563
|
+
enc.writeStringArr(7, this._tags ?? []);
|
|
1564
|
+
break;
|
|
1565
|
+
case 8:
|
|
1566
|
+
enc.writeUint32Arr(8, this._prefixes ?? []);
|
|
1567
|
+
break;
|
|
1568
|
+
case 9:
|
|
1569
|
+
if (this._location) {
|
|
1570
|
+
enc.beginSubMsg(9);
|
|
1571
|
+
encodeLocation(enc, this._location, options);
|
|
1572
|
+
enc.endSubMsg();
|
|
1573
|
+
}
|
|
1574
|
+
break;
|
|
1575
|
+
case 10: {
|
|
1576
|
+
const arr = this._neighbors ?? [];
|
|
1577
|
+
enc.beginSubMsgArr(10);
|
|
1578
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1579
|
+
enc.beginSubMsgElem();
|
|
1580
|
+
encodeNeighbor(enc, arr[i], options);
|
|
1581
|
+
enc.endSubMsgElem();
|
|
1582
|
+
}
|
|
1583
|
+
enc.endSubMsgArr();
|
|
1584
|
+
break;
|
|
1585
|
+
}
|
|
1586
|
+
case 11:
|
|
1587
|
+
enc.writeUint(11, this._sequence ?? 0);
|
|
1588
|
+
break;
|
|
1589
|
+
}
|
|
1590
|
+
});
|
|
1591
|
+
this._dirtyMask = 0;
|
|
1592
|
+
return this._raw;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
export { roundFloat32Shortest, readFloat32 };
|
|
1596
|
+
//# sourceMappingURL=peer_omnibuf.pb.js.map
|