import React from 'react'
import _ from 'lodash'
import { formatTimeStamp, formatTimeDelta } from '../../utils.js'
export function TimeStamp({ t, deltaTo, title }) {
return t ? (
{title}: |
{formatTimeStamp(t)}
{deltaTo && (
({formatTimeDelta(1000 * (t - deltaTo))})
)}
|
) : (
)
}
export function ConnectionInfo({ conn }) {
return (
Address: |
{conn.address.join(':')} |
{conn.sni && (
TLS SNI: |
{conn.sni} |
)}
)
}
export function CertificateInfo({ flow }) {
// @todo We should fetch human-readable certificate representation from the server
return (
{flow.client_conn.cert && [
Client Certificate
,
{flow.client_conn.cert}
]}
{flow.server_conn.cert && [
Server Certificate
,
{flow.server_conn.cert}
]}
)
}
export function Timing({ flow }) {
const { server_conn: sc, client_conn: cc, request: req, response: res } = flow
const timestamps = [
{
title: "Server conn. initiated",
t: sc.timestamp_start,
deltaTo: req.timestamp_start
}, {
title: "Server conn. TCP handshake",
t: sc.timestamp_tcp_setup,
deltaTo: req.timestamp_start
}, {
title: "Server conn. SSL handshake",
t: sc.timestamp_ssl_setup,
deltaTo: req.timestamp_start
}, {
title: "Client conn. established",
t: cc.timestamp_start,
deltaTo: req.timestamp_start
}, {
title: "Client conn. SSL handshake",
t: cc.timestamp_ssl_setup,
deltaTo: req.timestamp_start
}, {
title: "First request byte",
t: req.timestamp_start,
}, {
title: "Request complete",
t: req.timestamp_end,
deltaTo: req.timestamp_start
}, res && {
title: "First response byte",
t: res.timestamp_start,
deltaTo: req.timestamp_start
}, res && {
title: "Response complete",
t: res.timestamp_end,
deltaTo: req.timestamp_start
}
]
return (
Timing
{timestamps.filter(v => v).sort((a, b) => a.t - b.t).map(item => (
))}
)
}
export default function Details({ flow }) {
return (
Client Connection
Server Connection
)
}