aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/conf/parser.go
diff options
context:
space:
mode:
Diffstat (limited to 'conf/parser.go')
-rw-r--r--conf/parser.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/conf/parser.go b/conf/parser.go
index d26bdea4..dd0ee317 100644
--- a/conf/parser.go
+++ b/conf/parser.go
@@ -6,8 +6,10 @@
package conf
import (
+ "bufio"
"encoding/base64"
"encoding/hex"
+ "io"
"net"
"strconv"
"strings"
@@ -367,8 +369,7 @@ func FromWgQuickWithUnknownEncoding(s string, name string) (*Config, error) {
return nil, firstErr
}
-func FromUAPI(s string, existingConfig *Config) (*Config, error) {
- lines := strings.Split(s, "\n")
+func FromUAPI(reader io.Reader, existingConfig *Config) (*Config, error) {
parserState := inInterfaceSection
conf := Config{
Name: existingConfig.Name,
@@ -380,9 +381,15 @@ func FromUAPI(s string, existingConfig *Config) (*Config, error) {
},
}
var peer *Peer
- for _, line := range lines {
+ lineReader := bufio.NewReader(reader)
+ for {
+ line, err := lineReader.ReadString('\n')
+ if err != nil {
+ return nil, err
+ }
+ line = line[:len(line)-1]
if len(line) == 0 {
- continue
+ break
}
equals := strings.IndexByte(line, '=')
if equals < 0 {