mirror of
https://github.com/passepartoutvpn/passepartout-apple.git
synced 2025-01-19 06:59:10 +00:00
Fix IPv4/6 address validation (#308)
This commit is contained in:
parent
d05cf7140c
commit
36cad41529
@ -61,10 +61,9 @@ struct Validators {
|
||||
var sin = sockaddr_in()
|
||||
var sin6 = sockaddr_in6()
|
||||
|
||||
guard string.withCString({ cstring in inet_pton(AF_INET6, cstring, &sin6.sin6_addr) }) == 1 else {
|
||||
throw ValidationError.ipAddress
|
||||
}
|
||||
if string.withCString({ cstring in inet_pton(AF_INET, cstring, &sin.sin_addr) }) == 1 {
|
||||
guard string.withCString({ cstring in inet_pton(AF_INET6, cstring, &sin6.sin6_addr) }) == 1 ||
|
||||
string.withCString({ cstring in inet_pton(AF_INET, cstring, &sin.sin_addr) }) == 1 else {
|
||||
|
||||
throw ValidationError.ipAddress
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user