@ -42,6 +42,7 @@ import (
"github.com/dsnet/try"
"github.com/dsnet/try"
jsonv2 "github.com/go-json-experiment/json"
jsonv2 "github.com/go-json-experiment/json"
"github.com/go-json-experiment/json/jsontext"
"tailscale.com/types/logid"
"tailscale.com/types/logid"
"tailscale.com/types/netlogtype"
"tailscale.com/types/netlogtype"
"tailscale.com/util/cmpx"
"tailscale.com/util/cmpx"
@ -75,13 +76,13 @@ func main() {
func processStream ( r io . Reader ) ( err error ) {
func processStream ( r io . Reader ) ( err error ) {
defer try . Handle ( & err )
defer try . Handle ( & err )
dec := json v2 . NewDecoder ( os . Stdin )
dec := json text . NewDecoder ( os . Stdin )
for {
for {
processValue ( dec )
processValue ( dec )
}
}
}
}
func processValue ( dec * json v2 . Decoder ) {
func processValue ( dec * json text . Decoder ) {
switch dec . PeekKind ( ) {
switch dec . PeekKind ( ) {
case '[' :
case '[' :
processArray ( dec )
processArray ( dec )
@ -92,7 +93,7 @@ func processValue(dec *jsonv2.Decoder) {
}
}
}
}
func processArray ( dec * json v2 . Decoder ) {
func processArray ( dec * json text . Decoder ) {
try . E1 ( dec . ReadToken ( ) ) // parse '['
try . E1 ( dec . ReadToken ( ) ) // parse '['
for dec . PeekKind ( ) != ']' {
for dec . PeekKind ( ) != ']' {
processValue ( dec )
processValue ( dec )
@ -100,7 +101,7 @@ func processArray(dec *jsonv2.Decoder) {
try . E1 ( dec . ReadToken ( ) ) // parse ']'
try . E1 ( dec . ReadToken ( ) ) // parse ']'
}
}
func processObject ( dec * json v2 . Decoder ) {
func processObject ( dec * json text . Decoder ) {
var hasTraffic bool
var hasTraffic bool
var rawMsg [ ] byte
var rawMsg [ ] byte
try . E1 ( dec . ReadToken ( ) ) // parse '{'
try . E1 ( dec . ReadToken ( ) ) // parse '{'