Skip to content

Commit bc1a9de

Browse files
authored
PS dump optional show expiration times (#41)
1 parent 87c9760 commit bc1a9de

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tools/pathdb_dump/pathdb_dump.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,20 @@ func newSegment(segType proto.PathSegType, srcI addr.ISD, srcA addr.AS, dstI add
7676
interfaces: interfaces, Updated: time.Unix(0, updateTime), Expiry: time.Unix(0, expiryTime)}
7777
}
7878

79-
func (s segment) String() string {
79+
func (s segment) toString(showTimestamps bool) string {
8080
toRet := s.SegType.String() + "\t"
8181
now := time.Now()
8282
updatedStr := now.Sub(s.Updated).String()
8383
expiryStr := now.Sub(s.Expiry).String()
84-
return toRet + ifsArrayToString(s.interfaces) + "\tUpdated: " + updatedStr + "\t: Expires in: " + expiryStr
84+
toRet += ifsArrayToString(s.interfaces)
85+
if showTimestamps {
86+
toRet += "\tUpdated: " + updatedStr + "\t: Expires in: " + expiryStr
87+
}
88+
return toRet
89+
}
90+
91+
func (s segment) String() string {
92+
return s.toString(true)
8593
}
8694

8795
// returns if this segment is < the other segment. It relies on the
@@ -189,8 +197,11 @@ func removeAllDir(dirName string) {
189197

190198
func main() {
191199
var origFilename string
200+
var showTimestamps bool
192201
flag.StringVar(&origFilename, "db", "", "Sqlite DB file (optional)")
193202
flag.StringVar(&origFilename, "database", "", "Sqlite DB file (optional)")
203+
flag.BoolVar(&showTimestamps, "t", false, "Show update and expiration times")
204+
flag.BoolVar(&showTimestamps, "timestamps", false, "Show update and expiration times")
194205
flag.Parse()
195206

196207
if origFilename == "" {
@@ -268,6 +279,6 @@ func main() {
268279
return segments[i].lessThan(&segments[j])
269280
})
270281
for _, seg := range segments {
271-
fmt.Println(seg)
282+
fmt.Println(seg.toString(showTimestamps))
272283
}
273284
}

0 commit comments

Comments
 (0)