Actually, both.
Perimeter dead hand system algorithm:
1. If perimeter have been activated
2. AND there is nuclear explosion at russian territory
3. AND there is no connection to commander-in-chief
THAN release launch codes to every local military commander.