mirror of
https://github.com/qdm12/gluetun.git
synced 2026-06-17 08:54:10 +02:00
fix(openvpn/extract): trim spaces in config lines before parsing (#3327)
This commit is contained in:
committed by
GitHub
parent
fd12e5f9e7
commit
cd19093d1d
@@ -53,6 +53,8 @@ func extractDataFromLines(lines []string) (
|
|||||||
func extractDataFromLine(line string) (
|
func extractDataFromLine(line string) (
|
||||||
ip netip.Addr, port uint16, protocol string, err error,
|
ip netip.Addr, port uint16, protocol string, err error,
|
||||||
) {
|
) {
|
||||||
|
line = strings.TrimSpace(line)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(line, "proto "):
|
case strings.HasPrefix(line, "proto "):
|
||||||
protocol, err = extractProto(line)
|
protocol, err = extractProto(line)
|
||||||
|
|||||||
@@ -62,6 +62,14 @@ func Test_extractDataFromLines(t *testing.T) {
|
|||||||
Protocol: constants.UDP,
|
Protocol: constants.UDP,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"leading_whitespace": {
|
||||||
|
lines: []string{" proto tcp", "\tremote 1.2.3.4 443 tcp"},
|
||||||
|
connection: models.Connection{
|
||||||
|
IP: netip.AddrFrom4([4]byte{1, 2, 3, 4}),
|
||||||
|
Port: 443,
|
||||||
|
Protocol: constants.TCP,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, testCase := range testCases {
|
for name, testCase := range testCases {
|
||||||
|
|||||||
Reference in New Issue
Block a user