From c1bca2555919f9f2a7dd9d13dc3e14a4bf6a589a Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Fri, 16 Nov 2018 10:06:47 +0900 Subject: use google/protobuf/timestamp.proto use google/protobuf/timestamp.proto instead of our own way to represent time. Signed-off-by: FUJITA Tomonori --- pkg/server/grpc_server.go | 8 +++----- pkg/server/server.go | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'pkg') diff --git a/pkg/server/grpc_server.go b/pkg/server/grpc_server.go index 98b28b00..54d4b28d 100644 --- a/pkg/server/grpc_server.go +++ b/pkg/server/grpc_server.go @@ -28,6 +28,7 @@ import ( "time" farm "github.com/dgryski/go-farm" + "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/any" "github.com/golang/protobuf/ptypes/empty" log "github.com/sirupsen/logrus" @@ -115,10 +116,11 @@ func newValidationFromTableStruct(v *table.Validation) *api.RPKIValidation { func toPathAPI(binNlri []byte, binPattrs [][]byte, anyNlri *any.Any, anyPattrs []*any.Any, path *table.Path, v *table.Validation) *api.Path { nlri := path.GetNlri() + t, _ := ptypes.TimestampProto(path.GetTimestamp()) p := &api.Path{ Nlri: binNlri, Pattrs: binPattrs, - Age: path.GetTimestamp().Unix(), + Age: t, IsWithdraw: path.IsWithdraw, ValidationDetail: newValidationFromTableStruct(v), Family: &api.Family{Afi: api.Family_Afi(nlri.AFI()), Safi: api.Family_Safi(nlri.SAFI())}, @@ -615,8 +617,6 @@ func newNeighborFromAPIStruct(a *api.Peer) (*config.Neighbor, error) { if a.Timers.State != nil { pconf.Timers.State.KeepaliveInterval = float64(a.Timers.State.KeepaliveInterval) pconf.Timers.State.NegotiatedHoldTime = float64(a.Timers.State.NegotiatedHoldTime) - pconf.Timers.State.Uptime = int64(a.Timers.State.Uptime) - pconf.Timers.State.Downtime = int64(a.Timers.State.Downtime) } } if a.RouteReflector != nil { @@ -723,8 +723,6 @@ func newPeerGroupFromAPIStruct(a *api.PeerGroup) (*config.PeerGroup, error) { if a.Timers.State != nil { pconf.Timers.State.KeepaliveInterval = float64(a.Timers.State.KeepaliveInterval) pconf.Timers.State.NegotiatedHoldTime = float64(a.Timers.State.NegotiatedHoldTime) - pconf.Timers.State.Uptime = int64(a.Timers.State.Uptime) - pconf.Timers.State.Downtime = int64(a.Timers.State.Downtime) } } if a.RouteReflector != nil { diff --git a/pkg/server/server.go b/pkg/server/server.go index 256105aa..ce4f3b22 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -3380,8 +3380,8 @@ func (s *BgpServer) ListRpki(ctx context.Context, r *api.ListRpkiRequest, fn fun RemotePort: uint32(r.Config.Port), }, State: &api.RPKIState{ - Uptime: r.State.Uptime, - Downtime: r.State.Downtime, + Uptime: config.ProtoTimestamp(r.State.Uptime), + Downtime: config.ProtoTimestamp(r.State.Downtime), Up: r.State.Up, RecordIpv4: r.State.RecordsV4, RecordIpv6: r.State.RecordsV6, -- cgit v1.2.3