* feat: add configurable SMTP HELO hostname Allow the SMTP HELO/EHLO hostname to be configured separately from the SMTP server hostname. This is useful when the SMTP server requires clients to identify themselves with a fully qualified hostname different from the server address. * chore: remove vendored dependency changes * Bump go-pkgz/notify to v1.4.0 and document SMTP_HELO_HOST The HELOHost field lands in go-pkgz/notify v1.4.0, so the branch needs the bump to compile; v1.3.0 in master has no such field. The example module is tidied alongside, as any change to backend/go.mod requires. Documents the parameter in the parameters table and, separately, in the email setup page: what it does, that leaving it unset keeps the previous `localhost` greeting, and the case it exists for, a relay refusing the greeting under Postfix `reject_non_fqdn_helo_hostname`. Also records the current limit: verification emails for email authentication go through go-pkgz/auth's own sender, which has no equivalent setting, so the greeting there is unchanged. * Bump go-pkgz/auth to v2.2.0 and apply SMTP_HELO_HOST to verification email The verification email sender had no way to set the greeting, so a relay that refuses the HELO would accept notifications and still reject sign-in emails. EmailParams gains HELOHost in go-pkgz/auth v2.2.0, so the same SMTP_HELO_HOST now drives both paths. The example module is tidied alongside, as any change to backend/go.mod requires. --------- Co-authored-by: oli <someone@somewhere.tld> Co-authored-by: Dmitry Verkhoturov <paskal.07@gmail.com>
66 lines
2.0 KiB
Go
66 lines
2.0 KiB
Go
package stats
|
|
|
|
// MovingAverage calculates the rolling mean of the input over a trailing
|
|
// window. Only fully-populated windows produce output, so the result has
|
|
// len(input)-window+1 entries and entry i is the mean of input[i : i+window].
|
|
// The window must satisfy 1 <= window <= len(input) or ErrBounds is
|
|
// returned. An empty input returns ErrEmptyInput.
|
|
func MovingAverage(input Float64Data, window int) ([]float64, error) {
|
|
|
|
if input.Len() == 0 {
|
|
return nil, ErrEmptyInput
|
|
}
|
|
|
|
if window < 1 || window > input.Len() {
|
|
return nil, ErrBounds
|
|
}
|
|
|
|
output := make([]float64, input.Len()-window+1)
|
|
|
|
for i := range output {
|
|
// Mean cannot fail here since every window is non-empty
|
|
mean, _ := Mean(input[i : i+window])
|
|
output[i] = mean
|
|
}
|
|
|
|
return output, nil
|
|
}
|
|
|
|
// MovingStdDev calculates the rolling sample standard deviation of the input
|
|
// over a trailing window. Only fully-populated windows produce output, so the
|
|
// result has len(input)-window+1 entries and entry i is the sample standard
|
|
// deviation of input[i : i+window]. The window must satisfy
|
|
// 2 <= window <= len(input) or ErrBounds is returned, since the sample
|
|
// standard deviation of a single value is undefined. An empty input returns
|
|
// ErrEmptyInput.
|
|
func MovingStdDev(input Float64Data, window int) ([]float64, error) {
|
|
|
|
if input.Len() == 0 {
|
|
return nil, ErrEmptyInput
|
|
}
|
|
|
|
if window < 2 || window > input.Len() {
|
|
return nil, ErrBounds
|
|
}
|
|
|
|
output := make([]float64, input.Len()-window+1)
|
|
|
|
for i := range output {
|
|
// StandardDeviationSample cannot fail here since every window is non-empty
|
|
sdev, _ := StandardDeviationSample(input[i : i+window])
|
|
output[i] = sdev
|
|
}
|
|
|
|
return output, nil
|
|
}
|
|
|
|
// MovingAverage returns the rolling mean of the data over a trailing window
|
|
func (f Float64Data) MovingAverage(window int) ([]float64, error) {
|
|
return MovingAverage(f, window)
|
|
}
|
|
|
|
// MovingStdDev returns the rolling sample standard deviation of the data over a trailing window
|
|
func (f Float64Data) MovingStdDev(window int) ([]float64, error) {
|
|
return MovingStdDev(f, window)
|
|
}
|