Skip to content

Commit

Permalink
Cleanups
Browse files Browse the repository at this point in the history
* Remove latent capability for string parsing
* Cleanup documentation about VRP signing
* Add metadata 'buildtime' in JSON example
  • Loading branch information
job committed Jul 18, 2021
1 parent d74e626 commit da402a1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 33 deletions.
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ StayRTR is an open-source implementation of RPKI to Router protocol (RFC 6810) b
This project is not affiliated with Cloudflare and any references to Cloudflare are simply a function of forking. We do love the Cloudyflares though!

* `/lib` contains a library to create your own server and client.
* `/prefixfile` contains the structure of a JSON export file and signing capabilities.
* `/prefixfile` contains the structure of a JSON export file.
* `/cmd/stayrtr/stayrtr.go` is a simple implementation that fetches a list and offers it to a router.
* `/cmd/rtrdump/rtrdump.go` allows copying the PDUs sent by a RTR server as a JSON file.
* `/cmd/rtrmon/rtrmon.go` compare and monitor two RTR servers (using RTR and/or JSON), outputs diff and Prometheus metrics.
Expand Down Expand Up @@ -108,16 +108,6 @@ $ sudo dpkg -i stayrtr[...].deb
$ sudo systemctl start stayrtr
```

If you want to sign your list of prefixes, generate an ECDSA key.
Then generate the public key to be used in StayRTR.
You will have to setup your validator to use this key or have another
tool to sign the JSON file before passing it to StayRTR.

```bash
$ openssl ecparam -genkey -name prime256v1 -noout -outform pem > private.pem
$ openssl ec -in private.pem -pubout -outform pem > public.pem
```

## Run it

Once you have a binary:
Expand Down Expand Up @@ -269,11 +259,15 @@ Use your own validator, as long as the JSON source follows the following schema:

```
{
"metadata": {
"buildtime": "2021-07-18T13:36:26Z"
...
},
"roas": [
{
"prefix": "10.0.0.0/24",
"maxLength": 24,
"asn": "AS65001"
"asn": 65001
},
...
]
Expand Down
12 changes: 0 additions & 12 deletions prefixfile/prefixfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"errors"
"fmt"
"net"
"strconv"
"strings"
)

type VRPJson struct {
Expand All @@ -28,16 +26,6 @@ type VRPList struct {

func (vrp *VRPJson) GetASN2() (uint32, error) {
switch asnc := vrp.ASN.(type) {
case string:
asnStr := strings.TrimLeft(asnc, "aAsS")
asnInt, err := strconv.ParseUint(asnStr, 10, 32)
if err != nil {
return 0, errors.New(fmt.Sprintf("Could not decode ASN: %v as part of VRP", vrp.ASN))
}
asn := uint32(asnInt)
return asn, nil
case float64:
return uint32(asnc), nil
case int:
return uint32(asnc), nil
default:
Expand Down
6 changes: 1 addition & 5 deletions prefixfile/slurm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package prefixfile

import (
"encoding/json"
"fmt"
"io"
"net"
)
Expand All @@ -18,9 +17,6 @@ func (pf *SlurmPrefixFilter) GetASN() (uint32, bool) {
return 0, true
} else {
switch asn := pf.ASN.(type) {
case json.Number:
c, _ := asn.Int64()
return uint32(c), false
case uint32:
return asn, false
default:
Expand Down Expand Up @@ -144,7 +140,7 @@ func (s *SlurmLocallyAddedAssertions) AssertVRPs() []VRPJson {
maxLength = size
}
vrps = append(vrps, VRPJson{
ASN: fmt.Sprintf("AS%v", assertion.ASN),
ASN: assertion.ASN,
Prefix: assertion.Prefix,
Length: uint8(maxLength),
TA: assertion.Comment,
Expand Down
8 changes: 4 additions & 4 deletions prefixfile/slurm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@ func TestDecodeJSON(t *testing.T) {
func TestFilterOnVRPs(t *testing.T) {
vrps := []VRPJson{
VRPJson{
ASN: "AS65001",
ASN: uint32(65001),
Prefix: "192.168.0.0/25",
Length: 25,
},
VRPJson{
ASN: "AS65002",
ASN: uint32(65002),
Prefix: "192.168.1.0/24",
Length: 24,
},
VRPJson{
ASN: "AS65003",
ASN: uint32(65003),
Prefix: "192.168.2.0/24",
Length: 24,
},
VRPJson{
ASN: "AS65004",
ASN: uint32(65004),
Prefix: "10.0.0.0/24",
Length: 24,
},
Expand Down

0 comments on commit da402a1

Please sign in to comment.