diff options
-rw-r--r-- | api/gobgp.pb.go | 8 | ||||
-rw-r--r-- | api/gobgp.proto | 2 | ||||
-rw-r--r-- | gobgp/cmd/monitor.go | 3 | ||||
-rw-r--r-- | gobgp/cmd/rpki.go | 5 | ||||
-rw-r--r-- | server/rpki.go | 27 |
5 files changed, 15 insertions, 30 deletions
diff --git a/api/gobgp.pb.go b/api/gobgp.pb.go index 1085b4a3..8452693d 100644 --- a/api/gobgp.pb.go +++ b/api/gobgp.pb.go @@ -1298,7 +1298,7 @@ func (*MrtMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{ type RPKIConf struct { Address string `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"` - RemotePort uint32 `protobuf:"varint,2,opt,name=remote_port" json:"remote_port,omitempty"` + RemotePort string `protobuf:"bytes,2,opt,name=remote_port" json:"remote_port,omitempty"` } func (m *RPKIConf) Reset() { *m = RPKIConf{} } @@ -3130,7 +3130,7 @@ var fileDescriptor0 = []byte{ 0x2f, 0x8f, 0x07, 0xec, 0x22, 0xaf, 0x73, 0xae, 0x4b, 0x39, 0x8b, 0x28, 0x58, 0x89, 0x39, 0x4b, 0xec, 0xe3, 0x26, 0xac, 0x0d, 0xcd, 0x91, 0x41, 0x41, 0x91, 0x7b, 0x89, 0x4f, 0xa8, 0x75, 0x80, 0x7d, 0xd7, 0x0f, 0x5a, 0x16, 0xe4, 0x33, 0x34, 0x7c, 0x43, 0x1e, 0xf1, 0xde, 0x83, 0x42, 0xaf, - 0xfb, 0xa4, 0xcd, 0x33, 0x4b, 0xe4, 0x9c, 0x2d, 0x95, 0x54, 0x28, 0x44, 0x8a, 0xfa, 0x6b, 0x1a, + 0xfb, 0xa4, 0xcd, 0x33, 0x4b, 0xe4, 0x9c, 0x2d, 0x95, 0x54, 0x28, 0x44, 0xb2, 0xfb, 0x6b, 0x1a, 0x8a, 0x84, 0x22, 0xea, 0x6e, 0x58, 0xeb, 0x52, 0x7c, 0x68, 0x11, 0xad, 0x75, 0x1c, 0x11, 0x34, 0x03, 0x60, 0x17, 0x9b, 0x09, 0x4e, 0x09, 0xb0, 0x01, 0xc3, 0x0e, 0x5b, 0xb7, 0x9c, 0x67, 0x9f, 0xb1, 0x3b, 0x55, 0xe2, 0x8b, 0x0f, 0xe4, 0x58, 0x43, 0xc3, 0xb6, 0xc8, 0x7c, 0x0c, 0x99, 0x5f, @@ -3209,6 +3209,6 @@ var fileDescriptor0 = []byte{ 0x50, 0xda, 0xaf, 0xb1, 0x8f, 0x0a, 0xbe, 0x30, 0x50, 0xde, 0x8a, 0x27, 0xba, 0xf8, 0x67, 0x11, 0x49, 0x72, 0x76, 0x60, 0x6b, 0x21, 0x67, 0x64, 0xfe, 0x7f, 0xc9, 0x85, 0x60, 0xfd, 0x65, 0x97, 0x85, 0x57, 0x94, 0x2e, 0x6c, 0x25, 0x7c, 0xf0, 0xa0, 0xdc, 0x4c, 0x12, 0x6c, 0xf5, 0x7b, 0x88, - 0x04, 0x11, 0x4f, 0xf2, 0xfc, 0x05, 0xdd, 0xa7, 0xff, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x17, 0xfa, - 0x96, 0xd6, 0x50, 0x27, 0x00, 0x00, + 0x04, 0x11, 0x4f, 0xf2, 0xfc, 0x05, 0xdd, 0xa7, 0xff, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x21, + 0x2f, 0xae, 0x50, 0x27, 0x00, 0x00, } diff --git a/api/gobgp.proto b/api/gobgp.proto index d0e47804..6b4f4c82 100644 --- a/api/gobgp.proto +++ b/api/gobgp.proto @@ -468,7 +468,7 @@ message MrtMessage { message RPKIConf { string address = 1; - uint32 remote_port = 2; + string remote_port = 2; } message RPKIState { diff --git a/gobgp/cmd/monitor.go b/gobgp/cmd/monitor.go index f432ce45..af6f6c74 100644 --- a/gobgp/cmd/monitor.go +++ b/gobgp/cmd/monitor.go @@ -24,7 +24,6 @@ import ( "golang.org/x/net/context" "io" "net" - "strconv" "time" ) @@ -146,7 +145,7 @@ func NewMonitorCmd() *cobra.Command { if i != 0 { fmt.Printf(",") } - fmt.Printf(" [Source: %s, AS: %v, Prefix: %s, Prefixlen: %v, Maxlen: %v]", net.JoinHostPort(roa.Conf.Address, strconv.Itoa(int(roa.Conf.RemotePort))), roa.As, roa.Prefix, roa.Prefixlen, roa.Maxlen) + fmt.Printf(" [Source: %s, AS: %v, Prefix: %s, Prefixlen: %v, Maxlen: %v]", net.JoinHostPort(roa.Conf.Address, roa.Conf.RemotePort), roa.As, roa.Prefix, roa.Prefixlen, roa.Maxlen) } fmt.Printf("\n") } diff --git a/gobgp/cmd/rpki.go b/gobgp/cmd/rpki.go index a0844461..7aa8e40a 100644 --- a/gobgp/cmd/rpki.go +++ b/gobgp/cmd/rpki.go @@ -23,7 +23,6 @@ import ( "golang.org/x/net/context" "io" "net" - "strconv" "time" ) @@ -56,7 +55,7 @@ func showRPKIServer(args []string) error { uptime = fmt.Sprint(formatTimedelta(int64(time.Now().Sub(time.Unix(r.State.Uptime, 0)).Seconds()))) } - fmt.Printf(format, net.JoinHostPort(r.Conf.Address, strconv.Itoa(int(r.Conf.RemotePort))), s, uptime, fmt.Sprintf("%d/%d", r.State.RecordIpv4, r.State.RecordIpv6)) + fmt.Printf(format, net.JoinHostPort(r.Conf.Address, r.Conf.RemotePort), s, uptime, fmt.Sprintf("%d/%d", r.State.RecordIpv4, r.State.RecordIpv6)) } } else { for _, r := range servers { @@ -122,7 +121,7 @@ func showRPKITable(args []string) error { continue } - server := net.JoinHostPort(r.Conf.Address, strconv.Itoa(int(r.Conf.RemotePort))) + server := net.JoinHostPort(r.Conf.Address, r.Conf.RemotePort) fmt.Printf(format, fmt.Sprintf("%s/%d", r.Prefix, r.Prefixlen), fmt.Sprint(r.Maxlen), fmt.Sprint(r.As), server) } return nil diff --git a/server/rpki.go b/server/rpki.go index 0185b3f8..12769ef7 100644 --- a/server/rpki.go +++ b/server/rpki.go @@ -22,7 +22,6 @@ import ( "net" "sort" "strconv" - "strings" "time" log "github.com/Sirupsen/logrus" @@ -50,7 +49,7 @@ type roa struct { func (r *roa) toApiStruct() []*api.ROA { l := make([]*api.ROA, 0, len(r.AS)) for _, as := range r.AS { - host, port := splitHostPort(r.Src) + host, port, _ := net.SplitHostPort(r.Src) a := &api.ROA{ As: as, Maxlen: uint32(r.MaxLen), @@ -58,7 +57,7 @@ func (r *roa) toApiStruct() []*api.ROA { Prefix: r.bucket.Prefix.String(), Conf: &api.RPKIConf{ Address: host, - RemotePort: uint32(port), + RemotePort: port, }, } l = append(l, a) @@ -171,7 +170,7 @@ func (m *roaManager) deleteAllROA(network string) { func (m *roaManager) operate(op api.Operation, address string) error { for network, client := range m.clientMap { - add, _ := splitHostPort(network) + add, _, _ := net.SplitHostPort(network) if add == address { switch op { case api.Operation_ENABLE: @@ -397,25 +396,13 @@ func (c *roaManager) handleRTRMsg(client *roaClient, state *config.RpkiServerSta } } -func splitHostPort(network string) (host string, port int) { - if strings.HasPrefix(network, "[") { - l := strings.Split(network, "]:") - port, _ := strconv.Atoi(l[1]) - return l[0][1:], port - } else { - l := strings.Split(network, ":") - port, _ := strconv.Atoi(l[1]) - return l[0], port - } -} - func (c *roaManager) handleGRPC(grpcReq *GrpcRequest) { switch grpcReq.RequestType { case REQ_RPKI: results := make([]*GrpcResponse, 0) for _, client := range c.clientMap { state := client.state - addr, port := splitHostPort(client.host) + addr, port, _ := net.SplitHostPort(client.host) received := &state.RpkiMessages.RpkiReceived sent := client.state.RpkiMessages.RpkiSent up := true @@ -425,7 +412,7 @@ func (c *roaManager) handleGRPC(grpcReq *GrpcRequest) { rpki := &api.RPKI{ Conf: &api.RPKIConf{ Address: addr, - RemotePort: uint32(port), + RemotePort: port, }, State: &api.RPKIState{ Uptime: state.Uptime, @@ -477,7 +464,7 @@ func (c *roaManager) handleGRPC(grpcReq *GrpcRequest) { var roaList roas for _, r := range b.entries { for _, as := range r.AS { - host, port := splitHostPort(r.Src) + host, port, _ := net.SplitHostPort(r.Src) roa := &api.ROA{ As: as, Maxlen: uint32(r.MaxLen), @@ -485,7 +472,7 @@ func (c *roaManager) handleGRPC(grpcReq *GrpcRequest) { Prefix: b.Prefix.String(), Conf: &api.RPKIConf{ Address: host, - RemotePort: uint32(port), + RemotePort: port, }, } roaList = append(roaList, roa) |