mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
migrate ASN detail to caida, since bgpview no longer supports CORS headers [skip ci]
This commit is contained in:
@@ -57,8 +57,8 @@ const ASNode = (props: TNode<TNodeData>) => {
|
||||
<Box h={2} w={24}>
|
||||
<SkeletonText noOfLines={1} color={color} />
|
||||
</Box>
|
||||
) : !isError && asnData?.data?.description_short ? (
|
||||
asnData.data.description_short
|
||||
) : !isError && asnData?.data?.asn.organization?.orgName ? (
|
||||
asnData.data.asn.organization.orgName
|
||||
) : (
|
||||
name
|
||||
)}
|
||||
|
@@ -1,16 +1,22 @@
|
||||
import { useQuery } from 'react-query';
|
||||
|
||||
import type { TASNDetails } from '~/types';
|
||||
import type { TASNQuery } from '~/types';
|
||||
import type { TUseASNDetailFn } from './types';
|
||||
|
||||
async function query(ctx: TUseASNDetailFn): Promise<TASNDetails> {
|
||||
async function query(ctx: TUseASNDetailFn): Promise<TASNQuery> {
|
||||
const [asn] = ctx.queryKey;
|
||||
const res = await fetch(`https://api.bgpview.io/asn/${asn}`, { mode: 'cors' });
|
||||
const res = await fetch('https://api.asrank.caida.org/v2/graphql', {
|
||||
mode: 'cors',
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({ query: `{ asn(asn:\"${asn}\"){ organization { orgName } } }` }),
|
||||
});
|
||||
return await res.json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the bgpview.io API to get an ASN's organization name for the AS Path component.
|
||||
* Query the Caida AS Rank API to get an ASN's organization name for the AS Path component.
|
||||
* @see https://api.asrank.caida.org/v2/docs
|
||||
*/
|
||||
export function useASNDetail(asn: string) {
|
||||
return useQuery(asn, query, {
|
||||
|
@@ -1,26 +0,0 @@
|
||||
interface TASNRIRAllocation {
|
||||
rir_name: string | null;
|
||||
country_code: string | null;
|
||||
date_allocated: string | null;
|
||||
}
|
||||
interface TASNData {
|
||||
asn: number;
|
||||
name: string | null;
|
||||
description_short: string | null;
|
||||
description_full: string[];
|
||||
country_code: string;
|
||||
website: string | null;
|
||||
email_contacts: string[];
|
||||
abuse_contacts: string[];
|
||||
looking_glass: string | null;
|
||||
traffic_estimation: string | null;
|
||||
traffic_ratio: string | null;
|
||||
owner_address: string[];
|
||||
rir_allocation: TASNRIRAllocation;
|
||||
date_updated: string | null;
|
||||
}
|
||||
export interface TASNDetails {
|
||||
status: string;
|
||||
status_message: string;
|
||||
data: TASNData;
|
||||
}
|
9
hyperglass/ui/types/caida.ts
Normal file
9
hyperglass/ui/types/caida.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export interface TASNQuery {
|
||||
data: {
|
||||
asn: {
|
||||
organization: {
|
||||
orgName: string;
|
||||
} | null;
|
||||
};
|
||||
};
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
export * from './bgpview';
|
||||
export * from './caida';
|
||||
export * from './common';
|
||||
export * from './config';
|
||||
export * from './data';
|
||||
|
Reference in New Issue
Block a user