Maint: split custom config files in openvpn/custom
This commit is contained in:
27
internal/openvpn/custom/read.go
Normal file
27
internal/openvpn/custom/read.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package custom
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func readCustomConfigLines(filepath string) (
|
||||
lines []string, err error) {
|
||||
file, err := os.Open(filepath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
b, err := io.ReadAll(file)
|
||||
if err != nil {
|
||||
_ = file.Close()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := file.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return strings.Split(string(b), "\n"), nil
|
||||
}
|
||||
Reference in New Issue
Block a user