Skip to content

Commit

Permalink
Clean up more RTR v2 remnants (#129)
Browse files Browse the repository at this point in the history
Clean up more RTR v2 remnants
  • Loading branch information
job authored Sep 11, 2024
1 parent 00470a4 commit 91a6209
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 25 deletions.
11 changes: 3 additions & 8 deletions cmd/rtrdump/rtrdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var (
Serial = flag.Int("serial.value", 0, "Serial number")
Session = flag.Int("session.id", 0, "Session ID")

FlagVersion = flag.Int("rtr.version", 2, "What RTR version you want to use, Version 2 is draft-ietf-sidrops-8210bis-10")
FlagVersion = flag.Int("rtr.version", 1, "What RTR version you want to use, Version 1 is RFC8210")

ConnType = flag.String("type", "plain", "Type of connection: plain, tls or ssh")
ValidateCert = flag.Bool("tls.validate", true, "Validate TLS")
Expand Down Expand Up @@ -147,13 +147,11 @@ func main() {
}

targetVersion := rtr.PROTOCOL_VERSION_0
if *FlagVersion > 2 {
log.Fatalf("Invalid RTR Version provided, the highest version this release supports is 2")
if *FlagVersion > 1 {
log.Fatalf("Invalid RTR Version provided, the highest version this release supports is 1")
}
if *FlagVersion == 1 {
targetVersion = rtr.PROTOCOL_VERSION_1
} else if *FlagVersion == 2 {
targetVersion = rtr.PROTOCOL_VERSION_2
}

lvl, _ := log.ParseLevel(*LogLevel)
Expand Down Expand Up @@ -225,9 +223,6 @@ func main() {
log.Infof("Connecting with %v to %v", *ConnType, *Connect)
err := clientSession.Start(*Connect, typeToId[*ConnType], configTLS, configSSH)
if err != nil {
if err == io.EOF && targetVersion == rtr.PROTOCOL_VERSION_2 {
log.Warnf("EOF From remote side, This might be due to version 2 being requested, try using -rtr.version 1")
}
log.Fatal(err)
}

Expand Down
1 change: 0 additions & 1 deletion cmd/stayrtr/stayrtr.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ var (
protoverToLib = map[int]uint8{
0: rtr.PROTOCOL_VERSION_0,
1: rtr.PROTOCOL_VERSION_1,
2: rtr.PROTOCOL_VERSION_2,
}
)

Expand Down
14 changes: 0 additions & 14 deletions lib/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,6 @@ func (c *ClientSession) StartRW(rd io.Reader, wr io.Writer) error {
}
c.version = PROTOCOL_VERSION_0
}
if c.version == PROTOCOL_VERSION_2 {
downgraded := false
switch dec.GetVersion() {
case PROTOCOL_VERSION_0:
c.version = PROTOCOL_VERSION_0
downgraded = true
case PROTOCOL_VERSION_1:
c.version = PROTOCOL_VERSION_1
downgraded = true
}
if c.log != nil && downgraded {
c.log.Infof("Downgrading to version %d", c.version)
}
}

if c.handler != nil {
c.handler.HandlePDU(c, dec)
Expand Down
2 changes: 1 addition & 1 deletion lib/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ func (c *Client) SetDisableVersionCheck(disableCheck bool) {
}

func (c *Client) checkVersion(newversion uint8) {
if (!c.versionset || newversion == c.version) && (newversion == PROTOCOL_VERSION_2 || newversion == PROTOCOL_VERSION_1 || newversion == PROTOCOL_VERSION_0) {
if (!c.versionset || newversion == c.version) && (newversion == PROTOCOL_VERSION_1 || newversion == PROTOCOL_VERSION_0) {
c.SetVersion(newversion)
} else {
if c.log != nil {
Expand Down
1 change: 0 additions & 1 deletion lib/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const (

PROTOCOL_VERSION_0 = 0
PROTOCOL_VERSION_1 = 1
PROTOCOL_VERSION_2 = 2

PDU_ID_SERIAL_NOTIFY = 0
PDU_ID_SERIAL_QUERY = 1
Expand Down

0 comments on commit 91a6209

Please sign in to comment.