mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			20 lines
		
	
	
		
			525 B
		
	
	
	
		
			Swift
		
	
			
		
		
	
	
			20 lines
		
	
	
		
			525 B
		
	
	
	
		
			Swift
		
	
| // Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
 | |
| //
 | |
| // stringlint:disable
 | |
| 
 | |
| import Foundation
 | |
| 
 | |
| public enum IPv4 {
 | |
|     public static func toInt(_ ip: String) -> Int64? {
 | |
|         let octets: [Int64] = ip.split(separator: ".").compactMap { Int64($0) }
 | |
|         guard octets.count > 1 else { return nil }
 | |
|         
 | |
|         var result: Int64 = 0
 | |
|         for i in stride(from: 3, through: 0, by: -1) {
 | |
|             result += octets[ 3 - i ] << (i * 8)
 | |
|         }
 | |
|         
 | |
|         return (result > 0 ? result : nil)
 | |
|     }
 | |
| }
 |