diff --git a/go.mod b/go.mod index 0fecb9e7..59da8f9a 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,9 @@ go 1.13 require ( github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75 github.com/cheekybits/genny v1.0.0 + github.com/francoispqt/gojay v1.2.13 github.com/golang/mock v1.4.0 - github.com/golang/protobuf v1.3.0 + github.com/golang/protobuf v1.3.1 github.com/marten-seemann/chacha20 v0.2.0 github.com/marten-seemann/qpack v0.1.0 github.com/marten-seemann/qtls v0.7.1 diff --git a/go.sum b/go.sum index 3dbadd75..d395e5de 100644 --- a/go.sum +++ b/go.sum @@ -1,22 +1,80 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.37.0/go.mod h1:TS1dMSSfndXH133OKGwekG838Om/cQT0BUHV3HcBgoo= +dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU= +dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= +dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= +dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= +git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75 h1:3ILjVyslFbc4jl1w5TWuvvslFD/nDfR2H8tVaMVLrEY= github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75/go.mod h1:uAXEEpARkRhCZfEvy/y0Jcc888f9tHCc1W7/UeEtreE= +github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= +github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE= github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= +github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= +github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= +github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.4.0 h1:Rd1kQnQu0Hq3qvJppYSG0HtP+f5LPPUiDswTLiEegLg= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.0 h1:kbxbvI4Un1LUWKxufD+BiE6AEExYYgkQLQmLFqA1LFk= -github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= +github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= +github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= +github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/marten-seemann/chacha20 v0.2.0 h1:f40vqzzx+3GdOmzQoItkLX5WLvHgPgyYqFFIO5Gh4hQ= github.com/marten-seemann/chacha20 v0.2.0/go.mod h1:HSdjFau7GzYRj+ahFNwsO3ouVJr1HFkWoEwNDb4TMtE= github.com/marten-seemann/qpack v0.1.0 h1:/0M7lkda/6mus9B8u34Asqm8ZhHAAt9Ho0vniNuVSVg= github.com/marten-seemann/qpack v0.1.0/go.mod h1:LFt1NU/Ptjip0C2CPkhimBz5CGE3WGDAUWqna+CNTrI= github.com/marten-seemann/qtls v0.7.1 h1:+jBCODo2UW86tVlc1HCxAG+ccD51CZquJunNPUsaPQU= github.com/marten-seemann/qtls v0.7.1/go.mod h1:2MdmPXnAOf1oOfu871hbP8oYrClgWsykCQvi0S96jnw= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= +github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw= @@ -24,37 +82,139 @@ github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.8.1 h1:C5Dqfs/LeauYDX0jJXIe2SWmwCbGzx9yF8C8xy3Lh34= github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= +github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= +github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= +github.com/shurcooL/github_flavored_markdown v0.0.0-20181002035957-2122de532470/go.mod h1:2dOwnU2uBioM+SGy2aZoq1f/Sd1l9OkAeAUvjSyvgU0= +github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= +github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= +github.com/shurcooL/gofontwoff v0.0.0-20180329035133-29b52fc0a18d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw= +github.com/shurcooL/gopherjslib v0.0.0-20160914041154-feb6d3990c2c/go.mod h1:8d3azKNyqcHP1GaQE/c6dDgjkgSx2BZ4IoEi4F1reUI= +github.com/shurcooL/highlight_diff v0.0.0-20170515013008-09bb4053de1b/go.mod h1:ZpfEhSmds4ytuByIcDnOLkTHGUI6KNqRNPDLHDk+mUU= +github.com/shurcooL/highlight_go v0.0.0-20181028180052-98c3abbbae20/go.mod h1:UDKB5a1T23gOMUJrI+uSuH0VRDStOiUVSjBTRDVBVag= +github.com/shurcooL/home v0.0.0-20181020052607-80b7ffcb30f9/go.mod h1:+rgNQw2P9ARFAs37qieuu7ohDNQ3gds9msbT2yn85sg= +github.com/shurcooL/htmlg v0.0.0-20170918183704-d01228ac9e50/go.mod h1:zPn1wHpTIePGnXSHpsVPWEktKXHr6+SS6x/IKRb7cpw= +github.com/shurcooL/httperror v0.0.0-20170206035902-86b7830d14cc/go.mod h1:aYMfkZ6DWSJPJ6c4Wwz3QtW22G7mf/PEgaB9k/ik5+Y= +github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= +github.com/shurcooL/httpgzip v0.0.0-20180522190206-b1c53ac65af9/go.mod h1:919LwcH0M7/W4fcZ0/jy0qGght1GIhqyS/EgWGH2j5Q= +github.com/shurcooL/issues v0.0.0-20181008053335-6292fdc1e191/go.mod h1:e2qWDig5bLteJ4fwvDAc2NHzqFEthkqn7aOZAOpj+PQ= +github.com/shurcooL/issuesapp v0.0.0-20180602232740-048589ce2241/go.mod h1:NPpHK2TI7iSaM0buivtFUc9offApnI0Alt/K8hcHy0I= +github.com/shurcooL/notifications v0.0.0-20181007000457-627ab5aea122/go.mod h1:b5uSkrEVM1jQUspwbixRBhaIjIzL2xazXp6kntxYle0= +github.com/shurcooL/octicon v0.0.0-20181028054416-fa4f57f9efb2/go.mod h1:eWdoE5JD4R5UVWDucdOPg1g2fqQRq78IQa9zlOV1vpQ= +github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1lToEk4d2s07G3XGfz2QrgHXg4RJBvjrOozvoWfk= +github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= +github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= +github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= +github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= +github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= +github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= +go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= +go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= +golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= +golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 h1:Gv7RPwsi3eZ2Fgewe3CBsuOebPwO27PoXzRpJPsvSSM= golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181029044818-c44066c5c816/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190228165749-92fc7df08ae7 h1:Qe/u+eY379X4He4GBMFZYu3pmh1ML5yT1aL1ndNM1zQ= golang.org/x/net v0.0.0-20190228165749-92fc7df08ae7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= +google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= +google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= +google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= +sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= diff --git a/qlog/frame.go b/qlog/frame.go index e5c4653e..5e5bb708 100644 --- a/qlog/frame.go +++ b/qlog/frame.go @@ -1,9 +1,10 @@ package qlog import ( - "encoding/json" "fmt" + "github.com/francoispqt/gojay" + "github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/wire" ) @@ -12,26 +13,7 @@ type frame struct { Frame interface{} } -type streamType protocol.StreamType - -func (s streamType) String() string { - switch protocol.StreamType(s) { - case protocol.StreamTypeUni: - return "unidirectional" - case protocol.StreamTypeBidi: - return "bidirectional" - default: - panic("unknown stream type") - } -} - -func escapeStr(str string) []byte { return []byte("\"" + str + "\"") } - -type connectionID protocol.ConnectionID - -func (c connectionID) MarshalJSON() ([]byte, error) { - return escapeStr(fmt.Sprintf("%x", c)), nil -} +var _ gojay.MarshalerJSONObject = frame{} type cryptoFrame struct { Offset protocol.ByteCount @@ -67,294 +49,189 @@ func transformFrame(wf wire.Frame) *frame { } } -// MarshalJSON marshals to JSON -func (f frame) MarshalJSON() ([]byte, error) { +func (f frame) MarshalJSONObject(enc *gojay.Encoder) { switch frame := f.Frame.(type) { case *wire.PingFrame: - return marshalPingFrame(frame) + marshalPingFrame(enc, frame) case *wire.AckFrame: - return marshalAckFrame(frame) + marshalAckFrame(enc, frame) case *wire.ResetStreamFrame: - return marshalResetStreamFrame(frame) + marshalResetStreamFrame(enc, frame) case *wire.StopSendingFrame: - return marshalStopSendingFrame(frame) + marshalStopSendingFrame(enc, frame) case *cryptoFrame: - return marshalCryptoFrame(frame) + marshalCryptoFrame(enc, frame) case *wire.NewTokenFrame: - return marshalNewTokenFrame(frame) + marshalNewTokenFrame(enc, frame) case *streamFrame: - return marshalStreamFrame(frame) + marshalStreamFrame(enc, frame) case *wire.MaxDataFrame: - return marshalMaxDataFrame(frame) + marshalMaxDataFrame(enc, frame) case *wire.MaxStreamDataFrame: - return marshalMaxStreamDataFrame(frame) + marshalMaxStreamDataFrame(enc, frame) case *wire.MaxStreamsFrame: - return marshalMaxStreamsFrame(frame) + marshalMaxStreamsFrame(enc, frame) case *wire.DataBlockedFrame: - return marshalDataBlockedFrame(frame) + marshalDataBlockedFrame(enc, frame) case *wire.StreamDataBlockedFrame: - return marshalStreamDataBlockedFrame(frame) + marshalStreamDataBlockedFrame(enc, frame) case *wire.StreamsBlockedFrame: - return marshalStreamsBlockedFrame(frame) + marshalStreamsBlockedFrame(enc, frame) case *wire.NewConnectionIDFrame: - return marshalNewConnectionIDFrame(frame) + marshalNewConnectionIDFrame(enc, frame) case *wire.RetireConnectionIDFrame: - return marshalRetireConnectionIDFrame(frame) + marshalRetireConnectionIDFrame(enc, frame) case *wire.PathChallengeFrame: - return marshalPathChallengeFrame(frame) + marshalPathChallengeFrame(enc, frame) case *wire.PathResponseFrame: - return marshalPathResponseFrame(frame) + marshalPathResponseFrame(enc, frame) case *wire.ConnectionCloseFrame: - return marshalConnectionCloseFrame(frame) + marshalConnectionCloseFrame(enc, frame) case *wire.HandshakeDoneFrame: - return marshalHandshakeDoneFrame(frame) + marshalHandshakeDoneFrame(enc, frame) default: panic("unknown frame type") } } -func marshalPingFrame(_ *wire.PingFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - }{ - FrameType: "ping", - }) +func (f frame) IsNil() bool { return false } + +func marshalPingFrame(enc *gojay.Encoder, _ *wire.PingFrame) { + enc.StringKey("frame_type", "ping") } -type ackRange struct { - Smallest protocol.PacketNumber - Largest protocol.PacketNumber -} +type ackRanges []wire.AckRange -func (ar ackRange) MarshalJSON() ([]byte, error) { - if ar.Smallest == ar.Largest { - return json.Marshal([]string{fmt.Sprintf("%d", ar.Smallest)}) +func (ars ackRanges) MarshalJSONArray(enc *gojay.Encoder) { + for _, r := range ars { + enc.Array(ackRange(r)) } - return json.Marshal([]string{fmt.Sprintf("%d", ar.Smallest), fmt.Sprintf("%d", ar.Largest)}) } -func marshalAckFrame(f *wire.AckFrame) ([]byte, error) { - ranges := make([]ackRange, len(f.AckRanges)) - for i, r := range f.AckRanges { - ranges[i] = ackRange{Smallest: r.Smallest, Largest: r.Largest} +func (ars ackRanges) IsNil() bool { return false } + +type ackRange wire.AckRange + +func (ar ackRange) MarshalJSONArray(enc *gojay.Encoder) { + enc.AddString(toString(int64(ar.Smallest))) + if ar.Smallest != ar.Largest { + enc.AddString(toString(int64(ar.Largest))) } - return json.Marshal(struct { - FrameType string `json:"frame_type"` - AckDelay int64 `json:"ack_delay,string,omitempty"` - AckRanges []ackRange `json:"acked_ranges"` - }{ - FrameType: "ack", - AckDelay: f.DelayTime.Milliseconds(), - AckRanges: ranges, - }) } -func marshalResetStreamFrame(f *wire.ResetStreamFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - StreamID protocol.StreamID `json:"stream_id,string"` - ErrorCode protocol.ApplicationErrorCode `json:"error_code"` - FinalSize protocol.ByteCount `json:"final_size,string"` - }{ - FrameType: "reset_stream", - StreamID: f.StreamID, - ErrorCode: f.ErrorCode, - FinalSize: f.ByteOffset, - }) +func (ar ackRange) IsNil() bool { return false } + +func marshalAckFrame(enc *gojay.Encoder, f *wire.AckFrame) { + enc.StringKey("frame_type", "ack") + if f.DelayTime != 0 { + enc.StringKey("ack_delay", toString(f.DelayTime.Milliseconds())) + } + enc.ArrayKey("acked_ranges", ackRanges(f.AckRanges)) } -func marshalStopSendingFrame(f *wire.StopSendingFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - StreamID protocol.StreamID `json:"stream_id,string"` - ErrorCode protocol.ApplicationErrorCode `json:"error_code"` - }{ - FrameType: "stop_sending", - StreamID: f.StreamID, - ErrorCode: f.ErrorCode, - }) +func marshalResetStreamFrame(enc *gojay.Encoder, f *wire.ResetStreamFrame) { + enc.StringKey("frame_type", "reset_stream") + enc.StringKey("stream_id", toString(int64(f.StreamID))) + enc.Int64Key("error_code", int64(f.ErrorCode)) + enc.StringKey("final_size", toString(int64(f.ByteOffset))) } -func marshalCryptoFrame(f *cryptoFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - Offset protocol.ByteCount `json:"offset,string"` - Length protocol.ByteCount `json:"length"` - }{ - FrameType: "crypto", - Offset: f.Offset, - Length: f.Length, - }) +func marshalStopSendingFrame(enc *gojay.Encoder, f *wire.StopSendingFrame) { + enc.StringKey("frame_type", "stop_sending") + enc.StringKey("stream_id", toString(int64(f.StreamID))) + enc.Int64Key("error_code", int64(f.ErrorCode)) } -func marshalNewTokenFrame(f *wire.NewTokenFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - Length int `json:"length"` - Token string `json:"token"` - }{ - FrameType: "new_token", - Length: len(f.Token), - Token: fmt.Sprintf("%x", f.Token), - }) +func marshalCryptoFrame(enc *gojay.Encoder, f *cryptoFrame) { + enc.StringKey("frame_type", "crypto") + enc.StringKey("offset", toString(int64(f.Offset))) + enc.Int64Key("length", int64(f.Length)) } -func marshalStreamFrame(f *streamFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - StreamID protocol.StreamID `json:"stream_id,string"` - Offset protocol.ByteCount `json:"offset,string"` - Length protocol.ByteCount `json:"length"` - Fin bool `json:"fin,omitempty"` - }{ - FrameType: "stream", - StreamID: f.StreamID, - Offset: f.Offset, - Length: f.Length, - Fin: f.FinBit, - }) +func marshalNewTokenFrame(enc *gojay.Encoder, f *wire.NewTokenFrame) { + enc.StringKey("frame_type", "new_token") + enc.IntKey("length", len(f.Token)) + enc.StringKey("token", fmt.Sprintf("%x", f.Token)) } -func marshalMaxDataFrame(f *wire.MaxDataFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - Maximum protocol.ByteCount `json:"maximum,string"` - }{ - FrameType: "max_data", - Maximum: f.ByteOffset, - }) +func marshalStreamFrame(enc *gojay.Encoder, f *streamFrame) { + enc.StringKey("frame_type", "stream") + enc.StringKey("stream_id", toString(int64(f.StreamID))) + enc.StringKey("offset", toString(int64(f.Offset))) + enc.IntKey("length", int(f.Length)) + enc.BoolKeyOmitEmpty("fin", f.FinBit) } -func marshalMaxStreamDataFrame(f *wire.MaxStreamDataFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - StreamID protocol.StreamID `json:"stream_id,string"` - Maximum protocol.ByteCount `json:"maximum,string"` - }{ - FrameType: "max_stream_data", - StreamID: f.StreamID, - Maximum: f.ByteOffset, - }) +func marshalMaxDataFrame(enc *gojay.Encoder, f *wire.MaxDataFrame) { + enc.StringKey("frame_type", "max_data") + enc.StringKey("maximum", toString(int64(f.ByteOffset))) } -func marshalMaxStreamsFrame(f *wire.MaxStreamsFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - StreamType string `json:"stream_type"` - Maximum protocol.StreamNum `json:"maximum,string"` - }{ - FrameType: "max_streams", - StreamType: streamType(f.Type).String(), - Maximum: f.MaxStreamNum, - }) +func marshalMaxStreamDataFrame(enc *gojay.Encoder, f *wire.MaxStreamDataFrame) { + enc.StringKey("frame_type", "max_stream_data") + enc.StringKey("stream_id", toString(int64(f.StreamID))) + enc.StringKey("maximum", toString(int64(f.ByteOffset))) } -func marshalDataBlockedFrame(f *wire.DataBlockedFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - Limit protocol.ByteCount `json:"limit,string"` - }{ - FrameType: "data_blocked", - Limit: f.DataLimit, - }) +func marshalMaxStreamsFrame(enc *gojay.Encoder, f *wire.MaxStreamsFrame) { + enc.StringKey("frame_type", "max_streams") + enc.StringKey("stream_type", streamType(f.Type).String()) + enc.StringKey("maximum", toString(int64(f.MaxStreamNum))) } -func marshalStreamDataBlockedFrame(f *wire.StreamDataBlockedFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - StreamID protocol.StreamID `json:"stream_id,string"` - Limit protocol.ByteCount `json:"limit,string"` - }{ - FrameType: "stream_data_blocked", - StreamID: f.StreamID, - Limit: f.DataLimit, - }) +func marshalDataBlockedFrame(enc *gojay.Encoder, f *wire.DataBlockedFrame) { + enc.StringKey("frame_type", "data_blocked") + enc.StringKey("limit", toString(int64(f.DataLimit))) } -func marshalStreamsBlockedFrame(f *wire.StreamsBlockedFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - StreamType string `json:"stream_type"` - Limit protocol.StreamNum `json:"limit,string"` - }{ - FrameType: "streams_blocked", - StreamType: streamType(f.Type).String(), - Limit: f.StreamLimit, - }) +func marshalStreamDataBlockedFrame(enc *gojay.Encoder, f *wire.StreamDataBlockedFrame) { + enc.StringKey("frame_type", "stream_data_blocked") + enc.StringKey("stream_id", toString(int64(f.StreamID))) + enc.StringKey("limit", toString(int64(f.DataLimit))) } -func marshalNewConnectionIDFrame(f *wire.NewConnectionIDFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - SequenceNumber uint64 `json:"sequence_number,string"` - RetirePriorTo uint64 `json:"retire_prior_to,string"` - Length int `json:"length"` - ConnectionID connectionID `json:"connection_id"` - ResetToken string `json:"reset_token"` - }{ - FrameType: "new_connection_id", - SequenceNumber: f.SequenceNumber, - RetirePriorTo: f.RetirePriorTo, - Length: f.ConnectionID.Len(), - ConnectionID: connectionID(f.ConnectionID), - ResetToken: fmt.Sprintf("%x", f.StatelessResetToken), - }) +func marshalStreamsBlockedFrame(enc *gojay.Encoder, f *wire.StreamsBlockedFrame) { + enc.StringKey("frame_type", "streams_blocked") + enc.StringKey("stream_type", streamType(f.Type).String()) + enc.StringKey("limit", toString(int64(f.StreamLimit))) } -func marshalRetireConnectionIDFrame(f *wire.RetireConnectionIDFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - SequenceNumber uint64 `json:"sequence_number,string"` - }{ - FrameType: "retire_connection_id", - SequenceNumber: f.SequenceNumber, - }) +func marshalNewConnectionIDFrame(enc *gojay.Encoder, f *wire.NewConnectionIDFrame) { + enc.StringKey("frame_type", "new_connection_id") + enc.StringKey("sequence_number", toString(int64(f.SequenceNumber))) + enc.StringKey("retire_prior_to", toString(int64(f.RetirePriorTo))) + enc.IntKey("length", f.ConnectionID.Len()) + enc.StringKey("connection_id", connectionID(f.ConnectionID).String()) + enc.StringKey("reset_token", fmt.Sprintf("%x", f.StatelessResetToken)) } -func marshalPathChallengeFrame(f *wire.PathChallengeFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - Data string `json:"data"` - }{ - FrameType: "path_challenge", - Data: fmt.Sprintf("%x", f.Data[:]), - }) +func marshalRetireConnectionIDFrame(enc *gojay.Encoder, f *wire.RetireConnectionIDFrame) { + enc.StringKey("frame_type", "retire_connection_id") + enc.StringKey("sequence_number", toString(int64(f.SequenceNumber))) } -func marshalPathResponseFrame(f *wire.PathResponseFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - Data string `json:"data"` - }{ - FrameType: "path_response", - Data: fmt.Sprintf("%x", f.Data[:]), - }) +func marshalPathChallengeFrame(enc *gojay.Encoder, f *wire.PathChallengeFrame) { + enc.StringKey("frame_type", "path_challenge") + enc.StringKey("data", fmt.Sprintf("%x", f.Data[:])) } -func marshalConnectionCloseFrame(f *wire.ConnectionCloseFrame) ([]byte, error) { +func marshalPathResponseFrame(enc *gojay.Encoder, f *wire.PathResponseFrame) { + enc.StringKey("frame_type", "path_response") + enc.StringKey("data", fmt.Sprintf("%x", f.Data[:])) +} + +func marshalConnectionCloseFrame(enc *gojay.Encoder, f *wire.ConnectionCloseFrame) { errorSpace := "transport" if f.IsApplicationError { errorSpace = "application" } - return json.Marshal(struct { - FrameType string `json:"frame_type"` - ErrorSpace string `json:"error_space"` - ErrorCode uint64 `json:"error_code"` - RawErrorCode uint64 `json:"raw_error_code"` - Reason string `json:"reason"` - }{ - FrameType: "connection_close", - ErrorSpace: errorSpace, - ErrorCode: uint64(f.ErrorCode), - RawErrorCode: uint64(f.ErrorCode), - Reason: f.ReasonPhrase, - }) + enc.StringKey("frame_type", "connection_close") + enc.StringKey("error_space", errorSpace) + enc.Int64Key("error_code", int64(f.ErrorCode)) + enc.Int64Key("raw_error_code", int64(f.ErrorCode)) + enc.StringKey("reason", f.ReasonPhrase) } -func marshalHandshakeDoneFrame(_ *wire.HandshakeDoneFrame) ([]byte, error) { - return json.Marshal(struct { - FrameType string `json:"frame_type"` - }{ - FrameType: "handshake_done", - }) +func marshalHandshakeDoneFrame(enc *gojay.Encoder, _ *wire.HandshakeDoneFrame) { + enc.StringKey("frame_type", "handshake_done") } diff --git a/qlog/frame_test.go b/qlog/frame_test.go index b1935485..1ef01b1e 100644 --- a/qlog/frame_test.go +++ b/qlog/frame_test.go @@ -1,9 +1,12 @@ package qlog import ( + "bytes" "encoding/json" "time" + "github.com/francoispqt/gojay" + "github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/wire" @@ -13,8 +16,10 @@ import ( var _ = Describe("Frames", func() { check := func(f wire.Frame, expected map[string]interface{}) { - data, err := transformFrame(f).MarshalJSON() - ExpectWithOffset(1, err).ToNot(HaveOccurred()) + buf := &bytes.Buffer{} + enc := gojay.NewEncoder(buf) + ExpectWithOffset(1, enc.Encode(transformFrame(f))).To(Succeed()) + data := buf.Bytes() ExpectWithOffset(1, json.Valid(data)).To(BeTrue()) checkEncoding(data, expected) } diff --git a/qlog/packet_header.go b/qlog/packet_header.go index 00e005c7..933a46e8 100644 --- a/qlog/packet_header.go +++ b/qlog/packet_header.go @@ -1,19 +1,12 @@ package qlog import ( - "encoding/json" - "fmt" + "github.com/francoispqt/gojay" "github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/wire" ) -type versionNumber protocol.VersionNumber - -func (v versionNumber) MarshalJSON() ([]byte, error) { - return escapeStr(fmt.Sprintf("%x", v)), nil -} - func transformHeader(hdr *wire.ExtendedHeader) *packetHeader { return &packetHeader{ PacketNumber: hdr.PacketNumber, @@ -25,30 +18,30 @@ func transformHeader(hdr *wire.ExtendedHeader) *packetHeader { } type packetHeader struct { - PacketNumber protocol.PacketNumber `json:"packet_number,string"` - PacketSize protocol.ByteCount `json:"packet_size,omitempty"` - PayloadLength protocol.ByteCount `json:"payload_length,omitempty"` + PacketNumber protocol.PacketNumber + PacketSize protocol.ByteCount + PayloadLength protocol.ByteCount - Version protocol.VersionNumber `json:"version,omitempty"` - SrcConnectionID protocol.ConnectionID `json:"scid,string,omitempty"` - DestConnectionID protocol.ConnectionID `json:"dcid,string,omitempty"` + Version protocol.VersionNumber + SrcConnectionID protocol.ConnectionID + DestConnectionID protocol.ConnectionID } -func (h packetHeader) MarshalJSON() ([]byte, error) { - type Alias packetHeader - return json.Marshal(&struct { - SrcConnectionIDLen int `json:"scil,string,omitempty"` - SrcConnectionID connectionID `json:"scid,string,omitempty"` - DestConnectionIDLen int `json:"dcil,string,omitempty"` - DestConnectionID connectionID `json:"dcid,string,omitempty"` - Version versionNumber `json:"version,omitempty"` - Alias - }{ - Alias: (Alias)(h), - SrcConnectionIDLen: h.SrcConnectionID.Len(), - SrcConnectionID: connectionID(h.SrcConnectionID), - DestConnectionIDLen: h.DestConnectionID.Len(), - DestConnectionID: connectionID(h.DestConnectionID), - Version: versionNumber(h.Version), - }) +func (h packetHeader) MarshalJSONObject(enc *gojay.Encoder) { + enc.StringKey("packet_number", toString(int64(h.PacketNumber))) + enc.Int64KeyOmitEmpty("packet_size", int64(h.PacketSize)) + enc.Int64KeyOmitEmpty("payload_length", int64(h.PayloadLength)) + if h.Version != 0 { + enc.StringKey("version", versionNumber(h.Version).String()) + } + if h.SrcConnectionID.Len() > 0 { + enc.StringKey("scil", toString(int64(h.SrcConnectionID.Len()))) + enc.StringKey("scid", connectionID(h.SrcConnectionID).String()) + } + if h.DestConnectionID.Len() > 0 { + enc.StringKey("dcil", toString(int64(h.DestConnectionID.Len()))) + enc.StringKey("dcid", connectionID(h.DestConnectionID).String()) + } } + +func (packetHeader) IsNil() bool { return false } diff --git a/qlog/packet_header_test.go b/qlog/packet_header_test.go index 75b788c3..3d3470f9 100644 --- a/qlog/packet_header_test.go +++ b/qlog/packet_header_test.go @@ -1,8 +1,10 @@ package qlog import ( + "bytes" "encoding/json" + "github.com/francoispqt/gojay" "github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/wire" @@ -12,8 +14,10 @@ import ( var _ = Describe("Packet Header", func() { check := func(hdr *wire.ExtendedHeader, expected map[string]interface{}) { - data, err := json.Marshal(transformHeader(hdr)) - ExpectWithOffset(1, err).ToNot(HaveOccurred()) + buf := &bytes.Buffer{} + enc := gojay.NewEncoder(buf) + ExpectWithOffset(1, enc.Encode(transformHeader(hdr))).To(Succeed()) + data := buf.Bytes() ExpectWithOffset(1, json.Valid(data)).To(BeTrue()) checkEncoding(data, expected) } diff --git a/qlog/types.go b/qlog/types.go new file mode 100644 index 00000000..02154ad7 --- /dev/null +++ b/qlog/types.go @@ -0,0 +1,37 @@ +package qlog + +import ( + "fmt" + "strconv" + + "github.com/lucas-clemente/quic-go/internal/protocol" +) + +func toString(i int64) string { + return strconv.FormatInt(i, 10) +} + +type versionNumber protocol.VersionNumber + +func (v versionNumber) String() string { + return fmt.Sprintf("%x", uint32(v)) +} + +type streamType protocol.StreamType + +func (s streamType) String() string { + switch protocol.StreamType(s) { + case protocol.StreamTypeUni: + return "unidirectional" + case protocol.StreamTypeBidi: + return "bidirectional" + default: + panic("unknown stream type") + } +} + +type connectionID protocol.ConnectionID + +func (c connectionID) String() string { + return fmt.Sprintf("%x", []byte(c)) +}