fix(traffic): подтверждать идентичность соседних счётчиков
This commit is contained in:
1 parent
493c30bebc
commit
b57ae316ba
27 files changed
+1444
-36
No files matched your search
@@ -310,6 +310,7 @@ export const flowAsnMeta = pgTable("flow_asn_meta", {
|
||||
})
|
||||
|
||||
export const trafficSamples = pgTable("traffic_samples", {
|
||||
nativeCounterIdentity: text("native_counter_identity"),
|
||||
serverId: intPkRef().references(() => servers.id, { onDelete: "cascade" }),
|
||||
interfaceName: text("interface_name").notNull(),
|
||||
peerPublicKey: text("peer_public_key").notNull().default(""),
|
||||
|
||||
@@ -2,11 +2,19 @@ export const TRAFFIC_FLAG_RUNNING = 1
|
||||
export const TRAFFIC_FLAG_DISABLED = 2
|
||||
export const TRAFFIC_FLAG_COUNTERS_KNOWN = 4
|
||||
export const TRAFFIC_FLAG_STATUS_KNOWN = 8
|
||||
export const TRAFFIC_FLAG_CONTINUITY_KNOWN = 16
|
||||
export const TRAFFIC_FLAG_CONTINUITY_RECORDED = 32
|
||||
|
||||
export function encodeTrafficFlags(running: boolean, disabled: boolean, countersKnown = false, statusKnown = false): number {
|
||||
export function encodeTrafficFlags(running: boolean, disabled: boolean, countersKnown = false, statusKnown = false, continuityKnown?: boolean): number {
|
||||
return (running ? TRAFFIC_FLAG_RUNNING : 0) | (disabled ? TRAFFIC_FLAG_DISABLED : 0)
|
||||
| (countersKnown ? TRAFFIC_FLAG_COUNTERS_KNOWN : 0)
|
||||
| (statusKnown ? TRAFFIC_FLAG_STATUS_KNOWN : 0)
|
||||
| (continuityKnown === undefined ? 0 : TRAFFIC_FLAG_CONTINUITY_RECORDED | (continuityKnown ? TRAFFIC_FLAG_CONTINUITY_KNOWN : 0))
|
||||
}
|
||||
|
||||
/** Undefined retains the documented legacy boundary; new producers explicitly mark both outcomes. */
|
||||
export function trafficCounterContinuity(flags: number): boolean | undefined {
|
||||
return flags & TRAFFIC_FLAG_CONTINUITY_RECORDED ? !!(flags & TRAFFIC_FLAG_CONTINUITY_KNOWN) : undefined
|
||||
}
|
||||
|
||||
export function trafficFlagRunning(flags: number | null | undefined): boolean {
|
||||
|
||||
Reference in new issue
Block a user