ipv4 split

This commit is contained in:
Michal Srutek 2023-12-21 08:22:19 +01:00
parent ecfcb3d9f5
commit e50278a35e
2 changed files with 4 additions and 4 deletions

View File

@ -177,10 +177,10 @@ public class Util {
}
if let ipv4Range = Range(match.range(at: 2), in: address) {
let ipv4 = address[ipv4Range]
let ipv4Splitted = ipv4.split(separator: ".")
let ipv4Split = ipv4.split(separator: ".")
var ipv4Converted = Array(repeating: "0000", count: 4)
for i in 0...3 {
let byte = Int(ipv4Splitted[i])!
let byte = Int(ipv4Split[i])!
let hex = ("0" + String(byte, radix: 16))
var offset = hex.count - 3
offset = offset < 0 ? 0 : offset

View File

@ -106,10 +106,10 @@ public class Util {
}
if let ipv4Range = Range(match.range(at: 2), in: address) {
let ipv4 = address[ipv4Range]
let ipv4Splitted = ipv4.split(separator: ".")
let ipv4Split = ipv4.split(separator: ".")
var ipv4Converted = Array(repeating: "0000", count: 4)
for i in 0...3 {
let byte = Int(ipv4Splitted[i])!
let byte = Int(ipv4Split[i])!
let hex = ("0" + String(byte, radix: 16))
var offset = hex.count - 3
offset = offset < 0 ? 0 : offset