mirror of
https://github.com/bakito/adguardhome-sync.git
synced 2024-12-28 19:04:10 +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
|
@ -128,8 +128,9 @@ type syncStatus struct {
|
|||
}
|
||||
|
||||
type replicaStatus struct {
|
||||
Host string `json:"host"`
|
||||
URL string `json:"url"`
|
||||
Status string `json:"status"`
|
||||
Error string `json:"error"`
|
||||
Host string `json:"host"`
|
||||
URL string `json:"url"`
|
||||
Status string `json:"status"`
|
||||
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"}
|
||||
}
|
||||
sl := l.With("from", oc.Host())
|
||||
_, err = oc.Status()
|
||||
st, err := oc.Status()
|
||||
if err != nil {
|
||||
if errors.Is(err, client.ErrSetupNeeded) {
|
||||
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")
|
||||
return replicaStatus{Host: oc.Host(), URL: inst.URL, Error: err.Error(), Status: "danger"}
|
||||
}
|
||||
st := replicaStatus{Host: oc.Host(), URL: inst.URL, Status: "success"}
|
||||
return st
|
||||
return replicaStatus{
|
||||
Host: oc.Host(),
|
||||
URL: inst.URL,
|
||||
Status: "success",
|
||||
ProtectionEnabled: utils.Ptr(st.ProtectionEnabled),
|
||||
}
|
||||
}
|
||||
|
||||
func (w *worker) sync() {
|
||||
|
|
Loading…
Reference in a new issue