@@ -76,12 +76,20 @@ func newSegment(segType proto.PathSegType, srcI addr.ISD, srcA addr.AS, dstI add
76
76
interfaces : interfaces , Updated : time .Unix (0 , updateTime ), Expiry : time .Unix (0 , expiryTime )}
77
77
}
78
78
79
- func (s segment ) String ( ) string {
79
+ func (s segment ) toString ( showTimestamps bool ) string {
80
80
toRet := s .SegType .String () + "\t "
81
81
now := time .Now ()
82
82
updatedStr := now .Sub (s .Updated ).String ()
83
83
expiryStr := now .Sub (s .Expiry ).String ()
84
- return toRet + ifsArrayToString (s .interfaces ) + "\t Updated: " + updatedStr + "\t : Expires in: " + expiryStr
84
+ toRet += ifsArrayToString (s .interfaces )
85
+ if showTimestamps {
86
+ toRet += "\t Updated: " + updatedStr + "\t : Expires in: " + expiryStr
87
+ }
88
+ return toRet
89
+ }
90
+
91
+ func (s segment ) String () string {
92
+ return s .toString (true )
85
93
}
86
94
87
95
// returns if this segment is < the other segment. It relies on the
@@ -189,8 +197,11 @@ func removeAllDir(dirName string) {
189
197
190
198
func main () {
191
199
var origFilename string
200
+ var showTimestamps bool
192
201
flag .StringVar (& origFilename , "db" , "" , "Sqlite DB file (optional)" )
193
202
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" )
194
205
flag .Parse ()
195
206
196
207
if origFilename == "" {
@@ -268,6 +279,6 @@ func main() {
268
279
return segments [i ].lessThan (& segments [j ])
269
280
})
270
281
for _ , seg := range segments {
271
- fmt .Println (seg )
282
+ fmt .Println (seg . toString ( showTimestamps ) )
272
283
}
273
284
}
0 commit comments