Skip to content

Commit

Permalink
Merge branch 'development' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
stenya committed Feb 1, 2024
2 parents 3a445ae + 20c75d1 commit 1fa0ef1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
5 changes: 2 additions & 3 deletions daemon/service/dns/dnscryptproxy/dnscryptproxy_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ package dnscryptproxy

import (
"fmt"
"io/ioutil"
"os"
"strings"
)
Expand All @@ -39,7 +38,7 @@ func SaveConfigFile(dnsSvrStamp, configFileTemplate, configFileOut string) error
return err
}

input, err := ioutil.ReadFile(configFileTemplate)
input, err := os.ReadFile(configFileTemplate)
if err != nil {
return err
}
Expand Down Expand Up @@ -70,7 +69,7 @@ func SaveConfigFile(dnsSvrStamp, configFileTemplate, configFileOut string) error
}

output := strings.Join(lines, "\n")
err = ioutil.WriteFile(configFileOut, []byte(output), 0600) // read only for owner
err = os.WriteFile(configFileOut, []byte(output), 0600) // read only for owner
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions daemon/service/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ package platform
import (
"fmt"
"io/fs"
"io/ioutil"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -228,7 +227,7 @@ func createOpenVpnUserParamsFileExample() error {
builder.WriteString("# All changes are made at your own risk!\n")
builder.WriteString("# We recommend keeping this file empty.\n")

return ioutil.WriteFile(openvpnUserParamsFile, []byte(builder.String()), filerights.DefaultFilePermissionsForConfig())
return os.WriteFile(openvpnUserParamsFile, []byte(builder.String()), filerights.DefaultFilePermissionsForConfig())
}

func makeDir(description string, dirpath string, mode fs.FileMode) error {
Expand Down
13 changes: 8 additions & 5 deletions daemon/service/wgkeys/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type KeysManager struct {
wgToolBinPath string

activeRotationInterval time.Duration
stopMutex sync.Mutex
stop context.CancelFunc
activeRotationWg sync.WaitGroup
}
Expand Down Expand Up @@ -106,10 +107,11 @@ func (m *KeysManager) StartKeysRotation() error {
}

ctx, cancel := context.WithCancel(context.Background())
m.mutex.Lock()
m.stopMutex.Lock()
m.stop = cancel
m.stopMutex.Unlock()

m.activeRotationInterval = interval
m.mutex.Unlock()

m.activeRotationWg.Add(1)
go func(ctx context.Context) {
Expand Down Expand Up @@ -174,13 +176,14 @@ func (m *KeysManager) StartKeysRotation() error {
// StopKeysRotation stop keys rotation
func (m *KeysManager) StopKeysRotation() {
// send stop signal (if already running)
m.mutex.Lock()
m.stopMutex.Lock()
if m.stop != nil {
m.stop()
m.stop = nil
m.activeRotationInterval = 0
}
m.mutex.Unlock()
m.stopMutex.Unlock()
m.activeRotationInterval = 0

// wait untill keys rotution goroutine stops (if running)
m.activeRotationWg.Wait()
}
Expand Down
4 changes: 2 additions & 2 deletions daemon/vpn/wireguard/wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ package wireguard

import (
"fmt"
"io/ioutil"
"net"
"os"
"strconv"
"strings"

Expand Down Expand Up @@ -238,7 +238,7 @@ func (wg *WireGuard) generateAndSaveConfigFile(cfgFilePath string) error {
// write configuration into temporary file
configText := strings.Join(cfg, "\n")

err = ioutil.WriteFile(cfgFilePath, []byte(configText), 0600)
err = os.WriteFile(cfgFilePath, []byte(configText), 0600)
if err != nil {
return fmt.Errorf("failed to save WireGuard configuration into a file: %w", err)
}
Expand Down

0 comments on commit 1fa0ef1

Please sign in to comment.