This commit is contained in:
nathan 2020-08-18 22:33:40 +02:00
parent f8b4485cf2
commit 887729faf8
2 changed files with 4 additions and 4 deletions

View File

@ -80,7 +80,7 @@ internal object PingResultBuilder {
val host: String = matcher.group(2) val host: String = matcher.group(2)
val icmpSeq: Int = matcher.group(3).toInt() val icmpSeq: Int = matcher.group(3).toInt()
val ttl: Int = matcher.group(4).toInt() val ttl: Int = matcher.group(4).toInt()
val time = Duration.ofNanos((1000 * 1000 * matcher.group(5).toDouble()) as Long) val time = Duration.ofNanos(1000 * 1000 * matcher.group(5).toLong())
val response = PingResult.Response(bytes, host, icmpSeq, ttl, time) val response = PingResult.Response(bytes, host, icmpSeq, ttl, time)
result.responses.add(response) result.responses.add(response)

View File

@ -5,13 +5,13 @@ import java.util.regex.Pattern
class ResultParser(private val pattern: Pattern, private val reader: (PingResult, Matcher) -> PingResult) { class ResultParser(private val pattern: Pattern, private val reader: (PingResult, Matcher) -> PingResult) {
fun fill(result: PingResult, output: String): PingResult { fun fill(result: PingResult, output: String): PingResult {
var result = result var r = result
val matcher = pattern.matcher(output) val matcher = pattern.matcher(output)
while (matcher.find()) { while (matcher.find()) {
result = reader(result, matcher) r = reader(r, matcher)
} }
return result return r
} }
companion object { companion object {