mirror of
https://github.com/bakito/adguardhome-sync.git
synced 2025-01-01 04:41:51 +08:00
add protection flag to api status (#260)
This commit is contained in:
parent
cc13b9318d
commit
215ee946dd
2 changed files with 12 additions and 7 deletions
|
@ -131,5 +131,6 @@ type replicaStatus struct {
|
||||||
Host string `json:"host"`
|
Host string `json:"host"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Error string `json:"error"`
|
Error string `json:"error,omitempty"`
|
||||||
|
ProtectionEnabled *bool `json:"protection_enabled"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ func (w *worker) getStatus(inst types.AdGuardInstance) replicaStatus {
|
||||||
return replicaStatus{Host: oc.Host(), URL: inst.URL, Error: err.Error(), Status: "danger"}
|
return replicaStatus{Host: oc.Host(), URL: inst.URL, Error: err.Error(), Status: "danger"}
|
||||||
}
|
}
|
||||||
sl := l.With("from", oc.Host())
|
sl := l.With("from", oc.Host())
|
||||||
_, err = oc.Status()
|
st, err := oc.Status()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, client.ErrSetupNeeded) {
|
if errors.Is(err, client.ErrSetupNeeded) {
|
||||||
return replicaStatus{Host: oc.Host(), URL: inst.URL, Error: err.Error(), Status: "warning"}
|
return replicaStatus{Host: oc.Host(), URL: inst.URL, Error: err.Error(), Status: "warning"}
|
||||||
|
@ -127,8 +127,12 @@ func (w *worker) getStatus(inst types.AdGuardInstance) replicaStatus {
|
||||||
sl.With("error", err).Error("Error getting origin status")
|
sl.With("error", err).Error("Error getting origin status")
|
||||||
return replicaStatus{Host: oc.Host(), URL: inst.URL, Error: err.Error(), Status: "danger"}
|
return replicaStatus{Host: oc.Host(), URL: inst.URL, Error: err.Error(), Status: "danger"}
|
||||||
}
|
}
|
||||||
st := replicaStatus{Host: oc.Host(), URL: inst.URL, Status: "success"}
|
return replicaStatus{
|
||||||
return st
|
Host: oc.Host(),
|
||||||
|
URL: inst.URL,
|
||||||
|
Status: "success",
|
||||||
|
ProtectionEnabled: utils.Ptr(st.ProtectionEnabled),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *worker) sync() {
|
func (w *worker) sync() {
|
||||||
|
|
Loading…
Reference in a new issue