WIP ping
parent
f8b4485cf2
commit
887729faf8
|
@ -80,7 +80,7 @@ internal object PingResultBuilder {
|
|||
val host: String = matcher.group(2)
|
||||
val icmpSeq: Int = matcher.group(3).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)
|
||||
|
||||
result.responses.add(response)
|
||||
|
|
|
@ -5,13 +5,13 @@ import java.util.regex.Pattern
|
|||
|
||||
class ResultParser(private val pattern: Pattern, private val reader: (PingResult, Matcher) -> PingResult) {
|
||||
fun fill(result: PingResult, output: String): PingResult {
|
||||
var result = result
|
||||
var r = result
|
||||
val matcher = pattern.matcher(output)
|
||||
while (matcher.find()) {
|
||||
result = reader(result, matcher)
|
||||
r = reader(r, matcher)
|
||||
}
|
||||
|
||||
return result
|
||||
return r
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
Loading…
Reference in New Issue