Skip to content

Policy

The policy block sets per-level connection timeouts, buffer sizes, and which traffic counters the stats subsystem should populate.

Top-level options

FieldTypeDefaultAllowed valuesDescription
levelsmap[uint32]*Policy{}{ "<level>": Policy }Map keyed by user level (uint32). Each value is a Policy object whose flags apply to traffic from users at that level.
system*SystemPolicy(unset)SystemPolicySystem-wide policy. Currently only carries the four inbound/outbound traffic counter toggles.

Source: infra/conf/policy.go:73-76 · pinned at v26.6.1 (94ffd50)

Per-level Policy

Each entry under levels is a Policy object. Level 0 is the default for users with no explicit level set.

FieldTypeDefaultAllowed valuesDescription
handshake*uint324<seconds>Maximum time for the inbound to complete its handshake before the connection is closed.
connIdle*uint32300<seconds>Idle timeout. A connection with no traffic for this many seconds is closed.
uplinkOnly*uint322<seconds>Grace window after the downlink closes; the uplink is closed this many seconds later.
downlinkOnly*uint325<seconds>Grace window after the uplink closes; the downlink is closed this many seconds later.
statsUserUplinkboolfalsetrue | falseCount uplink bytes per user (requires the stats block to be present).
statsUserDownlinkboolfalsetrue | falseCount downlink bytes per user.
statsUserOnlineboolfalsetrue | falseTrack per-user online status.
bufferSize*int32(internal)<KB> | -1Per-connection internal buffer in KB. -1 (or any negative value) means unlimited.

Source: infra/conf/policy.go:7-16 · pinned at v26.6.1 (94ffd50)

SystemPolicy

FieldTypeDefaultAllowed valuesDescription
statsInboundUplinkboolfalsetrue | falsePer-inbound-tag uplink byte counter.
statsInboundDownlinkboolfalsetrue | falsePer-inbound-tag downlink byte counter.
statsOutboundUplinkboolfalsetrue | falsePer-outbound-tag uplink byte counter.
statsOutboundDownlinkboolfalsetrue | falsePer-outbound-tag downlink byte counter.

Source: infra/conf/policy.go:55-60 · pinned at v26.6.1 (94ffd50)

Example

json
{
  "stats": {},
  "policy": {
    "levels": {
      "0": {
        "handshake": 4,
        "connIdle": 300,
        "uplinkOnly": 2,
        "downlinkOnly": 5,
        "statsUserUplink": true,
        "statsUserDownlink": true,
        "bufferSize": 0
      }
    },
    "system": {
      "statsInboundUplink": true,
      "statsInboundDownlink": true,
      "statsOutboundUplink": true,
      "statsOutboundDownlink": true
    }
  }
}

Notes

  • Timeouts are pointers in the Go struct. Omitting a field leaves the internal default in place; setting it explicitly to 0 actually means "no timeout" for that field.
  • bufferSize is multiplied by 1024 in Policy.Build (infra/conf/policy.go:42-46) — the JSON value is in KB. Any negative value disables the cap.
  • Per-user counters require the user object on the relevant inbound to have a non-empty level whose number matches a key under policy.levels.

Source: infra/conf/policy.go:7-76 · v26.6.1 (94ffd50)

Core Tutorial by Argsment