1
0
mirror of https://github.com/bgp/stayrtr.git synced 2024-05-06 15:54:54 +00:00

Add BGPsec Router Key support to rtrdump

Tag: https://github.com/bgp/stayrtr/issues/57
This commit is contained in:
Ben Cartwright-Cox
2023-02-21 22:05:50 +00:00
parent 513bda0e5f
commit 19ca7b27e9
2 changed files with 14 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"crypto/tls"
"encoding/hex"
"encoding/json"
"flag"
"fmt"
@ -96,6 +97,18 @@ func (c *Client) HandlePDU(cs *rtr.ClientSession, pdu rtr.PDU) {
c.Data.Data = append(c.Data.Data, rj)
c.Data.Metadata.Counts++
if *LogDataPDU {
log.Debugf("Received: %v", pdu)
}
case *rtr.PDURouterKey:
skiHex := hex.EncodeToString(pdu.SubjectKeyIdentifier)
rj := prefixfile.BgpSecKeyJson{
Asn: uint32(pdu.ASN),
Pubkey: pdu.SubjectPublicKeyInfo,
Ski: skiHex,
}
c.Data.BgpSecKeys = append(c.Data.BgpSecKeys, rj)
if *LogDataPDU {
log.Debugf("Received: %v", pdu)
}

View File

@ -38,7 +38,7 @@ type VRPList struct {
type BgpSecKeyJson struct {
Asn uint32 `json:"asn"`
Expires *uint32 `json:"expires,omitempty"`
Ta string `json:"ta"`
Ta string `json:"ta,omitempty"`
// Base32 encoded, but encoding/json handles this for us
// Example: MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE4FxJr0n2bux1uX1Evl+QWwZYvIadPjLuFX2mxqKuAGUhKnr7VLLDgrE++l9p5eH2kWTNVAN22FUU3db/RKpE2w==