diff --git a/README.md b/README.md index 573622a..8899cf9 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ These differences include: - No offline activity tracking. The protocol's ping mechanism allows for tracking application usage, reporting the number of days since the last ping and how many of those days saw active usage. CoreUpdate does not use this, instead assuming update clients are always online and checking in once every ~45-50 minutes. - Each check in should include a ping and optionally an update check. + Clients not actively updating should send only a ping, indicating CoreUpdate's "Instance-Hold" state. + Clients requesting an update should send a ping, update check, and an UpdateComplete:SuccessReboot event indicating CoreUpdate's "Complete" state. - Various protocol extensions/abuses. update_engine, likely due to earlier limitations of the protocol and Google's server implementation, uses a number of non-standard fields. diff --git a/omaha/client/client.go b/omaha/client/client.go index 1187129..8bb4572 100644 --- a/omaha/client/client.go +++ b/omaha/client/client.go @@ -206,6 +206,11 @@ func (ac *AppClient) UpdateCheck() (*omaha.UpdateResponse, error) { app.AddPing() app.AddUpdateCheck() + // Tell CoreUpdate to consider us in its "Complete" state, + // otherwise it interprets ping as "Instance-Hold" which is + // nonsense when we are sending an update check! + app.Events = append(app.Events, EventComplete) + ac.sentPing = true appResp, err := ac.doReq(ac.apiEndpoint, req) diff --git a/omaha/client/client_test.go b/omaha/client/client_test.go index 251f3ff..bab5772 100644 --- a/omaha/client/client_test.go +++ b/omaha/client/client_test.go @@ -100,6 +100,15 @@ func TestClientNoUpdate(t *testing.T) { if len(r.checks) != 1 { t.Fatalf("expected 1 update check, not %d", len(r.checks)) } + + if len(r.events) != 1 { + t.Fatalf("expected 1 event, not %d", len(r.events)) + } + + if r.events[0].Type != omaha.EventTypeUpdateComplete || + r.events[0].Result != omaha.EventResultSuccessReboot { + t.Fatalf("expected %#v, not %#v", EventComplete, r.events[0]) + } } func TestClientWithUpdate(t *testing.T) { @@ -132,6 +141,15 @@ func TestClientWithUpdate(t *testing.T) { if len(r.checks) != 1 { t.Fatalf("expected 1 update check, not %d", len(r.checks)) } + + if len(r.events) != 1 { + t.Fatalf("expected 1 event, not %d", len(r.events)) + } + + if r.events[0].Type != omaha.EventTypeUpdateComplete || + r.events[0].Result != omaha.EventResultSuccessReboot { + t.Fatalf("expected %#v, not %#v", EventComplete, r.events[0]) + } } func TestClientPing(t *testing.T) {