Skip to content

Instantly share code, notes, and snippets.

@qdm12
Created February 9, 2020 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qdm12/a4dc08ffabb63386261d8240dbdb0a93 to your computer and use it in GitHub Desktop.
Save qdm12/a4dc08ffabb63386261d8240dbdb0a93 to your computer and use it in GitHub Desktop.
// CheckTUN checks the tunnel device is present and accessible
func (c *configurator) CheckTUN() error {
c.logger.Info("%s: checking for device %s", logPrefix, constants.TunnelDevice)
f, err := c.openFile(string(constants.TunnelDevice), os.O_RDWR, 0)
if err != nil {
return fmt.Errorf("TUN device is not available: %w", err)
}
if err := f.Close(); err != nil {
c.logger.Warn("Could not close TUN device file: %s", err)
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment