import React from "react";
import Alert from "@mui/material/Alert";
import Button from "@mui/material/Button";
import Card from "@mui/material/Card";
import CircularProgress from "@mui/material/CircularProgress";
import Tooltip from "@mui/material/Tooltip";
import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
import dateFormat from "dateformat";
import { resultClassName } from "../util";
class ScanView extends React.Component {
constructor(props) {
super(props);
this.state = {
loaded: false,
rescanInProgress: false
};
this.getData = this.getData.bind(this);
this.rescan = this.rescan.bind(this);
}
componentDidMount() {
this.getData();
}
getData() {
fetch(
`${window.injectedEnv.COLLECTOR_URL}/sc/v0/get/${this.props.id}`,
{
headers: {
Authorization: "Bearer " + this.props.token
}
}
)
.then(resp => {
if (resp.status !== 200)
throw new Error(
`Unexpected HTTP response code from soc_collector: ${resp.status} ${resp.statusText}`
);
return resp.json();
})
.then(json => {
this.setState({
loaded: true,
...json.docs,
timestamp: new Date(json.docs.timestamp)
});
})
.catch(e => this.props.setError(e));
}
// TODO: Trigger a real re-scan
rescan() {
this.setState({ rescanInProgress: true });
setTimeout(
() =>
this.setState(prevState => ({
rescanInProgress: false,
timestamp: Date.now()
})),
2000
);
}
render() {
return (
this.state.loaded && (
General info
{this.state.description && (
<>
Domain
{this.state.domain}
Endpoint
{`${this.state.ip}:${this.state.port}`}
Hostname
{this.state.ptr}
Owner
{this.state.whois_description}
ASN
{`${this.state.asn} (${this.state.asn_country_code})`}
Abuse mail
{this.state.abuse_mail}
Custom info