Maintenance: remove some type aliases

This commit is contained in:
Quentin McGaw
2021-02-06 18:31:14 +00:00
parent 43e140e6cc
commit b1f1f94a76
32 changed files with 88 additions and 229 deletions

View File

@@ -10,15 +10,14 @@ import (
// WriteAuthFile writes the OpenVPN auth file to disk with the right permissions.
func (c *configurator) WriteAuthFile(user, password string, puid, pgid int) error {
const filepath = string(constants.OpenVPNAuthConf)
file, err := c.os.OpenFile(filepath, os.O_RDONLY, 0)
file, err := c.os.OpenFile(constants.OpenVPNAuthConf, os.O_RDONLY, 0)
if err != nil && !os.IsNotExist(err) {
return err
}
if os.IsNotExist(err) {
file, err = c.os.OpenFile(filepath, os.O_WRONLY|os.O_CREATE, 0400)
file, err = c.os.OpenFile(constants.OpenVPNAuthConf, os.O_WRONLY|os.O_CREATE, 0400)
if err != nil {
return err
}
@@ -50,7 +49,7 @@ func (c *configurator) WriteAuthFile(user, password string, puid, pgid int) erro
}
c.logger.Info("username and password changed in %s", constants.OpenVPNAuthConf)
file, err = c.os.OpenFile(filepath, os.O_TRUNC|os.O_WRONLY, 0400)
file, err = c.os.OpenFile(constants.OpenVPNAuthConf, os.O_TRUNC|os.O_WRONLY, 0400)
if err != nil {
return err
}

View File

@@ -11,7 +11,7 @@ import (
func (c *configurator) Start(ctx context.Context) (
stdoutLines, stderrLines chan string, waitError chan error, err error) {
c.logger.Info("starting openvpn")
return c.commander.Start(ctx, "openvpn", "--config", string(constants.OpenVPNConf))
return c.commander.Start(ctx, "openvpn", "--config", constants.OpenVPNConf)
}
func (c *configurator) Version(ctx context.Context) (string, error) {

View File

@@ -237,7 +237,7 @@ func (l *looper) portForward(ctx context.Context, wg *sync.WaitGroup,
if !settings.Provider.PortForwarding.Enabled {
return
}
syncState := func(port uint16) (pfFilepath models.Filepath) {
syncState := func(port uint16) (pfFilepath string) {
l.state.portForwardedMu.Lock()
defer l.state.portForwardedMu.Unlock()
l.state.portForwarded = port
@@ -251,8 +251,7 @@ func (l *looper) portForward(ctx context.Context, wg *sync.WaitGroup,
}
func writeOpenvpnConf(lines []string, openFile os.OpenFileFunc) error {
const filepath = string(constants.OpenVPNConf)
file, err := openFile(filepath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
file, err := openFile(constants.OpenVPNConf, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
if err != nil {
return err
}

View File

@@ -11,7 +11,7 @@ import (
// CheckTUN checks the tunnel device is present and accessible.
func (c *configurator) CheckTUN() error {
c.logger.Info("checking for device %s", constants.TunnelDevice)
f, err := c.os.OpenFile(string(constants.TunnelDevice), os.O_RDWR, 0)
f, err := c.os.OpenFile(constants.TunnelDevice, os.O_RDWR, 0)
if err != nil {
return fmt.Errorf("TUN device is not available: %w", err)
}
@@ -32,12 +32,11 @@ func (c *configurator) CreateTUN() error {
minor = 200
)
dev := c.unix.Mkdev(major, minor)
if err := c.unix.Mknod(string(constants.TunnelDevice), unix.S_IFCHR, int(dev)); err != nil {
if err := c.unix.Mknod(constants.TunnelDevice, unix.S_IFCHR, int(dev)); err != nil {
return err
}
const filepath = string(constants.TunnelDevice)
file, err := c.os.OpenFile(filepath, os.O_WRONLY, 0666)
file, err := c.os.OpenFile(constants.TunnelDevice, os.O_WRONLY, 0666)
if err != nil {
return err
}