cmd/cli: handle stop signal from service manager

So using "ctrld stop" or service manager to stop ctrld will end up with
the same result, stopped ctrld with a working DNS, and deactivation pin
code will always have effects if set.
This commit is contained in:
Cuong Manh Le
2025-03-20 22:26:35 +07:00
committed by Cuong Manh Le
parent dacc67e50f
commit c6365e6b74
7 changed files with 60 additions and 42 deletions
+5 -1
View File
@@ -228,7 +228,7 @@ func (p *prog) registerControlServerHandler() {
}
// If pin code not set, allowing deactivation.
if deactivationPinNotSet() {
if !deactivationPinSet() {
w.WriteHeader(http.StatusOK)
return
}
@@ -244,6 +244,10 @@ func (p *prog) registerControlServerHandler() {
switch req.Pin {
case cdDeactivationPin.Load():
code = http.StatusOK
select {
case p.pinCodeValidCh <- struct{}{}:
default:
}
case defaultDeactivationPin:
// If the pin code was set, but users do not provide --pin, return proper code to client.
code = http.StatusBadRequest