all: sync with master
This commit is contained in:
@@ -131,9 +131,9 @@ func (clients *clientsContainer) handleGetClients(w http.ResponseWriter, r *http
|
||||
|
||||
// initPrev initializes the persistent client with the default or previous
|
||||
// client properties.
|
||||
func initPrev(cj clientJSON, prev *persistentClient) (c *persistentClient, err error) {
|
||||
func initPrev(cj clientJSON, prev *client.Persistent) (c *client.Persistent, err error) {
|
||||
var (
|
||||
uid UID
|
||||
uid client.UID
|
||||
ignoreQueryLog bool
|
||||
ignoreStatistics bool
|
||||
upsCacheEnabled bool
|
||||
@@ -166,14 +166,14 @@ func initPrev(cj clientJSON, prev *persistentClient) (c *persistentClient, err e
|
||||
return nil, fmt.Errorf("invalid blocked services: %w", err)
|
||||
}
|
||||
|
||||
if (uid == UID{}) {
|
||||
uid, err = NewUID()
|
||||
if (uid == client.UID{}) {
|
||||
uid, err = client.NewUID()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("generating uid: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return &persistentClient{
|
||||
return &client.Persistent{
|
||||
BlockedServices: svcs,
|
||||
UID: uid,
|
||||
IgnoreQueryLog: ignoreQueryLog,
|
||||
@@ -187,21 +187,21 @@ func initPrev(cj clientJSON, prev *persistentClient) (c *persistentClient, err e
|
||||
// errors.
|
||||
func (clients *clientsContainer) jsonToClient(
|
||||
cj clientJSON,
|
||||
prev *persistentClient,
|
||||
) (c *persistentClient, err error) {
|
||||
prev *client.Persistent,
|
||||
) (c *client.Persistent, err error) {
|
||||
c, err = initPrev(cj, prev)
|
||||
if err != nil {
|
||||
// Don't wrap the error since it's informative enough as is.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = c.setIDs(cj.IDs)
|
||||
err = c.SetIDs(cj.IDs)
|
||||
if err != nil {
|
||||
// Don't wrap the error since it's informative enough as is.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c.safeSearchConf = copySafeSearch(cj.SafeSearchConf, cj.SafeSearchEnabled)
|
||||
c.SafeSearchConf = copySafeSearch(cj.SafeSearchConf, cj.SafeSearchEnabled)
|
||||
c.Name = cj.Name
|
||||
c.Tags = cj.Tags
|
||||
c.Upstreams = cj.Upstreams
|
||||
@@ -211,9 +211,9 @@ func (clients *clientsContainer) jsonToClient(
|
||||
c.SafeBrowsingEnabled = cj.SafeBrowsingEnabled
|
||||
c.UseOwnBlockedServices = !cj.UseGlobalBlockedServices
|
||||
|
||||
if c.safeSearchConf.Enabled {
|
||||
err = c.setSafeSearch(
|
||||
c.safeSearchConf,
|
||||
if c.SafeSearchConf.Enabled {
|
||||
err = c.SetSafeSearch(
|
||||
c.SafeSearchConf,
|
||||
clients.safeSearchCacheSize,
|
||||
clients.safeSearchCacheTTL,
|
||||
)
|
||||
@@ -258,7 +258,7 @@ func copySafeSearch(
|
||||
func copyBlockedServices(
|
||||
sch *schedule.Weekly,
|
||||
svcStrs []string,
|
||||
prev *persistentClient,
|
||||
prev *client.Persistent,
|
||||
) (svcs *filtering.BlockedServices, err error) {
|
||||
var weekly *schedule.Weekly
|
||||
if sch != nil {
|
||||
@@ -283,15 +283,15 @@ func copyBlockedServices(
|
||||
}
|
||||
|
||||
// clientToJSON converts persistent client object to JSON object.
|
||||
func clientToJSON(c *persistentClient) (cj *clientJSON) {
|
||||
func clientToJSON(c *client.Persistent) (cj *clientJSON) {
|
||||
// TODO(d.kolyshev): Remove after cleaning the deprecated
|
||||
// [clientJSON.SafeSearchEnabled] field.
|
||||
cloneVal := c.safeSearchConf
|
||||
cloneVal := c.SafeSearchConf
|
||||
safeSearchConf := &cloneVal
|
||||
|
||||
return &clientJSON{
|
||||
Name: c.Name,
|
||||
IDs: c.ids(),
|
||||
IDs: c.IDs(),
|
||||
Tags: c.Tags,
|
||||
UseGlobalSettings: !c.UseOwnSettings,
|
||||
FilteringEnabled: c.FilteringEnabled,
|
||||
@@ -397,7 +397,7 @@ func (clients *clientsContainer) handleUpdateClient(w http.ResponseWriter, r *ht
|
||||
return
|
||||
}
|
||||
|
||||
var prev *persistentClient
|
||||
var prev *client.Persistent
|
||||
var ok bool
|
||||
|
||||
func() {
|
||||
|
||||
Reference in New Issue
Block a user