control/controlclient, ipn: add client audit logging (#14950)
updates tailscale/corp#26435 Adds client support for sending audit logs to control via /machine/audit-log. Specifically implements audit logging for user initiated disconnections. This will require further work to optimize the peristant storage and exclusion via build tags for mobile: tailscale/corp#27011 tailscale/corp#27012 Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
This commit is contained in:
@ -4,6 +4,8 @@
|
||||
package controlclient
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"slices"
|
||||
@ -147,3 +149,42 @@ func TestCanSkipStatus(t *testing.T) {
|
||||
t.Errorf("Status fields = %q; this code was only written to handle fields %q", f, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRetryableErrors(t *testing.T) {
|
||||
errorTests := []struct {
|
||||
err error
|
||||
want bool
|
||||
}{
|
||||
{errNoNoiseClient, true},
|
||||
{errNoNodeKey, true},
|
||||
{fmt.Errorf("%w: %w", errNoNoiseClient, errors.New("no noise")), true},
|
||||
{fmt.Errorf("%w: %w", errHTTPPostFailure, errors.New("bad post")), true},
|
||||
{fmt.Errorf("%w: %w", errNoNodeKey, errors.New("not node key")), true},
|
||||
{errBadHTTPResponse(429, "too may requests"), true},
|
||||
{errBadHTTPResponse(500, "internal server eror"), true},
|
||||
{errBadHTTPResponse(502, "bad gateway"), true},
|
||||
{errBadHTTPResponse(503, "service unavailable"), true},
|
||||
{errBadHTTPResponse(504, "gateway timeout"), true},
|
||||
{errBadHTTPResponse(1234, "random error"), false},
|
||||
}
|
||||
|
||||
for _, tt := range errorTests {
|
||||
t.Run(tt.err.Error(), func(t *testing.T) {
|
||||
if isRetryableErrorForTest(tt.err) != tt.want {
|
||||
t.Fatalf("retriable: got %v, want %v", tt.err, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type retryableForTest interface {
|
||||
Retryable() bool
|
||||
}
|
||||
|
||||
func isRetryableErrorForTest(err error) bool {
|
||||
var ae retryableForTest
|
||||
if errors.As(err, &ae) {
|
||||
return ae.Retryable()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user