File tree Expand file tree Collapse file tree 1 file changed +1
-36
lines changed Expand file tree Collapse file tree 1 file changed +1
-36
lines changed Original file line number Diff line number Diff line change @@ -196,42 +196,7 @@ class ServerProfile: NSObject, NSCopying {
196
196
}
197
197
198
198
func isValid( ) -> Bool {
199
- func validateIpAddress( _ ipToValidate: String ) -> Bool {
200
-
201
- var sin = sockaddr_in ( )
202
- var sin6 = sockaddr_in6 ( )
203
-
204
- if ipToValidate. withCString ( { cstring in inet_pton ( AF_INET6, cstring, & sin6. sin6_addr) } ) == 1 {
205
- // IPv6 peer.
206
- return true
207
- }
208
- else if ipToValidate. withCString ( { cstring in inet_pton ( AF_INET, cstring, & sin. sin_addr) } ) == 1 {
209
- // IPv4 peer.
210
- return true
211
- }
212
-
213
- return false ;
214
- }
215
-
216
- func validateDomainName( _ value: String ) -> Bool {
217
- let validHostnameRegex = " ^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9 \\ -]*[a-zA-Z0-9]) \\ .)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9 \\ -]*[A-Za-z0-9])$ "
218
-
219
- if ( value. range ( of: validHostnameRegex, options: . regularExpression) != nil ) {
220
- return true
221
- } else {
222
- return false
223
- }
224
- }
225
-
226
- if !( validateIpAddress ( serverHost) || validateDomainName ( serverHost) ) {
227
- return false
228
- }
229
-
230
- if password. isEmpty {
231
- return false
232
- }
233
-
234
- return true
199
+ return Validator . serverHost ( serverHost) && Validator . password ( password)
235
200
}
236
201
237
202
private func makeLegacyURL( ) -> URL ? {
You can’t perform that action at this time.
0 commit comments