diff --git a/go.mod b/go.mod index fa136ff..1869b1c 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,30 @@ module github.com/nobonobo/ssh-p2p +go 1.19 + +require ( + github.com/google/uuid v1.3.0 + github.com/pion/ice/v2 v2.2.7 + github.com/pion/webrtc/v3 v3.1.44 +) + require ( - github.com/google/go-cmp v0.2.0 // indirect - github.com/google/uuid v1.0.0 - github.com/pions/transport v0.1.0 // indirect - github.com/pions/webrtc v1.2.0 - gotest.tools v2.2.0+incompatible // indirect + github.com/pion/datachannel v1.5.2 // indirect + github.com/pion/dtls/v2 v2.1.5 // indirect + github.com/pion/interceptor v0.1.11 // indirect + github.com/pion/logging v0.2.2 // indirect + github.com/pion/mdns v0.0.5 // indirect + github.com/pion/randutil v0.1.0 // indirect + github.com/pion/rtcp v1.2.9 // indirect + github.com/pion/rtp v1.7.13 // indirect + github.com/pion/sctp v1.8.2 // indirect + github.com/pion/sdp/v3 v3.0.5 // indirect + github.com/pion/srtp/v2 v2.0.10 // indirect + github.com/pion/stun v0.3.5 // indirect + github.com/pion/transport v0.13.1 // indirect + github.com/pion/turn/v2 v2.0.8 // indirect + github.com/pion/udp v0.1.1 // indirect + golang.org/x/crypto v0.0.0-20220516162934-403b01795ae8 // indirect + golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect + golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 // indirect ) diff --git a/go.sum b/go.sum index f37296d..0ba9950 100644 --- a/go.sum +++ b/go.sum @@ -1,26 +1,159 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA= -github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/pions/dtls v1.0.2 h1:VOIp3whGooFWS4X0RBOXaykNORYr05yjs8mlNYqRc+4= -github.com/pions/dtls v1.0.2/go.mod h1:T22vu8VCOxNmIrbe3nnM1UdIo3m1Bx5CJNkHyehahLg= -github.com/pions/pkg v0.0.0-20181115215726-b60cd756f712 h1:ciXO7F7PusyAzW/EZJt01bETgfTxP/BIGoWQ15pBP54= -github.com/pions/pkg v0.0.0-20181115215726-b60cd756f712/go.mod h1:r9wKZs+Xxv2acLspex4CHQiIhFjGK1zGP+nUm/8klXA= -github.com/pions/transport v0.1.0 h1:9IEn3i8pmK8rMyQIqhT2RozgXJNH4k+IuNDzV5y+ddw= -github.com/pions/transport v0.1.0/go.mod h1:HLhzI7I0k8TyiQ99hfRZNRf84lG76eaFnZHnVy/wFnM= -github.com/pions/webrtc v1.2.0 h1:U/UYMmhlVF9c1S2cfYZhR+frL0daetdP6yQnWOQzhJo= -github.com/pions/webrtc v1.2.0/go.mod h1:bih1dMY7qksVxZTG2XMjIA6J7D5b92+MJzXYe+G2kng= -github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +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/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/pion/datachannel v1.5.2 h1:piB93s8LGmbECrpO84DnkIVWasRMk3IimbcXkTQLE6E= +github.com/pion/datachannel v1.5.2/go.mod h1:FTGQWaHrdCwIJ1rw6xBIfZVkslikjShim5yr05XFuCQ= +github.com/pion/dtls/v2 v2.1.3/go.mod h1:o6+WvyLDAlXF7YiPB/RlskRoeK+/JtuaZa5emwQcWus= +github.com/pion/dtls/v2 v2.1.5 h1:jlh2vtIyUBShchoTDqpCCqiYCyRFJ/lvf/gQ8TALs+c= +github.com/pion/dtls/v2 v2.1.5/go.mod h1:BqCE7xPZbPSubGasRoDFJeTsyJtdD1FanJYL0JGheqY= +github.com/pion/ice/v2 v2.2.6/go.mod h1:SWuHiOGP17lGromHTFadUe1EuPgFh/oCU6FCMZHooVE= +github.com/pion/ice/v2 v2.2.7 h1:kG9tux3WdYUSqqqnf+O5zKlpy41PdlvLUBlYJeV2emQ= +github.com/pion/ice/v2 v2.2.7/go.mod h1:Ckj7cWZ717rtU01YoDQA9ntGWCk95D42uVZ8sI0EL+8= +github.com/pion/interceptor v0.1.11 h1:00U6OlqxA3FFB50HSg25J/8cWi7P6FbSzw4eFn24Bvs= +github.com/pion/interceptor v0.1.11/go.mod h1:tbtKjZY14awXd7Bq0mmWvgtHB5MDaRN7HV3OZ/uy7s8= +github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= +github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= +github.com/pion/mdns v0.0.5 h1:Q2oj/JB3NqfzY9xGZ1fPzZzK7sDSD8rZPOvcIQ10BCw= +github.com/pion/mdns v0.0.5/go.mod h1:UgssrvdD3mxpi8tMxAXbsppL3vJ4Jipw1mTCW+al01g= +github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA= +github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= +github.com/pion/rtcp v1.2.9 h1:1ujStwg++IOLIEoOiIQ2s+qBuJ1VN81KW+9pMPsif+U= +github.com/pion/rtcp v1.2.9/go.mod h1:qVPhiCzAm4D/rxb6XzKeyZiQK69yJpbUDJSF7TgrqNo= +github.com/pion/rtp v1.7.13 h1:qcHwlmtiI50t1XivvoawdCGTP4Uiypzfrsap+bijcoA= +github.com/pion/rtp v1.7.13/go.mod h1:bDb5n+BFZxXx0Ea7E5qe+klMuqiBrP+w8XSjiWtCUko= +github.com/pion/sctp v1.8.0/go.mod h1:xFe9cLMZ5Vj6eOzpyiKjT9SwGM4KpK/8Jbw5//jc+0s= +github.com/pion/sctp v1.8.2 h1:yBBCIrUMJ4yFICL3RIvR4eh/H2BTTvlligmSTy+3kiA= +github.com/pion/sctp v1.8.2/go.mod h1:xFe9cLMZ5Vj6eOzpyiKjT9SwGM4KpK/8Jbw5//jc+0s= +github.com/pion/sdp/v3 v3.0.5 h1:ouvI7IgGl+V4CrqskVtr3AaTrPvPisEOxwgpdktctkU= +github.com/pion/sdp/v3 v3.0.5/go.mod h1:iiFWFpQO8Fy3S5ldclBkpXqmWy02ns78NOKoLLL0YQw= +github.com/pion/srtp/v2 v2.0.10 h1:b8ZvEuI+mrL8hbr/f1YiJFB34UMrOac3R3N1yq2UN0w= +github.com/pion/srtp/v2 v2.0.10/go.mod h1:XEeSWaK9PfuMs7zxXyiN252AHPbH12NX5q/CFDWtUuA= +github.com/pion/stun v0.3.5 h1:uLUCBCkQby4S1cf6CGuR9QrVOKcvUwFeemaC865QHDg= +github.com/pion/stun v0.3.5/go.mod h1:gDMim+47EeEtfWogA37n6qXZS88L5V6LqFcf+DZA2UA= +github.com/pion/transport v0.12.2/go.mod h1:N3+vZQD9HlDP5GWkZ85LohxNsDcNgofQmyL6ojX5d8Q= +github.com/pion/transport v0.12.3/go.mod h1:OViWW9SP2peE/HbwBvARicmAVnesphkNkCVZIWJ6q9A= +github.com/pion/transport v0.13.0/go.mod h1:yxm9uXpK9bpBBWkITk13cLo1y5/ur5VQpG22ny6EP7g= +github.com/pion/transport v0.13.1 h1:/UH5yLeQtwm2VZIPjxwnNFxjS4DFhyLfS4GlfuKUzfA= +github.com/pion/transport v0.13.1/go.mod h1:EBxbqzyv+ZrmDb82XswEE0BjfQFtuw1Nu6sjnjWCsGg= +github.com/pion/turn/v2 v2.0.8 h1:KEstL92OUN3k5k8qxsXHpr7WWfrdp7iJZHx99ud8muw= +github.com/pion/turn/v2 v2.0.8/go.mod h1:+y7xl719J8bAEVpSXBXvTxStjJv3hbz9YFflvkpcGPw= +github.com/pion/udp v0.1.1 h1:8UAPvyqmsxK8oOjloDk4wUt63TzFe9WEJkg5lChlj7o= +github.com/pion/udp v0.1.1/go.mod h1:6AFo+CMdKQm7UiA0eUPA8/eVCTx8jBIITLZHc9DWX5M= +github.com/pion/webrtc/v3 v3.1.44 h1:uY11C9cOupY36bS3Q16NI298c/XKhl5S9EMCo/TxH3Y= +github.com/pion/webrtc/v3 v3.1.44/go.mod h1:G/J8k0+grVsjC/rjCZ24AKoCCxcFFODgh7zThNZGs0M= 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/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= -gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220516162934-403b01795ae8 h1:y+mHpWoQJNAHt26Nhh6JP7hvM71IRZureyvZhoVALIs= +golang.org/x/crypto v0.0.0-20220516162934-403b01795ae8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220401154927-543a649e0bdd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220531201128-c960675eff93/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220630215102-69896b714898 h1:K7wO6V1IrczY9QOQ2WkVpw4JQSwCd52UsxVEirZUfiw= +golang.org/x/net v0.0.0-20220630215102-69896b714898/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 h1:wEZYwx+kK+KlZ0hpvP2Ls1Xr4+RWnlzGFwPP0aiDjIU= +golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index b5b70b9..f11c516 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "bytes" "context" + "encoding/base64" "encoding/json" "flag" "fmt" @@ -18,9 +19,8 @@ import ( "github.com/google/uuid" "github.com/nobonobo/ssh-p2p/signaling" - "github.com/pions/webrtc" - "github.com/pions/webrtc/pkg/datachannel" - "github.com/pions/webrtc/pkg/ice" + "github.com/pion/ice/v2" + "github.com/pion/webrtc/v3" ) const usage = `Usage: ssh-p2p SUBCMD [options] @@ -34,8 +34,8 @@ sub-commands: ` var ( - defaultRTCConfiguration = webrtc.RTCConfiguration{ - IceServers: []webrtc.RTCIceServer{ + defaultRTCConfiguration = webrtc.Configuration{ + ICEServers: []webrtc.ICEServer{ { URLs: []string{ "stun:stun.l.google.com:19302", @@ -45,6 +45,30 @@ var ( } ) +// Encode encodes the input in base64 +// It can optionally zip the input before encoding +func Encode(obj interface{}) string { + b, err := json.Marshal(obj) + if err != nil { + panic(err) + } + + return base64.StdEncoding.EncodeToString(b) +} + +// Decode decodes the input from base64 +// It can optionally unzip the input after decoding +func Decode(in string, obj interface{}) { + b, err := base64.StdEncoding.DecodeString(in) + if err != nil { + panic(err) + } + err = json.Unmarshal(b, obj) + if err != nil { + panic(err) + } +} + func push(dst, src, sdp string) error { buf := bytes.NewBuffer(nil) if err := json.NewEncoder(buf).Encode(signaling.ConnectInfo{ @@ -182,11 +206,11 @@ func main() { } type sendWrap struct { - *webrtc.RTCDataChannel + *webrtc.DataChannel } func (s *sendWrap) Write(b []byte) (int, error) { - err := s.RTCDataChannel.Send(datachannel.PayloadBinary{Data: b}) + err := s.DataChannel.Send(b) return len(b), err } @@ -194,7 +218,7 @@ func serve(ctx context.Context, key, addr string) { log.Println("server started") for v := range pull(ctx, key) { log.Printf("info: %#v", v) - pc, err := webrtc.New(defaultRTCConfiguration) + pc, err := webrtc.NewPeerConnection(defaultRTCConfiguration) if err != nil { log.Println("rtc error:", err) continue @@ -205,37 +229,33 @@ func serve(ctx context.Context, key, addr string) { pc.Close() continue } - pc.OnICEConnectionStateChange(func(state ice.ConnectionState) { + pc.OnICEConnectionStateChange(func(state webrtc.ICEConnectionState) { log.Print("pc ice state change:", state) if state == ice.ConnectionStateDisconnected { pc.Close() ssh.Close() } }) - pc.OnDataChannel(func(dc *webrtc.RTCDataChannel) { + pc.OnDataChannel(func(dc *webrtc.DataChannel) { //dc.Lock() dc.OnOpen(func() { log.Print("dial:", addr) io.Copy(&sendWrap{dc}, ssh) log.Println("disconnected") }) - dc.Onmessage(func(payload datachannel.Payload) { - switch p := payload.(type) { - case *datachannel.PayloadBinary: - _, err := ssh.Write(p.Data) - if err != nil { - log.Println("ssh write failed:", err) - pc.Close() - return - } + dc.OnMessage(func(msg webrtc.DataChannelMessage) { + _, err := ssh.Write(msg.Data) + if err != nil { + log.Println("ssh write failed:", err) + pc.Close() + return } }) //dc.Unlock() }) - if err := pc.SetRemoteDescription(webrtc.RTCSessionDescription{ - Type: webrtc.RTCSdpTypeOffer, - Sdp: string(v.SDP), - }); err != nil { + offer := webrtc.SessionDescription{} + Decode(v.SDP, &offer) + if err := pc.SetRemoteDescription(offer); err != nil { log.Println("rtc error:", err) pc.Close() ssh.Close() @@ -248,7 +268,19 @@ func serve(ctx context.Context, key, addr string) { ssh.Close() continue } - if err := push(v.Source, key, answer.Sdp); err != nil { + // Create channel that is blocked until ICE Gathering is complete + gatherComplete := webrtc.GatheringCompletePromise(pc) + + // Sets the LocalDescription, and starts our UDP listeners + err = pc.SetLocalDescription(answer) + if err != nil { + panic(err) + } + // Block until ICE Gathering is complete, disabling trickle ICE + // we do this because we only can exchange one signaling message + // in a production application you should exchange ICE Candidates via OnICECandidate + <-gatherComplete + if err := push(v.Source, key, Encode(*pc.LocalDescription())); err != nil { log.Println("rtc error:", err) pc.Close() ssh.Close() @@ -260,12 +292,12 @@ func serve(ctx context.Context, key, addr string) { func connect(ctx context.Context, key string, sock net.Conn) { id := uuid.New().String() log.Println("client id:", id) - pc, err := webrtc.New(defaultRTCConfiguration) + pc, err := webrtc.NewPeerConnection(defaultRTCConfiguration) if err != nil { log.Println("rtc error:", err) return } - pc.OnICEConnectionStateChange(func(state ice.ConnectionState) { + pc.OnICEConnectionStateChange(func(state webrtc.ICEConnectionState) { log.Print("pc ice state change:", state) }) dc, err := pc.CreateDataChannel("data", nil) @@ -280,28 +312,25 @@ func connect(ctx context.Context, key string, sock net.Conn) { pc.Close() log.Println("disconnected") }) - dc.OnMessage(func(payload datachannel.Payload) { - switch p := payload.(type) { - case *datachannel.PayloadBinary: - _, err := sock.Write(p.Data) - if err != nil { - log.Println("sock write failed:", err) - pc.Close() - return - } + dc.OnMessage(func(msg webrtc.DataChannelMessage) { + _, err := sock.Write(msg.Data) + if err != nil { + log.Println("sock write failed:", err) + pc.Close() + return } + }) //dc.Unlock() - log.Print("DataChannel:", dc) + log.Printf("DataChannel: %#v\n", dc) go func() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() for v := range pull(ctx, id) { log.Printf("info: %#v", v) - if err := pc.SetRemoteDescription(webrtc.RTCSessionDescription{ - Type: webrtc.RTCSdpTypeAnswer, - Sdp: string(v.SDP), - }); err != nil { + answer := webrtc.SessionDescription{} + Decode(v.SDP, &answer) + if err := pc.SetRemoteDescription(answer); err != nil { log.Println("rtc error:", err) pc.Close() return @@ -315,7 +344,17 @@ func connect(ctx context.Context, key string, sock net.Conn) { pc.Close() return } - if err := push(key, id, offer.Sdp); err != nil { + gatherComplete := webrtc.GatheringCompletePromise(pc) + err = pc.SetLocalDescription(offer) + if err != nil { + panic(err) + } + + // Block until ICE Gathering is complete, disabling trickle ICE + // we do this because we only can exchange one signaling message + // in a production application you should exchange ICE Candidates via OnICECandidate + <-gatherComplete + if err := push(key, id, Encode(*pc.LocalDescription())); err != nil { log.Println("push error:", err) pc.Close() return diff --git a/vendor/github.com/google/uuid/.travis.yml b/vendor/github.com/google/uuid/.travis.yml deleted file mode 100644 index d8156a6..0000000 --- a/vendor/github.com/google/uuid/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: go - -go: - - 1.4.3 - - 1.5.3 - - tip - -script: - - go test -v ./... diff --git a/vendor/github.com/google/uuid/CONTRIBUTING.md b/vendor/github.com/google/uuid/CONTRIBUTING.md deleted file mode 100644 index 04fdf09..0000000 --- a/vendor/github.com/google/uuid/CONTRIBUTING.md +++ /dev/null @@ -1,10 +0,0 @@ -# How to contribute - -We definitely welcome patches and contribution to this project! - -### Legal requirements - -In order to protect both you and ourselves, you will need to sign the -[Contributor License Agreement](https://cla.developers.google.com/clas). - -You may have already signed it for other Google projects. diff --git a/vendor/github.com/google/uuid/CONTRIBUTORS b/vendor/github.com/google/uuid/CONTRIBUTORS deleted file mode 100644 index b4bb97f..0000000 --- a/vendor/github.com/google/uuid/CONTRIBUTORS +++ /dev/null @@ -1,9 +0,0 @@ -Paul Borman -bmatsuo -shawnps -theory -jboverfelt -dsymonds -cd1 -wallclockbuilder -dansouza diff --git a/vendor/github.com/google/uuid/LICENSE b/vendor/github.com/google/uuid/LICENSE deleted file mode 100644 index 5dc6826..0000000 --- a/vendor/github.com/google/uuid/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009,2014 Google Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/google/uuid/README.md b/vendor/github.com/google/uuid/README.md deleted file mode 100644 index 9d92c11..0000000 --- a/vendor/github.com/google/uuid/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# uuid ![build status](https://travis-ci.org/google/uuid.svg?branch=master) -The uuid package generates and inspects UUIDs based on -[RFC 4122](http://tools.ietf.org/html/rfc4122) -and DCE 1.1: Authentication and Security Services. - -This package is based on the github.com/pborman/uuid package (previously named -code.google.com/p/go-uuid). It differs from these earlier packages in that -a UUID is a 16 byte array rather than a byte slice. One loss due to this -change is the ability to represent an invalid UUID (vs a NIL UUID). - -###### Install -`go get github.com/google/uuid` - -###### Documentation -[![GoDoc](https://godoc.org/github.com/google/uuid?status.svg)](http://godoc.org/github.com/google/uuid) - -Full `go doc` style documentation for the package can be viewed online without -installing this package by using the GoDoc site here: -http://godoc.org/github.com/google/uuid diff --git a/vendor/github.com/google/uuid/dce.go b/vendor/github.com/google/uuid/dce.go deleted file mode 100644 index fa820b9..0000000 --- a/vendor/github.com/google/uuid/dce.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2016 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package uuid - -import ( - "encoding/binary" - "fmt" - "os" -) - -// A Domain represents a Version 2 domain -type Domain byte - -// Domain constants for DCE Security (Version 2) UUIDs. -const ( - Person = Domain(0) - Group = Domain(1) - Org = Domain(2) -) - -// NewDCESecurity returns a DCE Security (Version 2) UUID. -// -// The domain should be one of Person, Group or Org. -// On a POSIX system the id should be the users UID for the Person -// domain and the users GID for the Group. The meaning of id for -// the domain Org or on non-POSIX systems is site defined. -// -// For a given domain/id pair the same token may be returned for up to -// 7 minutes and 10 seconds. -func NewDCESecurity(domain Domain, id uint32) (UUID, error) { - uuid, err := NewUUID() - if err == nil { - uuid[6] = (uuid[6] & 0x0f) | 0x20 // Version 2 - uuid[9] = byte(domain) - binary.BigEndian.PutUint32(uuid[0:], id) - } - return uuid, err -} - -// NewDCEPerson returns a DCE Security (Version 2) UUID in the person -// domain with the id returned by os.Getuid. -// -// NewDCESecurity(Person, uint32(os.Getuid())) -func NewDCEPerson() (UUID, error) { - return NewDCESecurity(Person, uint32(os.Getuid())) -} - -// NewDCEGroup returns a DCE Security (Version 2) UUID in the group -// domain with the id returned by os.Getgid. -// -// NewDCESecurity(Group, uint32(os.Getgid())) -func NewDCEGroup() (UUID, error) { - return NewDCESecurity(Group, uint32(os.Getgid())) -} - -// Domain returns the domain for a Version 2 UUID. Domains are only defined -// for Version 2 UUIDs. -func (uuid UUID) Domain() Domain { - return Domain(uuid[9]) -} - -// ID returns the id for a Version 2 UUID. IDs are only defined for Version 2 -// UUIDs. -func (uuid UUID) ID() uint32 { - return binary.BigEndian.Uint32(uuid[0:4]) -} - -func (d Domain) String() string { - switch d { - case Person: - return "Person" - case Group: - return "Group" - case Org: - return "Org" - } - return fmt.Sprintf("Domain%d", int(d)) -} diff --git a/vendor/github.com/google/uuid/doc.go b/vendor/github.com/google/uuid/doc.go deleted file mode 100644 index 5b8a4b9..0000000 --- a/vendor/github.com/google/uuid/doc.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package uuid generates and inspects UUIDs. -// -// UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security -// Services. -// -// A UUID is a 16 byte (128 bit) array. UUIDs may be used as keys to -// maps or compared directly. -package uuid diff --git a/vendor/github.com/google/uuid/hash.go b/vendor/github.com/google/uuid/hash.go deleted file mode 100644 index b174616..0000000 --- a/vendor/github.com/google/uuid/hash.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2016 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package uuid - -import ( - "crypto/md5" - "crypto/sha1" - "hash" -) - -// Well known namespace IDs and UUIDs -var ( - NameSpaceDNS = Must(Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")) - NameSpaceURL = Must(Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8")) - NameSpaceOID = Must(Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8")) - NameSpaceX500 = Must(Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8")) - Nil UUID // empty UUID, all zeros -) - -// NewHash returns a new UUID derived from the hash of space concatenated with -// data generated by h. The hash should be at least 16 byte in length. The -// first 16 bytes of the hash are used to form the UUID. The version of the -// UUID will be the lower 4 bits of version. NewHash is used to implement -// NewMD5 and NewSHA1. -func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID { - h.Reset() - h.Write(space[:]) - h.Write(data) - s := h.Sum(nil) - var uuid UUID - copy(uuid[:], s) - uuid[6] = (uuid[6] & 0x0f) | uint8((version&0xf)<<4) - uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 4122 variant - return uuid -} - -// NewMD5 returns a new MD5 (Version 3) UUID based on the -// supplied name space and data. It is the same as calling: -// -// NewHash(md5.New(), space, data, 3) -func NewMD5(space UUID, data []byte) UUID { - return NewHash(md5.New(), space, data, 3) -} - -// NewSHA1 returns a new SHA1 (Version 5) UUID based on the -// supplied name space and data. It is the same as calling: -// -// NewHash(sha1.New(), space, data, 5) -func NewSHA1(space UUID, data []byte) UUID { - return NewHash(sha1.New(), space, data, 5) -} diff --git a/vendor/github.com/google/uuid/marshal.go b/vendor/github.com/google/uuid/marshal.go deleted file mode 100644 index 7f9e0c6..0000000 --- a/vendor/github.com/google/uuid/marshal.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2016 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package uuid - -import "fmt" - -// MarshalText implements encoding.TextMarshaler. -func (uuid UUID) MarshalText() ([]byte, error) { - var js [36]byte - encodeHex(js[:], uuid) - return js[:], nil -} - -// UnmarshalText implements encoding.TextUnmarshaler. -func (uuid *UUID) UnmarshalText(data []byte) error { - id, err := ParseBytes(data) - if err == nil { - *uuid = id - } - return err -} - -// MarshalBinary implements encoding.BinaryMarshaler. -func (uuid UUID) MarshalBinary() ([]byte, error) { - return uuid[:], nil -} - -// UnmarshalBinary implements encoding.BinaryUnmarshaler. -func (uuid *UUID) UnmarshalBinary(data []byte) error { - if len(data) != 16 { - return fmt.Errorf("invalid UUID (got %d bytes)", len(data)) - } - copy(uuid[:], data) - return nil -} diff --git a/vendor/github.com/google/uuid/node.go b/vendor/github.com/google/uuid/node.go deleted file mode 100644 index 3e4e90d..0000000 --- a/vendor/github.com/google/uuid/node.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2016 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package uuid - -import ( - "sync" -) - -var ( - nodeMu sync.Mutex - ifname string // name of interface being used - nodeID [6]byte // hardware for version 1 UUIDs - zeroID [6]byte // nodeID with only 0's -) - -// NodeInterface returns the name of the interface from which the NodeID was -// derived. The interface "user" is returned if the NodeID was set by -// SetNodeID. -func NodeInterface() string { - defer nodeMu.Unlock() - nodeMu.Lock() - return ifname -} - -// SetNodeInterface selects the hardware address to be used for Version 1 UUIDs. -// If name is "" then the first usable interface found will be used or a random -// Node ID will be generated. If a named interface cannot be found then false -// is returned. -// -// SetNodeInterface never fails when name is "". -func SetNodeInterface(name string) bool { - defer nodeMu.Unlock() - nodeMu.Lock() - return setNodeInterface(name) -} - -func setNodeInterface(name string) bool { - iname, addr := getHardwareInterface(name) // null implementation for js - if iname != "" && addr != nil { - ifname = iname - copy(nodeID[:], addr) - return true - } - - // We found no interfaces with a valid hardware address. If name - // does not specify a specific interface generate a random Node ID - // (section 4.1.6) - if name == "" { - randomBits(nodeID[:]) - return true - } - return false -} - -// NodeID returns a slice of a copy of the current Node ID, setting the Node ID -// if not already set. -func NodeID() []byte { - defer nodeMu.Unlock() - nodeMu.Lock() - if nodeID == zeroID { - setNodeInterface("") - } - nid := nodeID - return nid[:] -} - -// SetNodeID sets the Node ID to be used for Version 1 UUIDs. The first 6 bytes -// of id are used. If id is less than 6 bytes then false is returned and the -// Node ID is not set. -func SetNodeID(id []byte) bool { - if len(id) < 6 { - return false - } - defer nodeMu.Unlock() - nodeMu.Lock() - copy(nodeID[:], id) - ifname = "user" - return true -} - -// NodeID returns the 6 byte node id encoded in uuid. It returns nil if uuid is -// not valid. The NodeID is only well defined for version 1 and 2 UUIDs. -func (uuid UUID) NodeID() []byte { - var node [6]byte - copy(node[:], uuid[10:]) - return node[:] -} diff --git a/vendor/github.com/google/uuid/node_js.go b/vendor/github.com/google/uuid/node_js.go deleted file mode 100644 index 24b78ed..0000000 --- a/vendor/github.com/google/uuid/node_js.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build js - -package uuid - -// getHardwareInterface returns nil values for the JS version of the code. -// This remvoves the "net" dependency, because it is not used in the browser. -// Using the "net" library inflates the size of the transpiled JS code by 673k bytes. -func getHardwareInterface(name string) (string, []byte) { return "", nil } diff --git a/vendor/github.com/google/uuid/node_net.go b/vendor/github.com/google/uuid/node_net.go deleted file mode 100644 index 0cbbcdd..0000000 --- a/vendor/github.com/google/uuid/node_net.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !js - -package uuid - -import "net" - -var interfaces []net.Interface // cached list of interfaces - -// getHardwareInterface returns the name and hardware address of interface name. -// If name is "" then the name and hardware address of one of the system's -// interfaces is returned. If no interfaces are found (name does not exist or -// there are no interfaces) then "", nil is returned. -// -// Only addresses of at least 6 bytes are returned. -func getHardwareInterface(name string) (string, []byte) { - if interfaces == nil { - var err error - interfaces, err = net.Interfaces() - if err != nil { - return "", nil - } - } - for _, ifs := range interfaces { - if len(ifs.HardwareAddr) >= 6 && (name == "" || name == ifs.Name) { - return ifs.Name, ifs.HardwareAddr - } - } - return "", nil -} diff --git a/vendor/github.com/google/uuid/sql.go b/vendor/github.com/google/uuid/sql.go deleted file mode 100644 index f326b54..0000000 --- a/vendor/github.com/google/uuid/sql.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2016 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package uuid - -import ( - "database/sql/driver" - "fmt" -) - -// Scan implements sql.Scanner so UUIDs can be read from databases transparently -// Currently, database types that map to string and []byte are supported. Please -// consult database-specific driver documentation for matching types. -func (uuid *UUID) Scan(src interface{}) error { - switch src := src.(type) { - case nil: - return nil - - case string: - // if an empty UUID comes from a table, we return a null UUID - if src == "" { - return nil - } - - // see Parse for required string format - u, err := Parse(src) - if err != nil { - return fmt.Errorf("Scan: %v", err) - } - - *uuid = u - - case []byte: - // if an empty UUID comes from a table, we return a null UUID - if len(src) == 0 { - return nil - } - - // assumes a simple slice of bytes if 16 bytes - // otherwise attempts to parse - if len(src) != 16 { - return uuid.Scan(string(src)) - } - copy((*uuid)[:], src) - - default: - return fmt.Errorf("Scan: unable to scan type %T into UUID", src) - } - - return nil -} - -// Value implements sql.Valuer so that UUIDs can be written to databases -// transparently. Currently, UUIDs map to strings. Please consult -// database-specific driver documentation for matching types. -func (uuid UUID) Value() (driver.Value, error) { - return uuid.String(), nil -} diff --git a/vendor/github.com/google/uuid/time.go b/vendor/github.com/google/uuid/time.go deleted file mode 100644 index e6ef06c..0000000 --- a/vendor/github.com/google/uuid/time.go +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2016 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package uuid - -import ( - "encoding/binary" - "sync" - "time" -) - -// A Time represents a time as the number of 100's of nanoseconds since 15 Oct -// 1582. -type Time int64 - -const ( - lillian = 2299160 // Julian day of 15 Oct 1582 - unix = 2440587 // Julian day of 1 Jan 1970 - epoch = unix - lillian // Days between epochs - g1582 = epoch * 86400 // seconds between epochs - g1582ns100 = g1582 * 10000000 // 100s of a nanoseconds between epochs -) - -var ( - timeMu sync.Mutex - lasttime uint64 // last time we returned - clockSeq uint16 // clock sequence for this run - - timeNow = time.Now // for testing -) - -// UnixTime converts t the number of seconds and nanoseconds using the Unix -// epoch of 1 Jan 1970. -func (t Time) UnixTime() (sec, nsec int64) { - sec = int64(t - g1582ns100) - nsec = (sec % 10000000) * 100 - sec /= 10000000 - return sec, nsec -} - -// GetTime returns the current Time (100s of nanoseconds since 15 Oct 1582) and -// clock sequence as well as adjusting the clock sequence as needed. An error -// is returned if the current time cannot be determined. -func GetTime() (Time, uint16, error) { - defer timeMu.Unlock() - timeMu.Lock() - return getTime() -} - -func getTime() (Time, uint16, error) { - t := timeNow() - - // If we don't have a clock sequence already, set one. - if clockSeq == 0 { - setClockSequence(-1) - } - now := uint64(t.UnixNano()/100) + g1582ns100 - - // If time has gone backwards with this clock sequence then we - // increment the clock sequence - if now <= lasttime { - clockSeq = ((clockSeq + 1) & 0x3fff) | 0x8000 - } - lasttime = now - return Time(now), clockSeq, nil -} - -// ClockSequence returns the current clock sequence, generating one if not -// already set. The clock sequence is only used for Version 1 UUIDs. -// -// The uuid package does not use global static storage for the clock sequence or -// the last time a UUID was generated. Unless SetClockSequence is used, a new -// random clock sequence is generated the first time a clock sequence is -// requested by ClockSequence, GetTime, or NewUUID. (section 4.2.1.1) -func ClockSequence() int { - defer timeMu.Unlock() - timeMu.Lock() - return clockSequence() -} - -func clockSequence() int { - if clockSeq == 0 { - setClockSequence(-1) - } - return int(clockSeq & 0x3fff) -} - -// SetClockSequence sets the clock sequence to the lower 14 bits of seq. Setting to -// -1 causes a new sequence to be generated. -func SetClockSequence(seq int) { - defer timeMu.Unlock() - timeMu.Lock() - setClockSequence(seq) -} - -func setClockSequence(seq int) { - if seq == -1 { - var b [2]byte - randomBits(b[:]) // clock sequence - seq = int(b[0])<<8 | int(b[1]) - } - oldSeq := clockSeq - clockSeq = uint16(seq&0x3fff) | 0x8000 // Set our variant - if oldSeq != clockSeq { - lasttime = 0 - } -} - -// Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in -// uuid. The time is only defined for version 1 and 2 UUIDs. -func (uuid UUID) Time() Time { - time := int64(binary.BigEndian.Uint32(uuid[0:4])) - time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32 - time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48 - return Time(time) -} - -// ClockSequence returns the clock sequence encoded in uuid. -// The clock sequence is only well defined for version 1 and 2 UUIDs. -func (uuid UUID) ClockSequence() int { - return int(binary.BigEndian.Uint16(uuid[8:10])) & 0x3fff -} diff --git a/vendor/github.com/google/uuid/util.go b/vendor/github.com/google/uuid/util.go deleted file mode 100644 index 5ea6c73..0000000 --- a/vendor/github.com/google/uuid/util.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2016 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package uuid - -import ( - "io" -) - -// randomBits completely fills slice b with random data. -func randomBits(b []byte) { - if _, err := io.ReadFull(rander, b); err != nil { - panic(err.Error()) // rand should never fail - } -} - -// xvalues returns the value of a byte as a hexadecimal digit or 255. -var xvalues = [256]byte{ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, - 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -} - -// xtob converts hex characters x1 and x2 into a byte. -func xtob(x1, x2 byte) (byte, bool) { - b1 := xvalues[x1] - b2 := xvalues[x2] - return (b1 << 4) | b2, b1 != 255 && b2 != 255 -} diff --git a/vendor/github.com/google/uuid/uuid.go b/vendor/github.com/google/uuid/uuid.go deleted file mode 100644 index 7f3643f..0000000 --- a/vendor/github.com/google/uuid/uuid.go +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright 2016 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package uuid - -import ( - "bytes" - "crypto/rand" - "encoding/hex" - "errors" - "fmt" - "io" - "strings" -) - -// A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC -// 4122. -type UUID [16]byte - -// A Version represents a UUID's version. -type Version byte - -// A Variant represents a UUID's variant. -type Variant byte - -// Constants returned by Variant. -const ( - Invalid = Variant(iota) // Invalid UUID - RFC4122 // The variant specified in RFC4122 - Reserved // Reserved, NCS backward compatibility. - Microsoft // Reserved, Microsoft Corporation backward compatibility. - Future // Reserved for future definition. -) - -var rander = rand.Reader // random function - -// Parse decodes s into a UUID or returns an error. Both the UUID form of -// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and -// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded. -func Parse(s string) (UUID, error) { - var uuid UUID - if len(s) != 36 { - if len(s) != 36+9 { - return uuid, fmt.Errorf("invalid UUID length: %d", len(s)) - } - if strings.ToLower(s[:9]) != "urn:uuid:" { - return uuid, fmt.Errorf("invalid urn prefix: %q", s[:9]) - } - s = s[9:] - } - if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' { - return uuid, errors.New("invalid UUID format") - } - for i, x := range [16]int{ - 0, 2, 4, 6, - 9, 11, - 14, 16, - 19, 21, - 24, 26, 28, 30, 32, 34} { - v, ok := xtob(s[x], s[x+1]) - if !ok { - return uuid, errors.New("invalid UUID format") - } - uuid[i] = v - } - return uuid, nil -} - -// ParseBytes is like Parse, except it parses a byte slice instead of a string. -func ParseBytes(b []byte) (UUID, error) { - var uuid UUID - if len(b) != 36 { - if len(b) != 36+9 { - return uuid, fmt.Errorf("invalid UUID length: %d", len(b)) - } - if !bytes.Equal(bytes.ToLower(b[:9]), []byte("urn:uuid:")) { - return uuid, fmt.Errorf("invalid urn prefix: %q", b[:9]) - } - b = b[9:] - } - if b[8] != '-' || b[13] != '-' || b[18] != '-' || b[23] != '-' { - return uuid, errors.New("invalid UUID format") - } - for i, x := range [16]int{ - 0, 2, 4, 6, - 9, 11, - 14, 16, - 19, 21, - 24, 26, 28, 30, 32, 34} { - v, ok := xtob(b[x], b[x+1]) - if !ok { - return uuid, errors.New("invalid UUID format") - } - uuid[i] = v - } - return uuid, nil -} - -// FromBytes creates a new UUID from a byte slice. Returns an error if the slice -// does not have a length of 16. The bytes are copied from the slice. -func FromBytes(b []byte) (uuid UUID, err error) { - err = uuid.UnmarshalBinary(b) - return uuid, err -} - -// Must returns uuid if err is nil and panics otherwise. -func Must(uuid UUID, err error) UUID { - if err != nil { - panic(err) - } - return uuid -} - -// String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -// , or "" if uuid is invalid. -func (uuid UUID) String() string { - var buf [36]byte - encodeHex(buf[:], uuid) - return string(buf[:]) -} - -// URN returns the RFC 2141 URN form of uuid, -// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, or "" if uuid is invalid. -func (uuid UUID) URN() string { - var buf [36 + 9]byte - copy(buf[:], "urn:uuid:") - encodeHex(buf[9:], uuid) - return string(buf[:]) -} - -func encodeHex(dst []byte, uuid UUID) { - hex.Encode(dst[:], uuid[:4]) - dst[8] = '-' - hex.Encode(dst[9:13], uuid[4:6]) - dst[13] = '-' - hex.Encode(dst[14:18], uuid[6:8]) - dst[18] = '-' - hex.Encode(dst[19:23], uuid[8:10]) - dst[23] = '-' - hex.Encode(dst[24:], uuid[10:]) -} - -// Variant returns the variant encoded in uuid. -func (uuid UUID) Variant() Variant { - switch { - case (uuid[8] & 0xc0) == 0x80: - return RFC4122 - case (uuid[8] & 0xe0) == 0xc0: - return Microsoft - case (uuid[8] & 0xe0) == 0xe0: - return Future - default: - return Reserved - } -} - -// Version returns the version of uuid. -func (uuid UUID) Version() Version { - return Version(uuid[6] >> 4) -} - -func (v Version) String() string { - if v > 15 { - return fmt.Sprintf("BAD_VERSION_%d", v) - } - return fmt.Sprintf("VERSION_%d", v) -} - -func (v Variant) String() string { - switch v { - case RFC4122: - return "RFC4122" - case Reserved: - return "Reserved" - case Microsoft: - return "Microsoft" - case Future: - return "Future" - case Invalid: - return "Invalid" - } - return fmt.Sprintf("BadVariant%d", int(v)) -} - -// SetRand sets the random number generator to r, which implements io.Reader. -// If r.Read returns an error when the package requests random data then -// a panic will be issued. -// -// Calling SetRand with nil sets the random number generator to the default -// generator. -func SetRand(r io.Reader) { - if r == nil { - rander = rand.Reader - return - } - rander = r -} diff --git a/vendor/github.com/google/uuid/version1.go b/vendor/github.com/google/uuid/version1.go deleted file mode 100644 index 199a1ac..0000000 --- a/vendor/github.com/google/uuid/version1.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2016 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package uuid - -import ( - "encoding/binary" -) - -// NewUUID returns a Version 1 UUID based on the current NodeID and clock -// sequence, and the current time. If the NodeID has not been set by SetNodeID -// or SetNodeInterface then it will be set automatically. If the NodeID cannot -// be set NewUUID returns nil. If clock sequence has not been set by -// SetClockSequence then it will be set automatically. If GetTime fails to -// return the current NewUUID returns nil and an error. -// -// In most cases, New should be used. -func NewUUID() (UUID, error) { - nodeMu.Lock() - if nodeID == zeroID { - setNodeInterface("") - } - nodeMu.Unlock() - - var uuid UUID - now, seq, err := GetTime() - if err != nil { - return uuid, err - } - - timeLow := uint32(now & 0xffffffff) - timeMid := uint16((now >> 32) & 0xffff) - timeHi := uint16((now >> 48) & 0x0fff) - timeHi |= 0x1000 // Version 1 - - binary.BigEndian.PutUint32(uuid[0:], timeLow) - binary.BigEndian.PutUint16(uuid[4:], timeMid) - binary.BigEndian.PutUint16(uuid[6:], timeHi) - binary.BigEndian.PutUint16(uuid[8:], seq) - copy(uuid[10:], nodeID[:]) - - return uuid, nil -} diff --git a/vendor/github.com/google/uuid/version4.go b/vendor/github.com/google/uuid/version4.go deleted file mode 100644 index 84af91c..0000000 --- a/vendor/github.com/google/uuid/version4.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2016 Google Inc. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package uuid - -import "io" - -// New creates a new random UUID or panics. New is equivalent to -// the expression -// -// uuid.Must(uuid.NewRandom()) -func New() UUID { - return Must(NewRandom()) -} - -// NewRandom returns a Random (Version 4) UUID. -// -// The strength of the UUIDs is based on the strength of the crypto/rand -// package. -// -// A note about uniqueness derived from the UUID Wikipedia entry: -// -// Randomly generated UUIDs have 122 random bits. One's annual risk of being -// hit by a meteorite is estimated to be one chance in 17 billion, that -// means the probability is about 0.00000000006 (6 × 10−11), -// equivalent to the odds of creating a few tens of trillions of UUIDs in a -// year and having one duplicate. -func NewRandom() (UUID, error) { - var uuid UUID - _, err := io.ReadFull(rander, uuid[:]) - if err != nil { - return Nil, err - } - uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 - uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 - return uuid, nil -} diff --git a/vendor/github.com/pions/dtls/LICENSE b/vendor/github.com/pions/dtls/LICENSE deleted file mode 100644 index ab60297..0000000 --- a/vendor/github.com/pions/dtls/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/pions/dtls/pkg/dtls/alert.go b/vendor/github.com/pions/dtls/pkg/dtls/alert.go deleted file mode 100644 index b747016..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/alert.go +++ /dev/null @@ -1,145 +0,0 @@ -package dtls - -import "fmt" - -type alertLevel byte - -const ( - alertLevelWarning alertLevel = 1 - alertLevelFatal alertLevel = 2 -) - -func (a alertLevel) String() string { - switch a { - case alertLevelWarning: - return "LevelWarning" - case alertLevelFatal: - return "LevelFatal" - default: - return "Invalid alert level" - } -} - -type alertDescription byte - -const ( - alertCloseNotify alertDescription = 0 - alertUnexpectedMessage alertDescription = 10 - alertBadRecordMac alertDescription = 20 - alertDecryptionFailed alertDescription = 21 - alertRecordOverflow alertDescription = 22 - alertDecompressionFailure alertDescription = 30 - alertHandshakeFailure alertDescription = 40 - alertNoCertificate alertDescription = 41 - alertBadCertificate alertDescription = 42 - alertUnsupportedCertificate alertDescription = 43 - alertCertificateRevoked alertDescription = 44 - alertCertificateExpired alertDescription = 45 - alertCertificateUnknown alertDescription = 46 - alertIllegalParameter alertDescription = 47 - alertUnknownCA alertDescription = 48 - alertAccessDenied alertDescription = 49 - alertDecodeError alertDescription = 50 - alertDecryptError alertDescription = 51 - alertExportRestriction alertDescription = 60 - alertProtocolVersion alertDescription = 70 - alertInsufficientSecurity alertDescription = 71 - alertInternalError alertDescription = 80 - alertUserCanceled alertDescription = 90 - alertNoRenegotiation alertDescription = 100 - alertUnsupportedExtension alertDescription = 110 -) - -func (a alertDescription) String() string { - switch a { - case alertCloseNotify: - return "CloseNotify" - case alertUnexpectedMessage: - return "UnexpectedMessage" - case alertBadRecordMac: - return "BadRecordMac" - case alertDecryptionFailed: - return "DecryptionFailed" - case alertRecordOverflow: - return "RecordOverflow" - case alertDecompressionFailure: - return "DecompressionFailure" - case alertHandshakeFailure: - return "HandshakeFailure" - case alertNoCertificate: - return "NoCertificate" - case alertBadCertificate: - return "BadCertificate" - case alertUnsupportedCertificate: - return "UnsupportedCertificate" - case alertCertificateRevoked: - return "CertificateRevoked" - case alertCertificateExpired: - return "CertificateExpired" - case alertCertificateUnknown: - return "CertificateUnknown" - case alertIllegalParameter: - return "IllegalParameter" - case alertUnknownCA: - return "UnknownCA" - case alertAccessDenied: - return "AccessDenied" - case alertDecodeError: - return "DecodeError" - case alertDecryptError: - return "DecryptError" - case alertExportRestriction: - return "ExportRestriction" - case alertProtocolVersion: - return "ProtocolVersion" - case alertInsufficientSecurity: - return "InsufficientSecurity" - case alertInternalError: - return "InternalError" - case alertUserCanceled: - return "UserCanceled" - case alertNoRenegotiation: - return "NoRenegotiation" - case alertUnsupportedExtension: - return "UnsupportedExtension" - default: - return "Invalid alert description" - } -} - -// One of the content types supported by the TLS record layer is the -// alert type. Alert messages convey the severity of the message -// (warning or fatal) and a description of the alert. Alert messages -// with a level of fatal result in the immediate termination of the -// connection. In this case, other connections corresponding to the -// session may continue, but the session identifier MUST be invalidated, -// preventing the failed session from being used to establish new -// connections. Like other messages, alert messages are encrypted and -// compressed, as specified by the current connection state. -// https://tools.ietf.org/html/rfc5246#section-7.2 -type alert struct { - alertLevel alertLevel - alertDescription alertDescription -} - -func (a alert) contentType() contentType { - return contentTypeAlert -} - -func (a *alert) Marshal() ([]byte, error) { - return []byte{byte(a.alertLevel), byte(a.alertDescription)}, nil -} - -func (a *alert) Unmarshal(data []byte) error { - if len(data) != 2 { - return errBufferTooSmall - } - - a.alertLevel = alertLevel(data[0]) - a.alertDescription = alertDescription(data[1]) - return nil -} - -func (a *alert) String() string { - return fmt.Sprintf("Alert %s: %s", a.alertLevel, a.alertDescription) -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/application_data.go b/vendor/github.com/pions/dtls/pkg/dtls/application_data.go deleted file mode 100644 index 679a103..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/application_data.go +++ /dev/null @@ -1,23 +0,0 @@ -package dtls - -// Application data messages are carried by the record layer and are -// fragmented, compressed, and encrypted based on the current connection -// state. The messages are treated as transparent data to the record -// layer. -// https://tools.ietf.org/html/rfc5246#section-10 -type applicationData struct { - data []byte -} - -func (a applicationData) contentType() contentType { - return contentTypeApplicationData -} - -func (a *applicationData) Marshal() ([]byte, error) { - return append([]byte{}, a.data...), nil -} - -func (a *applicationData) Unmarshal(data []byte) error { - a.data = append([]byte{}, data...) - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/change_cipher_spec.go b/vendor/github.com/pions/dtls/pkg/dtls/change_cipher_spec.go deleted file mode 100644 index f072d7f..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/change_cipher_spec.go +++ /dev/null @@ -1,25 +0,0 @@ -package dtls - -// The change cipher spec protocol exists to signal transitions in -// ciphering strategies. The protocol consists of a single message, -// which is encrypted and compressed under the current (not the pending) -// connection state. The message consists of a single byte of value 1. -// https://tools.ietf.org/html/rfc5246#section-7.1 -type changeCipherSpec struct { -} - -func (c changeCipherSpec) contentType() contentType { - return contentTypeChangeCipherSpec -} - -func (c *changeCipherSpec) Marshal() ([]byte, error) { - return []byte{0x01}, nil -} - -func (c *changeCipherSpec) Unmarshal(data []byte) error { - if len(data) == 1 && data[0] == 0x01 { - return nil - } - - return errInvalidCipherSpec -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite.go b/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite.go deleted file mode 100644 index 3110e29..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite.go +++ /dev/null @@ -1,82 +0,0 @@ -package dtls - -import ( - "encoding/binary" - "hash" -) - -type cipherSuiteID uint16 - -type cipherSuite interface { - ID() cipherSuiteID - certificateType() clientCertificateType - hashFunc() func() hash.Hash - - // Generate the internal encryption state - init(masterSecret, clientRandom, serverRandom []byte, isClient bool) error - - encrypt(pkt *recordLayer, raw []byte) ([]byte, error) - decrypt(in []byte) ([]byte, error) -} - -// Taken from https://www.iana.org/assignments/tls-parameters/tls-parameters.xml -// A cipherSuite is a specific combination of key agreement, cipher and MAC -// function. -func cipherSuiteForID(id cipherSuiteID) cipherSuite { - switch id { - case cipherSuiteTLSEcdheEcdsaWithAes128GcmSha256{}.ID(): - return &cipherSuiteTLSEcdheEcdsaWithAes128GcmSha256{} - case cipherSuiteTLSEcdheRsaWithAes128GcmSha256{}.ID(): - return &cipherSuiteTLSEcdheRsaWithAes128GcmSha256{} - case cipherSuiteTLSEcdheEcdsaWithAes256CbcSha{}.ID(): - return &cipherSuiteTLSEcdheEcdsaWithAes256CbcSha{} - case cipherSuiteTLSEcdheRsaWithAes256CbcSha{}.ID(): - return &cipherSuiteTLSEcdheRsaWithAes256CbcSha{} - } - - return nil -} - -// CipherSuites we support as a client -// Preferred at the bottom -func clientCipherSuites() []cipherSuite { - return []cipherSuite{ - &cipherSuiteTLSEcdheRsaWithAes256CbcSha{}, - &cipherSuiteTLSEcdheEcdsaWithAes256CbcSha{}, - &cipherSuiteTLSEcdheRsaWithAes128GcmSha256{}, - &cipherSuiteTLSEcdheEcdsaWithAes128GcmSha256{}, - } -} - -// CipherSuites we support as a server -// func serverCipherSuites() []cipherSuite { -// return []cipherSuite{ -// &cipherSuiteTLSEcdheEcdsaWithAes128GcmSha256{}, -// } -// } - -func decodeCipherSuites(buf []byte) ([]cipherSuite, error) { - if len(buf) < 2 { - return nil, errDTLSPacketInvalidLength - } - cipherSuitesCount := int(binary.BigEndian.Uint16(buf[0:])) / 2 - rtrn := []cipherSuite{} - for i := 0; i < cipherSuitesCount; i++ { - id := cipherSuiteID(binary.BigEndian.Uint16(buf[(i*2)+2:])) - if c := cipherSuiteForID(id); c != nil { - rtrn = append(rtrn, c) - } - } - return rtrn, nil -} - -func encodeCipherSuites(c []cipherSuite) []byte { - out := []byte{0x00, 0x00} - binary.BigEndian.PutUint16(out[len(out)-2:], uint16(len(c)*2)) - for i := len(c); i > 0; i-- { - out = append(out, []byte{0x00, 0x00}...) - binary.BigEndian.PutUint16(out[len(out)-2:], uint16(c[i-1].ID())) - } - - return out -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite_tls_ecdhe_ecdsa_with_aes_128_gcm_sha256.go b/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite_tls_ecdhe_ecdsa_with_aes_128_gcm_sha256.go deleted file mode 100644 index 3cc7913..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite_tls_ecdhe_ecdsa_with_aes_128_gcm_sha256.go +++ /dev/null @@ -1,60 +0,0 @@ -package dtls - -import ( - "crypto/sha256" - "errors" - "hash" -) - -type cipherSuiteTLSEcdheEcdsaWithAes128GcmSha256 struct { - gcm *cryptoGCM -} - -func (c cipherSuiteTLSEcdheEcdsaWithAes128GcmSha256) certificateType() clientCertificateType { - return clientCertificateTypeECDSASign -} - -func (c cipherSuiteTLSEcdheEcdsaWithAes128GcmSha256) ID() cipherSuiteID { - return 0xc02b -} - -func (c cipherSuiteTLSEcdheEcdsaWithAes128GcmSha256) hashFunc() func() hash.Hash { - return sha256.New -} - -func (c *cipherSuiteTLSEcdheEcdsaWithAes128GcmSha256) init(masterSecret, clientRandom, serverRandom []byte, isClient bool) error { - const ( - prfMacLen = 0 - prfKeyLen = 16 - prfIvLen = 4 - ) - - keys, err := prfEncryptionKeys(masterSecret, clientRandom, serverRandom, prfMacLen, prfKeyLen, prfIvLen, c.hashFunc()) - if err != nil { - return err - } - - if isClient { - c.gcm, err = newCryptoGCM(keys.clientWriteKey, keys.clientWriteIV, keys.serverWriteKey, keys.serverWriteIV) - } else { - c.gcm, err = newCryptoGCM(keys.serverWriteKey, keys.serverWriteIV, keys.clientWriteKey, keys.clientWriteIV) - } - - return err -} - -func (c *cipherSuiteTLSEcdheEcdsaWithAes128GcmSha256) encrypt(pkt *recordLayer, raw []byte) ([]byte, error) { - if c.gcm == nil { - return nil, errors.New("CipherSuite has not been initalized, unable to encrypt") - } - - return c.gcm.encrypt(pkt, raw) -} - -func (c *cipherSuiteTLSEcdheEcdsaWithAes128GcmSha256) decrypt(raw []byte) ([]byte, error) { - if c.gcm == nil { - return nil, errors.New("CipherSuite has not been initalized, unable to decrypt ") - } - - return c.gcm.decrypt(raw) -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite_tls_ecdhe_ecdsa_with_aes_256_cbc_sha.go b/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite_tls_ecdhe_ecdsa_with_aes_256_cbc_sha.go deleted file mode 100644 index 6f269fe..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite_tls_ecdhe_ecdsa_with_aes_256_cbc_sha.go +++ /dev/null @@ -1,66 +0,0 @@ -package dtls - -import ( - "crypto/sha256" - "errors" - "hash" -) - -type cipherSuiteTLSEcdheEcdsaWithAes256CbcSha struct { - cbc *cryptoCBC -} - -func (c cipherSuiteTLSEcdheEcdsaWithAes256CbcSha) certificateType() clientCertificateType { - return clientCertificateTypeECDSASign -} - -func (c cipherSuiteTLSEcdheEcdsaWithAes256CbcSha) ID() cipherSuiteID { - return 0xc00a -} - -func (c cipherSuiteTLSEcdheEcdsaWithAes256CbcSha) hashFunc() func() hash.Hash { - return sha256.New -} - -func (c *cipherSuiteTLSEcdheEcdsaWithAes256CbcSha) init(masterSecret, clientRandom, serverRandom []byte, isClient bool) error { - const ( - prfMacLen = 20 - prfKeyLen = 32 - prfIvLen = 16 - ) - - keys, err := prfEncryptionKeys(masterSecret, clientRandom, serverRandom, prfMacLen, prfKeyLen, prfIvLen, c.hashFunc()) - if err != nil { - return err - } - - if isClient { - c.cbc, err = newCryptoCBC( - keys.clientWriteKey, keys.clientWriteIV, keys.clientMACKey, - keys.serverWriteKey, keys.serverWriteIV, keys.serverMACKey, - ) - } else { - c.cbc, err = newCryptoCBC( - keys.serverWriteKey, keys.serverWriteIV, keys.serverMACKey, - keys.clientWriteKey, keys.clientWriteIV, keys.clientMACKey, - ) - } - - return err -} - -func (c *cipherSuiteTLSEcdheEcdsaWithAes256CbcSha) encrypt(pkt *recordLayer, raw []byte) ([]byte, error) { - if c.cbc == nil { - return nil, errors.New("CipherSuite has not been initalized, unable to encrypt") - } - - return c.cbc.encrypt(pkt, raw) -} - -func (c *cipherSuiteTLSEcdheEcdsaWithAes256CbcSha) decrypt(raw []byte) ([]byte, error) { - if c.cbc == nil { - return nil, errors.New("CipherSuite has not been initalized, unable to decrypt ") - } - - return c.cbc.decrypt(raw) -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite_tls_ecdhe_rsa_with_aes_128_gcm_sha256.go b/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite_tls_ecdhe_rsa_with_aes_128_gcm_sha256.go deleted file mode 100644 index 3ab201f..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite_tls_ecdhe_rsa_with_aes_128_gcm_sha256.go +++ /dev/null @@ -1,13 +0,0 @@ -package dtls - -type cipherSuiteTLSEcdheRsaWithAes128GcmSha256 struct { - cipherSuiteTLSEcdheEcdsaWithAes128GcmSha256 -} - -func (c cipherSuiteTLSEcdheRsaWithAes128GcmSha256) certificateType() clientCertificateType { - return clientCertificateTypeRSASign -} - -func (c cipherSuiteTLSEcdheRsaWithAes128GcmSha256) ID() cipherSuiteID { - return 0xc02f -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite_tls_ecdhe_rsa_with_aes_256_cbc_sha.go b/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite_tls_ecdhe_rsa_with_aes_256_cbc_sha.go deleted file mode 100644 index 2938b08..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/cipher_suite_tls_ecdhe_rsa_with_aes_256_cbc_sha.go +++ /dev/null @@ -1,13 +0,0 @@ -package dtls - -type cipherSuiteTLSEcdheRsaWithAes256CbcSha struct { - cipherSuiteTLSEcdheEcdsaWithAes256CbcSha -} - -func (c cipherSuiteTLSEcdheRsaWithAes256CbcSha) certificateType() clientCertificateType { - return clientCertificateTypeRSASign -} - -func (c cipherSuiteTLSEcdheRsaWithAes256CbcSha) ID() cipherSuiteID { - return 0x0035 -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/client_certificate_type.go b/vendor/github.com/pions/dtls/pkg/dtls/client_certificate_type.go deleted file mode 100644 index 8eb3526..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/client_certificate_type.go +++ /dev/null @@ -1,14 +0,0 @@ -package dtls - -// https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-10 -type clientCertificateType byte - -const ( - clientCertificateTypeRSASign clientCertificateType = 1 - clientCertificateTypeECDSASign clientCertificateType = 64 -) - -var clientCertificateTypes = map[clientCertificateType]bool{ - clientCertificateTypeRSASign: true, - clientCertificateTypeECDSASign: true, -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/client_handlers.go b/vendor/github.com/pions/dtls/pkg/dtls/client_handlers.go deleted file mode 100644 index 12c608a..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/client_handlers.go +++ /dev/null @@ -1,274 +0,0 @@ -package dtls - -import ( - "bytes" - "fmt" -) - -func clientExcludeRules(c *Conn) map[flightVal]handshakeCacheExcludeRule { - excludeRules := map[flightVal]handshakeCacheExcludeRule{} - if len(c.cookie) != 0 { - excludeRules[flight0] = handshakeCacheExcludeRule{isLocal: true, isRemote: true} - excludeRules[flight1] = handshakeCacheExcludeRule{isLocal: true, isRemote: true} - excludeRules[flight2] = handshakeCacheExcludeRule{isLocal: true, isRemote: true} - } - return excludeRules -} - -func clientHandshakeHandler(c *Conn) error { - c.lock.Lock() - defer c.lock.Unlock() - - for out, fragEpoch := c.fragmentBuffer.pop(); out != nil; out, fragEpoch = c.fragmentBuffer.pop() { - rawHandshake := &handshake{} - if err := rawHandshake.Unmarshal(out); err != nil { - return err - } - c.handshakeCache.push(out, fragEpoch, rawHandshake.handshakeHeader.messageSequence /* isLocal */, false, c.currFlight.get()) - - switch h := rawHandshake.handshakeMessage.(type) { - case *handshakeMessageHelloVerifyRequest: - if c.currFlight.get() == flight1 { - c.cookie = append([]byte{}, h.cookie...) - c.localSequenceNumber++ - if err := c.currFlight.set(flight3); err != nil { - return err - } - } - - case *handshakeMessageServerHello: - switch c.currFlight.get() { - case flight1: - // HelloVerifyRequest can be skipped by the server - if err := c.currFlight.set(flight3); err != nil { - return err - } - fallthrough - case flight3: - c.cipherSuite = h.cipherSuite - c.remoteRandom = h.random - } - - case *handshakeMessageCertificate: - if c.currFlight.get() == flight3 { - c.remoteCertificate = h.certificate - } - - case *handshakeMessageServerKeyExchange: - if c.currFlight.get() == flight3 && c.cipherSuite != nil { - c.remoteKeypair = &namedCurveKeypair{h.namedCurve, h.publicKey, nil} - - clientRandom, err := c.localRandom.Marshal() - if err != nil { - return err - } - serverRandom, err := c.remoteRandom.Marshal() - if err != nil { - return err - } - - c.localKeypair, err = generateKeypair(h.namedCurve) - if err != nil { - return err - } - - preMasterSecret, err := prfPreMasterSecret(c.remoteKeypair.publicKey, c.localKeypair.privateKey, c.localKeypair.curve) - if err != nil { - return err - } - - c.masterSecret, err = prfMasterSecret(preMasterSecret, clientRandom, serverRandom, c.cipherSuite.hashFunc()) - if err != nil { - return err - } - - if err := c.cipherSuite.init(c.masterSecret, clientRandom, serverRandom /* isClient */, true); err != nil { - return err - } - - expectedHash := valueKeySignature(clientRandom, serverRandom, h.publicKey, c.namedCurve, h.hashAlgorithm) - if err := verifyKeySignature(expectedHash, h.signature, c.remoteCertificate); err != nil { - return err - } - } - - case *handshakeMessageCertificateRequest: - c.remoteRequestedCertificate = true - - case *handshakeMessageServerHelloDone: - if c.currFlight.get() == flight3 { - c.localSequenceNumber++ - if err := c.currFlight.set(flight5); err != nil { - return err - } - } - - case *handshakeMessageFinished: - if c.currFlight.get() == flight5 { - c.localEpoch = 1 - c.localSequenceNumber = 1 - - expectedVerifyData, err := prfVerifyDataServer(c.masterSecret, c.handshakeCache.combinedHandshake(clientExcludeRules(c), true), c.cipherSuite.hashFunc()) - if err != nil { - return err - } - if !bytes.Equal(expectedVerifyData, h.verifyData) { - return errVerifyDataMismatch - } - c.signalHandshakeComplete() - } - - default: - return fmt.Errorf("Unhandled handshake %d", h.handshakeType()) - } - } - - return nil -} - -func clientFlightHandler(c *Conn) (bool, error) { - switch c.currFlight.get() { - case flight1: - fallthrough - case flight3: - c.lock.RLock() - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - sequenceNumber: c.localSequenceNumber, - protocolVersion: protocolVersion1_2, - }, - content: &handshake{ - // sequenceNumber and messageSequence line up, may need to be re-evaluated - handshakeHeader: handshakeHeader{ - messageSequence: uint16(c.localSequenceNumber), - }, - handshakeMessage: &handshakeMessageClientHello{ - version: protocolVersion1_2, - cookie: c.cookie, - random: c.localRandom, - cipherSuites: clientCipherSuites(), - compressionMethods: defaultCompressionMethods, - extensions: []extension{ - &extensionSupportedEllipticCurves{ - ellipticCurves: []namedCurve{namedCurveX25519, namedCurveP256}, - }, - &extensionUseSRTP{ - protectionProfiles: []srtpProtectionProfile{SRTP_AES128_CM_HMAC_SHA1_80}, - }, - &extensionSupportedPointFormats{ - pointFormats: []ellipticCurvePointFormat{ellipticCurvePointFormatUncompressed}, - }, - }, - }}, - }, false) - c.lock.RUnlock() - case flight5: - c.lock.RLock() - // TODO: Better way to end handshake - if c.remoteEpoch != 0 { - // Handshake is done - c.lock.RUnlock() - return true, nil - } - - sequenceNumber := c.localSequenceNumber - if c.remoteRequestedCertificate { - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - sequenceNumber: c.localSequenceNumber, - protocolVersion: protocolVersion1_2, - }, - content: &handshake{ - // sequenceNumber and messageSequence line up, may need to be re-evaluated - handshakeHeader: handshakeHeader{ - messageSequence: uint16(c.localSequenceNumber), - }, - handshakeMessage: &handshakeMessageCertificate{ - certificate: c.localCertificate, - }}, - }, false) - sequenceNumber++ - } - - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - sequenceNumber: sequenceNumber, - protocolVersion: protocolVersion1_2, - }, - content: &handshake{ - // sequenceNumber and messageSequence line up, may need to be re-evaluated - handshakeHeader: handshakeHeader{ - messageSequence: uint16(sequenceNumber), - }, - handshakeMessage: &handshakeMessageClientKeyExchange{ - publicKey: c.localKeypair.publicKey, - }}, - }, false) - sequenceNumber++ - - if c.remoteRequestedCertificate { - if len(c.localCertificateVerify) == 0 { - certVerify, err := generateCertificateVerify(c.handshakeCache.combinedHandshake(clientExcludeRules(c), false), c.localPrivateKey) - if err != nil { - return false, err - } - c.localCertificateVerify = certVerify - } - - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - sequenceNumber: sequenceNumber, - protocolVersion: protocolVersion1_2, - }, - content: &handshake{ - // sequenceNumber and messageSequence line up, may need to be re-evaluated - handshakeHeader: handshakeHeader{ - messageSequence: uint16(sequenceNumber), - }, - handshakeMessage: &handshakeMessageCertificateVerify{ - hashAlgorithm: HashAlgorithmSHA256, - signatureAlgorithm: signatureAlgorithmECDSA, - signature: c.localCertificateVerify, - }}, - }, false) - sequenceNumber++ - } - - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - sequenceNumber: sequenceNumber, - protocolVersion: protocolVersion1_2, - }, - content: &changeCipherSpec{}, - }, false) - - if len(c.localVerifyData) == 0 { - var err error - c.localVerifyData, err = prfVerifyDataClient(c.masterSecret, c.handshakeCache.combinedHandshake(clientExcludeRules(c), false), c.cipherSuite.hashFunc()) - if err != nil { - return false, err - } - } - - // TODO: Fix hard-coded epoch & sequenceNumber, taking retransmitting into account. - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - epoch: 1, - sequenceNumber: 0, // sequenceNumber restarts per epoch - protocolVersion: protocolVersion1_2, - }, - content: &handshake{ - // sequenceNumber and messageSequence line up, may need to be re-evaluated - handshakeHeader: handshakeHeader{ - messageSequence: uint16(sequenceNumber), // KeyExchange + 1 - }, - handshakeMessage: &handshakeMessageFinished{ - verifyData: c.localVerifyData, - }}, - }, true) - c.lock.RUnlock() - default: - return false, fmt.Errorf("Unhandled flight %s", c.currFlight.get()) - } - return false, nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/compression_method.go b/vendor/github.com/pions/dtls/pkg/dtls/compression_method.go deleted file mode 100644 index 55c255c..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/compression_method.go +++ /dev/null @@ -1,42 +0,0 @@ -package dtls - -type compressionMethodID byte - -const ( - compressionMethodNull compressionMethodID = 0 -) - -type compressionMethod struct { - id compressionMethodID -} - -var compressionMethods = map[compressionMethodID]*compressionMethod{ - compressionMethodNull: {id: compressionMethodNull}, -} - -var defaultCompressionMethods = []*compressionMethod{ - compressionMethods[compressionMethodNull], -} - -func decodeCompressionMethods(buf []byte) ([]*compressionMethod, error) { - if len(buf) < 1 { - return nil, errDTLSPacketInvalidLength - } - compressionMethodsCount := int(buf[0]) - c := []*compressionMethod{} - for i := 0; i < compressionMethodsCount; i++ { - id := compressionMethodID(buf[i+1]) - if compressionMethod, ok := compressionMethods[id]; ok { - c = append(c, compressionMethod) - } - } - return c, nil -} - -func encodeCompressionMethods(c []*compressionMethod) []byte { - out := []byte{byte(len(c))} - for i := len(c); i > 0; i-- { - out = append(out, byte(c[i-1].id)) - } - return out -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/config.go b/vendor/github.com/pions/dtls/pkg/dtls/config.go deleted file mode 100644 index e18d734..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/config.go +++ /dev/null @@ -1,13 +0,0 @@ -package dtls - -import ( - "crypto" - "crypto/x509" -) - -// Config is used to configure a DTLS client or server. -// After a Config is passed to a DTLS function it must not be modified. -type Config struct { - Certificate *x509.Certificate - PrivateKey crypto.PrivateKey -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/conn.go b/vendor/github.com/pions/dtls/pkg/dtls/conn.go deleted file mode 100644 index bb5cdf8..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/conn.go +++ /dev/null @@ -1,440 +0,0 @@ -package dtls - -import ( - "crypto" - "crypto/ecdsa" - "crypto/rand" - "crypto/x509" - "errors" - "fmt" - "net" - "sync" - "sync/atomic" - "time" -) - -const initialTickerInterval = time.Second -const cookieLength = 20 -const defaultNamedCurve = namedCurveX25519 - -var invalidKeyingLabels = map[string]bool{ - "client finished": true, - "server finished": true, - "master secret": true, - "key expansion": true, -} - -type handshakeMessageHandler func(*Conn) error -type flightHandler func(*Conn) (bool, error) - -// Conn represents a DTLS connection -type Conn struct { - lock sync.RWMutex // Internal lock (must not be public) - nextConn net.Conn // Embedded Conn, typically a udpconn we read/write from - fragmentBuffer *fragmentBuffer // out-of-order and missing fragment handling - handshakeCache *handshakeCache // caching of handshake messages for verifyData generation - decrypted chan []byte // Decrypted Application Data, pull by calling `Read` - workerTicker *time.Ticker - - isClient bool - remoteRequestedCertificate bool // Did we get a CertificateRequest - localEpoch, remoteEpoch uint16 - localSequenceNumber uint64 // uint48 - - currFlight *flight - cipherSuite cipherSuite // nil if a cipherSuite hasn't been chosen - namedCurve namedCurve - localRandom, remoteRandom handshakeRandom - localCertificate, remoteCertificate *x509.Certificate - localPrivateKey crypto.PrivateKey - localKeypair, remoteKeypair *namedCurveKeypair - cookie []byte - - localCertificateVerify []byte // cache CertificateVerify - localVerifyData []byte // cached VerifyData - - masterSecret []byte - - handshakeMessageHandler handshakeMessageHandler - flightHandler flightHandler - handshakeCompleted chan bool - - connErr atomic.Value -} - -func createConn(nextConn net.Conn, flightHandler flightHandler, handshakeMessageHandler handshakeMessageHandler, config *Config, isClient bool) (*Conn, error) { - if config == nil { - return nil, errors.New("No config provided") - } - - if config.PrivateKey != nil { - if _, ok := config.PrivateKey.(*ecdsa.PrivateKey); !ok { - return nil, errInvalidPrivateKey - } - } else if nextConn == nil { - return nil, errNilNextConn - } - - c := &Conn{ - isClient: isClient, - nextConn: nextConn, - currFlight: newFlight(isClient), - fragmentBuffer: newFragmentBuffer(), - handshakeCache: newHandshakeCache(), - handshakeMessageHandler: handshakeMessageHandler, - flightHandler: flightHandler, - localCertificate: config.Certificate, - localPrivateKey: config.PrivateKey, - namedCurve: defaultNamedCurve, - - decrypted: make(chan []byte), - workerTicker: time.NewTicker(initialTickerInterval), - handshakeCompleted: make(chan bool), - } - err := c.localRandom.populate() - if err != nil { - return nil, err - } - if !isClient { - c.cookie = make([]byte, cookieLength) - if _, err = rand.Read(c.cookie); err != nil { - return nil, err - } - } - - // Trigger outbound - c.startHandshakeOutbound() - - // Handle inbound - go func() { - defer func() { - close(c.decrypted) - }() - - b := make([]byte, 8192) - for { - i, err := c.nextConn.Read(b) - if err != nil { - c.stopWithError(err) - return - } else if c.getConnErr() != nil { - return - } - - if err := c.handleIncoming(b[:i]); err != nil { - c.stopWithError(err) - return - } - } - }() - - <-c.handshakeCompleted - return c, c.getConnErr() -} - -// Dial connects to the given network address and establishes a DTLS connection on top -func Dial(network string, raddr *net.UDPAddr, config *Config) (*Conn, error) { - pConn, err := net.DialUDP(network, nil, raddr) - if err != nil { - return nil, err - } - return Client(pConn, config) -} - -// Client establishes a DTLS connection over an existing conn -func Client(conn net.Conn, config *Config) (*Conn, error) { - return createConn(conn, clientFlightHandler, clientHandshakeHandler, config, true) -} - -// Server listens for incoming DTLS connections -func Server(conn net.Conn, config *Config) (*Conn, error) { - if config == nil || config.Certificate == nil { - return nil, errServerMustHaveCertificate - } - return createConn(conn, serverFlightHandler, serverHandshakeHandler, config, false) -} - -// Read reads data from the connection. -func (c *Conn) Read(p []byte) (n int, err error) { - out, ok := <-c.decrypted - if !ok { - return 0, c.getConnErr() - } - if len(p) < len(out) { - return 0, errBufferTooSmall - } - - copy(p, out) - return len(out), nil -} - -// Write writes len(p) bytes from p to the DTLS connection -func (c *Conn) Write(p []byte) (int, error) { - c.lock.Lock() - defer c.lock.Unlock() - - if c.localEpoch == 0 { - return 0, errHandshakeInProgress - } else if c.getConnErr() != nil { - return 0, c.getConnErr() - } - - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - epoch: c.localEpoch, - sequenceNumber: c.localSequenceNumber, - protocolVersion: protocolVersion1_2, - }, - content: &applicationData{ - data: p, - }, - }, true) - c.localSequenceNumber++ - - return len(p), nil -} - -// Close closes the connection. -func (c *Conn) Close() error { - c.notify(alertLevelFatal, alertCloseNotify) - c.stopWithError(ErrConnClosed) - if err := c.getConnErr(); err != ErrConnClosed { - return err - } - return nil -} - -// RemoteCertificate exposes the remote certificate -func (c *Conn) RemoteCertificate() *x509.Certificate { - c.lock.RLock() - defer c.lock.RUnlock() - return c.remoteCertificate -} - -// ExportKeyingMaterial from https://tools.ietf.org/html/rfc5705 -// This allows protocols to use DTLS for key establishment, but -// then use some of the keying material for their own purposes -func (c *Conn) ExportKeyingMaterial(label []byte, context []byte, length int) ([]byte, error) { - c.lock.Lock() - defer c.lock.Unlock() - - if c.localEpoch == 0 { - return nil, errHandshakeInProgress - } else if len(context) != 0 { - return nil, errContextUnsupported - } else if _, ok := invalidKeyingLabels[string(label)]; ok { - return nil, errReservedExportKeyingMaterial - } - - localRandom, err := c.localRandom.Marshal() - if err != nil { - return nil, err - } - remoteRandom, err := c.remoteRandom.Marshal() - if err != nil { - return nil, err - } - - seed := append([]byte{}, label...) - if c.isClient { - seed = append(append(seed, localRandom...), remoteRandom...) - } else { - seed = append(append(seed, remoteRandom...), localRandom...) - } - return prfPHash(c.masterSecret, seed, length, c.cipherSuite.hashFunc()) -} - -func (c *Conn) internalSend(pkt *recordLayer, shouldEncrypt bool) { - raw, err := pkt.Marshal() - if err != nil { - c.stopWithError(err) - return - } - - if h, ok := pkt.content.(*handshake); ok { - c.handshakeCache.push(raw[recordLayerHeaderSize:], pkt.recordLayerHeader.epoch, - h.handshakeHeader.messageSequence /* isLocal */, true, c.currFlight.get()) - } - - if shouldEncrypt { - raw, err = c.cipherSuite.encrypt(pkt, raw) - if err != nil { - c.stopWithError(err) - return - } - } - - if _, err := c.nextConn.Write(raw); err != nil { - c.stopWithError(err) - } -} - -func (c *Conn) handleIncoming(buf []byte) error { - pkts, err := unpackDatagram(buf) - if err != nil { - return err - } - - for _, p := range pkts { - err := c.handleIncomingPacket(p) - if err != nil { - return err - } - } - return nil -} - -func (c *Conn) handleIncomingPacket(buf []byte) error { - // TODO: avoid separate unmarshal - h := &recordLayerHeader{} - if err := h.Unmarshal(buf); err != nil { - return err - } - if h.epoch < c.remoteEpoch { - fmt.Println("handleIncoming: old epoch, dropping packet") - return nil - } - - if c.remoteEpoch != 0 { - if c.cipherSuite == nil { - fmt.Println("handleIncoming: Handshake not finished, dropping packet") - return nil - } - - var err error - buf, err = c.cipherSuite.decrypt(buf) - if err != nil { - fmt.Println(err) - return nil - } - } - - pushSuccess, err := c.fragmentBuffer.push(buf) - if err != nil { - return err - } else if pushSuccess { - // This was a fragmented buffer, therefore a handshake - return c.handshakeMessageHandler(c) - } - - r := &recordLayer{} - if err := r.Unmarshal(buf); err != nil { - return err - } - - switch content := r.content.(type) { - case *alert: - if content.alertDescription == alertCloseNotify { - return c.Close() - } - return fmt.Errorf("alert: %v", content) - case *changeCipherSpec: - c.remoteEpoch++ - case *applicationData: - c.decrypted <- content.data - default: - return fmt.Errorf("Unhandled contentType %d", content.contentType()) - } - return nil -} - -func (c *Conn) notify(level alertLevel, desc alertDescription) { - c.lock.Lock() - defer c.lock.Unlock() - - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - epoch: c.localEpoch, - sequenceNumber: c.localSequenceNumber, - protocolVersion: protocolVersion1_2, - }, - content: &alert{ - alertLevel: level, - alertDescription: desc, - }, - }, true) - - c.localSequenceNumber++ -} - -func (c *Conn) signalHandshakeComplete() { - select { - case <-c.handshakeCompleted: - default: - close(c.handshakeCompleted) - } -} - -func (c *Conn) startHandshakeOutbound() { - go func() { - for { - var ( - isFinished bool - err error - ) - select { - case <-c.handshakeCompleted: - return - case <-c.workerTicker.C: - isFinished, err = c.flightHandler(c) - case <-c.currFlight.workerTrigger: - isFinished, err = c.flightHandler(c) - } - - switch { - case err != nil: - c.stopWithError(err) - return - case c.getConnErr() != nil: - return - case isFinished: - return // Handshake is complete - } - } - }() -} - -func (c *Conn) stopWithError(err error) { - if connErr := c.nextConn.Close(); connErr != nil { - if err != ErrConnClosed { - connErr = fmt.Errorf("%v\n%v", err, connErr) - } - err = connErr - } - - c.connErr.Store(struct{ error }{err}) - - c.workerTicker.Stop() - - c.signalHandshakeComplete() -} - -func (c *Conn) getConnErr() error { - err, _ := c.connErr.Load().(struct{ error }) - return err.error -} - -// LocalAddr is a stub -func (c *Conn) LocalAddr() net.Addr { - return c.nextConn.LocalAddr() -} - -// RemoteAddr is a stub -func (c *Conn) RemoteAddr() net.Addr { - return c.nextConn.RemoteAddr() -} - -// SetDeadline is a stub -func (c *Conn) SetDeadline(t time.Time) error { - return c.nextConn.SetDeadline(t) -} - -// SetReadDeadline is a stub -func (c *Conn) SetReadDeadline(t time.Time) error { - return c.nextConn.SetReadDeadline(t) -} - -// SetWriteDeadline is a stub -func (c *Conn) SetWriteDeadline(t time.Time) error { - return c.nextConn.SetWriteDeadline(t) -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/content.go b/vendor/github.com/pions/dtls/pkg/dtls/content.go deleted file mode 100644 index c938cb7..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/content.go +++ /dev/null @@ -1,17 +0,0 @@ -package dtls - -// https://tools.ietf.org/html/rfc4346#section-6.2.1 -type contentType uint8 - -const ( - contentTypeChangeCipherSpec contentType = 20 - contentTypeAlert contentType = 21 - contentTypeHandshake contentType = 22 - contentTypeApplicationData contentType = 23 -) - -type content interface { - contentType() contentType - Marshal() ([]byte, error) - Unmarshal(data []byte) error -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/crypto.go b/vendor/github.com/pions/dtls/pkg/dtls/crypto.go deleted file mode 100644 index 194bc5c..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/crypto.go +++ /dev/null @@ -1,94 +0,0 @@ -package dtls - -import ( - "crypto" - "crypto/ecdsa" - "crypto/rand" - "crypto/rsa" - "crypto/sha256" - "crypto/x509" - "encoding/asn1" - "encoding/binary" - "math/big" -) - -type ecdsaSignature struct { - R, S *big.Int -} - -func valueKeySignature(clientRandom, serverRandom, publicKey []byte, namedCurve namedCurve, hashAlgorithm HashAlgorithm) []byte { - serverECDHParams := make([]byte, 4) - serverECDHParams[0] = 3 // named curve - binary.BigEndian.PutUint16(serverECDHParams[1:], uint16(namedCurve)) - serverECDHParams[3] = byte(len(publicKey)) - - plaintext := []byte{} - plaintext = append(plaintext, clientRandom...) - plaintext = append(plaintext, serverRandom...) - plaintext = append(plaintext, serverECDHParams...) - plaintext = append(plaintext, publicKey...) - return hashAlgorithm.digest(plaintext) -} - -// If the client provided a "signature_algorithms" extension, then all -// certificates provided by the server MUST be signed by a -// hash/signature algorithm pair that appears in that extension -// -// https://tools.ietf.org/html/rfc5246#section-7.4.2 -func generateKeySignature(clientRandom, serverRandom, publicKey []byte, namedCurve namedCurve, privateKey crypto.PrivateKey, hashAlgorithm HashAlgorithm) ([]byte, error) { - hashed := valueKeySignature(clientRandom, serverRandom, publicKey, namedCurve, hashAlgorithm) - switch p := privateKey.(type) { - case *ecdsa.PrivateKey: - return p.Sign(rand.Reader, hashed, crypto.SHA256) - case *rsa.PrivateKey: - return p.Sign(rand.Reader, hashed, crypto.SHA256) - } - - return nil, errKeySignatureGenerateUnimplemented -} - -func verifyKeySignature(hash, remoteKeySignature []byte, certificate *x509.Certificate) error { - switch p := certificate.PublicKey.(type) { - case *ecdsa.PublicKey: - ecdsaSig := &ecdsaSignature{} - if _, err := asn1.Unmarshal(remoteKeySignature, ecdsaSig); err != nil { - return err - } - if ecdsaSig.R.Sign() <= 0 || ecdsaSig.S.Sign() <= 0 { - return errInvalidECDSASignature - } - if !ecdsa.Verify(p, hash, ecdsaSig.R, ecdsaSig.S) { - return errKeySignatureMismatch - } - return nil - case *rsa.PublicKey: - return errKeySignatureVerifyUnimplemented - } - - return errKeySignatureVerifyUnimplemented -} - -// If the server has sent a CertificateRequest message, the client MUST send the Certificate -// message. The ClientKeyExchange message is now sent, and the content -// of that message will depend on the public key algorithm selected -// between the ClientHello and the ServerHello. If the client has sent -// a certificate with signing ability, a digitally-signed -// CertificateVerify message is sent to explicitly verify possession of -// the private key in the certificate. -// https://tools.ietf.org/html/rfc5246#section-7.3 -func generateCertificateVerify(handshakeBodies []byte, privateKey crypto.PrivateKey) ([]byte, error) { - h := sha256.New() - if _, err := h.Write(handshakeBodies); err != nil { - return nil, err - } - hashed := h.Sum(nil) - - switch p := privateKey.(type) { - case *ecdsa.PrivateKey: - return p.Sign(rand.Reader, hashed, crypto.SHA256) - case *rsa.PrivateKey: - return p.Sign(rand.Reader, hashed, crypto.SHA256) - } - - return nil, errInvalidSignatureAlgorithm -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/crypto_cbc.go b/vendor/github.com/pions/dtls/pkg/dtls/crypto_cbc.go deleted file mode 100644 index 4bc2031..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/crypto_cbc.go +++ /dev/null @@ -1,133 +0,0 @@ -package dtls - -import ( - "crypto/aes" - "crypto/cipher" - "crypto/hmac" - "crypto/rand" - "crypto/sha1" // #nosec - "encoding/binary" -) - -// block ciphers using cipher block chaining. -type cbcMode interface { - cipher.BlockMode - SetIV([]byte) -} - -// State needed to handle encrypted input/output -type cryptoCBC struct { - writeCBC, readCBC cbcMode - writeMac, readMac []byte -} - -// Currently hardcoded to be SHA1 only -var cryptoCBCMacFunc = sha1.New - -func newCryptoCBC(localKey, localWriteIV, localMac, remoteKey, remoteWriteIV, remoteMac []byte) (*cryptoCBC, error) { - writeBlock, err := aes.NewCipher(localKey) - if err != nil { - return nil, err - } - - readBlock, err := aes.NewCipher(remoteKey) - if err != nil { - return nil, err - } - - return &cryptoCBC{ - writeCBC: cipher.NewCBCEncrypter(writeBlock, localWriteIV).(cbcMode), - writeMac: localMac, - - readCBC: cipher.NewCBCDecrypter(readBlock, remoteWriteIV).(cbcMode), - readMac: remoteMac, - }, nil -} - -func (c *cryptoCBC) encrypt(pkt *recordLayer, raw []byte) ([]byte, error) { - payload := raw[recordLayerHeaderSize:] - raw = raw[:recordLayerHeaderSize] - blockSize := c.writeCBC.BlockSize() - - // Generate + Append MAC - h := pkt.recordLayerHeader - - MAC, err := prfMac(h.epoch, h.sequenceNumber, h.contentType, h.protocolVersion, payload, c.writeMac) - if err != nil { - return nil, err - } - payload = append(payload, MAC...) - - // Generate + Append padding - padding := make([]byte, blockSize-len(payload)%blockSize) - paddingLen := len(padding) - for i := 0; i < paddingLen; i++ { - padding[i] = byte(paddingLen - 1) - } - payload = append(payload, padding...) - - // Generate IV - iv := make([]byte, blockSize) - if _, err := rand.Read(iv); err != nil { - return nil, err - } - - // Set IV + Encrypt + Prepend IV - c.writeCBC.SetIV(iv) - c.writeCBC.CryptBlocks(payload, payload) - payload = append(iv, payload...) - - // Prepend unencrypte header with encrypted payload - raw = append(raw, payload...) - - // Update recordLayer size to include IV+MAC+Padding - binary.BigEndian.PutUint16(raw[recordLayerHeaderSize-2:], uint16(len(raw)-recordLayerHeaderSize)) - - return raw, nil -} - -func (c *cryptoCBC) decrypt(in []byte) ([]byte, error) { - body := in[recordLayerHeaderSize:] - blockSize := c.readCBC.BlockSize() - mac := cryptoCBCMacFunc() - - var h recordLayerHeader - err := h.Unmarshal(in) - switch { - case err != nil: - return nil, err - case h.contentType == contentTypeChangeCipherSpec: - // Nothing to encrypt with ChangeCipherSpec - return in, nil - case len(body)%blockSize != 0 || len(body) < blockSize+max(mac.Size()+1, blockSize): - return nil, errNotEnoughRoomForNonce - } - - // Set + remove per record IV - c.readCBC.SetIV(body[:blockSize]) - body = body[blockSize:] - - // Decrypt - c.readCBC.CryptBlocks(body, body) - - // Padding+MAC needs to be checked in constant time - // Otherwise we reveal information about the level of correctness - paddingLen, paddingGood := examinePadding(body) - - macSize := mac.Size() - if len(body) < macSize { - return nil, errInvalidMAC - } - - dataEnd := len(body) - macSize - paddingLen - - expectedMAC := body[dataEnd : dataEnd+macSize] - actualMAC, err := prfMac(h.epoch, h.sequenceNumber, h.contentType, h.protocolVersion, body[:dataEnd], c.readMac) - - // Compute Local MAC and compare - if paddingGood != 255 || err != nil || !hmac.Equal(actualMAC, expectedMAC) { - return nil, errInvalidMAC - } - - return append(in[:recordLayerHeaderSize], body[:dataEnd]...), nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/crypto_gcm.go b/vendor/github.com/pions/dtls/pkg/dtls/crypto_gcm.go deleted file mode 100644 index 58034c0..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/crypto_gcm.go +++ /dev/null @@ -1,105 +0,0 @@ -package dtls - -import ( - "crypto/aes" - "crypto/cipher" - "crypto/rand" - "encoding/binary" - "fmt" -) - -const cryptoGCMTagLength = 16 - -// State needed to handle encrypted input/output -type cryptoGCM struct { - localGCM, remoteGCM cipher.AEAD - localWriteIV, remoteWriteIV []byte -} - -func newCryptoGCM(localKey, localWriteIV, remoteKey, remoteWriteIV []byte) (*cryptoGCM, error) { - localBlock, err := aes.NewCipher(localKey) - if err != nil { - return nil, err - } - localGCM, err := cipher.NewGCM(localBlock) - if err != nil { - return nil, err - } - - remoteBlock, err := aes.NewCipher(remoteKey) - if err != nil { - return nil, err - } - remoteGCM, err := cipher.NewGCM(remoteBlock) - if err != nil { - return nil, err - } - - return &cryptoGCM{ - localGCM: localGCM, - localWriteIV: localWriteIV, - remoteGCM: remoteGCM, - remoteWriteIV: remoteWriteIV, - }, nil -} - -func (c *cryptoGCM) encrypt(pkt *recordLayer, raw []byte) ([]byte, error) { - payload := raw[recordLayerHeaderSize:] - raw = raw[:recordLayerHeaderSize] - - nonce := append(append([]byte{}, c.localWriteIV[:4]...), make([]byte, 8)...) - if _, err := rand.Read(nonce[4:]); err != nil { - return nil, err - } - - var additionalData [13]byte - // SequenceNumber MUST be set first - // we only want uint48, clobbering an extra 2 (using uint64, Golang doesn't have uint48) - binary.BigEndian.PutUint64(additionalData[:], pkt.recordLayerHeader.sequenceNumber) - binary.BigEndian.PutUint16(additionalData[:], pkt.recordLayerHeader.epoch) - additionalData[8] = byte(pkt.content.contentType()) - additionalData[9] = pkt.recordLayerHeader.protocolVersion.major - additionalData[10] = pkt.recordLayerHeader.protocolVersion.minor - binary.BigEndian.PutUint16(additionalData[len(additionalData)-2:], uint16(len(payload))) - encryptedPayload := c.localGCM.Seal(nil, nonce, payload, additionalData[:]) - - encryptedPayload = append(nonce[4:], encryptedPayload...) - raw = append(raw, encryptedPayload...) - - // Update recordLayer size to include explicit nonce - binary.BigEndian.PutUint16(raw[recordLayerHeaderSize-2:], uint16(len(raw)-recordLayerHeaderSize)) - return raw, nil - -} - -func (c *cryptoGCM) decrypt(in []byte) ([]byte, error) { - var h recordLayerHeader - err := h.Unmarshal(in) - switch { - case err != nil: - return nil, err - case h.contentType == contentTypeChangeCipherSpec: - // Nothing to encrypt with ChangeCipherSpec - return in, nil - case len(in) <= (8 + recordLayerHeaderSize): - return nil, errNotEnoughRoomForNonce - } - - nonce := append(append([]byte{}, c.remoteWriteIV[:4]...), in[recordLayerHeaderSize:recordLayerHeaderSize+8]...) - out := in[recordLayerHeaderSize+8:] - - var additionalData [13]byte - // SequenceNumber MUST be set first - // we only want uint48, clobbering an extra 2 (using uint64, Golang doesn't have uint48) - binary.BigEndian.PutUint64(additionalData[:], h.sequenceNumber) - binary.BigEndian.PutUint16(additionalData[:], h.epoch) - additionalData[8] = byte(h.contentType) - additionalData[9] = h.protocolVersion.major - additionalData[10] = h.protocolVersion.minor - binary.BigEndian.PutUint16(additionalData[len(additionalData)-2:], uint16(len(out)-cryptoGCMTagLength)) - out, err = c.remoteGCM.Open(out[:0], nonce, out, additionalData[:]) - if err != nil { - return nil, fmt.Errorf("decryptPacket: %v", err) - } - return append(in[:recordLayerHeaderSize], out...), nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/curve_type.go b/vendor/github.com/pions/dtls/pkg/dtls/curve_type.go deleted file mode 100644 index 37771f6..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/curve_type.go +++ /dev/null @@ -1,12 +0,0 @@ -package dtls - -// https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-10 -type ellipticCurveType byte - -const ( - ellipticCurveTypeNamedCurve ellipticCurveType = 0x03 -) - -var ellipticCurveTypes = map[ellipticCurveType]bool{ - ellipticCurveTypeNamedCurve: true, -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/errors.go b/vendor/github.com/pions/dtls/pkg/dtls/errors.go deleted file mode 100644 index 8bfedea..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/errors.go +++ /dev/null @@ -1,44 +0,0 @@ -package dtls - -import "errors" - -// Typed errors -var ( - ErrConnClosed = errors.New("dtls: conn is closed") - - errBufferTooSmall = errors.New("dtls: buffer is too small") - errCertificateUnset = errors.New("dtls: handshakeMessageCertificate can not be marshalled without a certificate") - errCipherSuiteNoIntersection = errors.New("dtls: Client+Server do not support any shared cipher suites") - errCipherSuiteUnset = errors.New("dtls: server hello can not be created without a cipher suite") - errCompressionmethodUnset = errors.New("dtls: server hello can not be created without a compression method") - errContextUnsupported = errors.New("dtls: context is not supported for ExportKeyingMaterial") - errCookieMismatch = errors.New("dtls: Client+Server cookie does not match") - errCookieTooLong = errors.New("dtls: cookie must not be longer then 255 bytes") - errDTLSPacketInvalidLength = errors.New("dtls: packet is too short") - errHandshakeInProgress = errors.New("dtls: Handshake is in progress") - errHandshakeMessageUnset = errors.New("dtls: handshake message unset, unable to marshal") - errInvalidCipherSpec = errors.New("dtls: cipher spec invalid") - errInvalidCipherSuite = errors.New("dtls: invalid or unknown cipher suite") - errInvalidCompressionMethod = errors.New("dtls: invalid or unknown compression method") - errInvalidContentType = errors.New("dtls: invalid content type") - errInvalidECDSASignature = errors.New("dtls: ECDSA signature contained zero or negative values") - errInvalidEllipticCurveType = errors.New("dtls: invalid or unknown elliptic curve type") - errInvalidExtensionType = errors.New("dtls: invalid extension type") - errInvalidHashAlgorithm = errors.New("dtls: invalid hash algorithm") - errInvalidMAC = errors.New("dtls: invalid mac") - errInvalidNamedCurve = errors.New("dtls: invalid named curve") - errInvalidPrivateKey = errors.New("dtls: invalid private key type") - errInvalidSignatureAlgorithm = errors.New("dtls: invalid signature algorithm") - errKeySignatureGenerateUnimplemented = errors.New("dtls: Unable to generate key signature, unimplemented") - errKeySignatureMismatch = errors.New("dtls: Expected and actual key signature do not match") - errKeySignatureVerifyUnimplemented = errors.New("dtls: Unable to verify key signature, unimplemented") - errLengthMismatch = errors.New("dtls: data length and declared length do not match") - errNilNextConn = errors.New("dtls: Conn can not be created with a nil nextConn") - errNotEnoughRoomForNonce = errors.New("dtls: Buffer not long enough to contain nonce") - errNotImplemented = errors.New("dtls: feature has not been implemented yet") - errReservedExportKeyingMaterial = errors.New("dtls: ExportKeyingMaterial can not be used with a reserved label") - errSequenceNumberOverflow = errors.New("dtls: sequence number overflow") - errServerMustHaveCertificate = errors.New("dtls: Certificate is mandatory for server") - errUnableToMarshalFragmented = errors.New("dtls: unable to marshal fragmented handshakes") - errVerifyDataMismatch = errors.New("dtls: Expected and actual verify data does not match") -) diff --git a/vendor/github.com/pions/dtls/pkg/dtls/extension.go b/vendor/github.com/pions/dtls/pkg/dtls/extension.go deleted file mode 100644 index 93ea6e3..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/extension.go +++ /dev/null @@ -1,70 +0,0 @@ -package dtls - -import ( - "encoding/binary" -) - -// https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml -type extensionValue uint16 - -const ( - extensionSupportedEllipticCurvesValue extensionValue = 10 - extensionSupportedPointFormatsValue extensionValue = 11 - extensionUseSRTPValue extensionValue = 14 -) - -type extension interface { - Marshal() ([]byte, error) - Unmarshal(data []byte) error - - extensionValue() extensionValue -} - -func decodeExtensions(buf []byte) ([]extension, error) { - declaredLen := binary.BigEndian.Uint16(buf) - if len(buf)-2 != int(declaredLen) { - return nil, errLengthMismatch - } - - extensions := []extension{} - unmarshalAndAppend := func(data []byte, e extension) error { - err := e.Unmarshal(data) - if err != nil { - return err - } - extensions = append(extensions, e) - return nil - } - - for offset := 2; offset < len(buf); { - var err error - switch extensionValue(binary.BigEndian.Uint16(buf[offset:])) { - case extensionSupportedEllipticCurvesValue: - err = unmarshalAndAppend(buf[offset:], &extensionSupportedEllipticCurves{}) - case extensionUseSRTPValue: - err = unmarshalAndAppend(buf[offset:], &extensionUseSRTP{}) - default: - } - if err != nil { - return nil, err - } - - extensionLength := binary.BigEndian.Uint16(buf[offset+2:]) - offset += (4 + int(extensionLength)) - } - return extensions, nil -} - -func encodeExtensions(e []extension) ([]byte, error) { - extensions := []byte{} - for _, e := range e { - raw, err := e.Marshal() - if err != nil { - return nil, err - } - extensions = append(extensions, raw...) - } - out := []byte{0x00, 0x00} - binary.BigEndian.PutUint16(out, uint16(len(extensions))) - return append(out, extensions...), nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/extension_supported_elliptic_curves.go b/vendor/github.com/pions/dtls/pkg/dtls/extension_supported_elliptic_curves.go deleted file mode 100644 index 3eef92c..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/extension_supported_elliptic_curves.go +++ /dev/null @@ -1,54 +0,0 @@ -package dtls - -import ( - "encoding/binary" -) - -const ( - extensionSupportedGroupsHeaderSize = 6 -) - -// https://tools.ietf.org/html/rfc8422#section-5.1.1 -type extensionSupportedEllipticCurves struct { - ellipticCurves []namedCurve -} - -func (e extensionSupportedEllipticCurves) extensionValue() extensionValue { - return extensionSupportedEllipticCurvesValue -} - -func (e *extensionSupportedEllipticCurves) Marshal() ([]byte, error) { - out := make([]byte, extensionSupportedGroupsHeaderSize) - - binary.BigEndian.PutUint16(out, uint16(e.extensionValue())) - binary.BigEndian.PutUint16(out[2:], uint16(2+(len(e.ellipticCurves)*2))) - binary.BigEndian.PutUint16(out[4:], uint16(len(e.ellipticCurves)*2)) - - for _, v := range e.ellipticCurves { - out = append(out, []byte{0x00, 0x00}...) - binary.BigEndian.PutUint16(out[len(out)-2:], uint16(v)) - } - - return out, nil -} - -func (e *extensionSupportedEllipticCurves) Unmarshal(data []byte) error { - if len(data) <= extensionSupportedGroupsHeaderSize { - return errBufferTooSmall - } else if extensionValue(binary.BigEndian.Uint16(data)) != e.extensionValue() { - return errInvalidExtensionType - } - - groupCount := int(binary.BigEndian.Uint16(data[4:]) / 2) - if extensionSupportedGroupsHeaderSize+(groupCount*2) > len(data) { - return errLengthMismatch - } - - for i := 0; i < groupCount; i++ { - supportedGroupID := namedCurve(binary.BigEndian.Uint16(data[(extensionSupportedGroupsHeaderSize + (i * 2)):])) - if _, ok := namedCurves[supportedGroupID]; ok { - e.ellipticCurves = append(e.ellipticCurves, supportedGroupID) - } - } - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/extension_supported_point_formats.go b/vendor/github.com/pions/dtls/pkg/dtls/extension_supported_point_formats.go deleted file mode 100644 index 5f2d968..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/extension_supported_point_formats.go +++ /dev/null @@ -1,56 +0,0 @@ -package dtls - -import "encoding/binary" - -const ( - extensionSupportedPointFormatsSize = 5 -) - -type ellipticCurvePointFormat byte - -const ellipticCurvePointFormatUncompressed ellipticCurvePointFormat = 0 - -// https://tools.ietf.org/html/rfc4492#section-5.1.2 -type extensionSupportedPointFormats struct { - pointFormats []ellipticCurvePointFormat -} - -func (e extensionSupportedPointFormats) extensionValue() extensionValue { - return extensionSupportedPointFormatsValue -} - -func (e *extensionSupportedPointFormats) Marshal() ([]byte, error) { - out := make([]byte, extensionSupportedPointFormatsSize) - - binary.BigEndian.PutUint16(out, uint16(e.extensionValue())) - binary.BigEndian.PutUint16(out[2:], uint16(1+(len(e.pointFormats)))) - out[4] = byte(len(e.pointFormats)) - - for _, v := range e.pointFormats { - out = append(out, byte(v)) - } - return out, nil -} - -func (e *extensionSupportedPointFormats) Unmarshal(data []byte) error { - if len(data) <= extensionSupportedPointFormatsSize { - return errBufferTooSmall - } else if extensionValue(binary.BigEndian.Uint16(data)) != e.extensionValue() { - return errInvalidExtensionType - } - - pointFormatCount := int(binary.BigEndian.Uint16(data[4:])) - if extensionSupportedGroupsHeaderSize+(pointFormatCount) > len(data) { - return errLengthMismatch - } - - for i := 0; i < pointFormatCount; i++ { - p := ellipticCurvePointFormat(data[extensionSupportedPointFormatsSize+i]) - switch p { - case ellipticCurvePointFormatUncompressed: - e.pointFormats = append(e.pointFormats, p) - default: - } - } - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/extension_use_srtp.go b/vendor/github.com/pions/dtls/pkg/dtls/extension_use_srtp.go deleted file mode 100644 index 64847c9..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/extension_use_srtp.go +++ /dev/null @@ -1,53 +0,0 @@ -package dtls - -import "encoding/binary" - -const ( - extensionUseSRTPHeaderSize = 6 -) - -// https://tools.ietf.org/html/rfc8422 -type extensionUseSRTP struct { - protectionProfiles []srtpProtectionProfile -} - -func (e extensionUseSRTP) extensionValue() extensionValue { - return extensionUseSRTPValue -} - -func (e *extensionUseSRTP) Marshal() ([]byte, error) { - out := make([]byte, extensionUseSRTPHeaderSize) - - binary.BigEndian.PutUint16(out, uint16(e.extensionValue())) - binary.BigEndian.PutUint16(out[2:], uint16(2+(len(e.protectionProfiles)*2)+ /* MKI Length */ 1)) - binary.BigEndian.PutUint16(out[4:], uint16(len(e.protectionProfiles)*2)) - - for _, v := range e.protectionProfiles { - out = append(out, []byte{0x00, 0x00}...) - binary.BigEndian.PutUint16(out[len(out)-2:], uint16(v)) - } - - out = append(out, 0x00) /* MKI Length */ - return out, nil -} - -func (e *extensionUseSRTP) Unmarshal(data []byte) error { - if len(data) <= extensionUseSRTPHeaderSize { - return errBufferTooSmall - } else if extensionValue(binary.BigEndian.Uint16(data)) != e.extensionValue() { - return errInvalidExtensionType - } - - profileCount := int(binary.BigEndian.Uint16(data[4:]) / 2) - if extensionSupportedGroupsHeaderSize+(profileCount*2) > len(data) { - return errLengthMismatch - } - - for i := 0; i < profileCount; i++ { - supportedProfile := srtpProtectionProfile(binary.BigEndian.Uint16(data[(extensionUseSRTPHeaderSize + (i * 2)):])) - if _, ok := srtpProtectionProfiles[supportedProfile]; ok { - e.protectionProfiles = append(e.protectionProfiles, supportedProfile) - } - } - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/fingerprint.go b/vendor/github.com/pions/dtls/pkg/dtls/fingerprint.go deleted file mode 100644 index bdc3863..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/fingerprint.go +++ /dev/null @@ -1,33 +0,0 @@ -package dtls - -import ( - "crypto/x509" - "errors" - "fmt" -) - -// Fingerprint creates a fingerprint for a certificate using the specified hash algorithm -func Fingerprint(cert *x509.Certificate, algo HashAlgorithm) (string, error) { - digest := []byte(fmt.Sprintf("%x", algo.digest(cert.Raw))) - - digestlen := len(digest) - if digestlen == 0 { - return "", nil - } - if digestlen%2 != 0 { - return "", errors.New("invalid fingerprint length") - } - res := make([]byte, digestlen>>1+digestlen-1) - - pos := 0 - for i, c := range digest { - res[pos] = c - pos++ - if (i)%2 != 0 && i < digestlen-1 { - res[pos] = byte(':') - pos++ - } - } - - return string(res), nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/flight.go b/vendor/github.com/pions/dtls/pkg/dtls/flight.go deleted file mode 100644 index e04a411..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/flight.go +++ /dev/null @@ -1,102 +0,0 @@ -package dtls - -import "sync" - -/* - DTLS messages are grouped into a series of message flights, according - to the diagrams below. Although each flight of messages may consist - of a number of messages, they should be viewed as monolithic for the - purpose of timeout and retransmission. - https://tools.ietf.org/html/rfc4347#section-4.2.4 - Client Server - ------ ------ - Waiting Flight 0 - - ClientHello --------> Flight 1 - - <------- HelloVerifyRequest Flight 2 - - ClientHello --------> Flight 3 - - ServerHello \ - Certificate* \ - ServerKeyExchange* Flight 4 - CertificateRequest* / - <-------- ServerHelloDone / - - Certificate* \ - ClientKeyExchange \ - CertificateVerify* Flight 5 - [ChangeCipherSpec] / - Finished --------> / - - [ChangeCipherSpec] \ Flight 6 - <-------- Finished / - -*/ - -type flightVal uint8 - -const ( - flight0 flightVal = iota + 1 - flight1 - flight2 - flight3 - flight4 - flight5 - flight6 -) - -func (f flightVal) String() string { - switch f { - case flight0: - return "Flight 0" - case flight1: - return "Flight 1" - case flight2: - return "Flight 2" - case flight3: - return "Flight 3" - case flight4: - return "Flight 4" - case flight5: - return "Flight 5" - case flight6: - return "Flight 6" - default: - return "Invalid Flight" - } -} - -type flight struct { - sync.RWMutex - val flightVal - workerTrigger chan struct{} // Temporary way to trigger next flight -} - -func newFlight(isClient bool) *flight { - val := flight0 - if isClient { - val = flight1 - } - return &flight{val: val, workerTrigger: make(chan struct{})} -} - -func (f *flight) get() flightVal { - f.RLock() - defer f.RUnlock() - return f.val -} - -func (f *flight) set(val flightVal) error { - f.Lock() - f.val = val // TODO ensure no invalid transitions - f.Unlock() - - select { - case f.workerTrigger <- struct{}{}: - default: - } - - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/fragment_buffer.go b/vendor/github.com/pions/dtls/pkg/dtls/fragment_buffer.go deleted file mode 100644 index 4e23b41..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/fragment_buffer.go +++ /dev/null @@ -1,106 +0,0 @@ -package dtls - -type fragment struct { - recordLayerHeader recordLayerHeader - handshakeHeader handshakeHeader - data []byte -} - -type fragmentBuffer struct { - // map of MessageSequenceNumbers that hold slices of fragments - cache map[uint16][]*fragment - - currentEpoch uint16 - currentMessageSequenceNumber uint16 -} - -func newFragmentBuffer() *fragmentBuffer { - return &fragmentBuffer{cache: map[uint16][]*fragment{}} -} - -// Attempts to push a DTLS packet to the fragmentBuffer -// when it returns true it means the fragmentBuffer has inserted and the buffer shouldn't be handled -// when an error returns it is fatal, and the DTLS connection should be stopped -func (f *fragmentBuffer) push(buf []byte) (bool, error) { - frag := new(fragment) - if err := frag.recordLayerHeader.Unmarshal(buf); err != nil { - return false, err - } - - // fragment isn't a handshake, we don't need to handle it - if frag.recordLayerHeader.contentType != contentTypeHandshake { - return false, nil - } - - if err := frag.handshakeHeader.Unmarshal(buf[recordLayerHeaderSize:]); err != nil { - return false, err - } - - // If the pushed epoch is greater then the current discard everything - // if the pushed epoch is less then discard the packet - // - // implementations SHOULD discard packets from earlier epochs - // https://tools.ietf.org/html/rfc6347#section-4.1 - if f.currentEpoch < frag.recordLayerHeader.epoch { - f.cache = map[uint16][]*fragment{} - f.currentEpoch = frag.recordLayerHeader.epoch - } else if f.currentEpoch > frag.recordLayerHeader.epoch { - return false, nil - } - - if _, ok := f.cache[frag.handshakeHeader.messageSequence]; !ok { - f.cache[frag.handshakeHeader.messageSequence] = []*fragment{} - } - - // Discard all headers, when rebuilding the packet we will re-build - frag.data = append([]byte{}, buf[recordLayerHeaderSize+handshakeHeaderLength:]...) - f.cache[frag.handshakeHeader.messageSequence] = append(f.cache[frag.handshakeHeader.messageSequence], frag) - - return true, nil -} - -func (f *fragmentBuffer) pop() ([]byte, uint16) { - frags, ok := f.cache[f.currentMessageSequenceNumber] - if !ok { - return nil, 0 - } - - // Go doesn't support recursive lambdas - var appendMessage func(targetOffset uint32) bool - - rawMessage := []byte{} - appendMessage = func(targetOffset uint32) bool { - for _, f := range frags { - if f.handshakeHeader.fragmentOffset == targetOffset { - fragmentEnd := (f.handshakeHeader.fragmentOffset + f.handshakeHeader.fragmentLength) - if fragmentEnd != f.handshakeHeader.length { - if !appendMessage(fragmentEnd) { - return false - } - } - - rawMessage = append(f.data, rawMessage...) - return true - } - } - return false - } - - // Recursively collect up - if !appendMessage(0) { - return nil, 0 - } - - firstHeader := frags[0].handshakeHeader - firstHeader.fragmentOffset = 0 - firstHeader.fragmentLength = firstHeader.length - - rawHeader, err := firstHeader.Marshal() - if err != nil { - return nil, 0 - } - - delete(f.cache, f.currentMessageSequenceNumber) - f.currentMessageSequenceNumber++ - return append(rawHeader, rawMessage...), f.currentEpoch -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake.go deleted file mode 100644 index 88621c9..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake.go +++ /dev/null @@ -1,106 +0,0 @@ -package dtls - -// https://tools.ietf.org/html/rfc5246#section-7.4 -type handshakeType uint8 - -const ( - handshakeTypeHelloRequest handshakeType = 0 - handshakeTypeClientHello handshakeType = 1 - handshakeTypeServerHello handshakeType = 2 - handshakeTypeHelloVerifyRequest handshakeType = 3 - handshakeTypeCertificate handshakeType = 11 - handshakeTypeServerKeyExchange handshakeType = 12 - handshakeTypeCertificateRequest handshakeType = 13 - handshakeTypeServerHelloDone handshakeType = 14 - handshakeTypeCertificateVerify handshakeType = 15 - handshakeTypeClientKeyExchange handshakeType = 16 - handshakeTypeFinished handshakeType = 20 - - // msg_len for Handshake messages assumes an extra 12 bytes for - // sequence, fragment and version information - handshakeMessageHeaderLength = 12 -) - -type handshakeMessage interface { - Marshal() ([]byte, error) - Unmarshal(data []byte) error - - handshakeType() handshakeType -} - -// The handshake protocol is responsible for selecting a cipher spec and -// generating a master secret, which together comprise the primary -// cryptographic parameters associated with a secure session. The -// handshake protocol can also optionally authenticate parties who have -// certificates signed by a trusted certificate authority. -// https://tools.ietf.org/html/rfc5246#section-7.3 -type handshake struct { - handshakeHeader handshakeHeader - handshakeMessage handshakeMessage -} - -func (h handshake) contentType() contentType { - return contentTypeHandshake -} - -func (h *handshake) Marshal() ([]byte, error) { - if h.handshakeMessage == nil { - return nil, errHandshakeMessageUnset - } else if h.handshakeHeader.fragmentOffset != 0 { - return nil, errUnableToMarshalFragmented - } - - msg, err := h.handshakeMessage.Marshal() - if err != nil { - return nil, err - } - - h.handshakeHeader.length = uint32(len(msg)) - h.handshakeHeader.fragmentLength = h.handshakeHeader.length - h.handshakeHeader.handshakeType = h.handshakeMessage.handshakeType() - header, err := h.handshakeHeader.Marshal() - if err != nil { - return nil, err - } - - return append(header, msg...), nil -} - -func (h *handshake) Unmarshal(data []byte) error { - if err := h.handshakeHeader.Unmarshal(data); err != nil { - return err - } - - reportedLen := bigEndianUint24(data[1:]) - if uint32(len(data)-handshakeMessageHeaderLength) != reportedLen { - return errLengthMismatch - } else if reportedLen != h.handshakeHeader.fragmentLength { - return errLengthMismatch - } - - switch handshakeType(data[0]) { - case handshakeTypeHelloRequest: - return errNotImplemented - case handshakeTypeClientHello: - h.handshakeMessage = &handshakeMessageClientHello{} - case handshakeTypeHelloVerifyRequest: - h.handshakeMessage = &handshakeMessageHelloVerifyRequest{} - case handshakeTypeServerHello: - h.handshakeMessage = &handshakeMessageServerHello{} - case handshakeTypeCertificate: - h.handshakeMessage = &handshakeMessageCertificate{} - case handshakeTypeServerKeyExchange: - h.handshakeMessage = &handshakeMessageServerKeyExchange{} - case handshakeTypeCertificateRequest: - h.handshakeMessage = &handshakeMessageCertificateRequest{} - case handshakeTypeServerHelloDone: - h.handshakeMessage = &handshakeMessageServerHelloDone{} - case handshakeTypeClientKeyExchange: - h.handshakeMessage = &handshakeMessageClientKeyExchange{} - case handshakeTypeFinished: - h.handshakeMessage = &handshakeMessageFinished{} - default: - return errNotImplemented - } - return h.handshakeMessage.Unmarshal(data[handshakeMessageHeaderLength:]) -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_cache.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_cache.go deleted file mode 100644 index 4268987..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_cache.go +++ /dev/null @@ -1,56 +0,0 @@ -package dtls - -type handshakeCacheItem struct { - flight flightVal - isLocal bool - epoch, messageSequence uint16 - data []byte -} - -type handshakeCache struct { - cache []handshakeCacheItem -} - -func newHandshakeCache() *handshakeCache { - return &handshakeCache{} -} - -func (h *handshakeCache) push(data []byte, epoch, messageSequence uint16, isLocal bool, currentFlight flightVal) { - for _, i := range h.cache { - if i.isLocal == isLocal && - i.epoch == epoch && - i.messageSequence == messageSequence { - return - } - } - h.cache = append(h.cache, handshakeCacheItem{ - flight: currentFlight, - data: append([]byte{}, data...), - epoch: epoch, - messageSequence: messageSequence, - isLocal: isLocal, - }) -} - -type handshakeCacheExcludeRule struct { - isLocal bool // Exclude handshake if we sent - isRemote bool // Exclude handshake if remote sent -} - -func (h *handshakeCache) combinedHandshake(excludeRules map[flightVal]handshakeCacheExcludeRule, excludeLast bool) []byte { - out := make([]byte, 0) - lastIndex := len(h.cache) - 1 // Safe if len(h.cache) == 0, no loop will occur - for i, v := range h.cache { - if e, ok := excludeRules[v.flight]; ok { - if e.isLocal && v.isLocal { - continue - } else if e.isRemote && !v.isLocal { - continue - } - } else if excludeLast && i == lastIndex { - break - } - out = append(out, v.data...) - } - return out -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_header.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_header.go deleted file mode 100644 index 8198294..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_header.go +++ /dev/null @@ -1,41 +0,0 @@ -package dtls - -import ( - "encoding/binary" -) - -// msg_len for Handshake messages assumes an extra 12 bytes for -// sequence, fragment and version information -const handshakeHeaderLength = 12 - -type handshakeHeader struct { - handshakeType handshakeType - length uint32 // uint24 in spec - messageSequence uint16 - fragmentOffset uint32 // uint24 in spec - fragmentLength uint32 // uint24 in spec -} - -func (h *handshakeHeader) Marshal() ([]byte, error) { - out := make([]byte, handshakeMessageHeaderLength) - - out[0] = byte(h.handshakeType) - putBigEndianUint24(out[1:], h.length) - binary.BigEndian.PutUint16(out[4:], h.messageSequence) - putBigEndianUint24(out[6:], h.fragmentOffset) - putBigEndianUint24(out[9:], h.fragmentLength) - return out, nil -} - -func (h *handshakeHeader) Unmarshal(data []byte) error { - if len(data) < handshakeHeaderLength { - return errBufferTooSmall - } - - h.handshakeType = handshakeType(data[0]) - h.length = bigEndianUint24(data[1:]) - h.messageSequence = binary.BigEndian.Uint16(data[4:]) - h.fragmentOffset = bigEndianUint24(data[6:]) - h.fragmentLength = bigEndianUint24(data[9:]) - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_certificate.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_certificate.go deleted file mode 100644 index 3627013..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_certificate.go +++ /dev/null @@ -1,47 +0,0 @@ -package dtls - -import ( - "crypto/x509" -) - -type handshakeMessageCertificate struct { - certificate *x509.Certificate -} - -func (h handshakeMessageCertificate) handshakeType() handshakeType { - return handshakeTypeCertificate -} - -func (h *handshakeMessageCertificate) Marshal() ([]byte, error) { - if h.certificate == nil { - return nil, errCertificateUnset - } - - out := make([]byte, 6) - putBigEndianUint24(out, uint32(len(h.certificate.Raw))+3) - putBigEndianUint24(out[3:], uint32(len(h.certificate.Raw))) - - return append(out, h.certificate.Raw...), nil -} - -func (h *handshakeMessageCertificate) Unmarshal(data []byte) error { - if len(data) < 6 { - return errBufferTooSmall - } - - certificateBodyLen := int(bigEndianUint24(data)) - certificateLen := int(bigEndianUint24(data[3:])) - if certificateBodyLen+3 != len(data) { - return errLengthMismatch - } else if certificateLen+6 != len(data) { - return errLengthMismatch - } - - cert, err := x509.ParseCertificate(data[6:]) - if err != nil { - return err - } - h.certificate = cert - - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_certificate_request.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_certificate_request.go deleted file mode 100644 index 8d5da19..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_certificate_request.go +++ /dev/null @@ -1,86 +0,0 @@ -package dtls - -import ( - "encoding/binary" -) - -/* -A non-anonymous server can optionally request a certificate from -the client, if appropriate for the selected cipher suite. This -message, if sent, will immediately follow the ServerKeyExchange -message (if it is sent; otherwise, this message follows the -server's Certificate message). -*/ - -type handshakeMessageCertificateRequest struct { - certificateTypes []clientCertificateType - signatureHashAlgorithms []signatureHashAlgorithm -} - -const ( - handshakeMessageCertificateRequestMinLength = 5 -) - -func (h handshakeMessageCertificateRequest) handshakeType() handshakeType { - return handshakeTypeCertificateRequest -} - -func (h *handshakeMessageCertificateRequest) Marshal() ([]byte, error) { - out := []byte{byte(len(h.certificateTypes))} - for _, v := range h.certificateTypes { - out = append(out, byte(v)) - } - - out = append(out, []byte{0x00, 0x00}...) - binary.BigEndian.PutUint16(out[len(out)-2:], uint16(len(h.signatureHashAlgorithms)*2)) - for _, v := range h.signatureHashAlgorithms { - out = append(out, byte(v.hash)) - out = append(out, byte(v.signature)) - } - - out = append(out, []byte{0x00, 0x00}...) // Distinguished Names Length - return out, nil -} - -func (h *handshakeMessageCertificateRequest) Unmarshal(data []byte) error { - if len(data) < handshakeMessageCertificateRequestMinLength { - return errBufferTooSmall - } - - offset := 0 - certificateTypesLength := int(data[0]) - offset++ - - if (offset + certificateTypesLength) > len(data) { - return errBufferTooSmall - } - - for i := 0; i < certificateTypesLength; i++ { - certType := clientCertificateType(data[offset+i]) - if _, ok := clientCertificateTypes[certType]; ok { - h.certificateTypes = append(h.certificateTypes, certType) - } - } - offset += certificateTypesLength - - signatureHashAlgorithmsLength := int(binary.BigEndian.Uint16(data[offset:])) - offset += 2 - - if (offset + signatureHashAlgorithmsLength) > len(data) { - return errBufferTooSmall - } - - for i := 0; i < signatureHashAlgorithmsLength; i += 2 { - hash := HashAlgorithm(data[offset+i]) - signature := signatureAlgorithm(data[offset+i+1]) - - if _, ok := hashAlgorithms[hash]; !ok { - continue - } else if _, ok := signatureAlgorithms[signature]; !ok { - continue - } - h.signatureHashAlgorithms = append(h.signatureHashAlgorithms, signatureHashAlgorithm{signature: signature, hash: hash}) - } - - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_certificate_verify.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_certificate_verify.go deleted file mode 100644 index dca6426..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_certificate_verify.go +++ /dev/null @@ -1,51 +0,0 @@ -package dtls - -import ( - "encoding/binary" -) - -type handshakeMessageCertificateVerify struct { - hashAlgorithm HashAlgorithm - signatureAlgorithm signatureAlgorithm - signature []byte -} - -const handshakeMessageCertificateVerifyMinLength = 4 - -func (h handshakeMessageCertificateVerify) handshakeType() handshakeType { - return handshakeTypeCertificateVerify -} - -func (h *handshakeMessageCertificateVerify) Marshal() ([]byte, error) { - out := make([]byte, 1+1+2+len(h.signature)) - - out[0] = byte(h.hashAlgorithm) - out[1] = byte(h.signatureAlgorithm) - binary.BigEndian.PutUint16(out[2:], uint16(len(h.signature))) - copy(out[4:], h.signature) - return out, nil -} - -func (h *handshakeMessageCertificateVerify) Unmarshal(data []byte) error { - if len(data) < handshakeMessageCertificateVerifyMinLength { - return errBufferTooSmall - } - - h.hashAlgorithm = HashAlgorithm(data[0]) - if _, ok := hashAlgorithms[h.hashAlgorithm]; !ok { - return errInvalidHashAlgorithm - } - - h.signatureAlgorithm = signatureAlgorithm(data[1]) - if _, ok := signatureAlgorithms[h.signatureAlgorithm]; !ok { - return errInvalidSignatureAlgorithm - } - - signatureLength := int(binary.BigEndian.Uint16(data[2:])) - if (signatureLength + 4) != len(data) { - return errBufferTooSmall - } - - h.signature = append([]byte{}, data[4:]...) - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_client_hello.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_client_hello.go deleted file mode 100644 index baf1892..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_client_hello.go +++ /dev/null @@ -1,100 +0,0 @@ -package dtls - -import ( - "encoding/binary" -) - -/* -When a client first connects to a server it is required to send -the client hello as its first message. The client can also send a -client hello in response to a hello request or on its own -initiative in order to renegotiate the security parameters in an -existing connection. -*/ -type handshakeMessageClientHello struct { - version protocolVersion - random handshakeRandom - cookie []byte - - cipherSuites []cipherSuite - compressionMethods []*compressionMethod - extensions []extension -} - -const handshakeMessageClientHelloVariableWidthStart = 34 - -func (h handshakeMessageClientHello) handshakeType() handshakeType { - return handshakeTypeClientHello -} - -func (h *handshakeMessageClientHello) Marshal() ([]byte, error) { - if len(h.cookie) > 255 { - return nil, errCookieTooLong - } - - out := make([]byte, handshakeMessageClientHelloVariableWidthStart) - out[0] = h.version.major - out[1] = h.version.minor - - rand, err := h.random.Marshal() - if err != nil { - return nil, err - } - copy(out[2:], rand) - - out = append(out, 0x00) // SessionID - - out = append(out, byte(len(h.cookie))) - out = append(out, h.cookie...) - out = append(out, encodeCipherSuites(h.cipherSuites)...) - out = append(out, encodeCompressionMethods(h.compressionMethods)...) - - extensions, err := encodeExtensions(h.extensions) - if err != nil { - return nil, err - } - - return append(out, extensions...), nil -} - -func (h *handshakeMessageClientHello) Unmarshal(data []byte) error { - h.version.major = data[0] - h.version.minor = data[1] - - if err := h.random.Unmarshal(data[2 : 2+handshakeRandomLength]); err != nil { - return err - } - - // rest of packet has variable width sections - currOffset := handshakeMessageClientHelloVariableWidthStart - currOffset += int(data[currOffset]) + 1 // SessionID - - currOffset++ - h.cookie = append([]byte{}, data[currOffset:currOffset+int(data[currOffset-1])]...) - currOffset += len(h.cookie) - - // Cipher Suites - cipherSuites, err := decodeCipherSuites(data[currOffset:]) - if err != nil { - return err - } - h.cipherSuites = cipherSuites - currOffset += int(binary.BigEndian.Uint16(data[currOffset:])) + 2 - - // Compression Methods - compressionMethods, err := decodeCompressionMethods(data[currOffset:]) - if err != nil { - return err - } - h.compressionMethods = compressionMethods - currOffset += int(data[currOffset]) + 1 - - // Extensions - extensions, err := decodeExtensions(data[currOffset:]) - if err != nil { - return err - } - h.extensions = extensions - - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_client_key_exchange.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_client_key_exchange.go deleted file mode 100644 index 7ece67a..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_client_key_exchange.go +++ /dev/null @@ -1,22 +0,0 @@ -package dtls - -type handshakeMessageClientKeyExchange struct { - publicKey []byte -} - -func (h handshakeMessageClientKeyExchange) handshakeType() handshakeType { - return handshakeTypeClientKeyExchange -} - -func (h *handshakeMessageClientKeyExchange) Marshal() ([]byte, error) { - return append([]byte{byte(len(h.publicKey))}, h.publicKey...), nil -} - -func (h *handshakeMessageClientKeyExchange) Unmarshal(data []byte) error { - publicKeyLength := int(data[0]) - if len(data) <= publicKeyLength { - return errBufferTooSmall - } - h.publicKey = append([]byte{}, data[1:]...) - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_finished.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_finished.go deleted file mode 100644 index 9149150..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_finished.go +++ /dev/null @@ -1,18 +0,0 @@ -package dtls - -type handshakeMessageFinished struct { - verifyData []byte -} - -func (h handshakeMessageFinished) handshakeType() handshakeType { - return handshakeTypeFinished -} - -func (h *handshakeMessageFinished) Marshal() ([]byte, error) { - return append([]byte{}, h.verifyData...), nil -} - -func (h *handshakeMessageFinished) Unmarshal(data []byte) error { - h.verifyData = append([]byte{}, data...) - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_hello_verify_request.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_hello_verify_request.go deleted file mode 100644 index 749f504..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_hello_verify_request.go +++ /dev/null @@ -1,51 +0,0 @@ -package dtls - -/* - The definition of HelloVerifyRequest is as follows: - - struct { - ProtocolVersion server_version; - opaque cookie<0..2^8-1>; - } HelloVerifyRequest; - - The HelloVerifyRequest message type is hello_verify_request(3). - - When the client sends its ClientHello message to the server, the server - MAY respond with a HelloVerifyRequest message. This message contains - a stateless cookie generated using the technique of [PHOTURIS]. The - client MUST retransmit the ClientHello with the cookie added. - - https://tools.ietf.org/html/rfc6347#section-4.2.1 -*/ -type handshakeMessageHelloVerifyRequest struct { - version protocolVersion - cookie []byte -} - -func (h handshakeMessageHelloVerifyRequest) handshakeType() handshakeType { - return handshakeTypeHelloVerifyRequest -} - -func (h *handshakeMessageHelloVerifyRequest) Marshal() ([]byte, error) { - if len(h.cookie) > 255 { - return nil, errCookieTooLong - } - - out := make([]byte, 3+len(h.cookie)) - out[0] = h.version.major - out[1] = h.version.minor - out[2] = byte(len(h.cookie)) - copy(out[3:], h.cookie) - - return out, nil -} - -func (h *handshakeMessageHelloVerifyRequest) Unmarshal(data []byte) error { - h.version.major = data[0] - h.version.minor = data[1] - cookieLength := data[2] - h.cookie = make([]byte, cookieLength) - - copy(h.cookie, data[3:3+cookieLength]) - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_server_hello.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_server_hello.go deleted file mode 100644 index d4f4634..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_server_hello.go +++ /dev/null @@ -1,97 +0,0 @@ -package dtls - -import ( - "encoding/binary" -) - -/* -The server will send this message in response to a ClientHello -message when it was able to find an acceptable set of algorithms. -If it cannot find such a match, it will respond with a handshake -failure alert. -https://tools.ietf.org/html/rfc5246#section-7.4.1.3 -*/ -type handshakeMessageServerHello struct { - version protocolVersion - random handshakeRandom - - cipherSuite cipherSuite - compressionMethod *compressionMethod - extensions []extension -} - -const handshakeMessageServerHelloVariableWidthStart = 2 + handshakeRandomLength - -func (h handshakeMessageServerHello) handshakeType() handshakeType { - return handshakeTypeServerHello -} - -func (h *handshakeMessageServerHello) Marshal() ([]byte, error) { - if h.cipherSuite == nil { - return nil, errCipherSuiteUnset - } else if h.compressionMethod == nil { - return nil, errCompressionmethodUnset - } - - out := make([]byte, handshakeMessageServerHelloVariableWidthStart) - out[0] = h.version.major - out[1] = h.version.minor - - rand, err := h.random.Marshal() - if err != nil { - return nil, err - } - copy(out[2:], rand) - - out = append(out, 0x00) // SessionID - - out = append(out, []byte{0x00, 0x00}...) - binary.BigEndian.PutUint16(out[len(out)-2:], uint16(h.cipherSuite.ID())) - - out = append(out, byte(h.compressionMethod.id)) - - extensions, err := encodeExtensions(h.extensions) - if err != nil { - return nil, err - } - - return append(out, extensions...), nil -} - -func (h *handshakeMessageServerHello) Unmarshal(data []byte) error { - h.version.major = data[0] - h.version.minor = data[1] - - if err := h.random.Unmarshal(data[2 : 2+handshakeRandomLength]); err != nil { - return err - } - - currOffset := handshakeMessageServerHelloVariableWidthStart - currOffset += int(data[currOffset]) + 1 // SessionID - - if c := cipherSuiteForID(cipherSuiteID(binary.BigEndian.Uint16(data[currOffset:]))); c != nil { - h.cipherSuite = c - currOffset += 2 - } else { - return errInvalidCipherSuite - } - - if compressionMethod, ok := compressionMethods[compressionMethodID(data[currOffset])]; ok { - h.compressionMethod = compressionMethod - currOffset++ - } else { - return errInvalidCompressionMethod - } - - if len(data) <= currOffset { - h.extensions = []extension{} - return nil - } - - extensions, err := decodeExtensions(data[currOffset:]) - if err != nil { - return err - } - h.extensions = extensions - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_server_hello_done.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_server_hello_done.go deleted file mode 100644 index 0d591d6..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_server_hello_done.go +++ /dev/null @@ -1,16 +0,0 @@ -package dtls - -type handshakeMessageServerHelloDone struct { -} - -func (h handshakeMessageServerHelloDone) handshakeType() handshakeType { - return handshakeTypeServerHelloDone -} - -func (h *handshakeMessageServerHelloDone) Marshal() ([]byte, error) { - return []byte{}, nil -} - -func (h *handshakeMessageServerHelloDone) Unmarshal(data []byte) error { - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_server_key_exchange.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_server_key_exchange.go deleted file mode 100644 index 1a27dd0..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_message_server_key_exchange.go +++ /dev/null @@ -1,71 +0,0 @@ -package dtls - -import ( - "encoding/binary" -) - -// Structure only supports ECDH -type handshakeMessageServerKeyExchange struct { - ellipticCurveType ellipticCurveType - namedCurve namedCurve - publicKey []byte - hashAlgorithm HashAlgorithm - signatureAlgorithm signatureAlgorithm - signature []byte -} - -func (h handshakeMessageServerKeyExchange) handshakeType() handshakeType { - return handshakeTypeServerKeyExchange -} - -func (h *handshakeMessageServerKeyExchange) Marshal() ([]byte, error) { - out := []byte{byte(h.ellipticCurveType), 0x00, 0x00} - binary.BigEndian.PutUint16(out[1:], uint16(h.namedCurve)) - - out = append(out, byte(len(h.publicKey))) - out = append(out, h.publicKey...) - - out = append(out, []byte{byte(h.hashAlgorithm), byte(h.signatureAlgorithm), 0x00, 0x00}...) - - binary.BigEndian.PutUint16(out[len(out)-2:], uint16(len(h.signature))) - out = append(out, h.signature...) - - return out, nil -} - -func (h *handshakeMessageServerKeyExchange) Unmarshal(data []byte) error { - if _, ok := ellipticCurveTypes[ellipticCurveType(data[0])]; ok { - h.ellipticCurveType = ellipticCurveType(data[0]) - } else { - return errInvalidEllipticCurveType - } - - h.namedCurve = namedCurve(binary.BigEndian.Uint16(data[1:])) - if _, ok := namedCurves[h.namedCurve]; !ok { - return errInvalidNamedCurve - } - - publicKeyLength := int(data[3]) - offset := 4 + publicKeyLength - if len(data) <= publicKeyLength { - return errBufferTooSmall - } - h.publicKey = append([]byte{}, data[4:offset]...) - - h.hashAlgorithm = HashAlgorithm(data[offset]) - if _, ok := hashAlgorithms[h.hashAlgorithm]; !ok { - return errInvalidHashAlgorithm - } - offset++ - - h.signatureAlgorithm = signatureAlgorithm(data[offset]) - if _, ok := signatureAlgorithms[h.signatureAlgorithm]; !ok { - return errInvalidSignatureAlgorithm - } - offset++ - - signatureLength := int(binary.BigEndian.Uint16(data[offset:])) - offset += 2 - h.signature = append([]byte{}, data[offset:offset+signatureLength]...) - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/handshake_random.go b/vendor/github.com/pions/dtls/pkg/dtls/handshake_random.go deleted file mode 100644 index fe5f743..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/handshake_random.go +++ /dev/null @@ -1,47 +0,0 @@ -package dtls - -import ( - "crypto/rand" - "encoding/binary" - "time" -) - -const randomBytesLength = 28 -const handshakeRandomLength = randomBytesLength + 4 - -// https://tools.ietf.org/html/rfc4346#section-7.4.1.2 -type handshakeRandom struct { - gmtUnixTime time.Time - randomBytes [randomBytesLength]byte -} - -func (h *handshakeRandom) Marshal() ([]byte, error) { - out := make([]byte, handshakeRandomLength) - - binary.BigEndian.PutUint32(out[0:], uint32(h.gmtUnixTime.Unix())) - copy(out[4:], h.randomBytes[:]) - - return out, nil -} - -func (h *handshakeRandom) Unmarshal(data []byte) error { - if len(data) != handshakeRandomLength { - return errBufferTooSmall - } - h.gmtUnixTime = time.Unix(int64(binary.BigEndian.Uint32(data[0:])), 0) - copy(h.randomBytes[:], data[4:]) - - return nil -} - -// populate fills the handshakeRandom with random values -// may be called multiple times -func (h *handshakeRandom) populate() error { - h.gmtUnixTime = time.Now() - - tmp := make([]byte, randomBytesLength) - _, err := rand.Read(tmp) - copy(h.randomBytes[:], tmp) - - return err -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/hash_algorithm.go b/vendor/github.com/pions/dtls/pkg/dtls/hash_algorithm.go deleted file mode 100644 index 0745e4d..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/hash_algorithm.go +++ /dev/null @@ -1,97 +0,0 @@ -package dtls - -import ( - "crypto/md5" // #nosec - "crypto/sha1" // #nosec - "crypto/sha256" - "crypto/sha512" -) - -// HashAlgorithm is used to indicate the hash algorithm used -// https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-18 -type HashAlgorithm uint16 - -// Supported hash hash algorithms -const ( - // HashAlgorithmMD2 HashAlgorithm = 0 // Blacklisted - HashAlgorithmMD5 HashAlgorithm = 1 // Blacklisted - HashAlgorithmSHA1 HashAlgorithm = 2 // Blacklisted - HashAlgorithmSHA224 HashAlgorithm = 3 - HashAlgorithmSHA256 HashAlgorithm = 4 - HashAlgorithmSHA384 HashAlgorithm = 5 - HashAlgorithmSHA512 HashAlgorithm = 6 -) - -// String makes HashAlgorithm printable -func (h HashAlgorithm) String() string { - switch h { - case HashAlgorithmMD5: - return "md5" // [RFC3279] - case HashAlgorithmSHA1: - return "sha-1" // [RFC3279] - case HashAlgorithmSHA224: - return "sha-224" // [RFC4055] - case HashAlgorithmSHA256: - return "sha-256" // [RFC4055] - case HashAlgorithmSHA384: - return "sha-384" // [RFC4055] - case HashAlgorithmSHA512: - return "sha-512" // [RFC4055] - default: - return "unknown hash algorithm" - } -} - -// HashAlgorithmString allows looking up a HashAlgorithm by it's string representation -func HashAlgorithmString(s string) (HashAlgorithm, error) { - switch s { - case "md5": - return HashAlgorithmMD5, nil // [RFC3279] - case "sha-1": - return HashAlgorithmSHA1, nil // [RFC3279] - case "sha-224": - return HashAlgorithmSHA224, nil // [RFC4055] - case "sha-256": - return HashAlgorithmSHA256, nil // [RFC4055] - case "sha-384": - return HashAlgorithmSHA384, nil // [RFC4055] - case "sha-512": - return HashAlgorithmSHA512, nil // [RFC4055] - default: - return 0, errInvalidHashAlgorithm - } -} - -func (h HashAlgorithm) digest(b []byte) []byte { - switch h { - case HashAlgorithmMD5: - hash := md5.Sum(b) // #nosec - return hash[:] - case HashAlgorithmSHA1: - hash := sha1.Sum(b) // #nosec - return hash[:] - case HashAlgorithmSHA224: - hash := sha256.Sum224(b) - return hash[:] - case HashAlgorithmSHA256: - hash := sha256.Sum256(b) - return hash[:] - case HashAlgorithmSHA384: - hash := sha512.Sum384(b) - return hash[:] - case HashAlgorithmSHA512: - hash := sha512.Sum512(b) - return hash[:] - default: - return nil - } -} - -var hashAlgorithms = map[HashAlgorithm]struct{}{ - HashAlgorithmMD5: {}, - HashAlgorithmSHA1: {}, - HashAlgorithmSHA224: {}, - HashAlgorithmSHA256: {}, - HashAlgorithmSHA384: {}, - HashAlgorithmSHA512: {}, -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/internal/udp/conn.go b/vendor/github.com/pions/dtls/pkg/dtls/internal/udp/conn.go deleted file mode 100644 index d94d325..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/internal/udp/conn.go +++ /dev/null @@ -1,230 +0,0 @@ -package udp - -import ( - "errors" - "io" - "net" - "sync" - "time" -) - -const receiveMTU = 8192 - -var errClosedListener = errors.New("udp: listener closed") - -// Listener augments a connection-oriented Listener over a UDP PacketConn -type Listener struct { - pConn *net.UDPConn - - lock sync.RWMutex - accepting bool - acceptCh chan *Conn - doneCh chan struct{} - doneOnce sync.Once - - conns map[string]*Conn -} - -// Accept waits for and returns the next connection to the listener. -// You have to either close or read on all connection that are created. -func (l *Listener) Accept() (*Conn, error) { - select { - case c := <-l.acceptCh: - return c, nil - - case <-l.doneCh: - return nil, errClosedListener - } -} - -// Close closes the listener. -// Any blocked Accept operations will be unblocked and return errors. -func (l *Listener) Close() error { - l.lock.Lock() - defer l.lock.Unlock() - - var err error - l.doneOnce.Do(func() { - l.accepting = false - close(l.doneCh) - err = l.cleanup() - }) - - return err -} - -// cleanup closes the packet conn if it is no longer used -// The caller should hold the read lock. -func (l *Listener) cleanup() error { - if !l.accepting && len(l.conns) == 0 { - return l.pConn.Close() - } - return nil -} - -// Addr returns the listener's network address. -func (l *Listener) Addr() net.Addr { - return l.pConn.LocalAddr() -} - -// Listen creates a new listener -func Listen(network string, laddr *net.UDPAddr) (*Listener, error) { - conn, err := net.ListenUDP(network, laddr) - if err != nil { - return nil, err - } - - l := &Listener{ - pConn: conn, - acceptCh: make(chan *Conn), - conns: make(map[string]*Conn), - accepting: true, - doneCh: make(chan struct{}), - } - - go l.readLoop() - - return l, nil -} - -// readLoop has to tasks: -// 1. Dispatching incoming packets to the correct Conn. -// It can therefore not be ended until all Conns are closed. -// 2. Creating a new Conn when receiving from a new remote. -func (l *Listener) readLoop() { - buf := make([]byte, receiveMTU) - -readLoop: - for { - n, raddr, err := l.pConn.ReadFrom(buf) - if err != nil { - return - } - conn, err := l.getConn(raddr) - if err != nil { - continue - } - select { - case cBuf := <-conn.readCh: - n = copy(cBuf, buf[:n]) - conn.sizeCh <- n - case <-conn.doneCh: - continue readLoop - } - } -} - -func (l *Listener) getConn(raddr net.Addr) (*Conn, error) { - l.lock.Lock() - defer l.lock.Unlock() - - conn, ok := l.conns[raddr.String()] - if !ok { - if !l.accepting { - return nil, errClosedListener - } - conn = l.newConn(raddr) - l.conns[raddr.String()] = conn - l.acceptCh <- conn - } - return conn, nil -} - -// Conn augments a connection-oriented connection over a UDP PacketConn -type Conn struct { - listener *Listener - - rAddr net.Addr - - readCh chan []byte - sizeCh chan int - - lock sync.RWMutex - doneCh chan struct{} - doneOnce sync.Once -} - -func (l *Listener) newConn(rAddr net.Addr) *Conn { - return &Conn{ - listener: l, - rAddr: rAddr, - readCh: make(chan []byte), - sizeCh: make(chan int), - doneCh: make(chan struct{}), - } -} - -// Read -func (c *Conn) Read(p []byte) (int, error) { - select { - case c.readCh <- p: - n := <-c.sizeCh - return n, nil - case <-c.doneCh: - return 0, io.EOF - } -} - -// Write writes len(p) bytes from p to the DTLS connection -func (c *Conn) Write(p []byte) (n int, err error) { - c.lock.Lock() - l := c.listener - c.lock.Unlock() - - if l == nil { - return 0, io.EOF - } - - return l.pConn.WriteTo(p, c.rAddr) -} - -// Close closes the conn and releases any Read calls -func (c *Conn) Close() error { - c.lock.Lock() - defer c.lock.Unlock() - - var err error - c.doneOnce.Do(func() { - close(c.doneCh) - c.listener.lock.Lock() - delete(c.listener.conns, c.rAddr.String()) - err = c.listener.cleanup() - c.listener.lock.Unlock() - c.listener = nil - }) - - return err -} - -// LocalAddr is a stub -func (c *Conn) LocalAddr() net.Addr { - c.lock.Lock() - l := c.listener - c.lock.Unlock() - - if l == nil { - return nil - } - - return l.pConn.LocalAddr() -} - -// RemoteAddr is a stub -func (c *Conn) RemoteAddr() net.Addr { - return c.rAddr -} - -// SetDeadline is a stub -func (c *Conn) SetDeadline(t time.Time) error { - return nil -} - -// SetReadDeadline is a stub -func (c *Conn) SetReadDeadline(t time.Time) error { - return nil -} - -// SetWriteDeadline is a stub -func (c *Conn) SetWriteDeadline(t time.Time) error { - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/listener.go b/vendor/github.com/pions/dtls/pkg/dtls/listener.go deleted file mode 100644 index 47f76dd..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/listener.go +++ /dev/null @@ -1,51 +0,0 @@ -package dtls - -import ( - "errors" - "net" - - "github.com/pions/dtls/pkg/dtls/internal/udp" -) - -// Listen creates a DTLS listener -func Listen(network string, laddr *net.UDPAddr, config *Config) (*Listener, error) { - if config == nil { - return nil, errors.New("No config provided") - } - parent, err := udp.Listen(network, laddr) - if err != nil { - return nil, err - } - return &Listener{ - config: config, - parent: parent, - }, nil -} - -// Listener represents a DTLS listener -type Listener struct { - config *Config - parent *udp.Listener -} - -// Accept waits for and returns the next connection to the listener. -// You have to either close or read on all connection that are created. -func (l *Listener) Accept() (net.Conn, error) { - c, err := l.parent.Accept() - if err != nil { - return nil, err - } - return Server(c, l.config) -} - -// Close closes the listener. -// Any blocked Accept operations will be unblocked and return errors. -// Already Accepted connections are not closed. -func (l *Listener) Close() error { - return l.parent.Close() -} - -// Addr returns the listener's network address. -func (l *Listener) Addr() net.Addr { - return l.parent.Addr() -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/named_curve.go b/vendor/github.com/pions/dtls/pkg/dtls/named_curve.go deleted file mode 100644 index dc347fa..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/named_curve.go +++ /dev/null @@ -1,51 +0,0 @@ -package dtls - -import ( - "crypto/elliptic" - "crypto/rand" - - "golang.org/x/crypto/curve25519" -) - -// https://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-8 -type namedCurve uint16 - -type namedCurveKeypair struct { - curve namedCurve - publicKey []byte - privateKey []byte -} - -const ( - namedCurveP256 namedCurve = 0x0017 - namedCurveX25519 namedCurve = 0x001d -) - -var namedCurves = map[namedCurve]bool{ - namedCurveX25519: true, - namedCurveP256: true, -} - -func generateKeypair(c namedCurve) (*namedCurveKeypair, error) { - switch c { - case namedCurveX25519: - tmp := make([]byte, 32) - if _, err := rand.Read(tmp); err != nil { - return nil, err - } - - var public, private [32]byte - copy(private[:], tmp) - - curve25519.ScalarBaseMult(&public, &private) - return &namedCurveKeypair{namedCurveX25519, public[:], private[:]}, nil - case namedCurveP256: - privateKey, x, y, err := elliptic.GenerateKey(elliptic.P256(), rand.Reader) - if err != nil { - return nil, err - } - - return &namedCurveKeypair{namedCurveP256, elliptic.Marshal(elliptic.P256(), x, y), privateKey}, nil - } - return nil, errInvalidNamedCurve -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/prf.go b/vendor/github.com/pions/dtls/pkg/dtls/prf.go deleted file mode 100644 index 7244238..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/prf.go +++ /dev/null @@ -1,209 +0,0 @@ -package dtls - -import ( - "crypto/elliptic" - "crypto/hmac" - "crypto/sha1" // #nosec - "encoding/binary" - "fmt" - "hash" - "math" - - "golang.org/x/crypto/curve25519" -) - -const ( - prfMasterSecretLabel = "master secret" - prfKeyExpansionLabel = "key expansion" - prfVerifyDataClientLabel = "client finished" - prfVerifyDataServerLabel = "server finished" -) - -type hashFunc func() hash.Hash - -type encryptionKeys struct { - masterSecret []byte - clientMACKey []byte - serverMACKey []byte - clientWriteKey []byte - serverWriteKey []byte - clientWriteIV []byte - serverWriteIV []byte -} - -func (e *encryptionKeys) String() string { - return fmt.Sprintf(`encryptionKeys: -- masterSecret: %#v -- clientMACKey: %#v -- serverMACKey: %#v -- clientWriteKey: %#v -- serverWriteKey: %#v -- clientWriteIV: %#v -- serverWriteIV: %#v -`, - e.masterSecret, - e.clientMACKey, - e.serverMACKey, - e.clientWriteKey, - e.serverWriteKey, - e.clientWriteIV, - e.serverWriteIV) -} - -func prfPreMasterSecret(publicKey, privateKey []byte, curve namedCurve) ([]byte, error) { - switch curve { - case namedCurveX25519: - var preMasterSecret, fixedWidthPrivateKey, fixedWidthPublicKey [32]byte - copy(fixedWidthPrivateKey[:], privateKey) - copy(fixedWidthPublicKey[:], publicKey) - - curve25519.ScalarMult(&preMasterSecret, &fixedWidthPrivateKey, &fixedWidthPublicKey) - return preMasterSecret[:], nil - case namedCurveP256: - x, y := elliptic.Unmarshal(elliptic.P256(), publicKey) - if x == nil || y == nil { - return nil, errInvalidNamedCurve - } - - curve := elliptic.P256() - result, _ := curve.ScalarMult(x, y, privateKey) - preMasterSecret := make([]byte, (curve.Params().BitSize+7)>>3) - resultBytes := result.Bytes() - copy(preMasterSecret[len(preMasterSecret)-len(resultBytes):], resultBytes) - return preMasterSecret, nil - } - - return nil, errInvalidNamedCurve -} - -// This PRF with the SHA-256 hash function is used for all cipher suites -// defined in this document and in TLS documents published prior to this -// document when TLS 1.2 is negotiated. New cipher suites MUST explicitly -// specify a PRF and, in general, SHOULD use the TLS PRF with SHA-256 or a -// stronger standard hash function. -// -// P_hash(secret, seed) = HMAC_hash(secret, A(1) + seed) + -// HMAC_hash(secret, A(2) + seed) + -// HMAC_hash(secret, A(3) + seed) + ... -// -// A() is defined as: -// -// A(0) = seed -// A(i) = HMAC_hash(secret, A(i-1)) -// -// P_hash can be iterated as many times as necessary to produce the -// required quantity of data. For example, if P_SHA256 is being used to -// create 80 bytes of data, it will have to be iterated three times -// (through A(3)), creating 96 bytes of output data; the last 16 bytes -// of the final iteration will then be discarded, leaving 80 bytes of -// output data. -// -// https://tools.ietf.org/html/rfc4346w -func prfPHash(secret, seed []byte, requestedLength int, h hashFunc) ([]byte, error) { - hmacSHA256 := func(key, data []byte) ([]byte, error) { - mac := hmac.New(h, key) - if _, err := mac.Write(data); err != nil { - return nil, err - } - return mac.Sum(nil), nil - } - - var err error - lastRound := seed - out := []byte{} - - iterations := int(math.Ceil(float64(requestedLength) / float64(h().Size()))) - for i := 0; i < iterations; i++ { - lastRound, err = hmacSHA256(secret, lastRound) - if err != nil { - return nil, err - } - withSecret, err := hmacSHA256(secret, append(lastRound, seed...)) - if err != nil { - return nil, err - } - out = append(out, withSecret...) - } - - return out[:requestedLength], nil -} - -func prfMasterSecret(preMasterSecret, clientRandom, serverRandom []byte, h hashFunc) ([]byte, error) { - seed := append(append([]byte(prfMasterSecretLabel), clientRandom...), serverRandom...) - return prfPHash(preMasterSecret, seed, 48, h) -} - -func prfEncryptionKeys(masterSecret, clientRandom, serverRandom []byte, prfMacLen, prfKeyLen, prfIvLen int, h hashFunc) (*encryptionKeys, error) { - seed := append(append([]byte(prfKeyExpansionLabel), serverRandom...), clientRandom...) - keyMaterial, err := prfPHash(masterSecret, seed, (2*prfMacLen)+(2*prfKeyLen)+(2*prfIvLen), h) - if err != nil { - return nil, err - } - - clientMACKey := keyMaterial[:prfMacLen] - keyMaterial = keyMaterial[prfMacLen:] - - serverMACKey := keyMaterial[:prfMacLen] - keyMaterial = keyMaterial[prfMacLen:] - - clientWriteKey := keyMaterial[:prfKeyLen] - keyMaterial = keyMaterial[prfKeyLen:] - - serverWriteKey := keyMaterial[:prfKeyLen] - keyMaterial = keyMaterial[prfKeyLen:] - - clientWriteIV := keyMaterial[:prfIvLen] - keyMaterial = keyMaterial[prfIvLen:] - - serverWriteIV := keyMaterial[:prfIvLen] - - return &encryptionKeys{ - masterSecret: masterSecret, - clientMACKey: clientMACKey, - serverMACKey: serverMACKey, - clientWriteKey: clientWriteKey, - serverWriteKey: serverWriteKey, - clientWriteIV: clientWriteIV, - serverWriteIV: serverWriteIV, - }, nil -} - -func prfVerifyData(masterSecret, handshakeBodies []byte, label string, hashFunc hashFunc) ([]byte, error) { - h := hashFunc() - if _, err := h.Write(handshakeBodies); err != nil { - return nil, err - } - - seed := append([]byte(label), h.Sum(nil)...) - return prfPHash(masterSecret, seed, 12, hashFunc) -} - -func prfVerifyDataClient(masterSecret, handshakeBodies []byte, h hashFunc) ([]byte, error) { - return prfVerifyData(masterSecret, handshakeBodies, prfVerifyDataClientLabel, h) -} - -func prfVerifyDataServer(masterSecret, handshakeBodies []byte, h hashFunc) ([]byte, error) { - return prfVerifyData(masterSecret, handshakeBodies, prfVerifyDataServerLabel, h) -} - -// compute the MAC using HMAC-SHA1 -func prfMac(epoch uint16, sequenceNumber uint64, contentType contentType, protocolVersion protocolVersion, payload []byte, key []byte) ([]byte, error) { - h := hmac.New(sha1.New, key) - - msg := make([]byte, 13) - - binary.BigEndian.PutUint16(msg, epoch) - putBigEndianUint48(msg[2:], sequenceNumber) - msg[8] = byte(contentType) - msg[9] = protocolVersion.major - msg[10] = protocolVersion.minor - binary.BigEndian.PutUint16(msg[11:], uint16(len(payload))) - - if _, err := h.Write(msg); err != nil { - return nil, err - } else if _, err := h.Write(payload); err != nil { - return nil, err - } - - return h.Sum(nil), nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/record_layer.go b/vendor/github.com/pions/dtls/pkg/dtls/record_layer.go deleted file mode 100644 index fa2c8ee..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/record_layer.go +++ /dev/null @@ -1,86 +0,0 @@ -package dtls - -import ( - "encoding/binary" -) - -/* - The TLS Record Layer which handles all data transport. - The record layer is assumed to sit directly on top of some - reliable transport such as TCP. The record layer can carry four types of content: - - 1. Handshake messages—used for algorithm negotiation and key establishment. - 2. ChangeCipherSpec messages—really part of the handshake but technically a separate kind of message. - 3. Alert messages—used to signal that errors have occurred - 4. Application layer data - - The DTLS record layer is extremely similar to that of TLS 1.1. The - only change is the inclusion of an explicit sequence number in the - record. This sequence number allows the recipient to correctly - verify the TLS MAC. - https://tools.ietf.org/html/rfc4347#section-4.1 -*/ -type recordLayer struct { - recordLayerHeader recordLayerHeader - content content -} - -func (r *recordLayer) Marshal() ([]byte, error) { - contentRaw, err := r.content.Marshal() - if err != nil { - return nil, err - } - - r.recordLayerHeader.contentLen = uint16(len(contentRaw)) - r.recordLayerHeader.contentType = r.content.contentType() - - headerRaw, err := r.recordLayerHeader.Marshal() - if err != nil { - return nil, err - } - - return append(headerRaw, contentRaw...), nil -} - -func (r *recordLayer) Unmarshal(data []byte) error { - if err := r.recordLayerHeader.Unmarshal(data); err != nil { - return err - } - - switch contentType(data[0]) { - case contentTypeChangeCipherSpec: - r.content = &changeCipherSpec{} - case contentTypeAlert: - r.content = &alert{} - case contentTypeHandshake: - r.content = &handshake{} - case contentTypeApplicationData: - r.content = &applicationData{} - default: - return errInvalidContentType - } - - return r.content.Unmarshal(data[recordLayerHeaderSize:]) -} - -// Note that as with TLS, multiple handshake messages may be placed in -// the same DTLS record, provided that there is room and that they are -// part of the same flight. Thus, there are two acceptable ways to pack -// two DTLS messages into the same datagram: in the same record or in -// separate records. -// https://tools.ietf.org/html/rfc6347#section-4.2.3 -func unpackDatagram(buf []byte) ([][]byte, error) { - out := [][]byte{} - - for offset := 0; len(buf) != offset; { - if len(buf)-offset <= recordLayerHeaderSize { - return nil, errDTLSPacketInvalidLength - } - - pktLen := (recordLayerHeaderSize + int(binary.BigEndian.Uint16(buf[offset+11:]))) - out = append(out, buf[offset:offset+pktLen]) - offset += pktLen - } - - return out, nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/record_layer_header.go b/vendor/github.com/pions/dtls/pkg/dtls/record_layer_header.go deleted file mode 100644 index 8f98f08..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/record_layer_header.go +++ /dev/null @@ -1,56 +0,0 @@ -package dtls - -import "encoding/binary" - -type recordLayerHeader struct { - contentType contentType - contentLen uint16 - protocolVersion protocolVersion - epoch uint16 - sequenceNumber uint64 // uint48 in spec - -} - -const ( - recordLayerHeaderSize = 13 - maxSequenceNumber = 0x0000FFFFFFFFFFFF - - dtls1_2Major = 0xfe - dtls1_2Minor = 0xfd -) - -var protocolVersion1_2 = protocolVersion{dtls1_2Major, dtls1_2Minor} - -// https://tools.ietf.org/html/rfc4346#section-6.2.1 -type protocolVersion struct { - major, minor uint8 -} - -func (r *recordLayerHeader) Marshal() ([]byte, error) { - if r.sequenceNumber > maxSequenceNumber { - return nil, errSequenceNumberOverflow - } - - out := make([]byte, recordLayerHeaderSize) - out[0] = byte(r.contentType) - out[1] = r.protocolVersion.major - out[2] = r.protocolVersion.minor - binary.BigEndian.PutUint16(out[3:], r.epoch) - putBigEndianUint48(out[5:], r.sequenceNumber) - binary.BigEndian.PutUint16(out[recordLayerHeaderSize-2:], r.contentLen) - return out, nil -} - -func (r *recordLayerHeader) Unmarshal(data []byte) error { - r.contentType = contentType(data[0]) - r.protocolVersion.major = data[1] - r.protocolVersion.minor = data[2] - r.epoch = binary.BigEndian.Uint16(data[3:]) - - // SequenceNumber is stored as uint48, make into uint64 - seqCopy := make([]byte, 8) - copy(seqCopy[2:], data[5:11]) - r.sequenceNumber = binary.BigEndian.Uint64(seqCopy) - - return nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/server_handlers.go b/vendor/github.com/pions/dtls/pkg/dtls/server_handlers.go deleted file mode 100644 index a1e5037..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/server_handlers.go +++ /dev/null @@ -1,290 +0,0 @@ -package dtls - -import ( - "bytes" - "fmt" -) - -func serverExcludeRules() map[flightVal]handshakeCacheExcludeRule { - // ClientHello and HelloVerifyRequest MUST NOT be included in the CertificateVerify - return map[flightVal]handshakeCacheExcludeRule{ - flight0: {isLocal: true, isRemote: true}, - flight1: {isLocal: true, isRemote: true}, - flight2: {isLocal: true, isRemote: false}, - } -} - -func serverHandshakeHandler(c *Conn) error { - c.lock.Lock() - defer c.lock.Unlock() - - for out, fragEpoch := c.fragmentBuffer.pop(); out != nil; out, fragEpoch = c.fragmentBuffer.pop() { - rawHandshake := &handshake{} - if err := rawHandshake.Unmarshal(out); err != nil { - return err - } - c.handshakeCache.push(out, fragEpoch, rawHandshake.handshakeHeader.messageSequence /* isLocal */, false, c.currFlight.get()) - - switch h := rawHandshake.handshakeMessage.(type) { - case *handshakeMessageClientHello: - if c.currFlight.get() == flight2 { - if !bytes.Equal(c.cookie, h.cookie) { - return errCookieMismatch - } - c.localSequenceNumber = 1 - if err := c.currFlight.set(flight4); err != nil { - return err - } - break - } - - c.remoteRandom = h.random - - if len(h.cipherSuites) == 0 { - return errCipherSuiteNoIntersection - } - c.cipherSuite = h.cipherSuites[0] // TODO assert we support (No RSA) - - for _, extension := range h.extensions { - switch e := extension.(type) { - case *extensionSupportedEllipticCurves: - c.namedCurve = e.ellipticCurves[0] - case *extensionUseSRTP: - // TODO expose to API - } - } - - if c.localKeypair == nil { - var err error - c.localKeypair, err = generateKeypair(c.namedCurve) - if err != nil { - return err - } - } - - if err := c.currFlight.set(flight2); err != nil { - return err - } - - case *handshakeMessageCertificate: - if c.currFlight.get() == flight4 { - c.remoteCertificate = h.certificate - } - - case *handshakeMessageClientKeyExchange: - if c.currFlight.get() == flight4 { - c.remoteKeypair = &namedCurveKeypair{c.namedCurve, h.publicKey, nil} - - serverRandom, err := c.localRandom.Marshal() - if err != nil { - return err - } - clientRandom, err := c.remoteRandom.Marshal() - if err != nil { - return err - } - - preMasterSecret, err := prfPreMasterSecret(c.remoteKeypair.publicKey, c.localKeypair.privateKey, c.localKeypair.curve) - if err != nil { - return err - } - - c.masterSecret, err = prfMasterSecret(preMasterSecret, clientRandom, serverRandom, c.cipherSuite.hashFunc()) - if err != nil { - return err - } - - if err := c.cipherSuite.init(c.masterSecret, clientRandom, serverRandom /* isClient */, false); err != nil { - return err - } - } - - case *handshakeMessageFinished: - if c.currFlight.get() == flight4 { - expectedVerifyData, err := prfVerifyDataClient(c.masterSecret, c.handshakeCache.combinedHandshake(serverExcludeRules(), true), c.cipherSuite.hashFunc()) - if err != nil { - return err - } else if !bytes.Equal(expectedVerifyData, h.verifyData) { - return errVerifyDataMismatch - } - c.localEpoch = 1 - c.localSequenceNumber = 5 - if err := c.currFlight.set(flight6); err != nil { - return err - } - } - - default: - return fmt.Errorf("Unhandled handshake %d", h.handshakeType()) - } - } - - return nil -} - -func serverFlightHandler(c *Conn) (bool, error) { - switch c.currFlight.get() { - case flight0: - // Waiting for ClientHello - case flight2: - c.lock.RLock() - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - sequenceNumber: c.localSequenceNumber, - protocolVersion: protocolVersion1_2, - }, - content: &handshake{ - // sequenceNumber and messageSequence line up, may need to be re-evaluated - handshakeHeader: handshakeHeader{ - messageSequence: uint16(c.localSequenceNumber), - }, - handshakeMessage: &handshakeMessageHelloVerifyRequest{ - version: protocolVersion1_2, - cookie: c.cookie, - }, - }, - }, false) - c.lock.RUnlock() - - case flight4: - c.lock.RLock() - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - sequenceNumber: c.localSequenceNumber, - protocolVersion: protocolVersion1_2, - }, - content: &handshake{ - // sequenceNumber and messageSequence line up, may need to be re-evaluated - handshakeHeader: handshakeHeader{ - messageSequence: uint16(c.localSequenceNumber), - }, - handshakeMessage: &handshakeMessageServerHello{ - version: protocolVersion1_2, - random: c.localRandom, - cipherSuite: c.cipherSuite, - compressionMethod: defaultCompressionMethods[0], - extensions: []extension{ - &extensionSupportedEllipticCurves{ - ellipticCurves: []namedCurve{namedCurveX25519, namedCurveP256}, - }, - &extensionUseSRTP{ - protectionProfiles: []srtpProtectionProfile{SRTP_AES128_CM_HMAC_SHA1_80}, - }, - &extensionSupportedPointFormats{ - pointFormats: []ellipticCurvePointFormat{ellipticCurvePointFormatUncompressed}, - }, - }, - }}, - }, false) - - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - sequenceNumber: c.localSequenceNumber + 1, - protocolVersion: protocolVersion1_2, - }, - content: &handshake{ - // sequenceNumber and messageSequence line up, may need to be re-evaluated - handshakeHeader: handshakeHeader{ - messageSequence: uint16(c.localSequenceNumber + 1), - }, - handshakeMessage: &handshakeMessageCertificate{ - certificate: c.localCertificate, - }}, - }, false) - - serverRandom, err := c.localRandom.Marshal() - if err != nil { - return false, err - } - clientRandom, err := c.remoteRandom.Marshal() - if err != nil { - return false, err - } - - signature, err := generateKeySignature(clientRandom, serverRandom, c.localKeypair.publicKey, c.namedCurve, c.localPrivateKey, HashAlgorithmSHA256) - if err != nil { - return false, err - } - - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - sequenceNumber: c.localSequenceNumber + 2, - protocolVersion: protocolVersion1_2, - }, - content: &handshake{ - // sequenceNumber and messageSequence line up, may need to be re-evaluated - handshakeHeader: handshakeHeader{ - messageSequence: uint16(c.localSequenceNumber + 2), - }, - handshakeMessage: &handshakeMessageServerKeyExchange{ - ellipticCurveType: ellipticCurveTypeNamedCurve, - namedCurve: c.namedCurve, - publicKey: c.localKeypair.publicKey, - hashAlgorithm: HashAlgorithmSHA256, - signatureAlgorithm: signatureAlgorithmECDSA, - signature: signature, - }}, - }, false) - - // TODO: CertificateRequest - - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - sequenceNumber: c.localSequenceNumber + 3, - protocolVersion: protocolVersion1_2, - }, - content: &handshake{ - // sequenceNumber and messageSequence line up, may need to be re-evaluated - handshakeHeader: handshakeHeader{ - messageSequence: uint16(c.localSequenceNumber + 3), - }, - handshakeMessage: &handshakeMessageServerHelloDone{}, - }, - }, false) - - c.lock.RUnlock() - - case flight6: - c.lock.RLock() - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - sequenceNumber: c.localSequenceNumber, - protocolVersion: protocolVersion1_2, - }, - content: &changeCipherSpec{}, - }, false) - - if len(c.localVerifyData) == 0 { - var err error - c.localVerifyData, err = prfVerifyDataServer(c.masterSecret, c.handshakeCache.combinedHandshake(serverExcludeRules(), false), c.cipherSuite.hashFunc()) - if err != nil { - return false, err - } - } - - c.internalSend(&recordLayer{ - recordLayerHeader: recordLayerHeader{ - epoch: 1, - sequenceNumber: 0, // sequenceNumber restarts per epoch - protocolVersion: protocolVersion1_2, - }, - content: &handshake{ - // sequenceNumber and messageSequence line up, may need to be re-evaluated - handshakeHeader: handshakeHeader{ - messageSequence: uint16(c.localSequenceNumber), // KeyExchange + 1 - }, - - handshakeMessage: &handshakeMessageFinished{ - verifyData: c.localVerifyData, - }}, - }, true) - c.lock.RUnlock() - - // TODO: Better way to end handshake - c.signalHandshakeComplete() - return true, nil - default: - return false, fmt.Errorf("Unhandled flight %s", c.currFlight.get()) - } - return false, nil -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/signature_algorithm.go b/vendor/github.com/pions/dtls/pkg/dtls/signature_algorithm.go deleted file mode 100644 index c1a8508..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/signature_algorithm.go +++ /dev/null @@ -1,14 +0,0 @@ -package dtls - -// https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-16 -type signatureAlgorithm uint16 - -const ( - signatureAlgorithmRSA signatureAlgorithm = 1 - signatureAlgorithmECDSA signatureAlgorithm = 3 -) - -var signatureAlgorithms = map[signatureAlgorithm]bool{ - signatureAlgorithmRSA: true, - signatureAlgorithmECDSA: true, -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/signature_hash_algorithm.go b/vendor/github.com/pions/dtls/pkg/dtls/signature_hash_algorithm.go deleted file mode 100644 index 6a2f0ea..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/signature_hash_algorithm.go +++ /dev/null @@ -1,6 +0,0 @@ -package dtls - -type signatureHashAlgorithm struct { - hash HashAlgorithm - signature signatureAlgorithm -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/srtp_protection_profile.go b/vendor/github.com/pions/dtls/pkg/dtls/srtp_protection_profile.go deleted file mode 100644 index 9f269c3..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/srtp_protection_profile.go +++ /dev/null @@ -1,11 +0,0 @@ -package dtls - -type srtpProtectionProfile uint16 - -const ( - SRTP_AES128_CM_HMAC_SHA1_80 srtpProtectionProfile = 0x0001 // nolint -) - -var srtpProtectionProfiles = map[srtpProtectionProfile]bool{ - SRTP_AES128_CM_HMAC_SHA1_80: true, -} diff --git a/vendor/github.com/pions/dtls/pkg/dtls/util.go b/vendor/github.com/pions/dtls/pkg/dtls/util.go deleted file mode 100644 index f2b8a57..0000000 --- a/vendor/github.com/pions/dtls/pkg/dtls/util.go +++ /dev/null @@ -1,132 +0,0 @@ -package dtls - -import ( - "crypto" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "crypto/x509" - "crypto/x509/pkix" - "encoding/binary" - "encoding/hex" - "math/big" - "time" -) - -// Parse a big endian uint24 -func bigEndianUint24(raw []byte) uint32 { - if len(raw) < 3 { - return 0 - } - - rawCopy := make([]byte, 4) - copy(rawCopy[1:], raw) - return binary.BigEndian.Uint32(rawCopy) -} - -func putBigEndianUint24(out []byte, in uint32) { - tmp := make([]byte, 4) - binary.BigEndian.PutUint32(tmp, in) - copy(out, tmp[1:]) -} - -func putBigEndianUint48(out []byte, in uint64) { - tmp := make([]byte, 8) - binary.BigEndian.PutUint64(tmp, in) - copy(out, tmp[2:]) -} - -// GenerateSelfSigned creates a self-signed certificate -func GenerateSelfSigned() (*x509.Certificate, crypto.PrivateKey, error) { - priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) - if err != nil { - return nil, nil, err - } - - origin := make([]byte, 16) - - // Max random value, a 130-bits integer, i.e 2^130 - 1 - maxBigInt := new(big.Int) - /* #nosec */ - maxBigInt.Exp(big.NewInt(2), big.NewInt(130), nil).Sub(maxBigInt, big.NewInt(1)) - serialNumber, err := rand.Int(rand.Reader, maxBigInt) - if err != nil { - return nil, nil, err - } - - template := x509.Certificate{ - ExtKeyUsage: []x509.ExtKeyUsage{ - x509.ExtKeyUsageClientAuth, - x509.ExtKeyUsageServerAuth, - }, - BasicConstraintsValid: true, - NotBefore: time.Now(), - KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, - NotAfter: time.Now().AddDate(0, 1, 0), - SerialNumber: serialNumber, - Version: 2, - Subject: pkix.Name{CommonName: hex.EncodeToString(origin)}, - IsCA: true, - } - - raw, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) - if err != nil { - return nil, nil, err - } - - cert, err := x509.ParseCertificate(raw) - if err != nil { - return nil, nil, err - } - - return cert, priv, nil -} - -func max(a, b int) int { - if a > b { - return a - } - return b -} - -// examinePadding returns, in constant time, the length of the padding to remove -// from the end of payload. It also returns a byte which is equal to 255 if the -// padding was valid and 0 otherwise. See RFC 2246, Section 6.2.3.2. -// -// https://github.com/golang/go/blob/039c2081d1178f90a8fa2f4e6958693129f8de33/src/crypto/tls/conn.go#L245 -func examinePadding(payload []byte) (toRemove int, good byte) { - if len(payload) < 1 { - return 0, 0 - } - - paddingLen := payload[len(payload)-1] - t := uint(len(payload)-1) - uint(paddingLen) - // if len(payload) >= (paddingLen - 1) then the MSB of t is zero - good = byte(int32(^t) >> 31) - - // The maximum possible padding length plus the actual length field - toCheck := 256 - // The length of the padded data is public, so we can use an if here - if toCheck > len(payload) { - toCheck = len(payload) - } - - for i := 0; i < toCheck; i++ { - t := uint(paddingLen) - uint(i) - // if i <= paddingLen then the MSB of t is zero - mask := byte(int32(^t) >> 31) - b := payload[len(payload)-1-i] - good &^= mask&paddingLen ^ mask&b - } - - // We AND together the bits of good and replicate the result across - // all the bits. - good &= good << 4 - good &= good << 2 - good &= good << 1 - good = uint8(int8(good) >> 7) - - toRemove = int(paddingLen) + 1 - - return toRemove, good -} diff --git a/vendor/github.com/pions/pkg/LICENSE.md b/vendor/github.com/pions/pkg/LICENSE.md deleted file mode 100644 index 5cc9cbd..0000000 --- a/vendor/github.com/pions/pkg/LICENSE.md +++ /dev/null @@ -1,7 +0,0 @@ -Copyright 2018 Pion LLC - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/pions/pkg/stun/attr_channel_number.go b/vendor/github.com/pions/pkg/stun/attr_channel_number.go deleted file mode 100644 index 7baa82d..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_channel_number.go +++ /dev/null @@ -1,34 +0,0 @@ -package stun - -import ( - "github.com/pkg/errors" -) - -// A ChannelNumber is a 4-byte header that identifies a Channel. Each channel -// number in use is bound to a specific peer and thus serves as a -// shorthand for the peer's host transport address. -// https://tools.ietf.org/html/rfc5766#section-2.5 -type ChannelNumber struct { - ChannelNumber uint16 -} - -// Pack a ChannelNumber attribute, adding it to the passed message -func (x *ChannelNumber) Pack(message *Message) error { - v := make([]byte, 2) - enc.PutUint16(v, x.ChannelNumber) - message.AddAttribute(AttrChannelNumber, v) - return nil -} - -// Unpack a ChannelNumber, deserializing the rawAttribute and populating the struct -func (x *ChannelNumber) Unpack(message *Message, rawAttribute *RawAttribute) error { - v := rawAttribute.Value - - if len(v) != 4 { - return errors.Errorf("invalid channel number length %d != %d (expected)", len(v), 2) - } - - x.ChannelNumber = enc.Uint16(v[:2]) - - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_data.go b/vendor/github.com/pions/pkg/stun/attr_data.go deleted file mode 100644 index 9a8a454..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_data.go +++ /dev/null @@ -1,23 +0,0 @@ -package stun - -// A Data represents the attribute is present in all Send and Data indications. The -// value portion of this attribute is variable length and consists of -// the application data (that is, the data that would immediately follow -// the UDP header if the data was been sent directly between the client -// and the peer). If the length of this attribute is not a multiple of -// 4, then padding must be added after this attribute. -type Data struct { - Data []byte -} - -// Pack a Data attribute, adding it to the passed message -func (d *Data) Pack(message *Message) error { - message.AddAttribute(AttrData, d.Data) - return nil -} - -// Unpack a Data, deserializing the rawAttribute and populating the struct -func (d *Data) Unpack(message *Message, rawAttribute *RawAttribute) error { - d.Data = rawAttribute.Value - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_error_code.go b/vendor/github.com/pions/pkg/stun/attr_error_code.go deleted file mode 100644 index e52e6e3..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_error_code.go +++ /dev/null @@ -1,83 +0,0 @@ -package stun - -import ( - "github.com/pkg/errors" -) - -// An ErrorCode attribute is used in error response messages. It -// contains a numeric error code value in the range of 300 to 699 plus a -// textual reason phrase encoded in UTF-8 -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Reserved, should be 0 |Class| Number | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Reason Phrase (variable) .. -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -type ErrorCode struct { - ErrorClass int - ErrorNumber int - Reason []byte -} - -var ( - // Err300TryAlternate a ErrorCode value - TryAlernate - Err300TryAlternate = ErrorCode{3, 0, []byte("Try Alternate: The client should contact an alternate server for this request.")} - // Err400BadRequest a ErrorCode value - BadRequest - Err400BadRequest = ErrorCode{4, 0, []byte("Bad Request: The request was malformed.")} - // Err401Unauthorized a ErrorCode value - Unauthorized - Err401Unauthorized = ErrorCode{4, 1, []byte("Unauthorized: The request did not contain the correct credentials to proceed.")} - // Err420UnknownAttributes a ErrorCode value - UnknownAttributes - Err420UnknownAttributes = ErrorCode{4, 20, []byte("Unknown Attribute: The server received a STUN packet containing a comprehension-required attribute that it did not understand.")} - // Err437AllocationMismatch a ErrorCode value - AllocationMismatch - Err437AllocationMismatch = ErrorCode{4, 37, []byte("AllocationMismatch: 5-TUPLE didn't match, or conflicted with existing state.")} - // Err438StaleNonce a ErrorCode value - StaleNonce - Err438StaleNonce = ErrorCode{4, 38, []byte("Stale Nonce: The NONCE used by the client was no longer valid.")} - // Err442UnsupportedTransportProtocol a ErrorCode value - UnsupportedTransportProtocol - Err442UnsupportedTransportProtocol = ErrorCode{4, 42, []byte("Unsupported Transport Protocol: UDP is the only supported transport protocol.")} - // Err500ServerError a ErrorCode value - ServerError - Err500ServerError = ErrorCode{5, 0, []byte("Server Error: The server has suffered a temporary error.")} - // Err508InsufficentCapacity a ErrorCode value - InsufficentCapacity - Err508InsufficentCapacity = ErrorCode{5, 8, []byte("Insufficent Capacity: The server doesn't have the capacity to fulfill this request.")} -) - -const ( - errorCodeHeaderLength = 4 - errorCodeMaxReasonLength = 763 - errorCodeClassStart = 2 - errorCodeNumberStart = 3 - errorCodeReasonStart = 4 -) - -// Pack a ErrorCode attribute, adding it to the passed message -func (e *ErrorCode) Pack(message *Message) error { - if len(e.Reason) > errorCodeMaxReasonLength { - return errors.Errorf("invalid reason length %d", len(e.Reason)) - } - - if e.ErrorClass < 3 || e.ErrorClass > 6 { - return errors.Errorf("invalid error class %d", e.ErrorClass) - } - - if e.ErrorNumber < 0 || e.ErrorNumber > 99 { - return errors.Errorf("invalid error subcode %d", e.ErrorNumber) - } - - len := errorCodeHeaderLength + len(e.Reason) - - v := make([]byte, len) - - v[errorCodeClassStart] = byte(e.ErrorClass) - v[errorCodeNumberStart] = byte(e.ErrorNumber) - - copy(v[errorCodeReasonStart:], e.Reason) - - message.AddAttribute(AttrErrorCode, v) - - return nil -} - -// Unpack a ErrorCode, deserializing the rawAttribute and populating the struct -func (e *ErrorCode) Unpack(message *Message, rawAttribute *RawAttribute) error { - return errors.New("ErrorCode.Unpack() unimplemented") -} diff --git a/vendor/github.com/pions/pkg/stun/attr_even_port.go b/vendor/github.com/pions/pkg/stun/attr_even_port.go deleted file mode 100644 index ff4d679..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_even_port.go +++ /dev/null @@ -1,24 +0,0 @@ -package stun - -import ( - "github.com/pkg/errors" -) - -// A EvenPort attribute allows the client to request that the port in the -// relayed transport address be even, and (optionally) that the server -// reserve the next-higher port number. The value portion of this -// attribute is 1 byte long. -type EvenPort struct { - ReserveAdditional bool -} - -// Pack a EvenNumber attribute, adding it to the passed message -func (e *EvenPort) Pack(message *Message) error { - return errors.Errorf("*EvenPort.Pack has not been implemented") -} - -// Unpack a EvenPort, deserializing the rawAttribute and populating the struct -func (e *EvenPort) Unpack(message *Message, rawAttribute *RawAttribute) error { - e.ReserveAdditional = rawAttribute.Value[0] != 0 - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_fingerprint.go b/vendor/github.com/pions/pkg/stun/attr_fingerprint.go deleted file mode 100644 index ac7a6d9..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_fingerprint.go +++ /dev/null @@ -1,51 +0,0 @@ -package stun - -import ( - "hash/crc32" - - "github.com/pkg/errors" -) - -// A Fingerprint attribute MAY be present in all STUN messages. The -// value of the attribute is computed as the CRC-32 of the STUN message -// up to (but excluding) the FINGERPRINT attribute itself, XOR'ed with -// the 32-bit value 0x5354554e (the XOR helps in cases where an -// application packet is also using CRC-32 in it) -type Fingerprint struct { - Fingerprint uint32 -} - -const ( - fingerprintXOR uint32 = 0x5354554e - fingerprintLength uint16 = 4 -) - -func calculateFingerprint(b []byte) uint32 { - return crc32.ChecksumIEEE(b) ^ fingerprintXOR -} - -// Pack with Fingerprint -func (s *Fingerprint) Pack(message *Message) error { - prevLen := message.Length - message.Length += attrHeaderLength + fingerprintLength - message.CommitLength() - v := make([]byte, fingerprintLength) - enc.PutUint32(v, calculateFingerprint(message.Raw)) - message.Length = prevLen - - message.AddAttribute(AttrFingerprint, v) - return nil -} - -//Unpack with Fingerprint -func (s *Fingerprint) Unpack(message *Message, rawAttribute *RawAttribute) error { - - s.Fingerprint = enc.Uint32(rawAttribute.Value) - - expected := calculateFingerprint(message.Raw[:rawAttribute.Offset]) - - if expected != s.Fingerprint { - return errors.Errorf("fingerprint mismatch %v != %v (expected)", s.Fingerprint, expected) - } - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_ice_controlled.go b/vendor/github.com/pions/pkg/stun/attr_ice_controlled.go deleted file mode 100644 index 91d9b97..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_ice_controlled.go +++ /dev/null @@ -1,31 +0,0 @@ -package stun - -import ( - "github.com/pkg/errors" -) - -// IceControlled struct representated tiebreak -type IceControlled struct { - TieBreaker uint64 -} - -// Pack with TieBreak -func (i *IceControlled) Pack(message *Message) error { - v := make([]byte, 8) - enc.PutUint64(v, i.TieBreaker) - message.AddAttribute(AttrIceControlled, v) - return nil -} - -// Unpack with TieBreak -func (i *IceControlled) Unpack(message *Message, rawAttribute *RawAttribute) error { - v := rawAttribute.Value - - if len(v) != 8 { - return errors.Errorf("invalid TieBreaker length %d != %d (expected)", len(v), 8) - } - - i.TieBreaker = enc.Uint64(v) - - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_ice_controlling.go b/vendor/github.com/pions/pkg/stun/attr_ice_controlling.go deleted file mode 100644 index fa60065..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_ice_controlling.go +++ /dev/null @@ -1,31 +0,0 @@ -package stun - -import ( - "github.com/pkg/errors" -) - -// IceControlling struct representated tiebreak -type IceControlling struct { - TieBreaker uint64 -} - -// Pack with TieBreak -func (i *IceControlling) Pack(message *Message) error { - v := make([]byte, 8) - enc.PutUint64(v, i.TieBreaker) - message.AddAttribute(AttrIceControlling, v) - return nil -} - -// Unpack with TieBreak -func (i *IceControlling) Unpack(message *Message, rawAttribute *RawAttribute) error { - v := rawAttribute.Value - - if len(v) != 8 { - return errors.Errorf("invalid TieBreaker length %d != %d (expected)", len(v), 8) - } - - i.TieBreaker = enc.Uint64(v) - - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_lifetime.go b/vendor/github.com/pions/pkg/stun/attr_lifetime.go deleted file mode 100644 index cdcd1db..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_lifetime.go +++ /dev/null @@ -1,31 +0,0 @@ -package stun - -import ( - "github.com/pkg/errors" -) - -// Lifetime represented duration -type Lifetime struct { - Duration uint32 -} - -//Pack with Lifetime duration -func (x *Lifetime) Pack(message *Message) error { - v := make([]byte, 4) - enc.PutUint32(v, x.Duration) - message.AddAttribute(AttrLifetime, v) - return nil -} - -//Unpack with lifetime -func (x *Lifetime) Unpack(message *Message, rawAttribute *RawAttribute) error { - v := rawAttribute.Value - - if len(v) != 4 { - return errors.Errorf("invalid lifetime length %d != %d (expected)", len(v), 4) - } - - x.Duration = enc.Uint32(v) - - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_message_integrity.go b/vendor/github.com/pions/pkg/stun/attr_message_integrity.go deleted file mode 100644 index 52942db..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_message_integrity.go +++ /dev/null @@ -1,64 +0,0 @@ -package stun - -import ( - "crypto/hmac" - "crypto/sha1" - - "github.com/pkg/errors" -) - -// https://tools.ietf.org/html/rfc5389#section-15.4 -// The MESSAGE-INTEGRITY attribute contains an HMAC-SHA1 [RFC2104] of -// the STUN message. The MESSAGE-INTEGRITY attribute can be present in -// any STUN message type. Since it uses the SHA1 hash, the HMAC will be -// 20 bytes. The text used as input to HMAC is the STUN message, -// including the header, up to and including the attribute preceding the -// MESSAGE-INTEGRITY attribute. With the exception of the FINGERPRINT -// attribute, which appears after MESSAGE-INTEGRITY, agents MUST ignore -// all other attributes that follow MESSAGE-INTEGRITY. - -// Look into this -// https://tools.ietf.org/html/rfc7635#appendix-B - -const ( - messageIntegrityLength = 20 -) - -// MessageIntegrity is struct represented MESSAGE-INTEGRITY attribute rfc5389#section-15.4 -type MessageIntegrity struct { - Key []byte -} - -//MessageIntegrityCalculateHMAC returns hmac checksum -func MessageIntegrityCalculateHMAC(key, message []byte) ([]byte, error) { - mac := hmac.New(sha1.New, key) - if _, err := mac.Write(message); err != nil { - // Can we recover from this failure? - return nil, errors.Wrap(err, "unable to create message integrity HMAC") - } - return mac.Sum(nil), nil -} - -//Pack message with MessageIntegrity -func (m *MessageIntegrity) Pack(message *Message) error { - prevLen := message.Length - message.Length += attrHeaderLength + messageIntegrityLength - message.CommitLength() - v, err := MessageIntegrityCalculateHMAC(m.Key[:], message.Raw) - if err != nil { - return err - } - message.Length = prevLen - - message.AddAttribute(AttrMessageIntegrity, v) - return nil -} - -//Unpack copy from Key to rawAttribute.Value -func (m *MessageIntegrity) Unpack(message *Message, rawAttribute *RawAttribute) error { - if len(rawAttribute.Value) != messageIntegrityLength { - return errors.Errorf("MessageIntegrity bad key length %d", len(rawAttribute.Value)) - } - copy(m.Key[:], rawAttribute.Value[:]) - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_nonce.go b/vendor/github.com/pions/pkg/stun/attr_nonce.go deleted file mode 100644 index d99f54d..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_nonce.go +++ /dev/null @@ -1,37 +0,0 @@ -package stun - -import "github.com/pkg/errors" - -// https://tools.ietf.org/html/rfc5389#section-15.8 -// The NONCE attribute may be present in requests and responses. It -// contains a sequence of qdtext or quoted-pair, which are defined in -// RFC 3261 [RFC3261]. Note that this means that the NONCE attribute -// will not contain actual quote characters. See RFC 2617 [RFC2617], -// Section 4.3, for guidance on selection of nonce values in a server. -// -// It MUST be less than 128 characters (which can be as long as 763 -// bytes). - -// Nonce struct represented by NONCE attribute rfc5389#section-15.8 -type Nonce struct { - Nonce string -} - -const ( - nonceMaxLength = 763 -) - -//Pack with checking nonce max length -func (n *Nonce) Pack(message *Message) error { - if len([]byte(n.Nonce)) > nonceMaxLength { - return errors.Errorf("invalid nonce length %d", len([]byte(n.Nonce))) - } - message.AddAttribute(AttrNonce, []byte(n.Nonce)) - return nil -} - -//Unpack nonce -func (n *Nonce) Unpack(message *Message, rawAttribute *RawAttribute) error { - n.Nonce = string(rawAttribute.Value) - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_priority.go b/vendor/github.com/pions/pkg/stun/attr_priority.go deleted file mode 100644 index e59e202..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_priority.go +++ /dev/null @@ -1,31 +0,0 @@ -package stun - -import ( - "github.com/pkg/errors" -) - -// Priority is a STUN Priority message -type Priority struct { - Priority uint32 -} - -// Pack a STUN Priority message -func (p *Priority) Pack(message *Message) error { - v := make([]byte, 4) - enc.PutUint32(v, p.Priority) - message.AddAttribute(AttrPriority, v) - return nil -} - -// Unpack a STUN Priority message -func (p *Priority) Unpack(message *Message, rawAttribute *RawAttribute) error { - v := rawAttribute.Value - - if len(v) != 4 { - return errors.Errorf("invalid priority length %d != %d (expected)", len(v), 4) - } - - p.Priority = enc.Uint32(v) - - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_realm.go b/vendor/github.com/pions/pkg/stun/attr_realm.go deleted file mode 100644 index c6c0dd8..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_realm.go +++ /dev/null @@ -1,42 +0,0 @@ -package stun - -import "github.com/pkg/errors" - -// https://tools.ietf.org/html/rfc5389#section-15.7 -// The REALM attribute may be present in requests and responses. It -// contains text that meets the grammar for "realm-value" as described -// in RFC 3261 [RFC3261] but without the double quotes and their -// surrounding whitespace. That is, it is an unquoted realm-value (and -// is therefore a sequence of qdtext or quoted-pair). It MUST be a -// UTF-8 [RFC3629] encoded sequence of less than 128 characters (which -// can be as long as 763 bytes), and MUST have been processed using -// SASLprep [RFC4013]. -// -// Presence of the REALM attribute in a request indicates that long-term -// credentials are being used for authentication. Presence in certain -// error responses indicates that the server wishes the client to use a -// long-term credential for authentication. - -//Realm represented REALM attribute rfc5389#section-15.7 -type Realm struct { - Realm string -} - -const ( - realmMaxLength = 763 -) - -//Pack with checking realm max length -func (r *Realm) Pack(message *Message) error { - if len([]byte(r.Realm)) > realmMaxLength { - return errors.Errorf("invalid realm length %d", len([]byte(r.Realm))) - } - message.AddAttribute(AttrRealm, []byte(r.Realm)) - return nil -} - -//Unpack realm -func (r *Realm) Unpack(message *Message, rawAttribute *RawAttribute) error { - r.Realm = string(rawAttribute.Value) - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_requested_transport.go b/vendor/github.com/pions/pkg/stun/attr_requested_transport.go deleted file mode 100644 index 305b55b..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_requested_transport.go +++ /dev/null @@ -1,49 +0,0 @@ -package stun - -import "github.com/pkg/errors" - -type protocolNumber byte - -//ProtocolUDP User Datagram https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml -const ( - ProtocolUDP protocolNumber = 0x11 -) - -// A RequestedTransport is used by the client to request a specific transport -// protocol for the allocated transport address. The value of this -// attribute is 4 bytes with the following format: -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Protocol | RFFU | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// -// The Protocol field specifies the desired protocol. The codepoints -// used in this field are taken from those allowed in the Protocol field -// in the IPv4 header and the NextHeader field in the IPv6 header -// [Protocol-Numbers]. This specification only allows the use of -// codepoint 17 (User Datagram Protocol). -// -// The RFFU field MUST be set to zero on transmission and MUST be -// ignored on reception. It is reserved for future uses. -// https://tools.ietf.org/html/rfc5766#section-14.7 - -//RequestedTransport represented transport protocol -type RequestedTransport struct { - Protocol protocolNumber -} - -//Pack always error -func (r *RequestedTransport) Pack(message *Message) error { - return errors.Errorf("stun.RequestedTransport Pack not implemented") -} - -//Unpack RequestedTransport protocol -func (r *RequestedTransport) Unpack(message *Message, rawAttribute *RawAttribute) error { - r.Protocol = protocolNumber(rawAttribute.Value[0]) - if r.Protocol != ProtocolUDP { - return errors.Errorf("UDP is the only supported protocol for RequestedTransport") - } - - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_reservation_token.go b/vendor/github.com/pions/pkg/stun/attr_reservation_token.go deleted file mode 100644 index a374f5c..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_reservation_token.go +++ /dev/null @@ -1,37 +0,0 @@ -package stun - -import "github.com/pkg/errors" - -// https://tools.ietf.org/html/rfc5766#section-14.9 -// The RESERVATION-TOKEN attribute contains a token that uniquely -// identifies a relayed transport address being held in reserve by the -// server. The server includes this attribute in a success response to -// tell the client about the token, and the client includes this -// attribute in a subsequent Allocate request to request the server use -// that relayed transport address for the allocation. -// -// The attribute value is 8 bytes and contains the token value. - -// ReservationToken struct representated RESERVATION-TOKEN attribute rfc5766#section-14.9 -type ReservationToken struct { - ReservationToken string -} - -const ( - reservationTokenMaxLength = 8 -) - -// Pack with checking reservationTokenMaxLength -func (r *ReservationToken) Pack(message *Message) error { - if len([]byte(r.ReservationToken)) > reservationTokenMaxLength { - return errors.Errorf("invalid ReservationToken length %d", len([]byte(r.ReservationToken))) - } - message.AddAttribute(AttrReservationToken, []byte(r.ReservationToken)) - return nil -} - -// Unpack ReservationToken -func (r *ReservationToken) Unpack(message *Message, rawAttribute *RawAttribute) error { - r.ReservationToken = string(rawAttribute.Value) - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_software.go b/vendor/github.com/pions/pkg/stun/attr_software.go deleted file mode 100644 index b991628..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_software.go +++ /dev/null @@ -1,31 +0,0 @@ -package stun - -import "github.com/pkg/errors" - -// https://tools.ietf.org/html/rfc5389#section-15.10 -// The SOFTWARE attribute contains a textual description of the software -// being used by the agent sending the message - -// Software struct has SOFTWARE field that rfc5389#section-15.10 -type Software struct { - Software string -} - -const ( - softwareMaxLength = 763 -) - -// Pack with checking softwareMaxLength -func (s *Software) Pack(message *Message) error { - if len([]byte(s.Software)) > softwareMaxLength { - return errors.Errorf("invalid software length %d", len([]byte(s.Software))) - } - message.AddAttribute(AttrSoftware, []byte(s.Software)) - return nil -} - -// Unpack Software field -func (s *Software) Unpack(message *Message, rawAttribute *RawAttribute) error { - s.Software = string(rawAttribute.Value) - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_unknown_attributes.go b/vendor/github.com/pions/pkg/stun/attr_unknown_attributes.go deleted file mode 100644 index e12aae4..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_unknown_attributes.go +++ /dev/null @@ -1,56 +0,0 @@ -package stun - -import ( - "github.com/pkg/errors" -) - -// https://tools.ietf.org/html/rfc5389#section-15.9 -// The UNKNOWN-ATTRIBUTES attribute is present only in an error response -// when the response code in the ERROR-CODE attribute is 420. -// -// The attribute contains a list of 16-bit values, each of which -// represents an attribute type that was not understood by the server. -// -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Attribute 1 Type | Attribute 2 Type | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Attribute 3 Type | Attribute 4 Type ... -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// -// -// Figure 8: Format of UNKNOWN-ATTRIBUTES Attribute -// -// Note: In [RFC3489], this field was padded to 32 by duplicating the -// last attribute. In this version of the specification, the normal -// padding rules for attributes are used instead. - -// UnknownAttributes has several attrTypes -type UnknownAttributes struct { - Attributes []AttrType -} - -const ( - unknownAttributesMax = 4 -) - -// Pack AttrUnknownAttributes -func (u *UnknownAttributes) Pack(message *Message) error { - if len(u.Attributes) > unknownAttributesMax { - return errors.Errorf("UnknownAttributes only supports up to 4 attributes") - } - - var v [8]byte - for i, attr := range u.Attributes { - enc.PutUint16(v[i*2:], uint16(attr)) - } - - message.AddAttribute(AttrUnknownAttributes, v[0:]) - return nil -} - -// Unpack always returns error -func (u *UnknownAttributes) Unpack(message *Message, rawAttribute *RawAttribute) error { - return errors.Errorf("stun.UnknownAttributes Unpack not implemented") -} diff --git a/vendor/github.com/pions/pkg/stun/attr_use_candidate.go b/vendor/github.com/pions/pkg/stun/attr_use_candidate.go deleted file mode 100644 index 666b847..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_use_candidate.go +++ /dev/null @@ -1,18 +0,0 @@ -package stun - -// https://tools.ietf.org/html/draft-ietf-ice-rfc5245bis-20#section-16.1 - -// UseCandidate has no field struct -type UseCandidate struct { -} - -// Pack with use-candidate attribute -func (u *UseCandidate) Pack(message *Message) error { - message.AddAttribute(AttrUseCandidate, []byte{}) - return nil -} - -// Unpack use-candidate attribute -func (u *UseCandidate) Unpack(message *Message, rawAttribute *RawAttribute) error { - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_username.go b/vendor/github.com/pions/pkg/stun/attr_username.go deleted file mode 100644 index eb8dc35..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_username.go +++ /dev/null @@ -1,36 +0,0 @@ -package stun - -import "github.com/pkg/errors" - -// https://tools.ietf.org/html/rfc5389#section-15.3 -// The USERNAME attribute is used for message integrity. It identifies -// the username and password combination used in the message-integrity -// check. -// -// The value of USERNAME is a variable-length value. It MUST contain a -// UTF-8 [RFC3629] encoded sequence of less than 513 bytes, and MUST -// have been processed using SASLprep [RFC4013]. - -// Username struct -type Username struct { - Username string -} - -const ( - usernameMaxLength = 513 -) - -// Pack messsage using USERNAME attribute -func (u *Username) Pack(message *Message) error { - if len([]byte(u.Username)) > usernameMaxLength { - return errors.Errorf("invalid username length %d", len([]byte(u.Username))) - } - message.AddAttribute(AttrUsername, []byte(u.Username)) - return nil -} - -// Unpack message as USERNAME -func (u *Username) Unpack(message *Message, rawAttribute *RawAttribute) error { - u.Username = string(rawAttribute.Value) - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_xor_mapped_address.go b/vendor/github.com/pions/pkg/stun/attr_xor_mapped_address.go deleted file mode 100644 index 790a263..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_xor_mapped_address.go +++ /dev/null @@ -1,24 +0,0 @@ -package stun - -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// |x x x x x x x x| Family | X-Port | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | X-Address (Variable) -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - -//XorMappedAddress https://tools.ietf.org/html/rfc5389#section-15.2 -type XorMappedAddress struct { - XorAddress -} - -// Pack writes an XorMappedAddress into a message -func (x *XorMappedAddress) Pack(message *Message) error { - v, err := x.packInner(message) - if err != nil { - return err - } - message.AddAttribute(AttrXORMappedAddress, v) - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_xor_peer_address.go b/vendor/github.com/pions/pkg/stun/attr_xor_peer_address.go deleted file mode 100644 index d04a9ba..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_xor_peer_address.go +++ /dev/null @@ -1,21 +0,0 @@ -package stun - -// The XOR-PEER-ADDRESS specifies the address and port of the peer as -// seen from the TURN server. (For example, the peer's server-reflexive -// transport address if the peer is behind a NAT.) It is encoded in the -// same way as XOR-MAPPED-ADDRESS [RFC5389]. - -//XorPeerAddress include XorAddress which encoded in the same way as XOR-MAPPED-ADDRESS [RFC5389] -type XorPeerAddress struct { - XorAddress -} - -//Pack using XOR-PEER-ADDRESS -func (x *XorPeerAddress) Pack(message *Message) error { - v, err := x.packInner(message) - if err != nil { - return err - } - message.AddAttribute(AttrXORPeerAddress, v) - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attr_xor_relayed_address.go b/vendor/github.com/pions/pkg/stun/attr_xor_relayed_address.go deleted file mode 100644 index 3461fd6..0000000 --- a/vendor/github.com/pions/pkg/stun/attr_xor_relayed_address.go +++ /dev/null @@ -1,22 +0,0 @@ -package stun - -// https://tools.ietf.org/html/rfc5766#section-14.5 -// The XOR-RELAYED-ADDRESS is present in Allocate responses. It -// specifies the address and port that the server allocated to the -// client. It is encoded in the same way as XOR-MAPPED-ADDRESS -// [RFC5389] - -//XorRelayedAddress include XorAddress which encoded in the same way as XOR-MAPPED-ADDRESS [RFC5389] -type XorRelayedAddress struct { - XorAddress -} - -//Pack using XOR-RELAYED-ADDRESS -func (x *XorRelayedAddress) Pack(message *Message) error { - v, err := x.packInner(message) - if err != nil { - return err - } - message.AddAttribute(AttrXORRelayedAddress, v) - return nil -} diff --git a/vendor/github.com/pions/pkg/stun/attribute.go b/vendor/github.com/pions/pkg/stun/attribute.go deleted file mode 100644 index 2948f3e..0000000 --- a/vendor/github.com/pions/pkg/stun/attribute.go +++ /dev/null @@ -1,129 +0,0 @@ -package stun - -import ( - "fmt" -) - -// AttrType represents an attribute type -// https://tools.ietf.org/html/rfc5389#section-15 -type AttrType uint16 - -// STUN Attribute Registry - -// Comprehension-required range (0x0000-0x7FFF) -const ( - AttrMappedAddress AttrType = 0x0001 // STUN - AttrResponseAddress AttrType = 0x0002 // STUN Invalid - AttrChangeAddress AttrType = 0x0003 // STUN Invalid - AttrSourceAddress AttrType = 0x0004 // STUN Invalid - AttrChangedAddress AttrType = 0x0005 // STUN Invalid - AttrUsername AttrType = 0x0006 // STUN - AttrPassword AttrType = 0x0007 // STUN Invalid - AttrMessageIntegrity AttrType = 0x0008 // STUN - AttrErrorCode AttrType = 0x0009 // STUN - AttrUnknownAttributes AttrType = 0x000A // STUN - AttrReflectedFrom AttrType = 0x000B // STUN Invalid - AttrChannelNumber AttrType = 0x000C // TURN - AttrLifetime AttrType = 0x000D // TURN - AttrBandwidth AttrType = 0x0010 // TURN Invalid - AttrXORPeerAddress AttrType = 0x0012 // TURN - AttrData AttrType = 0x0013 // TURN - AttrXORRelayedAddress AttrType = 0x0016 // TURN - AttrEvenPort AttrType = 0x0018 // TURN - AttrRequestedTransport AttrType = 0x0019 // TURN - AttrDontFragment AttrType = 0x001A // TURN - AttrTimerVal AttrType = 0x0021 // TURN - AttrReservationToken AttrType = 0x0022 // TURN - AttrRealm AttrType = 0x0014 // STUN - AttrNonce AttrType = 0x0015 // STUN - AttrXORMappedAddress AttrType = 0x0020 // STUN -) - -// Comprehension-optional range (0x8000-0xFFFF): -const ( - AttrSoftware AttrType = 0x8022 // STUN - AttrAlternateServer AttrType = 0x8023 // STUN - AttrFingerprint AttrType = 0x8028 // STUN -) - -// https://tools.ietf.org/html/rfc5245#section-19.1 -// ICE STUN Attributes -const ( - AttrPriority AttrType = 0x0024 // STUN ICE - AttrUseCandidate AttrType = 0x0025 // STUN ICE - AttrIceControlled AttrType = 0x8029 // STUN ICE - AttrIceControlling AttrType = 0x802A // STUN ICE -) - -var attrNames = map[AttrType]string{ - AttrMappedAddress: "MAPPED-ADDRESS", - AttrResponseAddress: "RESPONSE-ADDRESS", - AttrChangeAddress: "CHANGE-ADDRESS", - AttrSourceAddress: "SOURCE-ADDRESS", - AttrChangedAddress: "CHANGED-ADDRESS", - AttrUsername: "USERNAME", - AttrPassword: "PASSWORD", - AttrErrorCode: "ERROR-CODE", - AttrMessageIntegrity: "MESSAGE-INTEGRITY", - AttrUnknownAttributes: "UNKNOWN-ATTRIBUTES", - AttrReflectedFrom: "REFLECTED-FROM", - AttrChannelNumber: "CHANNEL-NUMBER", - AttrLifetime: "LIFETIME", - AttrBandwidth: "BANDWIDTH", - AttrXORPeerAddress: "XOR-PEER-ADDRESS", - AttrData: "DATA", - AttrXORRelayedAddress: "XOR-RELAYED-ADDRESS", - AttrEvenPort: "EVEN-PORT", - AttrRequestedTransport: "REQUESTED-TRANSPORT", - AttrDontFragment: "DONT-FRAGMENT", - AttrTimerVal: "TIMER-VAL", - AttrReservationToken: "RESERVATION-TOKEN", - AttrRealm: "REALM", - AttrNonce: "NONCE", - AttrXORMappedAddress: "XOR-MAPPED-ADDRESS", - AttrSoftware: "SOFTWARE", - AttrAlternateServer: "ALTERNATE-SERVER", - AttrFingerprint: "FINGERPRINT", - AttrPriority: "PRIORITY", - AttrUseCandidate: "USE-CANDIDATE", - AttrIceControlled: "ICE-CONTROLLED", - AttrIceControlling: "ICE-CONTROLLING", -} - -const ( - attrHeaderLength = 4 - attrLengthStart = 2 - attrLengthLength = 2 - attrValueStart = 4 - attrLengthMultiple = 4 -) - -func getAttrPadding(len int) int { - return (attrLengthMultiple - (len % attrLengthMultiple)) % attrLengthMultiple -} - -func (t AttrType) String() string { - s, ok := attrNames[t] - if !ok { - // Just return hex representation of unknown attribute type. - return fmt.Sprintf("0x%x", uint16(t)) - } - return s -} - -// RawAttribute represents an unprocessed view of the TLV structure -// for an attribute -// https://tools.ietf.org/html/rfc5389#section-15 -type RawAttribute struct { - Type AttrType - Length uint16 - Value []byte - Pad uint16 - Offset int -} - -// Attribute can impliment Pack and Unpack -type Attribute interface { - Pack(message *Message) error - Unpack(message *Message, rawAttribute *RawAttribute) error -} diff --git a/vendor/github.com/pions/pkg/stun/channel_data.go b/vendor/github.com/pions/pkg/stun/channel_data.go deleted file mode 100644 index 9bb9d39..0000000 --- a/vendor/github.com/pions/pkg/stun/channel_data.go +++ /dev/null @@ -1,41 +0,0 @@ -package stun - -import ( - "github.com/pkg/errors" -) - -//ChannelData is struct including ChannelNumber and Data -type ChannelData struct { - ChannelNumber uint16 - Length uint16 - Data []byte -} - -//NewChannelData return ChannelData from packet -func NewChannelData(packet []byte) (*ChannelData, error) { - cn, err := getChannelNumber(packet) - if err != nil { - return nil, err - } - - return &ChannelData{ - ChannelNumber: cn, - Length: getChannelLength(packet), - Data: packet[4:], - }, nil -} - -// 0b01: ChannelData message (since the channel number is the first -// field in the ChannelData message and channel numbers fall in the -// range 0x4000 - 0x7FFF). -func getChannelNumber(header []byte) (uint16, error) { - cn := enc.Uint16(header) - if cn < 0x4000 || cn > 0x7FFF { - return 0, errors.Errorf("ChannelNumber is out of range: %d", cn) - } - return cn, nil -} - -func getChannelLength(header []byte) uint16 { - return enc.Uint16(header[2:]) -} diff --git a/vendor/github.com/pions/pkg/stun/client.go b/vendor/github.com/pions/pkg/stun/client.go deleted file mode 100644 index 628ee4a..0000000 --- a/vendor/github.com/pions/pkg/stun/client.go +++ /dev/null @@ -1,77 +0,0 @@ -package stun - -import ( - "net" - "time" - - "github.com/pkg/errors" -) - -var ( - maxMessageSize = 1280 - - // ErrResponseTooBig is returned if more than maxMessageSize bytes are returned in the response - // see https://tools.ietf.org/html/rfc5389#section-7 for the size limit - ErrResponseTooBig = errors.New("received too much data") -) - -// Client is a STUN client that sents STUN requests and receives STUN responses -type Client struct { - conn net.Conn -} - -// NewClient creates a configured STUN client -func NewClient(protocol, server string, deadline time.Duration) (*Client, error) { - dialer := &net.Dialer{ - Timeout: deadline, - } - conn, err := dialer.Dial(protocol, server) - if err != nil { - return nil, err - } - err = conn.SetReadDeadline(time.Now().Add(deadline)) - if err != nil { - return nil, err - } - err = conn.SetWriteDeadline(time.Now().Add(deadline)) - if err != nil { - return nil, err - } - return &Client{ - conn: conn, - }, nil -} - -// LocalAddr returns local address of the client -func (c *Client) LocalAddr() net.Addr { - return c.conn.LocalAddr() -} - -// Close disconnects the client -func (c *Client) Close() error { - return c.conn.Close() -} - -// Request executes a STUN request against the clients server -func (c *Client) Request() (*Message, error) { - req, err := Build(ClassRequest, MethodBinding, GenerateTransactionId()) - if err != nil { - return nil, err - } - - _, err = c.conn.Write(req.Pack()) - if err != nil { - return nil, err - } - - bs := make([]byte, maxMessageSize) - n, err := c.conn.Read(bs) - if err != nil { - return nil, err - } - if n > maxMessageSize { - return nil, ErrResponseTooBig - } - - return NewMessage(bs[:n]) -} diff --git a/vendor/github.com/pions/pkg/stun/encoding.go b/vendor/github.com/pions/pkg/stun/encoding.go deleted file mode 100644 index 4ceb27b..0000000 --- a/vendor/github.com/pions/pkg/stun/encoding.go +++ /dev/null @@ -1,9 +0,0 @@ -package stun - -import "encoding/binary" - -// STUN expects all messages to be BigEndian encoded - -var ( - enc = binary.BigEndian -) diff --git a/vendor/github.com/pions/pkg/stun/message.go b/vendor/github.com/pions/pkg/stun/message.go deleted file mode 100644 index 0f0ba44..0000000 --- a/vendor/github.com/pions/pkg/stun/message.go +++ /dev/null @@ -1,383 +0,0 @@ -package stun - -import ( - "fmt" - "math/rand" - - "github.com/pkg/errors" - "golang.org/x/net/ipv4" -) - -// MessageClass of 0b00 is a request, a class of 0b01 is an -// indication, a class of 0b10 is a success response, and a class of -// 0b11 is an error response. -// https://tools.ietf.org/html/rfc5389#section-6 -type MessageClass byte - -const ( - // ClassRequest describes a request method type - ClassRequest MessageClass = 0x00 - // ClassIndication describes an indication method type - ClassIndication MessageClass = 0x01 - // ClassSuccessResponse describes an success response method type - ClassSuccessResponse MessageClass = 0x02 - // ClassErrorResponse describes an error response method type - ClassErrorResponse MessageClass = 0x03 -) - -// Method is selector which can be select MethodType -type Method uint16 - -//Method Type -const ( - MethodBinding Method = 0x01 // STUN - MethodSharedSecret Method = 0x02 // STUN - MethodAllocate Method = 0x03 // TURN (Req/Rsp) - MethodRefresh Method = 0x04 // TURN (Req/Rsp) - MethodSend Method = 0x06 // TURN (Ind) - MethodData Method = 0x07 // TURN (Ind) - MethodCreatePermission Method = 0x08 // TURN (Req/Rsp) - MethodChannelBind Method = 0x09 // TURN (Req/Rsp) -) - -var messageClassName = map[MessageClass]string{ - ClassRequest: "REQUEST", - ClassIndication: "INDICATION", - ClassSuccessResponse: "SUCCESS-RESPONSE", - ClassErrorResponse: "ERROR-RESPONSE", -} - -// String prints the known class names and a hex format for unknown class names -func (m MessageClass) String() string { - s, err := messageClassName[m] - if !err { - // Falling back to hex representation. - s = fmt.Sprintf("Unk 0x%x", uint16(m)) - } - return s -} - -var methodName = map[Method]string{ - MethodBinding: "BINDING", - MethodSharedSecret: "SHARED-SECRET", - MethodAllocate: "ALLOCATE", - MethodRefresh: "REFRESH", - MethodSend: "SEND", - MethodData: "DATA", - MethodCreatePermission: "CREATE-PERMISSION", - MethodChannelBind: "CHANNEL-BIND", -} - -// String prints the known method names and a hex format for unknown method names -func (m Method) String() string { - s, err := methodName[m] - if !err { - s = fmt.Sprintf("Unk 0x%x", uint16(m)) - } - return s -} - -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// |0 0| STUN Message Type | Message Length | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Magic Cookie | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | | -// | Transaction ID (96 bits) | -// | | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// - -const ( - messageHeaderStart int = 0 - messageHeaderLength int = 20 - messageLengthStart int = 2 - messageLengthLength int = 2 - magicCookieStart int = 4 - magicCookieLength int = 4 - transactionIDStart int = 4 - transactionIDLength int = 16 - - // TransactionIDSize is the size of the transaction according to RFC 5389: 96 bits - TransactionIDSize = 96 / 8 -) - -// Message structs -type Message struct { - Class MessageClass - Method Method - Length uint16 - TransactionID []byte - Attributes []*RawAttribute - Raw []byte -} - -// The most significant 2 bits of every STUN message MUST be zeroes. -// This can be used to differentiate STUN packets from other protocols -// when STUN is multiplexed with other protocols on the same port. -// https://tools.ietf.org/html/rfc5389#section-6 -func verifyStunHeaderMostSignificant2Bits(header []byte) bool { - return (header[0] >> 6) == 0 -} - -func verifyMagicCookie(header []byte) error { - const magicCookie = 0x2112A442 - c := header[magicCookieStart : magicCookieStart+magicCookieLength] - if enc.Uint32(c) != magicCookie { - return errors.Errorf("stun header magic cookie invalid; %v != %v (expected)", enc.Uint32(c), magicCookie) - } - return nil -} - -// The message length MUST contain the size, in bytes, of the message -// not including the 20-byte STUN header. Since all STUN attributes are -// padded to a multiple of 4 bytes, the last 2 bits of this field are -// always zero. This provides another way to distinguish STUN packets -// from packets of other protocols. -// https://tools.ietf.org/html/rfc5389#section-6 -func getMessageLength(header []byte) (uint16, error) { - messageLength := enc.Uint16(header[messageLengthStart : messageLengthStart+messageLengthLength]) - if messageLength%4 != 0 { - return 0, errors.Errorf("stun header message length must be a factor of 4 (%d)", messageLength) - } - - return messageLength, nil -} - -// 0 1 -// 2 3 4 5 6 7 8 9 0 1 2 3 4 5 -// -// +--+--+-+-+-+-+-+-+-+-+-+-+-+-+ -// |M |M |M|M|M|C|M|M|M|C|M|M|M|M| -// |11|10|9|8|7|1|6|5|4|0|3|2|1|0| -// +--+--+-+-+-+-+-+-+-+-+-+-+-+-+ -const ( - c0Mask = 0x10 // 0b10000 - c1Mask = 0x01 // 0b00001 - c0ShiftR = 4 // R 0b10000 -> 0b00001 - c1ShiftL = 1 // L 0b00001 -> 0b00010 - - m0Mask = 0x0F // 0b00001111 - m4Mask = 0xE0 // 0b11100000 - m7Mask = 0x3E // 0b00111110 - m4ShiftR = 1 // R 0b01110000 -> 0b00111000 - m7ShiftL = 5 // L 0b00111110 -> 0b0000011111000000 -) - -func setMessageType(header []byte, class MessageClass, method Method) { - m := uint16(method) - c := uint16(class) - - mt := m & m0Mask - // Make room for c0 - mt |= (m & (m4Mask >> m4ShiftR)) << 1 - mt |= (m & (m7Mask << 6)) << 2 - mt |= (c & 0x1) << 4 - mt |= (c >> 1) << 8 - - enc.PutUint16(header[messageHeaderStart:], mt) -} - -func getMessageType(header []byte) (MessageClass, Method) { - mByte0 := header[0] - mByte1 := header[1] - - c0 := (mByte1 & c0Mask) >> c0ShiftR - c1 := (mByte0 & c1Mask) << c1ShiftL - - class := MessageClass(c1 | c0) - - m := (uint16(mByte0) & m7Mask) << m7ShiftL - m |= uint16(mByte1 & m0Mask) - m |= uint16((mByte1 & m4Mask) >> m4ShiftR) - - method := Method(m) - - return class, method -} - -// 0 1 2 3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Type | Length | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Value (variable) .... -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -func getAttribute(attribute []byte, offset int) *RawAttribute { - typ := AttrType(enc.Uint16(attribute)) - len := enc.Uint16(attribute[attrLengthStart : attrLengthStart+attrLengthLength]) - pad := (attrLengthMultiple - (len % attrLengthMultiple)) % attrLengthMultiple - return &RawAttribute{typ, len, attribute[attrValueStart : attrValueStart+len], pad, offset} -} - -// IsSTUN determines if a package is likely a STUN package -// Used for de-multiplexing STUN packages -func IsSTUN(packet []byte) bool { - if len(packet) < 20 { - return false - } - - header := packet[messageHeaderStart : messageHeaderStart+messageHeaderLength] - - if !verifyStunHeaderMostSignificant2Bits(header) { - return false - } - - return verifyMagicCookie(header) == nil -} - -// NewMessage parses a binary STUN message into a Message struct -// TODO Break this apart, too big -func NewMessage(packet []byte) (*Message, error) { - - if len(packet) < 20 { - return nil, errors.Errorf("stun header must be at least 20 bytes, was %d", len(packet)) - } - - header := packet[messageHeaderStart : messageHeaderStart+messageHeaderLength] - - if !verifyStunHeaderMostSignificant2Bits(header) { - return nil, errors.New("stun header most significant 2 bits must equal 0b00") - } - - err := verifyMagicCookie(header) - if err != nil { - return nil, errors.Wrap(err, "stun header invalid") - } - - ml, err := getMessageLength(header) - if err != nil { - return nil, errors.Wrap(err, "stun header invalid") - } - - if len(packet) != messageHeaderLength+int(ml) { - return nil, errors.Errorf("stun header length invalid; %d != %d (expected)", messageHeaderLength+int(ml), len(packet)) - } - - t := header[transactionIDStart : transactionIDStart+transactionIDLength] - - class, method := getMessageType(header) - - ra := []*RawAttribute{} - // TODO Check attr length <= attr slice remaining - attr := packet[messageHeaderLength:] - for len(attr) > 0 { - a := getAttribute(attr, cap(packet)-cap(attr)) - attr = attr[attrValueStart+a.Length+a.Pad:] - ra = append(ra, a) - } - - m := Message{} - m.Class = class - m.Method = method - m.Length = ml - m.TransactionID = t[0:transactionIDLength] - m.Attributes = ra - m.Raw = packet - - return &m, nil -} - -// GetOneAttribute can get a RawAttribute which adopts attrbute type -func (m *Message) GetOneAttribute(attrType AttrType) (*RawAttribute, bool) { - for _, v := range m.Attributes { - if v.Type == attrType { - return v, true - } - } - - return nil, false -} - -// GetAllAttributes can get all RawAttributes which adopt attrbute type -func (m *Message) GetAllAttributes(attrType AttrType) ([]*RawAttribute, bool) { - var attrs []*RawAttribute - for _, v := range m.Attributes { - if v.Type == attrType { - attrs = append(attrs, v) - } - } - - return attrs, len(attrs) > 0 -} - -// CommitLength returns message length -func (m *Message) CommitLength() { - enc.PutUint16(m.Raw[messageLengthStart:], uint16(m.Length)) -} - -// AddAttribute append bytes formatted RawAttribute to message -func (m *Message) AddAttribute(attrType AttrType, v []byte) { - - ra := RawAttribute{ - Type: attrType, - Value: v, - Pad: uint16(getAttrPadding(len(v))), - Length: uint16(len(v)), - Offset: int(m.Length), - } - - a := make([]byte, attrHeaderLength+ra.Length+ra.Pad) - - enc.PutUint16(a, uint16(ra.Type)) - enc.PutUint16(a[attrLengthStart:attrLengthStart+attrLengthLength], ra.Length) - - copy(a[attrValueStart:], ra.Value) - - m.Attributes = append(m.Attributes, &ra) - m.Raw = append(m.Raw, a...) - m.Length += uint16(len(a)) - m.CommitLength() -} - -// Pack returns Message.Raw -func (m *Message) Pack() []byte { - - setMessageType(m.Raw[messageHeaderStart:2], m.Class, m.Method) - m.CommitLength() - copy(m.Raw[transactionIDStart:], m.TransactionID) - - return m.Raw -} - -// BuildAndSend is building message, pack using attribute and send -func BuildAndSend(conn *ipv4.PacketConn, addr *TransportAddr, class MessageClass, method Method, transactionID []byte, attrs ...Attribute) error { - - rsp, err := Build(class, method, transactionID, attrs...) - if err != nil { - return err - } - - b := rsp.Pack() - l, err := conn.WriteTo(b, nil, addr.Addr()) - if err != nil { - return errors.Wrap(err, "failed writing to socket") - } - - if l != len(b) { - return errors.Errorf("packet write smaller than packet %d != %d (expected)", l, len(b)) - } - - return nil -} - -// GenerateTransactionId returns 16bytes ids -func GenerateTransactionId() []byte { - randSeq := func(n int) string { - letters := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") - b := make([]rune, n) - for i := range b { - b[i] = letters[rand.Intn(len(letters))] - } - return string(b) - } - - transactionID := []byte(randSeq(16)) - transactionID[0] = 33 - transactionID[1] = 18 - transactionID[2] = 164 - transactionID[3] = 66 - return transactionID -} diff --git a/vendor/github.com/pions/pkg/stun/message_builder.go b/vendor/github.com/pions/pkg/stun/message_builder.go deleted file mode 100644 index 56f5185..0000000 --- a/vendor/github.com/pions/pkg/stun/message_builder.go +++ /dev/null @@ -1,30 +0,0 @@ -package stun - -import ( - "github.com/pkg/errors" -) - -// Build return messsage which is built from class, method, transactionID, and pack message using attribute -func Build(class MessageClass, method Method, transactionID []byte, attrs ...Attribute) (*Message, error) { - - m := &Message{ - Class: class, - Method: method, - TransactionID: transactionID, - } - - m.Raw = make([]byte, messageHeaderLength) - - setMessageType(m.Raw[messageHeaderStart:2], class, method) - - copy(m.Raw[transactionIDStart:], m.TransactionID) - - for _, v := range attrs { - err := v.Pack(m) - if err != nil { - return nil, errors.Wrap(err, "failed packing attribute") - } - } - - return m, nil -} diff --git a/vendor/github.com/pions/pkg/stun/packet.go b/vendor/github.com/pions/pkg/stun/packet.go deleted file mode 100644 index 62654db..0000000 --- a/vendor/github.com/pions/pkg/stun/packet.go +++ /dev/null @@ -1,29 +0,0 @@ -package stun - -import ( - "github.com/pkg/errors" -) - -// PacketType is whether STUN or ChannelData -type PacketType int - -// PacketTypes -const ( - PacketTypeSTUN PacketType = iota - PacketTypeChannelData PacketType = iota -) - -// GetPacketType returns PacketType(whether STUN or ChannelData) -func GetPacketType(packet []byte) (PacketType, error) { - if len(packet) < 2 { - return 0, errors.Errorf("Packet is too short to determine type: %d", len(packet)) - } - - if verifyStunHeaderMostSignificant2Bits(packet) { - return PacketTypeSTUN, nil - } else if _, err := getChannelNumber(packet); err == nil { - return PacketTypeChannelData, nil - } - - return 0, errors.Errorf("%08b %08b", packet[0], packet[1]) -} diff --git a/vendor/github.com/pions/pkg/stun/transport_addr.go b/vendor/github.com/pions/pkg/stun/transport_addr.go deleted file mode 100644 index 4e839f2..0000000 --- a/vendor/github.com/pions/pkg/stun/transport_addr.go +++ /dev/null @@ -1,64 +0,0 @@ -package stun - -import ( - "fmt" - "net" - "strconv" - - "github.com/pkg/errors" -) - -// TransportAddr is struct with ip address and port number -type TransportAddr struct { - IP net.IP - Port int - //Zone string (udpv6, tcpv6) - //Network string (udp, tcp) -} - -func netAddrIPPort(addr net.Addr) (net.IP, int, error) { - host, portStr, err := net.SplitHostPort(addr.String()) - if err != nil { - return nil, 0, err - } - port, err := strconv.Atoi(portStr) - if err != nil { - return nil, 0, err - } - - return net.ParseIP(host), port, nil -} - -// NewTransportAddr returns transportadd struct within address and port -func NewTransportAddr(addr net.Addr) (*TransportAddr, error) { - ip, port, err := netAddrIPPort(addr) - if err != nil { - return nil, errors.Wrap(err, "unable to parse addr") - } - - return &TransportAddr{ - IP: ip, - Port: port, - }, nil -} - -// Equal returns both of address and port is same -func (a *TransportAddr) Equal(b *TransportAddr) bool { - return a.IP.Equal(b.IP) && a.Port == b.Port -} - -// Addr returns net.UDPAddr from TransportAddr -func (a *TransportAddr) Addr() net.Addr { - return &net.UDPAddr{ - IP: a.IP, - Port: a.Port, - //Zone: a.Zone, // udpv6 - } - - // Handle other network types here (TCPv4/6) -} - -// String returns "address:port" -func (a *TransportAddr) String() string { - return fmt.Sprintf("%s:%d", a.IP.String(), a.Port) -} diff --git a/vendor/github.com/pions/pkg/stun/xor_address.go b/vendor/github.com/pions/pkg/stun/xor_address.go deleted file mode 100644 index 4bf724c..0000000 --- a/vendor/github.com/pions/pkg/stun/xor_address.go +++ /dev/null @@ -1,152 +0,0 @@ -package stun - -import ( - "io" - "net" - - "github.com/pkg/errors" -) - -// Clipped from net.IP -// Is p all zeros? -func isZeros(p net.IP) bool { - for i := 0; i < len(p); i++ { - if p[i] != 0 { - return false - } - } - return true -} - -// Clipped from net.IP -// To4 converts the IPv4 address ip to a 4-byte representation. -// If ip is not an IPv4 address, To4 returns nil. -func toIPv4(ip net.IP) net.IP { - if len(ip) == net.IPv4len { - return ip - } - if len(ip) == net.IPv6len && - isZeros(ip[0:10]) && - ip[10] == 0xff && - ip[11] == 0xff { - return ip[12:16] - } - return nil -} - -func xor(dst, l, r []byte) { - n := len(l) - if len(r) < n { - n = len(r) - } - for i := 0; i < n; i++ { - dst[i] = l[i] ^ r[i] - } -} - -// https://tools.ietf.org/html/rfc5389#section-15.1 -// The address family can take on the following values: -// 0x01:IPv4 -// 0x02:IPv6 -const ( - familyIPv4 uint16 = 0x01 - familyIPv6 uint16 = 0x02 -) - -const ( - familyStart = 0 - // family length is actually 1 byte, but the preceding byte in the header must be all zero according - // to https://tools.ietf.org/html/rfc5389#section-15.1 - familyLength = 2 - portStart = 2 - portLength = 2 - addressStart = 4 -) - -func getIPAndFamily(unkIP net.IP) (ip net.IP, family uint16, err error) { - ip = unkIP - family = familyIPv4 - - if len(ip) == net.IPv6len { - ipv4 := toIPv4(ip) - if ipv4 != nil { - ip = ipv4 - } else { - family = familyIPv6 - } - } else if len(ip) != net.IPv4len { - err = errors.Errorf("invalid IP length %d", len(ip)) - } - - return ip, family, err -} - -// XorAddress is struct with in ip address and port number -type XorAddress struct { - IP net.IP - Port int -} - -func (x *XorAddress) packInner(message *Message) ([]byte, error) { - ip, family, err := getIPAndFamily(x.IP) - if err != nil { - return []byte{}, errors.Wrap(err, "unable to get IP and family") - } - - len := familyLength + portLength + len(ip) - v := make([]byte, len) - - // Family - enc.PutUint16(v[familyStart:familyStart+familyLength], family) - // Port - enc.PutUint16(v[portStart:portStart+portLength], uint16(x.Port)) - xor(v[portStart:portStart+portLength], v[portStart:portStart+portLength], message.TransactionID[0:2]) - // Address - copy(v[addressStart:], ip) - xor(v[addressStart:], v[addressStart:], message.TransactionID) - - return v, nil -} - -// Unpack message checking address and port suites -func (x *XorAddress) Unpack(message *Message, rawAttribute *RawAttribute) error { - v := rawAttribute.Value - - if len(v) < familyStart+familyLength { - return io.ErrUnexpectedEOF - } - - family := enc.Uint16(v[familyStart : familyStart+familyLength]) - - if family != familyIPv4 && family != familyIPv6 { - return errors.Errorf("invalid family %d (expected IPv4(%d) or IPv6(%d)", family, familyIPv4, familyIPv6) - } - - if len(v[portStart:]) < portLength { - return io.ErrUnexpectedEOF - } - - var p [2]byte - // Transaction ID [0,2] is top half of magic cookie - xor(p[:], v[portStart:portStart+portLength], message.TransactionID[0:2]) - - x.Port = int(enc.Uint16(p[:])) - - al := net.IPv4len - if family == familyIPv6 { - al = net.IPv6len - } - - if len(v[addressStart:]) < al { - return io.ErrUnexpectedEOF - } - - if len(v[addressStart:]) > al { - return errors.Errorf("invalid length for %d family address (%d)", family, len(v[4:])) - } - - x.IP = make([]byte, al) - xor(x.IP[:], v[4:], message.TransactionID) - - return nil -} diff --git a/vendor/github.com/pions/webrtc/.codacy.yaml b/vendor/github.com/pions/webrtc/.codacy.yaml deleted file mode 100644 index 2fd9877..0000000 --- a/vendor/github.com/pions/webrtc/.codacy.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -exclude_paths: - - examples/examples.json \ No newline at end of file diff --git a/vendor/github.com/pions/webrtc/.eslintrc.json b/vendor/github.com/pions/webrtc/.eslintrc.json deleted file mode 100644 index a755cdb..0000000 --- a/vendor/github.com/pions/webrtc/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["standard"] -} diff --git a/vendor/github.com/pions/webrtc/.gitignore b/vendor/github.com/pions/webrtc/.gitignore deleted file mode 100644 index 40ab633..0000000 --- a/vendor/github.com/pions/webrtc/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -### JetBrains IDE ### -##################### -.idea/ - -### Emacs Temporary Files ### -############################# -*~ - -### Folders ### -############### -bin/ -vendor/ - -### Files ### -############# -*.ivf -tags \ No newline at end of file diff --git a/vendor/github.com/pions/webrtc/.golangci.yml b/vendor/github.com/pions/webrtc/.golangci.yml deleted file mode 100644 index 4cbc30e..0000000 --- a/vendor/github.com/pions/webrtc/.golangci.yml +++ /dev/null @@ -1,15 +0,0 @@ -linters-settings: - govet: - check-shadowing: true - misspell: - locale: US - -linters: - enable-all: true - disable: - - maligned - - lll - - dupl - -issues: - exclude-use-default: false diff --git a/vendor/github.com/pions/webrtc/.travis.yml b/vendor/github.com/pions/webrtc/.travis.yml deleted file mode 100644 index c9fd4d4..0000000 --- a/vendor/github.com/pions/webrtc/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: go - -go: - - "1.x" # use the latest Go release - -notifications: - email: false - slack: - secure: IYjXoe03KykZ3v4GgUwGzfWRepO5DnJdxB87lSQ2IMsF6PBFSc3CaOX3GUclHIlzTdchR+PHj1jtEZZVSkgfp9amZBCcqbJTBOPG1YA6hxOvTpgeWIttMH0cmMxSCuCa4RfkuRH2+UXbjREMJ3ENau2CTMKReyW4Jddh9dREZohVmYuqN6uuBqCndYpt3Lm1Hv+T+vqxwTDdE/q0hwGMiwgvQm7N3K397e1q1mg+o4tMGwqyUIPnEPjaSKcEuOBa8Rqyl96nn+HGZK0zvNqUOxlzeRMM0VBcxe2s+zY/SuLj4OwNl1zEmIfY6Qj70t2cmT3xJvJprB4pCwR7q78b4lfpNu6rqCJPIZG/qDFT+XSuhDCmLlCO/+Uhtu11pgjV8UMNLTKJth+7hurH7oLNb7jYk9VYsiKhs41LICyDjJNzS5yPatF5xj0HOujb6Uh/pfI+9a+IpPSeXv1gBo8H3oWa6TfRhuTUS3Jc48p/jriZmgWgbKa1HKTaY9ENvAdZFfxJdrRg3Y4SKnjZcAPw7ijRIx1oaM3rHYbOTm/dj4ggho7EgTO3k8toQ5PKohrbBG5RERqHJvC47SXDt0fEjeGnAfN7Xtj0Pq8YyaFIj7CmCCGoI//2sWkK3AmjnwIuW0hUMsL3GsED+p0lsu6FX9wysJwy2Z2mTfIX/CXmB6w= - -before_install: - - sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev - -before_script: - - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.10.2 - - go get github.com/mattn/goveralls - -script: - - bash .github/build-examples.sh - - rm -rf examples - # Remove examples, no test coverage for them - - golangci-lint run - - goveralls -v -race -covermode=atomic -service=travis-ci - - bash .github/assert-contributors.sh - - bash .github/lint-disallowed-functions-in-library.sh - - bash .github/lint-commit-message.sh diff --git a/vendor/github.com/pions/webrtc/CONTRIBUTING.md b/vendor/github.com/pions/webrtc/CONTRIBUTING.md deleted file mode 100644 index 7bb5a4d..0000000 --- a/vendor/github.com/pions/webrtc/CONTRIBUTING.md +++ /dev/null @@ -1,5 +0,0 @@ -

- Contributing -

- -Moved to the **[contributing wiki](https://github.com/pions/webrtc/wiki/Contributing)**. diff --git a/vendor/github.com/pions/webrtc/DESIGN.md b/vendor/github.com/pions/webrtc/DESIGN.md deleted file mode 100644 index 39a052f..0000000 --- a/vendor/github.com/pions/webrtc/DESIGN.md +++ /dev/null @@ -1,37 +0,0 @@ -

- Design -

-WebRTC is a powerful, but complicated technology. You can build amazing things with it comes with a steep learning curve though. -Using WebRTC in the browser is easy, but outside the browser is more of a challenge. There are multiple libraries, and they all have -varying levels of quality. Most are also difficult to build, and depend on libraries that aren't available in repos or portable. - -Pion WebRTC aims to solve all that! Built in native Go you should be able to send and receive media and text from anywhere with minimal headache. -These are the design principals that drive Pion WebRTC and hopefully convince you it is worth a try. - -### Portable -Pion WebRTC is written in Go and extremely portable. Anywhere Golang runs, Pion WebRTC should work as well! Instead of dealing with complicated -cross-compiling of multiple libraries, you now can run anywhere with one `go build` - -### Simple API -If you know how to use WebRTC in your browser, you know how to use Pion WebRTC. -We try our best just to duplicate the Javascript API, so your code can look the same everywhere. - -If this is your first time using WebRTC, don't worry! We have multiple [examples](https://github.com/pions/webrtc/tree/master/examples) and [GoDoc](https://godoc.org/github.com/pions/webrtc) - -### Bring your own media -Pion WebRTC doesn't make any assumptions about where your audio, video or text come from. You can use FFmpeg, GStreamer, MLT or just serve a video file. -This library only serves to transport, not create media. - -### Safe -Golang provides a great foundation to build safe network services. -Especially when running a networked service that is highly concurrent bugs can be devastating. - -### Readable -If code comes from an RFC we try to make sure everything is commented with a link to the spec. -This makes learning and debugging easier, this WebRTC library was written to also serve as a guide for others. - -### Tested -Every commit is tested via travis-ci Go provides fantastic facilities for testing, and more will be added as time goes on. - -### Shared libraries -Every pion product is built using shared libraries, allowing others to review and reuse our libraries. diff --git a/vendor/github.com/pions/webrtc/LICENSE b/vendor/github.com/pions/webrtc/LICENSE deleted file mode 100644 index ab60297..0000000 --- a/vendor/github.com/pions/webrtc/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/pions/webrtc/README.md b/vendor/github.com/pions/webrtc/README.md deleted file mode 100644 index a47e2ce..0000000 --- a/vendor/github.com/pions/webrtc/README.md +++ /dev/null @@ -1,77 +0,0 @@ -

- Pion WebRTC -
- Pion WebRTC -
-

-

A pure Go implementation of the WebRTC API

-

- Pion webrtc - Sourcegraph Widget - Slack Widget - Waffle board -
- Build Status - GoDoc - Coverage Status - Go Report Card - Codacy Badge - License: MIT -

-
- -See [DESIGN.md](DESIGN.md) for an overview of features and future goals. - -### Usage -Check out the **[example applications](examples/README.md)** to help you along your Pion WebRTC journey. - -The Pion WebRTC API closely matches the JavaScript **[WebRTC API](https://w3c.github.io/webrtc-pc/)**. Most existing documentation is therefore also usefull when working with Pion. Furthermore, our **[GoDoc](https://godoc.org/github.com/pions/webrtc)** is actively maintained. - -Now go forth and build some awesome apps! Here are some **ideas** to get your creative juices flowing: -* Send a video file to multiple browser in real time for perfectly synchronized movie watching. -* Send a webcam on an embedded device to your browser with no additional server required! -* Securely send data between two servers, without using pub/sub. -* Record your webcam and do special effects server side. -* Build a conferencing application that processes audio/video and make decisions off of it. - -### Roadmap -The library is in active development, please refer to the [roadmap](https://github.com/pions/webrtc/issues/9) to track our major milestones. - -### Community -Pion has an active community on the [Golang Slack](https://invite.slack.golangbridge.org/). Sign up and join the **#pion** channel for discussions and support. You can also use [Pion mailing list](https://groups.google.com/forum/#!forum/pion). - -We are always looking to support **your projects**. Please reach out if you have something to build! - -If you need commercial support or don't want to use public methods you can contact us at [team@pion.ly](mailto:team@pion.ly) - -### Related projects -* [pions/turn](https://github.com/pions/turn): A simple extendable Golang TURN server -* [WIP] [pions/media-server](https://github.com/pions/media-server): A Pion WebRTC powered media server, providing the building blocks for anything RTC. -* [WIP] [pions/dcnet](https://github.com/pions/dcnet): A package providing Golang [net](https://godoc.org/net) interfaces around Pion WebRTC data channels. - -### Contributing -Check out the **[contributing wiki](https://github.com/pions/webrtc/wiki/Contributing)** to join the group of amazing people making this project possible: - -* [John Bradley](https://github.com/kc5nra) - *Original Author* -* [Michael Melvin Santry](https://github.com/santrym) - *Mascot* -* [Raphael Randschau](https://github.com/nicolai86) - *STUN* -* [Sean DuBois](https://github.com/Sean-Der) - *Original Author* -* [Michiel De Backker](https://github.com/backkem) - *SDP, Public API, Project Management* -* [Brendan Rius](https://github.com/brendanrius) - *Cleanup* -* [Konstantin Itskov](https://github.com/trivigy) - *SDP Parsing* -* [chenkaiC4](https://github.com/chenkaiC4) - *Fix GolangCI Linter* -* [Ronan J](https://github.com/ronanj) - *Fix STCP PPID* -* [wattanakorn495](https://github.com/wattanakorn495) -* [Max Hawkins](https://github.com/maxhawkins) - *RTCP* -* [Justin Okamoto](https://github.com/justinokamoto) - *Fix Docs* -* [leeoxiang](https://github.com/notedit) - *Implement Janus examples* -* [Denis](https://github.com/Hixon10) - *Adding docker-compose to pion-to-pion example* -* [earle](https://github.com/aguilEA) - *Generate DTLS fingerprint in Go* -* [Jake B](https://github.com/silbinarywolf) - *Fix Windows installation instructions* -* [Michael MacDonald](https://github.com/mjmac) -* [Oleg Kovalov](https://github.com/cristaloleg) *Use wildcards instead of hardcoding travis-ci config* -* [Woodrow Douglass](https://github.com/wdouglass) *RTCP, RTP improvements* -* [Tobias Fridén](https://github.com/tobiasfriden) *SRTP authentication verification* - -### License -MIT License - see [LICENSE](LICENSE) for full text diff --git a/vendor/github.com/pions/webrtc/errors.go b/vendor/github.com/pions/webrtc/errors.go deleted file mode 100644 index 2d651a4..0000000 --- a/vendor/github.com/pions/webrtc/errors.go +++ /dev/null @@ -1,71 +0,0 @@ -package webrtc - -import ( - "errors" -) - -var ( - // ErrUnknownType indicates an error with Unknown info. - ErrUnknownType = errors.New("unknown") - - // ErrConnectionClosed indicates an operation executed after connection - // has already been closed. - ErrConnectionClosed = errors.New("connection closed") - - // ErrCertificateExpired indicates that an x509 certificate has expired. - ErrCertificateExpired = errors.New("x509Cert expired") - - // ErrNoTurnCredencials indicates that a TURN server URL was provided - // without required credentials. - ErrNoTurnCredencials = errors.New("turn server credentials required") - - // ErrTurnCredencials indicates that provided TURN credentials are partial - // or malformed. - ErrTurnCredencials = errors.New("invalid turn server credentials") - - // ErrExistingTrack indicates that a track already exists. - ErrExistingTrack = errors.New("track aready exists") - - // ErrPrivateKeyType indicates that a particular private key encryption - // chosen to generate a certificate is not supported. - ErrPrivateKeyType = errors.New("private key type not supported") - - // ErrModifyingPeerIdentity indicates that an attempt to modify - // PeerIdentity was made after RTCPeerConnection has been initialized. - ErrModifyingPeerIdentity = errors.New("peerIdentity cannot be modified") - - // ErrModifyingCertificates indicates that an attempt to modify - // Certificates was made after RTCPeerConnection has been initialized. - ErrModifyingCertificates = errors.New("certificates cannot be modified") - - // ErrModifyingBundlePolicy indicates that an attempt to modify - // BundlePolicy was made after RTCPeerConnection has been initialized. - ErrModifyingBundlePolicy = errors.New("bundle policy cannot be modified") - - // ErrModifyingRtcpMuxPolicy indicates that an attempt to modify - // RtcpMuxPolicy was made after RTCPeerConnection has been initialized. - ErrModifyingRtcpMuxPolicy = errors.New("rtcp mux policy cannot be modified") - - // ErrModifyingIceCandidatePoolSize indicates that an attempt to modify - // IceCandidatePoolSize was made after RTCPeerConnection has been initialized. - ErrModifyingIceCandidatePoolSize = errors.New("ice candidate pool size cannot be modified") - - // ErrStringSizeLimit indicates that the character size limit of string is - // exceeded. The limit is hardcoded to 65535 according to specifications. - ErrStringSizeLimit = errors.New("data channel label exceeds size limit") - - // ErrMaxDataChannelID indicates that the maximum number ID that could be - // specified for a data channel has been exceeded. - ErrMaxDataChannelID = errors.New("maximum number ID for datachannel specified") - - // ErrNegotiatedWithoutID indicates that an attempt to create a data channel - // was made while setting the negotiated option to true without providing - // the negotiated channel ID. - ErrNegotiatedWithoutID = errors.New("negotiated set without channel id") - - // ErrRetransmitsOrPacketLifeTime indicates that an attempt to create a data - // channel was made with both options MaxPacketLifeTime and MaxRetransmits - // set together. Such configuration is not supported by the specification - // and is mutually exclusive. - ErrRetransmitsOrPacketLifeTime = errors.New("both MaxPacketLifeTime and MaxRetransmits was set") -) diff --git a/vendor/github.com/pions/webrtc/go.mod b/vendor/github.com/pions/webrtc/go.mod deleted file mode 100644 index 28e3a82..0000000 --- a/vendor/github.com/pions/webrtc/go.mod +++ /dev/null @@ -1,12 +0,0 @@ -module github.com/pions/webrtc - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/pions/dtls v1.0.2 - github.com/pions/pkg v0.0.0-20181115215726-b60cd756f712 - github.com/pkg/errors v0.8.0 - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/testify v1.2.2 - golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 // indirect - golang.org/x/net v0.0.0-20181220203305-927f97764cc3 // indirect -) diff --git a/vendor/github.com/pions/webrtc/go.sum b/vendor/github.com/pions/webrtc/go.sum deleted file mode 100644 index 44409bc..0000000 --- a/vendor/github.com/pions/webrtc/go.sum +++ /dev/null @@ -1,16 +0,0 @@ -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/pions/dtls v1.0.2 h1:VOIp3whGooFWS4X0RBOXaykNORYr05yjs8mlNYqRc+4= -github.com/pions/dtls v1.0.2/go.mod h1:T22vu8VCOxNmIrbe3nnM1UdIo3m1Bx5CJNkHyehahLg= -github.com/pions/pkg v0.0.0-20181115215726-b60cd756f712 h1:ciXO7F7PusyAzW/EZJt01bETgfTxP/BIGoWQ15pBP54= -github.com/pions/pkg v0.0.0-20181115215726-b60cd756f712/go.mod h1:r9wKZs+Xxv2acLspex4CHQiIhFjGK1zGP+nUm/8klXA= -github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= -github.com/pkg/errors v0.8.0/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/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= diff --git a/vendor/github.com/pions/webrtc/internal/datachannel/datachannel.go b/vendor/github.com/pions/webrtc/internal/datachannel/datachannel.go deleted file mode 100644 index 5bf086b..0000000 --- a/vendor/github.com/pions/webrtc/internal/datachannel/datachannel.go +++ /dev/null @@ -1,226 +0,0 @@ -package datachannel - -import ( - "fmt" - - "github.com/pions/webrtc/internal/sctp" - "github.com/pkg/errors" -) - -const receiveMTU = 8192 - -// DataChannel represents a data channel -type DataChannel struct { - Config - stream *sctp.Stream -} - -// Config is used to configure the data channel. -type Config struct { - ChannelType ChannelType - Priority uint16 - ReliabilityParameter uint32 - Label string -} - -// Dial opens a data channels over SCTP -func Dial(a *sctp.Association, id uint16, config *Config) (*DataChannel, error) { - stream, err := a.OpenStream(id, sctp.PayloadTypeWebRTCBinary) - if err != nil { - return nil, err - } - - dc, err := Client(stream, config) - if err != nil { - return nil, err - } - - return dc, nil -} - -// Client opens a data channel over an SCTP stream -func Client(stream *sctp.Stream, config *Config) (*DataChannel, error) { - msg := &ChannelOpen{ - ChannelType: config.ChannelType, - Priority: config.Priority, - ReliabilityParameter: config.ReliabilityParameter, - - Label: []byte(config.Label), - Protocol: []byte(""), - } - - rawMsg, err := msg.Marshal() - if err != nil { - return nil, fmt.Errorf("failed to marshal ChannelOpen %v", err) - } - - _, err = stream.WriteSCTP(rawMsg, sctp.PayloadTypeWebRTCDCEP) - if err != nil { - return nil, fmt.Errorf("failed to send ChannelOpen %v", err) - } - - dataChannel := &DataChannel{ - Config: *config, - stream: stream, - } - - return dataChannel, nil -} - -// Accept is used to accept incoming data channels over SCTP -func Accept(a *sctp.Association) (*DataChannel, error) { - stream, err := a.AcceptStream() - if err != nil { - return nil, err - } - - stream.SetDefaultPayloadType(sctp.PayloadTypeWebRTCBinary) - - dc, err := Server(stream) - if err != nil { - return nil, err - } - - return dc, nil -} - -// Server accepts a data channel over an SCTP stream -func Server(stream *sctp.Stream) (*DataChannel, error) { - buffer := make([]byte, receiveMTU) // TODO: Can probably be smaller - n, ppi, err := stream.ReadSCTP(buffer) - if err != nil { - return nil, err - } - - if ppi != sctp.PayloadTypeWebRTCDCEP { - return nil, fmt.Errorf("unexpected packet type: %s", ppi) - } - - openMsg, err := ParseExpectDataChannelOpen(buffer[:n]) - if err != nil { - return nil, errors.Wrap(err, "failed to parse DataChannelOpen packet") - } - - dataChannel := &DataChannel{ - Config: Config{ - ChannelType: openMsg.ChannelType, - Priority: openMsg.Priority, - ReliabilityParameter: openMsg.ReliabilityParameter, - Label: string(openMsg.Label), - }, - stream: stream, - } - - err = dataChannel.writeDataChannelAck() - if err != nil { - return nil, err - } - return dataChannel, nil - -} - -// Read reads a packet of len(p) bytes as binary data -func (c *DataChannel) Read(p []byte) (int, error) { - n, _, err := c.ReadDataChannel(p) - return n, err -} - -// ReadDataChannel reads a packet of len(p) bytes -func (c *DataChannel) ReadDataChannel(p []byte) (int, bool, error) { - for { - n, ppi, err := c.stream.ReadSCTP(p) - - var isString bool - switch ppi { - case sctp.PayloadTypeWebRTCDCEP: - err = c.handleDCEP(p[:n]) - if err != nil { - fmt.Println("Failed to handle DCEP:", err) - continue - } - continue - case sctp.PayloadTypeWebRTCString, sctp.PayloadTypeWebRTCStringEmpty: - isString = true - } - return n, isString, err - } -} - -// StreamIdentifier returns the Stream identifier associated to the stream. -func (c *DataChannel) StreamIdentifier() uint16 { - return c.stream.StreamIdentifier() -} - -func (c *DataChannel) handleDCEP(data []byte) error { - msg, err := Parse(data) - if err != nil { - return errors.Wrap(err, "Failed to parse DataChannel packet") - } - - switch msg := msg.(type) { - case *ChannelOpen: - err = c.writeDataChannelAck() - if err != nil { - return fmt.Errorf("failed to ACK channel open: %v", err) - } - // TODO: Should not happen? - - case *ChannelAck: - // TODO: handle ChannelAck (https://tools.ietf.org/html/draft-ietf-rtcweb-data-protocol-09#section-5.2) - // TODO: handle? - - default: - return fmt.Errorf("unhandled DataChannel message %v", msg) - } - - return nil -} - -// Write writes len(p) bytes from p as binary data -func (c *DataChannel) Write(p []byte) (n int, err error) { - return c.WriteDataChannel(p, false) -} - -// WriteDataChannel writes len(p) bytes from p -func (c *DataChannel) WriteDataChannel(p []byte, isString bool) (n int, err error) { - // https://tools.ietf.org/html/draft-ietf-rtcweb-data-channel-12#section-6.6 - // SCTP does not support the sending of empty user messages. Therefore, - // if an empty message has to be sent, the appropriate PPID (WebRTC - // String Empty or WebRTC Binary Empty) is used and the SCTP user - // message of one zero byte is sent. When receiving an SCTP user - // message with one of these PPIDs, the receiver MUST ignore the SCTP - // user message and process it as an empty message. - var ppi sctp.PayloadProtocolIdentifier - switch { - case !isString && len(p) > 0: - ppi = sctp.PayloadTypeWebRTCBinary - case !isString && len(p) == 0: - ppi = sctp.PayloadTypeWebRTCBinaryEmpty - case isString && len(p) > 0: - ppi = sctp.PayloadTypeWebRTCString - case isString && len(p) == 0: - ppi = sctp.PayloadTypeWebRTCStringEmpty - } - - return c.stream.WriteSCTP(p, ppi) -} - -func (c *DataChannel) writeDataChannelAck() error { - ack := ChannelAck{} - ackMsg, err := ack.Marshal() - if err != nil { - return fmt.Errorf("failed to marshal ChannelOpen ACK: %v", err) - } - - _, err = c.stream.WriteSCTP(ackMsg, sctp.PayloadTypeWebRTCDCEP) - if err != nil { - return fmt.Errorf("failed to send ChannelOpen ACK: %v", err) - } - - return err -} - -// Close closes the DataChannel and the underlying SCTP stream. -func (c *DataChannel) Close() error { - return c.stream.Close() -} diff --git a/vendor/github.com/pions/webrtc/internal/datachannel/message.go b/vendor/github.com/pions/webrtc/internal/datachannel/message.go deleted file mode 100644 index 6cc0304..0000000 --- a/vendor/github.com/pions/webrtc/internal/datachannel/message.go +++ /dev/null @@ -1,94 +0,0 @@ -package datachannel - -import ( - "fmt" - - "github.com/pkg/errors" -) - -// Message is a parsed DataChannel message -type Message interface { - Marshal() ([]byte, error) - Unmarshal([]byte) error -} - -// MessageType is the first byte in a DataChannel message that specifies type -type MessageType byte - -// DataChannel Message Types -const ( - DataChannelAck MessageType = 0x02 - DataChannelOpen MessageType = 0x03 -) - -func (t MessageType) String() string { - switch t { - case DataChannelAck: - return "DataChannelAck" - case DataChannelOpen: - return "DataChannelOpen" - default: - return fmt.Sprintf("Unknown MessageType: %d", t) - } -} - -// Parse accepts raw input and returns a DataChannel message -func Parse(raw []byte) (Message, error) { - if len(raw) == 0 { - return nil, errors.Errorf("DataChannel message is not long enough to determine type ") - } - - var msg Message - switch MessageType(raw[0]) { - case DataChannelOpen: - msg = &ChannelOpen{} - case DataChannelAck: - msg = &ChannelAck{} - default: - return nil, errors.Errorf("Unknown MessageType %v", MessageType(raw[0])) - } - - if err := msg.Unmarshal(raw); err != nil { - return nil, err - } - - return msg, nil -} - -// ParseExpectDataChannelOpen parses a DataChannelOpen message -// or throws an error -func ParseExpectDataChannelOpen(raw []byte) (*ChannelOpen, error) { - if len(raw) == 0 { - return nil, errors.Errorf("the DataChannel message is not long enough to determine type") - } - - if actualTyp := MessageType(raw[0]); actualTyp != DataChannelOpen { - return nil, errors.Errorf("expected DataChannelOpen but got %s", actualTyp) - } - - msg := &ChannelOpen{} - if err := msg.Unmarshal(raw); err != nil { - return nil, err - } - - return msg, nil -} - -// ParseExpectDataChannelAck parses a DataChannelAck message -// or throws an error -func ParseExpectDataChannelAck(raw []byte) (*ChannelAck, error) { - if len(raw) == 0 { - return nil, errors.Errorf("the DataChannel message is not long enough to determine type") - } - - if actualTyp := MessageType(raw[0]); actualTyp != DataChannelAck { - return nil, errors.Errorf("expected DataChannelAck but got %s", actualTyp) - } - - msg := &ChannelAck{} - if err := msg.Unmarshal(raw); err != nil { - return nil, err - } - - return msg, nil -} diff --git a/vendor/github.com/pions/webrtc/internal/datachannel/message_channel_ack.go b/vendor/github.com/pions/webrtc/internal/datachannel/message_channel_ack.go deleted file mode 100644 index 5d19abe..0000000 --- a/vendor/github.com/pions/webrtc/internal/datachannel/message_channel_ack.go +++ /dev/null @@ -1,22 +0,0 @@ -package datachannel - -// ChannelAck is used to ACK a DataChannel open -type ChannelAck struct{} - -const ( - channelOpenAckLength = 4 -) - -// Marshal returns raw bytes for the given message -func (c *ChannelAck) Marshal() ([]byte, error) { - raw := make([]byte, channelOpenAckLength) - raw[0] = uint8(DataChannelAck) - - return raw, nil -} - -// Unmarshal populates the struct with the given raw data -func (c *ChannelAck) Unmarshal(raw []byte) error { - // Message type already checked in Parse and there is no further data - return nil -} diff --git a/vendor/github.com/pions/webrtc/internal/datachannel/message_channel_open.go b/vendor/github.com/pions/webrtc/internal/datachannel/message_channel_open.go deleted file mode 100644 index edf0921..0000000 --- a/vendor/github.com/pions/webrtc/internal/datachannel/message_channel_open.go +++ /dev/null @@ -1,123 +0,0 @@ -package datachannel - -import ( - "encoding/binary" - - "github.com/pkg/errors" -) - -/* -ChannelOpen represents a DATA_CHANNEL_OPEN Message - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Message Type | Channel Type | Priority | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Reliability Parameter | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Label Length | Protocol Length | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | -| Label | -| | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | -| Protocol | -| | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -*/ -type ChannelOpen struct { - ChannelType ChannelType - Priority uint16 - ReliabilityParameter uint32 - - Label []byte - Protocol []byte -} - -const ( - channelOpenHeaderLength = 12 -) - -// ChannelType determines the reliability of the WebRTC DataChannel -type ChannelType byte - -// ChannelType enums -const ( - // ChannelTypeReliable determines the Data Channel provides a - // reliable in-order bi-directional communication. - ChannelTypeReliable ChannelType = 0x00 - // ChannelTypeReliableUnordered determines the Data Channel - // provides a reliable unordered bi-directional communication. - ChannelTypeReliableUnordered ChannelType = 0x80 - // ChannelTypePartialReliableRexmit determines the Data Channel - // provides a partially-reliable in-order bi-directional communication. - // User messages will not be retransmitted more times than specified in the Reliability Parameter. - ChannelTypePartialReliableRexmit ChannelType = 0x01 - // ChannelTypePartialReliableRexmitUnordered determines - // the Data Channel provides a partial reliable unordered bi-directional communication. - // User messages will not be retransmitted more times than specified in the Reliability Parameter. - ChannelTypePartialReliableRexmitUnordered ChannelType = 0x81 - // ChannelTypePartialReliableTimed determines the Data Channel - // provides a partial reliable in-order bi-directional communication. - // User messages might not be transmitted or retransmitted after - // a specified life-time given in milli- seconds in the Reliability Parameter. - // This life-time starts when providing the user message to the protocol stack. - ChannelTypePartialReliableTimed ChannelType = 0x02 - // The Data Channel provides a partial reliable unordered bi-directional - // communication. User messages might not be transmitted or retransmitted - // after a specified life-time given in milli- seconds in the Reliability Parameter. - // This life-time starts when providing the user message to the protocol stack. - ChannelTypePartialReliableTimedUnordered ChannelType = 0x82 -) - -// ChannelPriority enums -const ( - ChannelPriorityBelowNormal uint16 = 128 - ChannelPriorityNormal uint16 = 256 - ChannelPriorityHigh uint16 = 512 - ChannelPriorityExtraHigh uint16 = 1024 -) - -// Marshal returns raw bytes for the given message -func (c *ChannelOpen) Marshal() ([]byte, error) { - labelLength := len(c.Label) - protocolLength := len(c.Protocol) - - totalLen := channelOpenHeaderLength + labelLength + protocolLength - raw := make([]byte, totalLen) - - raw[0] = uint8(DataChannelOpen) - raw[1] = byte(c.ChannelType) - binary.BigEndian.PutUint16(raw[2:], c.Priority) - binary.BigEndian.PutUint32(raw[4:], c.ReliabilityParameter) - binary.BigEndian.PutUint16(raw[8:], uint16(labelLength)) - binary.BigEndian.PutUint16(raw[10:], uint16(protocolLength)) - endLabel := channelOpenHeaderLength + labelLength - copy(raw[channelOpenHeaderLength:endLabel], c.Label) - copy(raw[endLabel:endLabel+protocolLength], c.Protocol) - - return raw, nil -} - -// Unmarshal populates the struct with the given raw data -func (c *ChannelOpen) Unmarshal(raw []byte) error { - if len(raw) < channelOpenHeaderLength { - return errors.Errorf("Length of input is not long enough to satisfy header %d", len(raw)) - } - c.ChannelType = ChannelType(raw[1]) - c.Priority = binary.BigEndian.Uint16(raw[2:]) - c.ReliabilityParameter = binary.BigEndian.Uint32(raw[4:]) - - labelLength := binary.BigEndian.Uint16(raw[8:]) - protocolLength := binary.BigEndian.Uint16(raw[10:]) - - if len(raw) != int(channelOpenHeaderLength+labelLength+protocolLength) { - return errors.Errorf("Label + Protocol length don't match full packet length") - } - - c.Label = raw[channelOpenHeaderLength : channelOpenHeaderLength+labelLength] - c.Protocol = raw[channelOpenHeaderLength+labelLength : channelOpenHeaderLength+labelLength+protocolLength] - return nil -} diff --git a/vendor/github.com/pions/webrtc/internal/mux/endpoint.go b/vendor/github.com/pions/webrtc/internal/mux/endpoint.go deleted file mode 100644 index c5c33a2..0000000 --- a/vendor/github.com/pions/webrtc/internal/mux/endpoint.go +++ /dev/null @@ -1,78 +0,0 @@ -package mux - -import ( - "errors" - "net" - "time" -) - -// Endpoint implements net.Conn. It is used to read muxed packets. -type Endpoint struct { - mux *Mux - readCh chan []byte - wroteCh chan int - doneCh chan struct{} -} - -// Close unregisters the endpoint from the Mux -func (e *Endpoint) Close() error { - e.close() - e.mux.RemoveEndpoint(e) - return nil -} - -func (e *Endpoint) close() { - select { - case <-e.doneCh: - default: - close(e.doneCh) - } -} - -// Read reads a packet of len(p) bytes from the underlying conn -// that are matched by the associated MuxFunc -func (e *Endpoint) Read(p []byte) (int, error) { - select { - case e.readCh <- p: - n := <-e.wroteCh - return n, nil - case <-e.doneCh: - // Unblock Mux.dispatch - select { - case <-e.readCh: - default: - close(e.readCh) - } - return 0, errors.New("Endpoint closed") - } -} - -// Write writes len(p) bytes to the underlying conn -func (e *Endpoint) Write(p []byte) (n int, err error) { - return e.mux.nextConn.Write(p) -} - -// LocalAddr is a stub -func (e *Endpoint) LocalAddr() net.Addr { - return e.mux.nextConn.LocalAddr() -} - -// RemoteAddr is a stub -func (e *Endpoint) RemoteAddr() net.Addr { - return e.mux.nextConn.LocalAddr() -} - -// SetDeadline is a stub -func (e *Endpoint) SetDeadline(t time.Time) error { - return nil -} - -// SetReadDeadline is a stub -func (e *Endpoint) SetReadDeadline(t time.Time) error { - return nil -} - -// SetWriteDeadline is a stub -func (e *Endpoint) SetWriteDeadline(t time.Time) error { - return nil -} diff --git a/vendor/github.com/pions/webrtc/internal/mux/mux.go b/vendor/github.com/pions/webrtc/internal/mux/mux.go deleted file mode 100644 index 7816389..0000000 --- a/vendor/github.com/pions/webrtc/internal/mux/mux.go +++ /dev/null @@ -1,110 +0,0 @@ -package mux - -import ( - "fmt" - "net" - "sync" -) - -// Mux allows multiplexing -type Mux struct { - lock sync.RWMutex - nextConn net.Conn - endpoints map[*Endpoint]MatchFunc - bufferSize int - closedCh chan struct{} -} - -// NewMux creates a new Mux -func NewMux(conn net.Conn, bufferSize int) *Mux { - m := &Mux{ - nextConn: conn, - endpoints: make(map[*Endpoint]MatchFunc), - bufferSize: bufferSize, - closedCh: make(chan struct{}), - } - - go m.readLoop() - - return m -} - -// NewEndpoint creates a new Endpoint -func (m *Mux) NewEndpoint(f MatchFunc) *Endpoint { - e := &Endpoint{ - mux: m, - readCh: make(chan []byte), - wroteCh: make(chan int), - doneCh: make(chan struct{}), - } - - m.lock.Lock() - m.endpoints[e] = f - m.lock.Unlock() - - return e -} - -// RemoveEndpoint removes an endpoint from the Mux -func (m *Mux) RemoveEndpoint(e *Endpoint) { - m.lock.Lock() - defer m.lock.Unlock() - delete(m.endpoints, e) -} - -// Close closes the Mux and all associated Endpoints. -func (m *Mux) Close() error { - m.lock.Lock() - for e := range m.endpoints { - e.close() - delete(m.endpoints, e) - } - m.lock.Unlock() - - err := m.nextConn.Close() - if err != nil { - return err - } - - // Wait for readLoop to end - <-m.closedCh - - return nil -} - -func (m *Mux) readLoop() { - defer func() { - close(m.closedCh) - }() - buf := make([]byte, m.bufferSize) - for { - n, err := m.nextConn.Read(buf) - if err != nil { - return - } - - m.dispatch(buf[:n]) - } -} - -func (m *Mux) dispatch(buf []byte) { - m.lock.Lock() - defer m.lock.Unlock() - for e, f := range m.endpoints { - if f(buf) { - select { - case readBuf, ok := <-e.readCh: - if !ok { - return - } - n := copy(readBuf, buf) - e.wroteCh <- n - case <-e.doneCh: - return - } - return - } - } - - fmt.Printf("Warning: mux: no endpoint for packet starting with %d\n", buf[0]) -} diff --git a/vendor/github.com/pions/webrtc/internal/mux/muxfunc.go b/vendor/github.com/pions/webrtc/internal/mux/muxfunc.go deleted file mode 100644 index 99e991b..0000000 --- a/vendor/github.com/pions/webrtc/internal/mux/muxfunc.go +++ /dev/null @@ -1,49 +0,0 @@ -package mux - -// MatchFunc allows custom logic for mapping packets to an Endpoint -type MatchFunc func([]byte) bool - -// MatchRange is a MatchFunc that accepts packets with the first byte in [lower..upper] -func MatchRange(lower, upper byte) MatchFunc { - return func(buf []byte) bool { - if len(buf) < 1 { - return false - } - b := buf[0] - return b >= lower && b <= upper - } -} - -// MatchFuncs as described in RFC7983 -// https://tools.ietf.org/html/rfc7983 -// +----------------+ -// | [0..3] -+--> forward to STUN -// | | -// | [16..19] -+--> forward to ZRTP -// | | -// packet --> | [20..63] -+--> forward to DTLS -// | | -// | [64..79] -+--> forward to TURN Channel -// | | -// | [128..191] -+--> forward to RTP/RTCP -// +----------------+ - -// MatchSTUN is a MatchFunc that accepts packets with the first byte in [0..3] -// as defied in RFC7983 -var MatchSTUN = MatchRange(0, 3) - -// MatchZRTP is a MatchFunc that accepts packets with the first byte in [16..19] -// as defied in RFC7983 -var MatchZRTP = MatchRange(16, 19) - -// MatchDTLS is a MatchFunc that accepts packets with the first byte in [20..63] -// as defied in RFC7983 -var MatchDTLS = MatchRange(20, 63) - -// MatchTURN is a MatchFunc that accepts packets with the first byte in [64..79] -// as defied in RFC7983 -var MatchTURN = MatchRange(64, 79) - -// MatchSRTP is a MatchFunc that accepts packets with the first byte in [128..191] -// as defied in RFC7983 -var MatchSRTP = MatchRange(128, 191) diff --git a/vendor/github.com/pions/webrtc/internal/network/manager.go b/vendor/github.com/pions/webrtc/internal/network/manager.go deleted file mode 100644 index c10692b..0000000 --- a/vendor/github.com/pions/webrtc/internal/network/manager.go +++ /dev/null @@ -1,315 +0,0 @@ -package network - -import ( - "context" - "crypto" - "crypto/x509" - "fmt" - "strings" - "sync" - - "github.com/pions/dtls/pkg/dtls" - "github.com/pions/webrtc/internal/datachannel" - "github.com/pions/webrtc/internal/mux" - "github.com/pions/webrtc/internal/sctp" - "github.com/pions/webrtc/internal/srtp" - "github.com/pions/webrtc/pkg/ice" - "github.com/pions/webrtc/pkg/rtcp" - "github.com/pions/webrtc/pkg/rtp" -) - -const receiveMTU = 8192 - -// TransportPair allows the application to be notified about both Rtp -// and Rtcp messages incoming from the remote host -type TransportPair struct { - RTP chan<- *rtp.Packet - RTCP chan<- rtcp.Packet -} - -// Manager contains all network state (DTLS, SRTP) that is shared between ports -// It is also used to perform operations that involve multiple ports -type Manager struct { - IceAgent *ice.Agent - iceConn *ice.Conn - isOffer bool - - mux *mux.Mux - - dtlsEndpoint *mux.Endpoint - srtpEndpoint *mux.Endpoint - - srtpInboundContextLock sync.RWMutex - srtpInboundContext *srtp.Context - srtpOutboundContextLock sync.RWMutex - srtpOutboundContext *srtp.Context - - bufferTransportGenerator BufferTransportGenerator - pairsLock sync.RWMutex - bufferTransportPairs map[uint32]*TransportPair - - dtlsConn *dtls.Conn - - sctpAssociation *sctp.Association -} - -//AddTransportPair notifies the network manager that an RTCTrack has -//been created externally, and packets may be incoming with this ssrc -func (m *Manager) AddTransportPair(ssrc uint32, Rtp chan<- *rtp.Packet, Rtcp chan<- rtcp.Packet) { - m.pairsLock.Lock() - defer m.pairsLock.Unlock() - bufferTransport := m.bufferTransportPairs[ssrc] - if bufferTransport == nil { - bufferTransport = &TransportPair{Rtp, Rtcp} - m.bufferTransportPairs[ssrc] = bufferTransport - } -} - -// NewManager creates a new network.Manager -func NewManager(urls []*ice.URL, btg BufferTransportGenerator, ntf ICENotifier) *Manager { - iceAgent := ice.NewAgent(urls, ntf) - - return &Manager{ - IceAgent: iceAgent, - bufferTransportPairs: make(map[uint32]*TransportPair), - bufferTransportGenerator: btg, - } -} - -func (m *Manager) getBufferTransports(ssrc uint32) *TransportPair { - m.pairsLock.RLock() - defer m.pairsLock.RUnlock() - return m.bufferTransportPairs[ssrc] -} - -func (m *Manager) getOrCreateBufferTransports(ssrc uint32, payloadtype uint8) *TransportPair { - m.pairsLock.Lock() - defer m.pairsLock.Unlock() - bufferTransport := m.bufferTransportPairs[ssrc] - if bufferTransport == nil { - bufferTransport = m.bufferTransportGenerator(ssrc, payloadtype) - m.bufferTransportPairs[ssrc] = bufferTransport - } - - return bufferTransport -} - -// Start allocates the network stack -// TODO: Turn into the ORTC constructors -func (m *Manager) Start(isOffer bool, - remoteUfrag, remotePwd string, - dtlsCert *x509.Certificate, dtlsPrivKey crypto.PrivateKey, fingerprint, fingerprintHash string) error { - - m.isOffer = isOffer - - if err := m.startICE(isOffer, remoteUfrag, remotePwd); err != nil { - return err - } - - m.mux = mux.NewMux(m.iceConn, receiveMTU) - m.dtlsEndpoint = m.mux.NewEndpoint(mux.MatchDTLS) - m.srtpEndpoint = m.mux.NewEndpoint(mux.MatchSRTP) - - m.startSRTP() - - if err := m.startDTLS(isOffer, dtlsCert, dtlsPrivKey, fingerprint, fingerprintHash); err != nil { - return err - } - - if err := m.createContextSRTP(isOffer); err != nil { - return err - } - - if err := m.startSCTP(isOffer); err != nil { - return err - } - - return nil -} - -func (m *Manager) startICE(isOffer bool, remoteUfrag, remotePwd string) error { - if isOffer { - iceConn, err := m.IceAgent.Dial(context.TODO(), remoteUfrag, remotePwd) - if err != nil { - return err - } - m.iceConn = iceConn - } else { - iceConn, err := m.IceAgent.Accept(context.TODO(), remoteUfrag, remotePwd) - if err != nil { - return err - } - m.iceConn = iceConn - } - return nil -} - -func (m *Manager) startSRTP() { - // Glue code until SRTP is a Conn. - go func() { - buf := make([]byte, receiveMTU) - for { - n, err := m.srtpEndpoint.Read(buf) - if err != nil { - return - } - m.handleSRTP(buf[:n]) - } - }() -} - -func (m *Manager) createContextSRTP(isOffer bool) error { - keyingMaterial, err := m.dtlsConn.ExportKeyingMaterial([]byte("EXTRACTOR-dtls_srtp"), nil, (srtpMasterKeyLen*2)+(srtpMasterKeySaltLen*2)) - if err != nil { - return err - } - if err = m.CreateContextSRTP(keyingMaterial, isOffer); err != nil { - return err - } - return nil -} - -func (m *Manager) startDTLS(isOffer bool, dtlsCert *x509.Certificate, dtlsPrivKey crypto.PrivateKey, fingerprint, fingerprintHash string) error { - dtlsCofig := &dtls.Config{Certificate: dtlsCert, PrivateKey: dtlsPrivKey} - if isOffer { - // Assumes we offer to be passive and this is accepted. - dtlsConn, err := dtls.Server(m.dtlsEndpoint, dtlsCofig) - if err != nil { - return err - } - m.dtlsConn = dtlsConn - } else { - // Assumes the peer offered to be passive and we accepted. - dtlsConn, err := dtls.Client(m.dtlsEndpoint, dtlsCofig) - if err != nil { - return err - } - m.dtlsConn = dtlsConn - } - - // Check the fingerprint if a certificate was exchanged - cert := m.dtlsConn.RemoteCertificate() - if cert != nil { - hashAlgo, err := dtls.HashAlgorithmString(fingerprintHash) - if err != nil { - return err - } - - fp := "" - fp, err = dtls.Fingerprint(cert, hashAlgo) - if err != nil { - return err - } - - if strings.ToUpper(fp) != fingerprint { - return fmt.Errorf("invalid fingerprint: %s <> %s", fp, fingerprint) - } - } else { - fmt.Println("Warning: Certificate not checked") - } - return nil -} - -func (m *Manager) startSCTP(isOffer bool) error { - if isOffer { - sctpAssociation, err := sctp.Client(m.dtlsConn) - if err != nil { - return err - } - m.sctpAssociation = sctpAssociation - } else { - sctpAssociation, err := sctp.Server(m.dtlsConn) - if err != nil { - return err - } - m.sctpAssociation = sctpAssociation - } - return nil -} - -// OpenDataChannel is used to open a data channel -// TODO: Move to RTCSctpTransport -func (m *Manager) OpenDataChannel(id uint16, config *datachannel.Config) (*datachannel.DataChannel, error) { - return datachannel.Dial(m.sctpAssociation, id, config) -} - -// AcceptDataChannel is used to accept incoming data channels -// TODO: Move to RTCSctpTransport -func (m *Manager) AcceptDataChannel() (*datachannel.DataChannel, error) { - return datachannel.Accept(m.sctpAssociation) -} - -// Close cleans up all the allocated state -func (m *Manager) Close() error { - // Shutdown strategy: - // 1. All Conn close by closing their underlying Conn. - // 2. A Mux stops this chain. It won't close the underlying - // Conn if one of the endpoints is closed down. To - // continue the chain the Mux has to be closed. - - // Close SCTP. This should close the data channels, SCTP, and DTLS - var errSCTP, errMux error - if m.sctpAssociation != nil { - errSCTP = m.sctpAssociation.Close() - } - - // Close the Mux. This should close the Mux and ICE. - if m.mux != nil { - errMux = m.mux.Close() - } - - // TODO: better way to combine/handle errors? - if errSCTP != nil || - errMux != nil { - return fmt.Errorf("Failed to close: %v, %v", errSCTP, errMux) - } - - return nil -} - -// SendRTP finds a connected port and sends the passed RTP packet -func (m *Manager) SendRTP(packet *rtp.Packet) { - m.srtpOutboundContextLock.Lock() - defer m.srtpOutboundContextLock.Unlock() - if m.srtpOutboundContext == nil { - // TODO log-level - // fmt.Printf("Tried to send RTP packet but no SRTP Context to handle it \n") - return - } - - if ok := m.srtpOutboundContext.EncryptRTP(packet); !ok { - fmt.Println("SendRTP failed to encrypt packet") - return - } - - raw, err := packet.Marshal() - if err != nil { - fmt.Printf("SendRTP failed to marshal packet: %s \n", err.Error()) - } - - _, err = m.iceConn.Write(raw) - if err != nil { - fmt.Println("SendRTP failed to write:", err) - } -} - -// SendRTCP finds a connected port and sends the passed RTCP packet -func (m *Manager) SendRTCP(pkt []byte) { - m.srtpOutboundContextLock.Lock() - defer m.srtpOutboundContextLock.Unlock() - if m.srtpOutboundContext == nil { - fmt.Printf("Tried to send RTCP packet but no SRTP Context to handle it \n") - return - } - - encrypted, err := m.srtpOutboundContext.EncryptRTCP(pkt) - if err != nil { - fmt.Println("SendRTCP failed to encrypt packet:", err) - return - } - - _, err = m.iceConn.Write(encrypted) - if err != nil { - fmt.Println("SendRTCP failed to write:", err) - } -} diff --git a/vendor/github.com/pions/webrtc/internal/network/network.go b/vendor/github.com/pions/webrtc/internal/network/network.go deleted file mode 100644 index f860d0a..0000000 --- a/vendor/github.com/pions/webrtc/internal/network/network.go +++ /dev/null @@ -1,60 +0,0 @@ -package network - -import ( - "github.com/pions/webrtc/pkg/datachannel" - "github.com/pions/webrtc/pkg/ice" -) - -// BufferTransportGenerator generates a new channel for the associated SSRC -// This channel is used to send RTP and RTCP packets to users of pion-WebRTC -type BufferTransportGenerator func(uint32, uint8) *TransportPair - -// ICENotifier notifies the RTCPeerConnection if ICE state has changed -type ICENotifier func(ice.ConnectionState) - -// DataChannelEventHandler notifies the RTCPeerConnection of events relating to DataChannels -type DataChannelEventHandler func(DataChannelEvent) - -// DataChannelEventType is the enum used to represent different types of DataChannelEvent -type DataChannelEventType int - -// Enums for DataChannelEventType -const ( - NewDataChannel int = iota + 1 - NewMessage -) - -// DataChannelEvent is the interface for all events that flow across the DataChannelEventHandler -type DataChannelEvent interface { - StreamIdentifier() uint16 -} - -// DataChannelCreated is emitted when a new DataChannel is created -type DataChannelCreated struct { - Label string - streamIdentifier uint16 -} - -// StreamIdentifier returns the streamIdentifier -func (d *DataChannelCreated) StreamIdentifier() uint16 { - return d.streamIdentifier -} - -// DataChannelMessage is emitted when a DataChannel receives a message -type DataChannelMessage struct { - Payload datachannel.Payload - streamIdentifier uint16 -} - -// StreamIdentifier returns the streamIdentifier -func (d *DataChannelMessage) StreamIdentifier() uint16 { - return d.streamIdentifier -} - -// DataChannelOpen is emitted when all channels should be opened -type DataChannelOpen struct{} - -// StreamIdentifier returns the streamIdentifier -func (d *DataChannelOpen) StreamIdentifier() uint16 { - return 0 -} diff --git a/vendor/github.com/pions/webrtc/internal/network/srtp.go b/vendor/github.com/pions/webrtc/internal/network/srtp.go deleted file mode 100644 index f31be95..0000000 --- a/vendor/github.com/pions/webrtc/internal/network/srtp.go +++ /dev/null @@ -1,149 +0,0 @@ -package network - -import ( - "bytes" - "encoding/binary" - "fmt" - "io" - - "github.com/pions/webrtc/internal/srtp" - "github.com/pions/webrtc/pkg/rtcp" - "github.com/pions/webrtc/pkg/rtp" - "github.com/pkg/errors" -) - -const ( - srtpMasterKeyLen = 16 - srtpMasterKeySaltLen = 14 -) - -// TODO: Migrate to srtp.Conn - -// CreateContextSRTP takes the exported keying material from DTLS and creates Client/Server contexts -func (m *Manager) CreateContextSRTP(keyingMaterial []byte, isOffer bool) error { - offset := 0 - - clientWriteKey := append([]byte{}, keyingMaterial[offset:offset+srtpMasterKeyLen]...) - offset += srtpMasterKeyLen - - serverWriteKey := append([]byte{}, keyingMaterial[offset:offset+srtpMasterKeyLen]...) - offset += srtpMasterKeyLen - - clientWriteKey = append(clientWriteKey, keyingMaterial[offset:offset+srtpMasterKeySaltLen]...) - offset += srtpMasterKeySaltLen - - serverWriteKey = append(serverWriteKey, keyingMaterial[offset:offset+srtpMasterKeySaltLen]...) - - var err error - m.srtpInboundContextLock.Lock() - if isOffer { - m.srtpInboundContext, err = srtp.CreateContext(clientWriteKey[0:16], clientWriteKey[16:] /* Profile */, "") - } else { - m.srtpInboundContext, err = srtp.CreateContext(serverWriteKey[0:16], serverWriteKey[16:] /* Profile */, "") - } - m.srtpInboundContextLock.Unlock() - if err != nil { - return errors.New("failed to build inbound SRTP context") - } - - m.srtpOutboundContextLock.Lock() - if isOffer { - m.srtpOutboundContext, err = srtp.CreateContext(serverWriteKey[0:16], serverWriteKey[16:] /* Profile */, "") - } else { - m.srtpOutboundContext, err = srtp.CreateContext(clientWriteKey[0:16], clientWriteKey[16:] /* Profile */, "") - } - m.srtpOutboundContextLock.Unlock() - if err != nil { - return errors.New("failed to build outbound SRTP context") - } - - return nil -} - -func handleRTCP(getBufferTransports func(uint32) *TransportPair, buffer []byte) { - //decrypted packets can also be compound packets, so we have to nest our reader loop here. - compoundPacket := rtcp.NewReader(bytes.NewReader(buffer)) - for { - _, rawrtcp, err := compoundPacket.ReadPacket() - - if err != nil { - if err == io.EOF { - break - } - fmt.Println(err) - return - } - - var report rtcp.Packet - report, _, err = rtcp.Unmarshal(rawrtcp) - if err != nil { - fmt.Println(err) - return - } - - f := func(ssrc uint32) { - bufferTransport := getBufferTransports(ssrc) - if bufferTransport != nil && bufferTransport.RTCP != nil { - select { - case bufferTransport.RTCP <- report: - default: - } - } - } - - for _, ssrc := range report.DestinationSSRC() { - f(ssrc) - } - } -} - -func (m *Manager) handleSRTP(buffer []byte) { - m.srtpInboundContextLock.Lock() - defer m.srtpInboundContextLock.Unlock() - if m.srtpInboundContext == nil { - fmt.Printf("Got RTP packet but no SRTP Context to handle it \n") - return - } - - if len(buffer) > 4 { - var rtcpPacketType uint8 - - r := bytes.NewReader([]byte{buffer[1]}) - if err := binary.Read(r, binary.BigEndian, &rtcpPacketType); err != nil { - fmt.Println("Failed to check packet for RTCP") - return - } - - if rtcpPacketType >= 192 && rtcpPacketType <= 223 { - decrypted, err := m.srtpInboundContext.DecryptRTCP(buffer) - if err != nil { - fmt.Println(err) - fmt.Println(decrypted) - return - } - - handleRTCP(m.getBufferTransports, decrypted) - return - } - } - - packet := &rtp.Packet{} - if err := packet.Unmarshal(buffer); err != nil { - fmt.Println("Failed to unmarshal RTP packet") - return - } - - if ok := m.srtpInboundContext.DecryptRTP(packet); !ok { - fmt.Println("Failed to decrypt packet") - return - } - - bufferTransport := m.getOrCreateBufferTransports(packet.SSRC, packet.PayloadType) - if bufferTransport != nil && bufferTransport.RTP != nil { - select { - case bufferTransport.RTP <- packet: - default: - } - } - -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/association.go b/vendor/github.com/pions/webrtc/internal/sctp/association.go deleted file mode 100644 index ccd96fe..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/association.go +++ /dev/null @@ -1,686 +0,0 @@ -package sctp - -import ( - "bytes" - "fmt" - "net" - "sync" - - "math" - "math/rand" - "time" - - "github.com/pkg/errors" -) - -const receiveMTU = 8192 - -var errAssociationClosed = errors.New("The association is closed") - -// AssociationState is an enum for the states that an Association will transition -// through while connecting -// https://tools.ietf.org/html/rfc4960#section-13.2 -type AssociationState uint8 - -// AssociationState enums -const ( - Open AssociationState = iota + 1 - CookieEchoed - CookieWait - Established - ShutdownAckSent - ShutdownPending - ShutdownReceived - ShutdownSent -) - -func (a AssociationState) String() string { - switch a { - case Open: - return "Open" - case CookieEchoed: - return "CookieEchoed" - case CookieWait: - return "CookieWait" - case Established: - return "Established" - case ShutdownPending: - return "ShutdownPending" - case ShutdownSent: - return "ShutdownSent" - case ShutdownReceived: - return "ShutdownReceived" - case ShutdownAckSent: - return "ShutdownAckSent" - default: - return fmt.Sprintf("Invalid AssociationState %d", a) - } -} - -// Association represents an SCTP association -// 13.2. Parameters Necessary per Association (i.e., the TCB) -// Peer : Tag value to be sent in every packet and is received -// Verification: in the INIT or INIT ACK chunk. -// Tag : -// -// My : Tag expected in every inbound packet and sent in the -// Verification: INIT or INIT ACK chunk. -// -// Tag : -// State : A state variable indicating what state the association -// : is in, i.e., COOKIE-WAIT, COOKIE-ECHOED, ESTABLISHED, -// : SHUTDOWN-PENDING, SHUTDOWN-SENT, SHUTDOWN-RECEIVED, -// : SHUTDOWN-ACK-SENT. -// -// Note: No "CLOSED" state is illustrated since if a -// association is "CLOSED" its TCB SHOULD be removed. -type Association struct { - lock sync.Mutex - - nextConn net.Conn - - peerVerificationTag uint32 - myVerificationTag uint32 - state AssociationState - //peerTransportList - //primaryPath - //overallErrorCount - //overallErrorThreshold - //peerReceiverWindow (peerRwnd) - myNextTSN uint32 // nextTSN - peerLastTSN uint32 // lastRcvdTSN - //peerMissingTSN (MappingArray) - //ackState - //inboundStreams - //outboundStreams - //reassemblyQueue - //localTransportAddressList - //associationPTMU - - // Non-RFC internal data - sourcePort uint16 - destinationPort uint16 - myMaxNumInboundStreams uint16 - myMaxNumOutboundStreams uint16 - myReceiverWindowCredit uint32 - myCookie *paramStateCookie - payloadQueue *payloadQueue - inflightQueue *payloadQueue - myMaxMTU uint16 - peerCumulativeTSNAckPoint uint32 - - streams map[uint16]*Stream - acceptCh chan *Stream - doneCh chan struct{} - handshakeCompletedCh chan struct{} -} - -// Server accepts a SCTP stream over a conn -func Server(nextConn net.Conn) (*Association, error) { - a := createAssocation(nextConn) - go a.readLoop() - <-a.handshakeCompletedCh - - return a, nil -} - -// Client opens a SCTP stream over a conn -func Client(nextConn net.Conn) (*Association, error) { - a := createAssocation(nextConn) - go a.readLoop() - a.init() - <-a.handshakeCompletedCh - - return a, nil -} - -func createAssocation(nextConn net.Conn) *Association { - rs := rand.NewSource(time.Now().UnixNano()) - r := rand.New(rs) - - tsn := r.Uint32() - return &Association{ - nextConn: nextConn, - myMaxNumOutboundStreams: math.MaxUint16, - myMaxNumInboundStreams: math.MaxUint16, - myReceiverWindowCredit: 10 * 1500, // 10 Max MTU packets buffer - payloadQueue: &payloadQueue{}, - inflightQueue: &payloadQueue{}, - myMaxMTU: 1200, - myVerificationTag: r.Uint32(), - myNextTSN: tsn, - state: Open, - streams: make(map[uint16]*Stream), - acceptCh: make(chan *Stream), - doneCh: make(chan struct{}), - handshakeCompletedCh: make(chan struct{}), - peerCumulativeTSNAckPoint: tsn - 1, - } -} - -func (a *Association) init() { - a.lock.Lock() - defer a.lock.Unlock() - - err := a.send(a.createInit()) - if err != nil { - fmt.Printf("Failed to send init: %v", err) - } - a.setState(CookieWait) -} - -// Close ends the SCTP Association and cleans up any state -func (a *Association) Close() error { - err := a.nextConn.Close() - if err != nil { - return err - } - - // Wait for readLoop to end - <-a.doneCh - - return nil -} - -func (a *Association) readLoop() { - defer func() { - a.lock.Lock() - for _, s := range a.streams { - close(s.closeCh) - close(s.readNotifier) - delete(a.streams, s.streamIdentifier) - } - a.lock.Unlock() - close(a.acceptCh) - close(a.doneCh) - }() - for { - // buffer is recreated because the user data is - // passed to the reassembly queue without copying - buffer := make([]byte, receiveMTU) - n, err := a.nextConn.Read(buffer) - if err != nil { - return - } - - if err = a.handleInbound(buffer[:n]); err != nil { - fmt.Println(errors.Wrap(err, "Failed to push SCTP packet")) - } - } -} - -// HandleInbound parses incoming raw packets -func (a *Association) handleInbound(raw []byte) error { - p := &packet{} - if err := p.unmarshal(raw); err != nil { - return errors.Wrap(err, "Unable to parse SCTP packet") - } - - if err := checkPacket(p); err != nil { - return errors.Wrap(err, "Failed validating packet") - } - - for _, c := range p.chunks { - packets, err := a.handleChunk(p, c) - if err != nil { - return errors.Wrap(err, "Failed handling chunk") - } - for _, p := range packets { - err = a.send(p) - if err != nil { - return errors.Wrap(err, "Failed sending reply") - } - } - } - - return nil -} - -func checkPacket(p *packet) error { - // All packets must adhere to these rules - - // This is the SCTP sender's port number. It can be used by the - // receiver in combination with the source IP address, the SCTP - // destination port, and possibly the destination IP address to - // identify the association to which this packet belongs. The port - // number 0 MUST NOT be used. - if p.sourcePort == 0 { - return errors.New("SCTP Packet must not have a source port of 0") - } - - // This is the SCTP port number to which this packet is destined. - // The receiving host will use this port number to de-multiplex the - // SCTP packet to the correct receiving endpoint/application. The - // port number 0 MUST NOT be used. - if p.destinationPort == 0 { - return errors.New("SCTP Packet must not have a destination port of 0") - } - - // Check values on the packet that are specific to a particular chunk type - for _, c := range p.chunks { - switch c.(type) { - case *chunkInit: - // An INIT or INIT ACK chunk MUST NOT be bundled with any other chunk. - // They MUST be the only chunks present in the SCTP packets that carry - // them. - if len(p.chunks) != 1 { - return errors.New("INIT chunk must not be bundled with any other chunk") - } - - // A packet containing an INIT chunk MUST have a zero Verification - // Tag. - if p.verificationTag != 0 { - return errors.Errorf("INIT chunk expects a verification tag of 0 on the packet when out-of-the-blue") - } - } - } - - return nil -} - -func min(a, b uint16) uint16 { - if a < b { - return a - } - return b -} - -// setState sets the state of the Association. -func (a *Association) setState(state AssociationState) { - if a.state != state { - a.state = state - } -} - -// The caller should hold the lock. -func (a *Association) createInit() *packet { - outbound := &packet{} - outbound.verificationTag = a.peerVerificationTag - a.sourcePort = 5000 // TODO: Spec?? - a.destinationPort = 5000 // TODO: Spec?? - outbound.sourcePort = a.sourcePort - outbound.destinationPort = a.destinationPort - - init := &chunkInit{} - - init.initialTSN = a.myNextTSN - init.numOutboundStreams = a.myMaxNumOutboundStreams - init.numInboundStreams = a.myMaxNumInboundStreams - init.initiateTag = a.myVerificationTag - init.advertisedReceiverWindowCredit = a.myReceiverWindowCredit - - outbound.chunks = []chunk{init} - - return outbound -} - -// The caller should hold the lock. -func (a *Association) handleInit(p *packet, i *chunkInit) *packet { - // Should we be setting any of these permanently until we've ACKed further? - a.myMaxNumInboundStreams = min(i.numInboundStreams, a.myMaxNumInboundStreams) - a.myMaxNumOutboundStreams = min(i.numOutboundStreams, a.myMaxNumOutboundStreams) - a.peerVerificationTag = i.initiateTag - a.sourcePort = p.destinationPort - a.destinationPort = p.sourcePort - - // 13.2 This is the last TSN received in sequence. This value - // is set initially by taking the peer's initial TSN, - // received in the INIT or INIT ACK chunk, and - // subtracting one from it. - a.peerLastTSN = i.initialTSN - 1 - - outbound := &packet{} - outbound.verificationTag = a.peerVerificationTag - outbound.sourcePort = a.sourcePort - outbound.destinationPort = a.destinationPort - - initAck := &chunkInitAck{} - - initAck.initialTSN = a.myNextTSN - initAck.numOutboundStreams = a.myMaxNumOutboundStreams - initAck.numInboundStreams = a.myMaxNumInboundStreams - initAck.initiateTag = a.myVerificationTag - initAck.advertisedReceiverWindowCredit = a.myReceiverWindowCredit - - if a.myCookie == nil { - a.myCookie = newRandomStateCookie() - } - - initAck.params = []param{a.myCookie} - - outbound.chunks = []chunk{initAck} - - return outbound -} - -// The caller should hold the lock. -func (a *Association) handleInitAck(p *packet, i *chunkInitAck) (*packet, error) { - a.myMaxNumInboundStreams = min(i.numInboundStreams, a.myMaxNumInboundStreams) - a.myMaxNumOutboundStreams = min(i.numOutboundStreams, a.myMaxNumOutboundStreams) - a.peerVerificationTag = i.initiateTag - a.peerLastTSN = i.initialTSN - 1 - if a.sourcePort != p.destinationPort || - a.destinationPort != p.sourcePort { - fmt.Println("handleInitAck: port mismatch") - } - - outbound := &packet{} - outbound.verificationTag = a.peerVerificationTag - outbound.sourcePort = a.sourcePort - outbound.destinationPort = a.destinationPort - - var cookieParam *paramStateCookie - for _, param := range i.params { - switch v := param.(type) { - case *paramStateCookie: - cookieParam = v - } - } - if cookieParam == nil { - return nil, errors.New("no cookie in InitAck") - } - - cookieEcho := &chunkCookieEcho{} - - cookieEcho.cookie = cookieParam.cookie - - outbound.chunks = []chunk{cookieEcho} - - return outbound, nil -} - -// The caller should hold the lock. -func (a *Association) handleData(d *chunkPayloadData) *packet { - a.payloadQueue.push(d, a.peerLastTSN) - - pd, popOk := a.payloadQueue.pop(a.peerLastTSN + 1) - - for popOk { - s := a.getOrCreateStream(pd.streamIdentifier) - s.handleData(pd) - - a.peerLastTSN++ - pd, popOk = a.payloadQueue.pop(a.peerLastTSN + 1) - } - - outbound := &packet{} - outbound.verificationTag = a.peerVerificationTag - outbound.sourcePort = a.sourcePort - outbound.destinationPort = a.destinationPort - - sack := &chunkSelectiveAck{} - - sack.cumulativeTSNAck = a.peerLastTSN - sack.advertisedReceiverWindowCredit = a.myReceiverWindowCredit - sack.duplicateTSN = a.payloadQueue.popDuplicates() - sack.gapAckBlocks = a.payloadQueue.getGapAckBlocks(a.peerLastTSN) - outbound.chunks = []chunk{sack} - - return outbound -} - -// OpenStream opens a stream -func (a *Association) OpenStream(streamIdentifier uint16, defaultPayloadType PayloadProtocolIdentifier) (*Stream, error) { - a.lock.Lock() - defer a.lock.Unlock() - - if _, ok := a.streams[streamIdentifier]; ok { - return nil, fmt.Errorf("there already exists a stream with identifier %d", streamIdentifier) - } - - s := a.createStream(streamIdentifier, false) - s.setDefaultPayloadType(defaultPayloadType) - - return s, nil -} - -// AcceptStream accepts a stream -func (a *Association) AcceptStream() (*Stream, error) { - s, ok := <-a.acceptCh - if !ok { - return nil, errAssociationClosed - } - return s, nil -} - -// createStream creates a stream. The caller should hold the lock and check no stream exists for this id. -func (a *Association) createStream(streamIdentifier uint16, accept bool) *Stream { - s := &Stream{ - association: a, - streamIdentifier: streamIdentifier, - reassemblyQueue: &reassemblyQueue{}, - readNotifier: make(chan struct{}), - closeCh: make(chan struct{}), - } - - a.streams[streamIdentifier] = s - - if accept { - a.acceptCh <- s - } - - return s -} - -// getOrCreateStream gets or creates a stream. The caller should hold the lock. -func (a *Association) getOrCreateStream(streamIdentifier uint16) *Stream { - if s, ok := a.streams[streamIdentifier]; ok { - return s - } - - return a.createStream(streamIdentifier, true) -} - -// The caller should hold the lock. -func (a *Association) handleSack(d *chunkSelectiveAck) ([]*packet, error) { - // i) If Cumulative TSN Ack is less than the Cumulative TSN Ack - // Point, then drop the SACK. Since Cumulative TSN Ack is - // monotonically increasing, a SACK whose Cumulative TSN Ack is - // less than the Cumulative TSN Ack Point indicates an out-of- - // order SACK. - - // This is an old SACK, toss - if a.peerCumulativeTSNAckPoint > d.cumulativeTSNAck { - return nil, errors.Errorf("SACK Cumulative ACK %v is older than ACK point %v", - d.cumulativeTSNAck, a.peerCumulativeTSNAckPoint) - } - - // New ack point, so pop all ACKed packets from inflightQueue - // We add 1 because the "currentAckPoint" has already been popped from the inflight queue - // For the first SACK we take care of this by setting the ackpoint to cumAck - 1 - for i := a.peerCumulativeTSNAckPoint + 1; i <= d.cumulativeTSNAck; i++ { - _, ok := a.inflightQueue.pop(i) - if !ok { - return nil, errors.Errorf("TSN %v unable to be popped from inflight queue", i) - } - } - - a.peerCumulativeTSNAckPoint = d.cumulativeTSNAck - - var sackDataPackets []*packet - var prevEnd uint16 - for _, g := range d.gapAckBlocks { - for i := prevEnd + 1; i < g.start; i++ { - pp, ok := a.inflightQueue.get(d.cumulativeTSNAck + uint32(i)) - if !ok { - return nil, errors.Errorf("Requested non-existent TSN %v", d.cumulativeTSNAck+uint32(i)) - } - - sackDataPackets = append(sackDataPackets, &packet{ - verificationTag: a.peerVerificationTag, - sourcePort: a.sourcePort, - destinationPort: a.destinationPort, - chunks: []chunk{pp}, - }) - } - prevEnd = g.end - } - - return sackDataPackets, nil -} - -// sendPayloadData sends the data chunks. -func (a *Association) sendPayloadData(chunks []*chunkPayloadData) error { - packets := []*packet{} - - a.lock.Lock() - for _, c := range chunks { - c.tsn = a.generateNextTSN() - - // TODO: FIX THIS HACK, inflightQueue uses PayloadQueue which is really meant for inbound SACK generation - a.inflightQueue.pushNoCheck(c) - - p := &packet{ - sourcePort: a.sourcePort, - destinationPort: a.destinationPort, - verificationTag: a.peerVerificationTag, - chunks: []chunk{c}} - packets = append(packets, p) - } - a.lock.Unlock() - - for _, p := range packets { - if err := a.send(p); err != nil { - return errors.Wrap(err, "Unable to send outbound packet") - } - } - - return nil -} - -// generateNextTSN returns the myNextTSN and increases it. The caller should hold the lock. -func (a *Association) generateNextTSN() uint32 { - tsn := a.myNextTSN - a.myNextTSN++ - return tsn -} - -// send sends a packet over nextConn. The caller should hold the lock. -func (a *Association) send(p *packet) error { - raw, err := p.marshal() - if err != nil { - return errors.Wrap(err, "Failed to send packet to outbound handler") - } - - _, err = a.nextConn.Write(raw) - return err -} - -func pack(p *packet) []*packet { - return []*packet{p} -} - -func (a *Association) handleChunk(p *packet, c chunk) ([]*packet, error) { - a.lock.Lock() - defer a.lock.Unlock() - - if _, err := c.check(); err != nil { - return nil, errors.Wrap(err, "Failed validating chunk") - // TODO: Create ABORT - } - - switch c := c.(type) { - case *chunkInit: - switch a.state { - case Open: - return pack(a.handleInit(p, c)), nil - case CookieWait: - // https://tools.ietf.org/html/rfc4960#section-5.2.1 - // Upon receipt of an INIT in the COOKIE-WAIT state, an endpoint MUST - // respond with an INIT ACK using the same parameters it sent in its - // original INIT chunk (including its Initiate Tag, unchanged). When - // responding, the endpoint MUST send the INIT ACK back to the same - // address that the original INIT (sent by this endpoint) was sent. - return pack(a.handleInit(p, c)), nil - - case CookieEchoed: - // https://tools.ietf.org/html/rfc4960#section-5.2.1 - // Upon receipt of an INIT in the COOKIE-ECHOED state, an endpoint MUST - // respond with an INIT ACK using the same parameters it sent in its - // original INIT chunk (including its Initiate Tag, unchanged) - return nil, errors.Errorf("TODO respond with original cookie %s", a.state.String()) - default: - // 5.2.2. Unexpected INIT in States Other than CLOSED, COOKIE-ECHOED, - // COOKIE-WAIT, and SHUTDOWN-ACK-SENT - return nil, errors.Errorf("TODO Handle Init when in state %s", a.state.String()) - } - - case *chunkInitAck: - switch a.state { - case CookieWait: - r, err := a.handleInitAck(p, c) - if err != nil { - return nil, err - } - a.setState(CookieEchoed) - return pack(r), nil - default: - return nil, errors.Errorf("TODO Handle Init acks when in state %s", a.state.String()) - } - - case *chunkAbort: - fmt.Println("Abort chunk, with errors:") - for _, e := range c.errorCauses { - fmt.Printf("error cause: %s\n", e) - } - - case *chunkHeartbeat: - hbi, ok := c.params[0].(*paramHeartbeatInfo) - if !ok { - fmt.Println("Failed to handle Heartbeat, no ParamHeartbeatInfo") - } - - return pack(&packet{ - verificationTag: a.peerVerificationTag, - sourcePort: a.sourcePort, - destinationPort: a.destinationPort, - chunks: []chunk{&chunkHeartbeatAck{ - params: []param{ - ¶mHeartbeatInfo{ - heartbeatInformation: hbi.heartbeatInformation, - }, - }, - }}, - }), nil - - case *chunkCookieEcho: - if bytes.Equal(a.myCookie.cookie, c.cookie) { - p := &packet{ - verificationTag: a.peerVerificationTag, - sourcePort: a.sourcePort, - destinationPort: a.destinationPort, - chunks: []chunk{&chunkCookieAck{}}, - } - a.setState(Established) - close(a.handshakeCompletedCh) - - return pack(p), nil - } - - case *chunkCookieAck: - switch a.state { - case CookieEchoed: - a.setState(Established) - close(a.handshakeCompletedCh) - return nil, nil - default: - return nil, errors.Errorf("TODO Handle Init acks when in state %s", a.state.String()) - } - - // TODO Abort - case *chunkPayloadData: - return pack(a.handleData(c)), nil - - case *chunkSelectiveAck: - p, err := a.handleSack(c) - if err != nil { - return nil, errors.Wrap(err, "Failure handling SACK") - } - return p, nil - - default: - return nil, errors.New("unhandled chunk type") - } - - return nil, nil -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/chunk.go b/vendor/github.com/pions/webrtc/internal/sctp/chunk.go deleted file mode 100644 index b545f0e..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/chunk.go +++ /dev/null @@ -1,157 +0,0 @@ -package sctp - -import ( - "encoding/binary" - "fmt" - - "github.com/pkg/errors" -) - -// chunkType is an enum for SCTP Chunk Type field -// This field identifies the type of information contained in the -// Chunk Value field. -type chunkType uint8 - -// List of known chunkType enums -const ( - PAYLOADDATA chunkType = 0 - INIT chunkType = 1 - INITACK chunkType = 2 - SACK chunkType = 3 - HEARTBEAT chunkType = 4 - HEARTBEATACK chunkType = 5 - ABORT chunkType = 6 - SHUTDOWN chunkType = 7 - SHUTDOWNACK chunkType = 8 - ERROR chunkType = 9 - COOKIEECHO chunkType = 10 - COOKIEACK chunkType = 11 - CWR chunkType = 13 - SHUTDOWNCOMPLETE chunkType = 14 -) - -func (c chunkType) String() string { - switch c { - case PAYLOADDATA: - return "Payload data" - case INIT: - return "Initiation" - case INITACK: - return "Initiation Acknowledgement" - case SACK: - return "Selective Acknowledgement" - case HEARTBEAT: - return "Heartbeat" - case HEARTBEATACK: - return "Heartbeat Acknowledgement" - case ABORT: - return "Abort" - case SHUTDOWN: - return "Shutdown" - case SHUTDOWNACK: - return "Shutdown Acknowledgement" - case ERROR: - return "Error" - case COOKIEECHO: - return "Cookie Echo" - case COOKIEACK: - return "Cookie Acknowledgement" - case CWR: - return "Congestion Window Reduced" - case SHUTDOWNCOMPLETE: - return "Shutdown Complete" - default: - return fmt.Sprintf("Unknown ChunkType: %d", c) - } -} - -/* -chunkHeader represents a SCTP Chunk header, defined in https://tools.ietf.org/html/rfc4960#section-3.2 -The figure below illustrates the field format for the chunks to be -transmitted in the SCTP packet. Each chunk is formatted with a Chunk -Type field, a chunk-specific Flag field, a Chunk Length field, and a -Value field. - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Chunk Type | Chunk Flags | Chunk Length | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | -| Chunk Value | -| | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -*/ -type chunkHeader struct { - typ chunkType - flags byte - raw []byte -} - -const ( - chunkHeaderSize = 4 -) - -func (c *chunkHeader) unmarshal(raw []byte) error { - if len(raw) < chunkHeaderSize { - return errors.Errorf("raw only %d bytes, %d is the minimum length for a SCTP chunk", len(raw), chunkHeaderSize) - } - - c.typ = chunkType(raw[0]) - c.flags = raw[1] - length := binary.BigEndian.Uint16(raw[2:]) - - // Length includes Chunk header - valueLength := int(length - chunkHeaderSize) - lengthAfterValue := len(raw) - (chunkHeaderSize + valueLength) - - if lengthAfterValue < 0 { - return errors.Errorf("Not enough data left in SCTP packet to satisfy requested length remain %d req %d ", valueLength, len(raw)-chunkHeaderSize) - } else if lengthAfterValue < 4 { - // https://tools.ietf.org/html/rfc4960#section-3.2 - // The Chunk Length field does not count any chunk padding. - // Chunks (including Type, Length, and Value fields) are padded out - // by the sender with all zero bytes to be a multiple of 4 bytes - // long. This padding MUST NOT be more than 3 bytes in total. The - // Chunk Length value does not include terminating padding of the - // chunk. However, it does include padding of any variable-length - // parameter except the last parameter in the chunk. The receiver - // MUST ignore the padding. - for i := lengthAfterValue; i > 0; i-- { - paddingOffset := chunkHeaderSize + valueLength + (i - 1) - if raw[paddingOffset] != 0 { - return errors.Errorf("Chunk padding is non-zero at offset %d ", paddingOffset) - } - } - } - - c.raw = raw[chunkHeaderSize : chunkHeaderSize+valueLength] - return nil -} - -func (c *chunkHeader) marshal() ([]byte, error) { - raw := make([]byte, 4+len(c.raw)) - - raw[0] = uint8(c.typ) - raw[1] = c.flags - binary.BigEndian.PutUint16(raw[2:], uint16(len(c.raw)+chunkHeaderSize)) - copy(raw[4:], c.raw) - return raw, nil -} - -func (c *chunkHeader) valueLength() int { - return len(c.raw) -} - -type chunk interface { - unmarshal(raw []byte) error - marshal() ([]byte, error) - check() (bool, error) - - valueLength() int -} - -// String makes chunkHeader printable -func (c chunkHeader) String() string { - return c.typ.String() -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/chunk_abort.go b/vendor/github.com/pions/webrtc/internal/sctp/chunk_abort.go deleted file mode 100644 index 7465d17..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/chunk_abort.go +++ /dev/null @@ -1,77 +0,0 @@ -package sctp - -import ( - "fmt" - - "github.com/pkg/errors" -) - -/* -Abort represents an SCTP Chunk of type ABORT - -The ABORT chunk is sent to the peer of an association to close the -association. The ABORT chunk may contain Cause Parameters to inform -the receiver about the reason of the abort. DATA chunks MUST NOT be -bundled with ABORT. Control chunks (except for INIT, INIT ACK, and -SHUTDOWN COMPLETE) MAY be bundled with an ABORT, but they MUST be -placed before the ABORT in the SCTP packet or they will be ignored by -the receiver. - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Type = 6 |Reserved |T| Length | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | -| zero or more Error Causes | -| | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -*/ -type chunkAbort struct { - chunkHeader - errorCauses []errorCause -} - -func (a *chunkAbort) unmarshal(raw []byte) error { - if err := a.chunkHeader.unmarshal(raw); err != nil { - return err - } - - if a.typ != ABORT { - return errors.Errorf("ChunkType is not of type ABORT, actually is %s", a.typ.String()) - } - - offset := chunkHeaderSize - for { - if len(raw)-offset < 4 { - break - } - - e, err := buildErrorCause(raw[offset:]) - if err != nil { - return errors.Wrap(err, "Failed build Abort Chunk") - } - - offset += int(e.length()) - a.errorCauses = append(a.errorCauses, e) - } - return nil -} -func (a *chunkAbort) marshal() ([]byte, error) { - return nil, errors.Errorf("Unimplemented") -} - -func (a *chunkAbort) check() (abort bool, err error) { - return false, nil -} - -// String makes chunkAbort printable -func (a *chunkAbort) String() string { - res := a.chunkHeader.String() - - for _, cause := range a.errorCauses { - res += fmt.Sprintf("\n - %s", cause) - } - - return res -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/chunk_cookie_ack.go b/vendor/github.com/pions/webrtc/internal/sctp/chunk_cookie_ack.go deleted file mode 100644 index 4882db4..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/chunk_cookie_ack.go +++ /dev/null @@ -1,44 +0,0 @@ -package sctp - -import ( - "github.com/pkg/errors" -) - -/* -chunkCookieAck represents an SCTP Chunk of type chunkCookieAck - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Type = 11 |Chunk Flags | Length = 4 | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -*/ -type chunkCookieAck struct { - chunkHeader -} - -func (c *chunkCookieAck) unmarshal(raw []byte) error { - if err := c.chunkHeader.unmarshal(raw); err != nil { - return err - } - - if c.typ != COOKIEACK { - return errors.Errorf("ChunkType is not of type COOKIEACK, actually is %s", c.typ.String()) - } - - return nil -} - -func (c *chunkCookieAck) marshal() ([]byte, error) { - c.chunkHeader.typ = COOKIEACK - return c.chunkHeader.marshal() -} - -func (c *chunkCookieAck) check() (abort bool, err error) { - return false, nil -} - -// String makes chunkCookieAck printable -func (c *chunkCookieAck) String() string { - return c.chunkHeader.String() -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/chunk_cookie_echo.go b/vendor/github.com/pions/webrtc/internal/sctp/chunk_cookie_echo.go deleted file mode 100644 index 7744c1f..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/chunk_cookie_echo.go +++ /dev/null @@ -1,46 +0,0 @@ -package sctp - -import ( - "github.com/pkg/errors" -) - -/* -CookieEcho represents an SCTP Chunk of type CookieEcho - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Type = 10 |Chunk Flags | Length | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Cookie | -| | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - -*/ -type chunkCookieEcho struct { - chunkHeader - cookie []byte -} - -func (c *chunkCookieEcho) unmarshal(raw []byte) error { - if err := c.chunkHeader.unmarshal(raw); err != nil { - return err - } - - if c.typ != COOKIEECHO { - return errors.Errorf("ChunkType is not of type COOKIEECHO, actually is %s", c.typ.String()) - } - c.cookie = c.raw - - return nil -} - -func (c *chunkCookieEcho) marshal() ([]byte, error) { - c.chunkHeader.typ = COOKIEECHO - c.chunkHeader.raw = c.cookie - return c.chunkHeader.marshal() -} - -func (c *chunkCookieEcho) check() (abort bool, err error) { - return false, nil -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/chunk_heartbeat.go b/vendor/github.com/pions/webrtc/internal/sctp/chunk_heartbeat.go deleted file mode 100644 index b2a6e35..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/chunk_heartbeat.go +++ /dev/null @@ -1,74 +0,0 @@ -package sctp - -import ( - "encoding/binary" - - "github.com/pkg/errors" -) - -/* -chunkHeartbeat represents an SCTP Chunk of type HEARTBEAT - -An endpoint should send this chunk to its peer endpoint to probe the -reachability of a particular destination transport address defined in -the present association. - -The parameter field contains the Heartbeat Information, which is a -variable-length opaque data structure understood only by the sender. - - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Type = 4 | Chunk Flags | Heartbeat Length | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | -| Heartbeat Information TLV (Variable-Length) | -| | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - -Defined as a variable-length parameter using the format described -in Section 3.2.1, i.e.: - -Variable Parameters Status Type Value -------------------------------------------------------------- -heartbeat Info Mandatory 1 - -*/ -type chunkHeartbeat struct { - chunkHeader - params []param -} - -func (h *chunkHeartbeat) unmarshal(raw []byte) error { - if err := h.chunkHeader.unmarshal(raw); err != nil { - return err - } else if h.typ != HEARTBEAT { - return errors.Errorf("ChunkType is not of type HEARTBEAT, actually is %s", h.typ.String()) - } - - if len(raw) <= chunkHeaderSize { - return errors.Errorf("Heartbeat is not long enough to contain Heartbeat Info %d", len(raw)) - } - - pType := paramType(binary.BigEndian.Uint16(raw[chunkHeaderSize:])) - if pType != heartbeatInfo { - return errors.Errorf("Heartbeat should only have HEARTBEAT param, instead have %s", pType.String()) - } - - p, err := buildParam(pType, raw[chunkHeaderSize:]) - if err != nil { - return errors.Wrap(err, "Failed unmarshalling param in Heartbeat Chunk") - } - h.params = append(h.params, p) - - return nil -} - -func (h *chunkHeartbeat) Marshal() ([]byte, error) { - return nil, errors.Errorf("Unimplemented") -} - -func (h *chunkHeartbeat) check() (abort bool, err error) { - return false, nil -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/chunk_heartbeat_ack.go b/vendor/github.com/pions/webrtc/internal/sctp/chunk_heartbeat_ack.go deleted file mode 100644 index 18ff520..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/chunk_heartbeat_ack.go +++ /dev/null @@ -1,88 +0,0 @@ -package sctp - -import ( - "github.com/pkg/errors" -) - -/* -chunkHeartbeatAck represents an SCTP Chunk of type HEARTBEAT ACK - -An endpoint should send this chunk to its peer endpoint as a response -to a HEARTBEAT chunk (see Section 8.3). A HEARTBEAT ACK is always -sent to the source IP address of the IP datagram containing the -HEARTBEAT chunk to which this ack is responding. - -The parameter field contains a variable-length opaque data structure. - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Type = 5 | Chunk Flags | Heartbeat Ack Length | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | -| Heartbeat Information TLV (Variable-Length) | -| | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - -Defined as a variable-length parameter using the format described -in Section 3.2.1, i.e.: - -Variable Parameters Status Type Value -------------------------------------------------------------- -Heartbeat Info Mandatory 1 - -*/ -type chunkHeartbeatAck struct { - chunkHeader - params []param -} - -func (h *chunkHeartbeatAck) unmarshal(raw []byte) error { - return errors.Errorf("Unimplemented") -} - -func (h *chunkHeartbeatAck) marshal() ([]byte, error) { - if len(h.params) != 1 { - return nil, errors.Errorf("Heartbeat Ack must have one param") - } - - switch h.params[0].(type) { - case *paramHeartbeatInfo: - // ParamHeartbeatInfo is valid - default: - return nil, errors.Errorf("Heartbeat Ack must have one param, and it should be a HeartbeatInfo") - - } - - out := make([]byte, 0) - for idx, p := range h.params { - pp, err := p.marshal() - if err != nil { - return nil, errors.Wrap(err, "Unable to marshal parameter for Heartbeat Ack") - } - - out = append(out, pp...) - - // Chunks (including Type, Length, and Value fields) are padded out - // by the sender with all zero bytes to be a multiple of 4 bytes - // long. This padding MUST NOT be more than 3 bytes in total. The - // Chunk Length value does not include terminating padding of the - // chunk. *However, it does include padding of any variable-length - // parameter except the last parameter in the chunk.* The receiver - // MUST ignore the padding. - if idx != len(h.params)-1 { - padding := make([]byte, getPadding(len(pp))) - out = append(out, padding...) - } - } - - h.chunkHeader.typ = HEARTBEATACK - h.chunkHeader.raw = out - - return h.chunkHeader.marshal() -} - -func (h *chunkHeartbeatAck) check() (abort bool, err error) { - return false, nil -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/chunk_init.go b/vendor/github.com/pions/webrtc/internal/sctp/chunk_init.go deleted file mode 100644 index ad02fd2..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/chunk_init.go +++ /dev/null @@ -1,123 +0,0 @@ -package sctp - -import ( - "fmt" - - "github.com/pkg/errors" -) - -/* -Init represents an SCTP Chunk of type INIT - -See chunkInitCommon for the fixed headers - -Variable Parameters Status Type Value -------------------------------------------------------------- -IPv4 IP (Note 1) Optional 5 -IPv6 IP (Note 1) Optional 6 -Cookie Preservative Optional 9 -Reserved for ECN Capable (Note 2) Optional 32768 (0x8000) -Host Name IP (Note 3) Optional 11 -Supported IP Types (Note 4) Optional 12 -*/ -type chunkInit struct { - chunkHeader - chunkInitCommon -} - -func (i *chunkInit) unmarshal(raw []byte) error { - if err := i.chunkHeader.unmarshal(raw); err != nil { - return err - } - - if i.typ != INIT { - return errors.Errorf("ChunkType is not of type INIT, actually is %s", i.typ.String()) - } else if len(i.raw) < initChunkMinLength { - return errors.Errorf("Chunk Value isn't long enough for mandatory parameters exp: %d actual: %d", initChunkMinLength, len(i.raw)) - } - - // The Chunk Flags field in INIT is reserved, and all bits in it should - // be set to 0 by the sender and ignored by the receiver. The sequence - // of parameters within an INIT can be processed in any order. - if i.flags != 0 { - return errors.New("ChunkType of type INIT flags must be all 0") - } - - if err := i.chunkInitCommon.unmarshal(i.raw); err != nil { - return errors.Wrap(err, "Failed to unmarshal INIT body") - } - - return nil -} - -func (i *chunkInit) marshal() ([]byte, error) { - initShared, err := i.chunkInitCommon.marshal() - if err != nil { - return nil, errors.Wrap(err, "Failed marshalling INIT common data") - } - - i.chunkHeader.typ = INIT - i.chunkHeader.raw = initShared - return i.chunkHeader.marshal() -} - -func (i *chunkInit) check() (abort bool, err error) { - // The receiver of the INIT (the responding end) records the value of - // the Initiate Tag parameter. This value MUST be placed into the - // Verification Tag field of every SCTP packet that the receiver of - // the INIT transmits within this association. - // - // The Initiate Tag is allowed to have any value except 0. See - // Section 5.3.1 for more on the selection of the tag value. - // - // If the value of the Initiate Tag in a received INIT chunk is found - // to be 0, the receiver MUST treat it as an error and close the - // association by transmitting an ABORT. - if i.initiateTag == 0 { - abort = true - return abort, errors.New("ChunkType of type INIT InitiateTag must not be 0") - } - - // Defines the maximum number of streams the sender of this INIT - // chunk allows the peer end to create in this association. The - // value 0 MUST NOT be used. - // - // Note: There is no negotiation of the actual number of streams but - // instead the two endpoints will use the min(requested, offered). - // See Section 5.1.1 for details. - // - // Note: A receiver of an INIT with the MIS value of 0 SHOULD abort - // the association. - if i.numInboundStreams == 0 { - abort = true - return abort, errors.New("INIT inbound stream request must be > 0") - } - - // Defines the number of outbound streams the sender of this INIT - // chunk wishes to create in this association. The value of 0 MUST - // NOT be used. - // - // Note: A receiver of an INIT with the OS value set to 0 SHOULD - // abort the association. - - if i.numOutboundStreams == 0 { - abort = true - return abort, errors.New("INIT outbound stream request must be > 0") - } - - // An SCTP receiver MUST be able to receive a minimum of 1500 bytes in - // one SCTP packet. This means that an SCTP endpoint MUST NOT indicate - // less than 1500 bytes in its initial a_rwnd sent in the INIT or INIT - // ACK. - if i.advertisedReceiverWindowCredit < 1500 { - abort = true - return abort, errors.New("INIT Advertised Receiver Window Credit (a_rwnd) must be >= 1500") - } - - return false, nil -} - -// String makes chunkInit printable -func (i *chunkInit) String() string { - return fmt.Sprintf("%s\n%s", i.chunkHeader, i.chunkInitCommon) -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/chunk_init_ack.go b/vendor/github.com/pions/webrtc/internal/sctp/chunk_init_ack.go deleted file mode 100644 index 83c1244..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/chunk_init_ack.go +++ /dev/null @@ -1,127 +0,0 @@ -package sctp - -import ( - "fmt" - - "github.com/pkg/errors" -) - -/* -chunkInitAck represents an SCTP Chunk of type INIT ACK - -See chunkInitCommon for the fixed headers - -Variable Parameters Status Type Value -------------------------------------------------------------- -State Cookie Mandatory 7 -IPv4 IP (Note 1) Optional 5 -IPv6 IP (Note 1) Optional 6 -Unrecognized Parameter Optional 8 -Reserved for ECN Capable (Note 2) Optional 32768 (0x8000) -Host Name IP (Note 3) Optional 11 - -*/ -type chunkInitAck struct { - chunkHeader - chunkInitCommon -} - -func (i *chunkInitAck) unmarshal(raw []byte) error { - if err := i.chunkHeader.unmarshal(raw); err != nil { - return err - } - - if i.typ != INITACK { - return errors.Errorf("ChunkType is not of type INIT ACK, actually is %s", i.typ.String()) - } else if len(i.raw) < initChunkMinLength { - return errors.Errorf("Chunk Value isn't long enough for mandatory parameters exp: %d actual: %d", initChunkMinLength, len(i.raw)) - } - - // The Chunk Flags field in INIT is reserved, and all bits in it should - // be set to 0 by the sender and ignored by the receiver. The sequence - // of parameters within an INIT can be processed in any order. - if i.flags != 0 { - return errors.New("ChunkType of type INIT ACK flags must be all 0") - } - - if err := i.chunkInitCommon.unmarshal(i.raw); err != nil { - return errors.Wrap(err, "Failed to unmarshal INIT body") - } - - return nil -} - -func (i *chunkInitAck) marshal() ([]byte, error) { - initShared, err := i.chunkInitCommon.marshal() - if err != nil { - return nil, errors.Wrap(err, "Failed marshalling INIT common data") - } - - i.chunkHeader.typ = INITACK - i.chunkHeader.raw = initShared - return i.chunkHeader.marshal() -} - -func (i *chunkInitAck) check() (abort bool, err error) { - - // The receiver of the INIT ACK records the value of the Initiate Tag - // parameter. This value MUST be placed into the Verification Tag - // field of every SCTP packet that the INIT ACK receiver transmits - // within this association. - // - // The Initiate Tag MUST NOT take the value 0. See Section 5.3.1 for - // more on the selection of the Initiate Tag value. - // - // If the value of the Initiate Tag in a received INIT ACK chunk is - // found to be 0, the receiver MUST destroy the association - // discarding its TCB. The receiver MAY send an ABORT for debugging - // purpose. - if i.initiateTag == 0 { - abort = true - return abort, errors.New("ChunkType of type INIT ACK InitiateTag must not be 0") - } - - // Defines the maximum number of streams the sender of this INIT ACK - // chunk allows the peer end to create in this association. The - // value 0 MUST NOT be used. - // - // Note: There is no negotiation of the actual number of streams but - // instead the two endpoints will use the min(requested, offered). - // See Section 5.1.1 for details. - // - // Note: A receiver of an INIT ACK with the MIS value set to 0 SHOULD - // destroy the association discarding its TCB. - if i.numInboundStreams == 0 { - abort = true - return abort, errors.New("INIT ACK inbound stream request must be > 0") - } - - // Defines the number of outbound streams the sender of this INIT ACK - // chunk wishes to create in this association. The value of 0 MUST - // NOT be used, and the value MUST NOT be greater than the MIS value - // sent in the INIT chunk. - // - // Note: A receiver of an INIT ACK with the OS value set to 0 SHOULD - // destroy the association discarding its TCB. - - if i.numOutboundStreams == 0 { - abort = true - return abort, errors.New("INIT ACK outbound stream request must be > 0") - } - - // An SCTP receiver MUST be able to receive a minimum of 1500 bytes in - // one SCTP packet. This means that an SCTP endpoint MUST NOT indicate - // less than 1500 bytes in its initial a_rwnd sent in the INIT or INIT - // ACK. - if i.advertisedReceiverWindowCredit < 1500 { - abort = true - return abort, errors.New("INIT ACK Advertised Receiver Window Credit (a_rwnd) must be >= 1500") - } - - return false, nil -} - -// String makes chunkInitAck printable -func (i *chunkInitAck) String() string { - return fmt.Sprintf("%s\n%s", i.chunkHeader, i.chunkInitCommon) -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/chunk_init_common.go b/vendor/github.com/pions/webrtc/internal/sctp/chunk_init_common.go deleted file mode 100644 index 238b889..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/chunk_init_common.go +++ /dev/null @@ -1,154 +0,0 @@ -package sctp - -import ( - "encoding/binary" - "fmt" - - "github.com/pkg/errors" -) - -/* -chunkInitCommon represents an SCTP Chunk body of type INIT and INIT ACK - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Type = 1 | Chunk Flags | Chunk Length | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Initiate Tag | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Advertised Receiver Window Credit (a_rwnd) | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Number of Outbound Streams | Number of Inbound Streams | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Initial TSN | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | -| Optional/Variable-Length Parameters | -| | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - -The INIT chunk contains the following parameters. Unless otherwise -noted, each parameter MUST only be included once in the INIT chunk. - -Fixed Parameters Status ----------------------------------------------- -Initiate Tag Mandatory -Advertised Receiver Window Credit Mandatory -Number of Outbound Streams Mandatory -Number of Inbound Streams Mandatory -Initial TSN Mandatory -*/ - -type chunkInitCommon struct { - initiateTag uint32 - advertisedReceiverWindowCredit uint32 - numOutboundStreams uint16 - numInboundStreams uint16 - initialTSN uint32 - params []param -} - -const ( - initChunkMinLength = 16 - initOptionalVarHeaderLength = 4 -) - -func (i *chunkInitCommon) unmarshal(raw []byte) error { - - i.initiateTag = binary.BigEndian.Uint32(raw[0:]) - i.advertisedReceiverWindowCredit = binary.BigEndian.Uint32(raw[4:]) - i.numOutboundStreams = binary.BigEndian.Uint16(raw[8:]) - i.numInboundStreams = binary.BigEndian.Uint16(raw[10:]) - i.initialTSN = binary.BigEndian.Uint32(raw[12:]) - - // https://tools.ietf.org/html/rfc4960#section-3.2.1 - // - // Chunk values of SCTP control chunks consist of a chunk-type-specific - // header of required fields, followed by zero or more parameters. The - // optional and variable-length parameters contained in a chunk are - // defined in a Type-Length-Value format as shown below. - // - // 0 1 2 3 - // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - // | Parameter Type | Parameter Length | - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - // | | - // | Parameter Value | - // | | - // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - offset := initChunkMinLength - remaining := len(raw) - offset - for remaining > 0 { - if remaining > initOptionalVarHeaderLength { - pType := paramType(binary.BigEndian.Uint16(raw[offset:])) - p, err := buildParam(pType, raw[offset:]) - if err != nil { - return errors.Wrap(err, "Failed unmarshalling param in Init Chunk") - } - i.params = append(i.params, p) - padding := getPadding(p.length()) - offset += p.length() + padding - remaining -= p.length() + padding - } else { - break - } - } - - return nil -} - -func (i *chunkInitCommon) marshal() ([]byte, error) { - out := make([]byte, initChunkMinLength) - binary.BigEndian.PutUint32(out[0:], i.initiateTag) - binary.BigEndian.PutUint32(out[4:], i.advertisedReceiverWindowCredit) - binary.BigEndian.PutUint16(out[8:], i.numOutboundStreams) - binary.BigEndian.PutUint16(out[10:], i.numInboundStreams) - binary.BigEndian.PutUint32(out[12:], i.initialTSN) - for idx, p := range i.params { - pp, err := p.marshal() - if err != nil { - return nil, errors.Wrap(err, "Unable to marshal parameter for INIT/INITACK") - } - - out = append(out, pp...) - - // Chunks (including Type, Length, and Value fields) are padded out - // by the sender with all zero bytes to be a multiple of 4 bytes - // long. This padding MUST NOT be more than 3 bytes in total. The - // Chunk Length value does not include terminating padding of the - // chunk. *However, it does include padding of any variable-length - // parameter except the last parameter in the chunk.* The receiver - // MUST ignore the padding. - if idx != len(i.params)-1 { - padding := make([]byte, getPadding(len(pp))) - out = append(out, padding...) - } - } - - return out, nil -} - -// String makes chunkInitCommon printable -func (i chunkInitCommon) String() string { - format := `initiateTag: %d - advertisedReceiverWindowCredit: %d - numOutboundStreams: %d - numInboundStreams: %d - initialTSN: %d` - - res := fmt.Sprintf(format, - i.initiateTag, - i.advertisedReceiverWindowCredit, - i.numOutboundStreams, - i.numInboundStreams, - i.initialTSN, - ) - - for i, param := range i.params { - res = res + fmt.Sprintf("Param %d:\n %s", i, param) - } - return res -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/chunk_payload_data.go b/vendor/github.com/pions/webrtc/internal/sctp/chunk_payload_data.go deleted file mode 100644 index 9142753..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/chunk_payload_data.go +++ /dev/null @@ -1,154 +0,0 @@ -package sctp - -import ( - "encoding/binary" - "fmt" -) - -/* -chunkPayloadData represents an SCTP Chunk of type DATA - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Type = 0 | Reserved|U|B|E| Length | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| TSN | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Stream Identifier S | Stream Sequence Number n | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Payload Protocol Identifier | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| | -| User Data (seq n of Stream S) | -| | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - -An unfragmented user message shall have both the B and E bits set to -'1'. Setting both B and E bits to '0' indicates a middle fragment of -a multi-fragment user message, as summarized in the following table: - B E Description -============================================================ -| 1 0 | First piece of a fragmented user message | -+----------------------------------------------------------+ -| 0 0 | Middle piece of a fragmented user message | -+----------------------------------------------------------+ -| 0 1 | Last piece of a fragmented user message | -+----------------------------------------------------------+ -| 1 1 | Unfragmented message | -============================================================ -| Table 1: Fragment Description Flags | -============================================================ -*/ -type chunkPayloadData struct { - chunkHeader - - unordered bool - beginingFragment bool - endingFragment bool - immediateSack bool - - tsn uint32 - streamIdentifier uint16 - streamSequenceNumber uint16 - payloadType PayloadProtocolIdentifier - userData []byte -} - -const ( - payloadDataEndingFragmentBitmask = 1 - payloadDataBeginingFragmentBitmask = 2 - payloadDataUnorderedBitmask = 4 - payloadDataImmediateSACK = 8 - - payloadDataHeaderSize = 12 -) - -// PayloadProtocolIdentifier is an enum for DataChannel payload types -type PayloadProtocolIdentifier uint32 - -// PayloadProtocolIdentifier enums -// https://www.iana.org/assignments/sctp-parameters/sctp-parameters.xhtml#sctp-parameters-25 -const ( - PayloadTypeWebRTCDCEP PayloadProtocolIdentifier = 50 - PayloadTypeWebRTCString PayloadProtocolIdentifier = 51 - PayloadTypeWebRTCBinary PayloadProtocolIdentifier = 53 - PayloadTypeWebRTCStringEmpty PayloadProtocolIdentifier = 56 - PayloadTypeWebRTCBinaryEmpty PayloadProtocolIdentifier = 57 -) - -func (p PayloadProtocolIdentifier) String() string { - switch p { - case PayloadTypeWebRTCDCEP: - return "WebRTC DCEP" - case PayloadTypeWebRTCString: - return "WebRTC String" - case PayloadTypeWebRTCBinary: - return "WebRTC Binary" - case PayloadTypeWebRTCStringEmpty: - return "WebRTC String (Empty)" - case PayloadTypeWebRTCBinaryEmpty: - return "WebRTC Binary (Empty)" - default: - return fmt.Sprintf("Unknown Payload Protocol Identifier: %d", p) - } -} - -func (p *chunkPayloadData) unmarshal(raw []byte) error { - if err := p.chunkHeader.unmarshal(raw); err != nil { - return err - } - - p.immediateSack = p.flags&payloadDataImmediateSACK != 0 - p.unordered = p.flags&payloadDataUnorderedBitmask != 0 - p.beginingFragment = p.flags&payloadDataBeginingFragmentBitmask != 0 - p.endingFragment = p.flags&payloadDataEndingFragmentBitmask != 0 - - p.tsn = binary.BigEndian.Uint32(p.raw[0:]) - p.streamIdentifier = binary.BigEndian.Uint16(p.raw[4:]) - p.streamSequenceNumber = binary.BigEndian.Uint16(p.raw[6:]) - p.payloadType = PayloadProtocolIdentifier(binary.BigEndian.Uint32(p.raw[8:])) - p.userData = p.raw[payloadDataHeaderSize:] - - return nil -} - -func (p *chunkPayloadData) marshal() ([]byte, error) { - - payRaw := make([]byte, payloadDataHeaderSize+len(p.userData)) - - binary.BigEndian.PutUint32(payRaw[0:], p.tsn) - binary.BigEndian.PutUint16(payRaw[4:], p.streamIdentifier) - binary.BigEndian.PutUint16(payRaw[6:], p.streamSequenceNumber) - binary.BigEndian.PutUint32(payRaw[8:], uint32(p.payloadType)) - copy(payRaw[payloadDataHeaderSize:], p.userData) - - flags := uint8(0) - if p.endingFragment { - flags = 1 - } - if p.beginingFragment { - flags |= 1 << 1 - } - if p.unordered { - flags |= 1 << 2 - } - if p.immediateSack { - flags |= 1 << 3 - } - - p.chunkHeader.flags = flags - p.chunkHeader.typ = PAYLOADDATA - p.chunkHeader.raw = payRaw - return p.chunkHeader.marshal() -} - -func (p *chunkPayloadData) check() (abort bool, err error) { - return false, nil -} - -// String makes chunkPayloadData printable -func (p *chunkPayloadData) String() string { - return fmt.Sprintf("%s\n%d", p.chunkHeader, p.tsn) -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/chunk_selective_ack.go b/vendor/github.com/pions/webrtc/internal/sctp/chunk_selective_ack.go deleted file mode 100644 index 57a5261..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/chunk_selective_ack.go +++ /dev/null @@ -1,139 +0,0 @@ -package sctp - -import ( - "encoding/binary" - "fmt" - - "github.com/pkg/errors" -) - -/* -chunkSelectiveAck represents an SCTP Chunk of type SACK - -This chunk is sent to the peer endpoint to acknowledge received DATA -chunks and to inform the peer endpoint of gaps in the received -subsequences of DATA chunks as represented by their TSNs. -0 1 2 3 -0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Type = 3 |Chunk Flags | Chunk Length | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Cumulative TSN Ack | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Advertised Receiver Window Credit (a_rwnd) | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Number of Gap Ack Blocks = N | Number of Duplicate TSNs = X | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Gap Ack Block #1 Start | Gap Ack Block #1 End | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -/ / -\ ... \ -/ / -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Gap Ack Block #N Start | Gap Ack Block #N End | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Duplicate TSN 1 | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -/ / -\ ... \ -/ / -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Duplicate TSN X | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -*/ - -type gapAckBlock struct { - start uint16 - end uint16 -} - -// String makes gapAckBlock printable -func (g gapAckBlock) String() string { - return fmt.Sprintf("%d - %d", g.start, g.end) -} - -type chunkSelectiveAck struct { - chunkHeader - cumulativeTSNAck uint32 - advertisedReceiverWindowCredit uint32 - gapAckBlocks []gapAckBlock - duplicateTSN []uint32 -} - -const ( - selectiveAckHeaderSize = 12 -) - -func (s *chunkSelectiveAck) unmarshal(raw []byte) error { - if err := s.chunkHeader.unmarshal(raw); err != nil { - return err - } - - if s.typ != SACK { - return errors.Errorf("ChunkType is not of type SACK, actually is %s", s.typ.String()) - } - - if len(s.raw) < selectiveAckHeaderSize { - return errors.Errorf("SACK Chunk size is not large enough to contain header (%v remaining, needs %v bytes)", - len(s.raw), selectiveAckHeaderSize) - } - - s.cumulativeTSNAck = binary.BigEndian.Uint32(s.raw[0:]) - s.advertisedReceiverWindowCredit = binary.BigEndian.Uint32(s.raw[4:]) - s.gapAckBlocks = make([]gapAckBlock, binary.BigEndian.Uint16(s.raw[8:])) - s.duplicateTSN = make([]uint32, binary.BigEndian.Uint16(s.raw[10:])) - - if len(s.raw) != selectiveAckHeaderSize+(4*len(s.gapAckBlocks)+(4*len(s.duplicateTSN))) { - return errors.Errorf("SACK Chunk size does not match predicted amount from header values") - } - - offset := selectiveAckHeaderSize - for i := range s.gapAckBlocks { - s.gapAckBlocks[i].start = binary.BigEndian.Uint16(s.raw[offset:]) - s.gapAckBlocks[i].end = binary.BigEndian.Uint16(s.raw[offset+2:]) - offset += 4 - } - for i := range s.duplicateTSN { - s.duplicateTSN[i] = binary.BigEndian.Uint32(s.raw[offset:]) - offset += 4 - } - - return nil -} - -func (s *chunkSelectiveAck) marshal() ([]byte, error) { - sackRaw := make([]byte, selectiveAckHeaderSize+(4*len(s.gapAckBlocks)+(4*len(s.duplicateTSN)))) - binary.BigEndian.PutUint32(sackRaw[0:], s.cumulativeTSNAck) - binary.BigEndian.PutUint32(sackRaw[4:], s.advertisedReceiverWindowCredit) - binary.BigEndian.PutUint16(sackRaw[8:], uint16(len(s.gapAckBlocks))) - binary.BigEndian.PutUint16(sackRaw[10:], uint16(len(s.duplicateTSN))) - offset := selectiveAckHeaderSize - for _, g := range s.gapAckBlocks { - binary.BigEndian.PutUint16(sackRaw[offset:], g.start) - binary.BigEndian.PutUint16(sackRaw[offset+2:], g.end) - offset += 4 - } - for _, t := range s.duplicateTSN { - binary.BigEndian.PutUint32(sackRaw[offset:], t) - offset += 4 - } - - s.chunkHeader.typ = SACK - s.chunkHeader.raw = sackRaw - return s.chunkHeader.marshal() -} - -func (s *chunkSelectiveAck) check() (abort bool, err error) { - return false, nil -} - -// String makes chunkSelectiveAck printable -func (s *chunkSelectiveAck) String() string { - res := fmt.Sprintf("%s\n%d", s.chunkHeader, s.cumulativeTSNAck) - - for _, gap := range s.gapAckBlocks { - res = fmt.Sprintf("\n gap ack: %s", gap) - } - - return res -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/common.go b/vendor/github.com/pions/webrtc/internal/sctp/common.go deleted file mode 100644 index d0c2432..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/common.go +++ /dev/null @@ -1,9 +0,0 @@ -package sctp - -const ( - paddingMultiple = 4 -) - -func getPadding(len int) int { - return (paddingMultiple - (len % paddingMultiple)) % paddingMultiple -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/error_cause.go b/vendor/github.com/pions/webrtc/internal/sctp/error_cause.go deleted file mode 100644 index e94cc5c..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/error_cause.go +++ /dev/null @@ -1,91 +0,0 @@ -package sctp - -import ( - "encoding/binary" - "fmt" - - "github.com/pkg/errors" -) - -// errorCauseCode is a cause code that appears in either a ERROR or ABORT chunk -type errorCauseCode uint16 - -type errorCause interface { - unmarshal([]byte) error - marshal() ([]byte, error) - length() uint16 - String() string - - errorCauseCode() errorCauseCode -} - -// buildErrorCause delegates the building of a error cause from raw bytes to the correct structure -func buildErrorCause(raw []byte) (errorCause, error) { - var e errorCause - - c := errorCauseCode(binary.BigEndian.Uint16(raw[0:])) - switch c { - case invalidMandatoryParameter: - e = &errorCauseInvalidMandatoryParameter{} - case unrecognizedChunkType: - e = &errorCauseUnrecognizedChunkType{} - case protocolViolation: - e = &errorCauseProtocolViolation{} - default: - return nil, errors.Errorf("BuildErrorCause does not handle %s", c.String()) - } - - if err := e.unmarshal(raw); err != nil { - return nil, err - } - return e, nil -} - -const ( - invalidStreamIdentifier errorCauseCode = 1 - missingMandatoryParameter errorCauseCode = 2 - staleCookieError errorCauseCode = 3 - outOfResource errorCauseCode = 4 - unresolvableAddress errorCauseCode = 5 - unrecognizedChunkType errorCauseCode = 6 - invalidMandatoryParameter errorCauseCode = 7 - unrecognizedParameters errorCauseCode = 8 - noUserData errorCauseCode = 9 - cookieReceivedWhileShuttingDown errorCauseCode = 10 - restartOfAnAssociationWithNewAddresses errorCauseCode = 11 - userInitiatedAbort errorCauseCode = 12 - protocolViolation errorCauseCode = 13 -) - -func (e errorCauseCode) String() string { - switch e { - case invalidStreamIdentifier: - return "Invalid Stream Identifier" - case missingMandatoryParameter: - return "Missing Mandatory Parameter" - case staleCookieError: - return "Stale Cookie Error" - case outOfResource: - return "Out Of Resource" - case unresolvableAddress: - return "Unresolvable IP" - case unrecognizedChunkType: - return "Unrecognized Chunk Type" - case invalidMandatoryParameter: - return "Invalid Mandatory Parameter" - case unrecognizedParameters: - return "Unrecognized Parameters" - case noUserData: - return "No User Data" - case cookieReceivedWhileShuttingDown: - return "Cookie Received While Shutting Down" - case restartOfAnAssociationWithNewAddresses: - return "Restart Of An Association With New Addresses" - case userInitiatedAbort: - return "User Initiated Abort" - case protocolViolation: - return "Protocol Violation" - default: - return fmt.Sprintf("Unknown CauseCode: %d", e) - } -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/error_cause_header.go b/vendor/github.com/pions/webrtc/internal/sctp/error_cause_header.go deleted file mode 100644 index d1b09aa..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/error_cause_header.go +++ /dev/null @@ -1,43 +0,0 @@ -package sctp - -import ( - "encoding/binary" - - "github.com/pkg/errors" -) - -// errorCauseHeader represents the shared header that is shared by all error causes -type errorCauseHeader struct { - code errorCauseCode - len uint16 - raw []byte -} - -const ( - errorCauseHeaderLength = 4 -) - -func (e *errorCauseHeader) marshal() ([]byte, error) { - return nil, errors.Errorf("Unimplemented") -} - -func (e *errorCauseHeader) unmarshal(raw []byte) error { - e.code = errorCauseCode(binary.BigEndian.Uint16(raw[0:])) - e.len = binary.BigEndian.Uint16(raw[2:]) - valueLength := e.len - errorCauseHeaderLength - e.raw = raw[errorCauseHeaderLength : errorCauseHeaderLength+valueLength] - return nil -} - -func (e *errorCauseHeader) length() uint16 { - return e.len -} - -func (e *errorCauseHeader) errorCauseCode() errorCauseCode { - return e.code -} - -// String makes errorCauseHeader printable -func (e errorCauseHeader) String() string { - return e.code.String() -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/error_cause_invalid_mandatory_parameter.go b/vendor/github.com/pions/webrtc/internal/sctp/error_cause_invalid_mandatory_parameter.go deleted file mode 100644 index 3da8b47..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/error_cause_invalid_mandatory_parameter.go +++ /dev/null @@ -1,19 +0,0 @@ -package sctp - -// errorCauseInvalidMandatoryParameter represents an SCTP error cause -type errorCauseInvalidMandatoryParameter struct { - errorCauseHeader -} - -func (e *errorCauseInvalidMandatoryParameter) marshal() ([]byte, error) { - return e.errorCauseHeader.marshal() -} - -func (e *errorCauseInvalidMandatoryParameter) unmarshal(raw []byte) error { - return e.errorCauseHeader.unmarshal(raw) -} - -// String makes errorCauseInvalidMandatoryParameter printable -func (e *errorCauseInvalidMandatoryParameter) String() string { - return e.errorCauseHeader.String() -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/error_cause_protocol_violation.go b/vendor/github.com/pions/webrtc/internal/sctp/error_cause_protocol_violation.go deleted file mode 100644 index 8b457f4..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/error_cause_protocol_violation.go +++ /dev/null @@ -1,50 +0,0 @@ -package sctp - -import ( - "fmt" - - "github.com/pkg/errors" -) - -/* - This error cause MAY be included in ABORT chunks that are sent - because an SCTP endpoint detects a protocol violation of the peer - that is not covered by the error causes described in Section 3.3.10.1 - to Section 3.3.10.12. An implementation MAY provide additional - information specifying what kind of protocol violation has been - detected. - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Cause Code=13 | Cause Length=Variable | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - / Additional Information / - \ \ - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -*/ -type errorCauseProtocolViolation struct { - errorCauseHeader - additionalInformation []byte -} - -func (e *errorCauseProtocolViolation) marshal() ([]byte, error) { - e.raw = e.additionalInformation - return e.errorCauseHeader.marshal() -} - -func (e *errorCauseProtocolViolation) unmarshal(raw []byte) error { - err := e.errorCauseHeader.unmarshal(raw) - if err != nil { - return errors.Wrap(err, "Unable to unmarshal Protocol Violation error") - } - - e.additionalInformation = e.raw - - return nil -} - -// String makes errorCauseProtocolViolation printable -func (e *errorCauseProtocolViolation) String() string { - return fmt.Sprintf("%s: %s", e.errorCauseHeader, e.additionalInformation) -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/error_cause_unrecognized_chunk_type.go b/vendor/github.com/pions/webrtc/internal/sctp/error_cause_unrecognized_chunk_type.go deleted file mode 100644 index c02886b..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/error_cause_unrecognized_chunk_type.go +++ /dev/null @@ -1,19 +0,0 @@ -package sctp - -// errorCauseUnrecognizedChunkType represents an SCTP error cause -type errorCauseUnrecognizedChunkType struct { - errorCauseHeader -} - -func (e *errorCauseUnrecognizedChunkType) marshal() ([]byte, error) { - return e.errorCauseHeader.marshal() -} - -func (e *errorCauseUnrecognizedChunkType) unmarshal(raw []byte) error { - return e.errorCauseHeader.unmarshal(raw) -} - -// String makes errorCauseUnrecognizedChunkType printable -func (e *errorCauseUnrecognizedChunkType) String() string { - return e.errorCauseHeader.String() -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/packet.go b/vendor/github.com/pions/webrtc/internal/sctp/packet.go deleted file mode 100644 index 229f159..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/packet.go +++ /dev/null @@ -1,169 +0,0 @@ -package sctp - -import ( - "encoding/binary" - "fmt" - "hash/crc32" - - "github.com/pkg/errors" -) - -/* -Packet represents an SCTP packet, defined in https://tools.ietf.org/html/rfc4960#section-3 -An SCTP packet is composed of a common header and chunks. A chunk -contains either control information or user data. - - - SCTP Packet Format - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Common Header | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Chunk #1 | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| ... | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Chunk #n | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - - SCTP Common Header Format - - 0 1 2 3 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Source Value Number | Destination Value Number | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Verification Tag | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -| Checksum | -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - -*/ -type packet struct { - sourcePort uint16 - destinationPort uint16 - verificationTag uint32 - chunks []chunk -} - -const ( - packetHeaderSize = 12 -) - -func (p *packet) unmarshal(raw []byte) error { - if len(raw) < packetHeaderSize { - return errors.Errorf("raw only %d bytes, %d is the minimum length for a SCTP packet", len(raw), packetHeaderSize) - } - - p.sourcePort = binary.BigEndian.Uint16(raw[0:]) - p.destinationPort = binary.BigEndian.Uint16(raw[2:]) - p.verificationTag = binary.BigEndian.Uint32(raw[4:]) - - offset := packetHeaderSize - for { - // Exact match, no more chunks - if offset == len(raw) { - break - } else if offset+chunkHeaderSize > len(raw) { - return errors.Errorf("Unable to parse SCTP chunk, not enough data for complete header: offset %d remaining %d", offset, len(raw)) - } - - var c chunk - switch chunkType(raw[offset]) { - case INIT: - c = &chunkInit{} - case INITACK: - c = &chunkInitAck{} - case ABORT: - c = &chunkAbort{} - case COOKIEECHO: - c = &chunkCookieEcho{} - case COOKIEACK: - c = &chunkCookieAck{} - case HEARTBEAT: - c = &chunkHeartbeat{} - case PAYLOADDATA: - c = &chunkPayloadData{} - case SACK: - c = &chunkSelectiveAck{} - default: - return errors.Errorf("Failed to unmarshal, contains unknown chunk type %s", chunkType(raw[offset]).String()) - } - - if err := c.unmarshal(raw[offset:]); err != nil { - return err - } - - p.chunks = append(p.chunks, c) - chunkValuePadding := getPadding(c.valueLength()) - offset += chunkHeaderSize + c.valueLength() + chunkValuePadding - } - theirChecksum := binary.LittleEndian.Uint32(raw[8:]) - ourChecksum := generatePacketChecksum(raw) - if theirChecksum != ourChecksum { - return errors.Errorf("Checksum mismatch theirs: %d ours: %d", theirChecksum, ourChecksum) - } - return nil -} - -func (p *packet) marshal() ([]byte, error) { - raw := make([]byte, packetHeaderSize) - - // Populate static headers - // 8-12 is Checksum which will be populated when packet is complete - binary.BigEndian.PutUint16(raw[0:], p.sourcePort) - binary.BigEndian.PutUint16(raw[2:], p.destinationPort) - binary.BigEndian.PutUint32(raw[4:], p.verificationTag) - - // Populate chunks - for _, c := range p.chunks { - chunkRaw, err := c.marshal() - if err != nil { - return nil, err - } - raw = append(raw, chunkRaw...) - - paddingNeeded := getPadding(len(raw)) - if paddingNeeded != 0 { - raw = append(raw, make([]byte, paddingNeeded)...) - } - } - - // Checksum is already in BigEndian - // Using LittleEndian.PutUint32 stops it from being flipped - binary.LittleEndian.PutUint32(raw[8:], generatePacketChecksum(raw)) - return raw, nil -} - -func generatePacketChecksum(raw []byte) uint32 { - rawCopy := make([]byte, len(raw)) - copy(rawCopy, raw) - - // Clear existing checksum - for offset := 8; offset <= 11; offset++ { - rawCopy[offset] = 0x00 - } - - return crc32.Checksum(rawCopy, crc32.MakeTable(crc32.Castagnoli)) -} - -// String makes packet printable -func (p *packet) String() string { - format := `Packet: - sourcePort: %d - destinationPort: %d - verificationTag: %d - ` - res := fmt.Sprintf(format, - p.sourcePort, - p.destinationPort, - p.verificationTag, - ) - for i, chunk := range p.chunks { - res = res + fmt.Sprintf("Chunk %d:\n %s", i, chunk) - } - return res -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/param.go b/vendor/github.com/pions/webrtc/internal/sctp/param.go deleted file mode 100644 index 3a52971..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/param.go +++ /dev/null @@ -1,123 +0,0 @@ -package sctp - -import ( - "fmt" - - "github.com/pkg/errors" -) - -// paramType represents a SCTP INIT/INITACK parameter -type paramType uint16 - -type param interface { - marshal() ([]byte, error) - length() int -} - -func buildParam(t paramType, rawParam []byte) (param, error) { - switch t { - case forwardTSNSupp: - return (¶mForwardTSNSupported{}).unmarshal(rawParam) - case supportedExt: - return (¶mSupportedExtensions{}).unmarshal(rawParam) - case random: - return (¶mRandom{}).unmarshal(rawParam) - case reqHMACAlgo: - return (¶mRequestedHMACAlgorithm{}).unmarshal(rawParam) - case chunkList: - return (¶mChunkList{}).unmarshal(rawParam) - case stateCookie: - return (¶mStateCookie{}).unmarshal(rawParam) - case heartbeatInfo: - return (¶mHeartbeatInfo{}).unmarshal(rawParam) - } - return nil, errors.Errorf("Unhandled ParamType %v", t) -} - -const ( - heartbeatInfo paramType = 1 // Heartbeat Info [RFC4960] - ipV4Addr paramType = 5 // IPv4 IP [RFC4960] - ipV6Addr paramType = 6 // IPv6 IP [RFC4960] - stateCookie paramType = 7 // State Cookie [RFC4960] - unrecognizedParam paramType = 8 // Unrecognized Parameters [RFC4960] - cookiePreservative paramType = 9 // Cookie Preservative [RFC4960] - hostNameAddr paramType = 11 // Host Name IP [RFC4960] - supportedAddrTypes paramType = 12 // Supported IP Types [RFC4960] - outSSNResetReq paramType = 13 // Outgoing SSN Reset Request Parameter [RFC6525] - incSSNResetReq paramType = 14 // Incoming SSN Reset Request Parameter [RFC6525] - ssnTSNResetReq paramType = 15 // SSN/TSN Reset Request Parameter [RFC6525] - reconfigResp paramType = 16 // Re-configuration Response Parameter [RFC6525] - addOutStreamsReq paramType = 17 // Add Outgoing Streams Request Parameter [RFC6525] - addIncStreamsReq paramType = 18 // Add Incoming Streams Request Parameter [RFC6525] - random paramType = 32770 // Random (0x8002) [RFC4805] - chunkList paramType = 32771 // Chunk List (0x8003) [RFC4895] - reqHMACAlgo paramType = 32772 // Requested HMAC Algorithm Parameter (0x8004) [RFC4895] - padding paramType = 32773 // Padding (0x8005) - supportedExt paramType = 32776 // Supported Extensions (0x8008) [RFC5061] - forwardTSNSupp paramType = 49152 // Forward TSN supported (0xC000) [RFC3758] - addIPAddr paramType = 49153 // Add IP IP (0xC001) [RFC5061] - delIPAddr paramType = 49154 // Delete IP IP (0xC002) [RFC5061] - errClauseInd paramType = 49155 // Error Cause Indication (0xC003) [RFC5061] - setPriAddr paramType = 49156 // Set Primary IP (0xC004) [RFC5061] - successInd paramType = 49157 // Success Indication (0xC005) [RFC5061] - adaptLayerInd paramType = 49158 // Adaptation Layer Indication (0xC006) [RFC5061] -) - -func (p paramType) String() string { - switch p { - case heartbeatInfo: - return "Heartbeat Info" - case ipV4Addr: - return "IPv4 IP" - case ipV6Addr: - return "IPv6 IP" - case stateCookie: - return "State Cookie" - case unrecognizedParam: - return "Unrecognized Parameters" - case cookiePreservative: - return "Cookie Preservative" - case hostNameAddr: - return "Host Name IP" - case supportedAddrTypes: - return "Supported IP Types" - case outSSNResetReq: - return "Outgoing SSN Reset Request Parameter" - case incSSNResetReq: - return "Incoming SSN Reset Request Parameter" - case ssnTSNResetReq: - return "SSN/TSN Reset Request Parameter" - case reconfigResp: - return "Re-configuration Response Parameter" - case addOutStreamsReq: - return "Add Outgoing Streams Request Parameter" - case addIncStreamsReq: - return "Add Incoming Streams Request Parameter" - case random: - return "Random" - case chunkList: - return "Chunk List" - case reqHMACAlgo: - return "Requested HMAC Algorithm Parameter" - case padding: - return "Padding" - case supportedExt: - return "Supported Extensions" - case forwardTSNSupp: - return "Forward TSN supported" - case addIPAddr: - return "Add IP IP" - case delIPAddr: - return "Delete IP IP" - case errClauseInd: - return "Error Cause Indication" - case setPriAddr: - return "Set Primary IP" - case successInd: - return "Success Indication" - case adaptLayerInd: - return "Adaptation Layer Indication" - default: - return fmt.Sprintf("Unknown ParamType: %d", p) - } -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/param_chunk_list.go b/vendor/github.com/pions/webrtc/internal/sctp/param_chunk_list.go deleted file mode 100644 index e1c441f..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/param_chunk_list.go +++ /dev/null @@ -1,25 +0,0 @@ -package sctp - -type paramChunkList struct { - paramHeader - chunkTypes []chunkType -} - -func (c *paramChunkList) marshal() ([]byte, error) { - c.typ = chunkList - c.raw = make([]byte, len(c.chunkTypes)) - for i, t := range c.chunkTypes { - c.raw[i] = byte(t) - } - - return c.paramHeader.marshal() -} - -func (c *paramChunkList) unmarshal(raw []byte) (param, error) { - c.paramHeader.unmarshal(raw) - for _, t := range c.raw { - c.chunkTypes = append(c.chunkTypes, chunkType(t)) - } - - return c, nil -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/param_forward_tsn_supported.go b/vendor/github.com/pions/webrtc/internal/sctp/param_forward_tsn_supported.go deleted file mode 100644 index 2bb69eb..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/param_forward_tsn_supported.go +++ /dev/null @@ -1,16 +0,0 @@ -package sctp - -type paramForwardTSNSupported struct { - paramHeader -} - -func (f *paramForwardTSNSupported) marshal() ([]byte, error) { - f.typ = forwardTSNSupp - f.raw = []byte{} - return f.paramHeader.marshal() -} - -func (f *paramForwardTSNSupported) unmarshal(raw []byte) (param, error) { - f.paramHeader.unmarshal(raw) - return f, nil -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/param_header.go b/vendor/github.com/pions/webrtc/internal/sctp/param_header.go deleted file mode 100644 index ffc1015..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/param_header.go +++ /dev/null @@ -1,45 +0,0 @@ -package sctp - -import ( - "encoding/binary" - "fmt" -) - -type paramHeader struct { - typ paramType - len int - raw []byte -} - -const ( - paramHeaderLength = 4 -) - -func (p *paramHeader) marshal() ([]byte, error) { - paramLengthPlusHeader := paramHeaderLength + len(p.raw) - - rawParam := make([]byte, paramLengthPlusHeader) - binary.BigEndian.PutUint16(rawParam[0:], uint16(p.typ)) - binary.BigEndian.PutUint16(rawParam[2:], uint16(paramLengthPlusHeader)) - copy(rawParam[paramHeaderLength:], p.raw) - - return rawParam, nil -} - -func (p *paramHeader) unmarshal(raw []byte) { - paramLengthPlusHeader := binary.BigEndian.Uint16(raw[2:]) - paramLength := paramLengthPlusHeader - initOptionalVarHeaderLength - - p.typ = paramType(binary.BigEndian.Uint16(raw[0:])) - p.raw = raw[paramHeaderLength : paramHeaderLength+paramLength] - p.len = int(paramLengthPlusHeader) -} - -func (p *paramHeader) length() int { - return p.len -} - -// String makes paramHeader printable -func (p paramHeader) String() string { - return fmt.Sprintf("%s (%d): %s", p.typ, p.len, p.raw) -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/param_heartbeat_info.go b/vendor/github.com/pions/webrtc/internal/sctp/param_heartbeat_info.go deleted file mode 100644 index ce0ee3e..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/param_heartbeat_info.go +++ /dev/null @@ -1,18 +0,0 @@ -package sctp - -type paramHeartbeatInfo struct { - paramHeader - heartbeatInformation []byte -} - -func (h *paramHeartbeatInfo) marshal() ([]byte, error) { - h.typ = heartbeatInfo - h.raw = h.heartbeatInformation - return h.paramHeader.marshal() -} - -func (h *paramHeartbeatInfo) unmarshal(raw []byte) (param, error) { - h.paramHeader.unmarshal(raw) - h.heartbeatInformation = h.raw - return h, nil -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/param_random.go b/vendor/github.com/pions/webrtc/internal/sctp/param_random.go deleted file mode 100644 index d788c4c..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/param_random.go +++ /dev/null @@ -1,18 +0,0 @@ -package sctp - -type paramRandom struct { - paramHeader - randomData []byte -} - -func (r *paramRandom) marshal() ([]byte, error) { - r.typ = random - r.raw = r.randomData - return r.paramHeader.marshal() -} - -func (r *paramRandom) unmarshal(raw []byte) (param, error) { - r.paramHeader.unmarshal(raw) - r.randomData = r.raw - return r, nil -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/param_requested_hmac_algorithm.go b/vendor/github.com/pions/webrtc/internal/sctp/param_requested_hmac_algorithm.go deleted file mode 100644 index 3895301..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/param_requested_hmac_algorithm.go +++ /dev/null @@ -1,70 +0,0 @@ -package sctp - -import ( - "encoding/binary" - "fmt" - - "github.com/pkg/errors" -) - -type hmacAlgorithm uint16 - -const ( - hmacResv1 hmacAlgorithm = 0 - hmacSHA128 = 1 - hmacResv2 hmacAlgorithm = 2 - hmacSHA256 hmacAlgorithm = 3 -) - -func (c hmacAlgorithm) String() string { - switch c { - case hmacResv1: - return "HMAC Reserved (0x00)" - case hmacSHA128: - return "HMAC SHA-128" - case hmacResv2: - return "HMAC Reserved (0x02)" - case hmacSHA256: - return "HMAC SHA-256" - default: - return fmt.Sprintf("Unknown HMAC Algorithm type: %d", c) - } -} - -type paramRequestedHMACAlgorithm struct { - paramHeader - availableAlgorithms []hmacAlgorithm -} - -func (r *paramRequestedHMACAlgorithm) marshal() ([]byte, error) { - r.typ = reqHMACAlgo - r.raw = make([]byte, len(r.availableAlgorithms)*2) - i := 0 - for _, a := range r.availableAlgorithms { - binary.BigEndian.PutUint16(r.raw[i:], uint16(a)) - i += 2 - } - - return r.paramHeader.marshal() -} - -func (r *paramRequestedHMACAlgorithm) unmarshal(raw []byte) (param, error) { - r.paramHeader.unmarshal(raw) - - i := 0 - for i < len(r.raw) { - a := hmacAlgorithm(binary.BigEndian.Uint16(r.raw[i:])) - switch a { - case hmacSHA128: - fallthrough - case hmacSHA256: - r.availableAlgorithms = append(r.availableAlgorithms, a) - default: - return nil, errors.Errorf("Invalid algorithm type '%v'", a) - } - - i += 2 - } - - return r, nil -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/param_state_cookie.go b/vendor/github.com/pions/webrtc/internal/sctp/param_state_cookie.go deleted file mode 100644 index 915782f..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/param_state_cookie.go +++ /dev/null @@ -1,47 +0,0 @@ -package sctp - -import ( - "encoding/binary" - "fmt" - "math/rand" - "time" -) - -type paramStateCookie struct { - paramHeader - cookie []byte -} - -func newRandomStateCookie() *paramStateCookie { - rs := rand.NewSource(time.Now().UnixNano()) - r := rand.New(rs) - randCookie := make([]byte, 32) - i := 0 - for i < 4 { - binary.BigEndian.PutUint64(randCookie[i*4:], r.Uint64()) - i++ - } - - s := ¶mStateCookie{ - cookie: randCookie, - } - - return s -} - -func (s *paramStateCookie) marshal() ([]byte, error) { - s.typ = stateCookie - s.raw = s.cookie - return s.paramHeader.marshal() -} - -func (s *paramStateCookie) unmarshal(raw []byte) (param, error) { - s.paramHeader.unmarshal(raw) - s.cookie = s.raw - return s, nil -} - -// String makes paramStateCookie printable -func (s *paramStateCookie) String() string { - return fmt.Sprintf("%s: %s", s.paramHeader, s.cookie) -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/param_supported_extensions.go b/vendor/github.com/pions/webrtc/internal/sctp/param_supported_extensions.go deleted file mode 100644 index d884c34..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/param_supported_extensions.go +++ /dev/null @@ -1,26 +0,0 @@ -package sctp - -type paramSupportedExtensions struct { - paramHeader - ChunkTypes []chunkType -} - -func (s *paramSupportedExtensions) marshal() ([]byte, error) { - s.typ = supportedExt - s.raw = make([]byte, len(s.ChunkTypes)) - for i, c := range s.ChunkTypes { - s.raw[i] = byte(c) - } - - return s.paramHeader.marshal() -} - -func (s *paramSupportedExtensions) unmarshal(raw []byte) (param, error) { - s.paramHeader.unmarshal(raw) - - for _, t := range s.raw { - s.ChunkTypes = append(s.ChunkTypes, chunkType(t)) - } - - return s, nil -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/payload_queue.go b/vendor/github.com/pions/webrtc/internal/sctp/payload_queue.go deleted file mode 100644 index 54af0a7..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/payload_queue.go +++ /dev/null @@ -1,101 +0,0 @@ -package sctp - -import ( - "sort" -) - -type payloadDataArray []*chunkPayloadData - -func (s payloadDataArray) search(tsn uint32) (*chunkPayloadData, bool) { - i := sort.Search(len(s), func(i int) bool { - return s[i].tsn >= tsn - }) - - if i < len(s) && s[i].tsn == tsn { - return s[i], true - } - - return nil, false -} - -func (s payloadDataArray) sort() { - sort.Slice(s, func(i, j int) bool { return s[i].tsn < s[j].tsn }) -} - -type payloadQueue struct { - orderedPackets payloadDataArray - dupTSN []uint32 -} - -func (r *payloadQueue) pushNoCheck(p *chunkPayloadData) { - r.orderedPackets = append(r.orderedPackets, p) - r.orderedPackets.sort() -} - -func (r *payloadQueue) push(p *chunkPayloadData, cumulativeTSN uint32) { - _, ok := r.orderedPackets.search(p.tsn) - - // If the Data payload is already in our queue or older than our cumulativeTSN marker - if ok || p.tsn <= cumulativeTSN { - // Found the packet, log in dups - r.dupTSN = append(r.dupTSN, p.tsn) - return - } - - r.orderedPackets = append(r.orderedPackets, p) - r.orderedPackets.sort() -} - -func (r *payloadQueue) pop(tsn uint32) (*chunkPayloadData, bool) { - if len(r.orderedPackets) > 0 && tsn == r.orderedPackets[0].tsn { - pd := r.orderedPackets[0] - r.orderedPackets = r.orderedPackets[1:] - return pd, true - } - - return nil, false -} - -func (r *payloadQueue) get(tsn uint32) (*chunkPayloadData, bool) { - return r.orderedPackets.search(tsn) -} - -func (r *payloadQueue) popDuplicates() []uint32 { - dups := r.dupTSN - r.dupTSN = []uint32{} - return dups -} - -func (r *payloadQueue) getGapAckBlocks(cumulativeTSN uint32) (gapAckBlocks []gapAckBlock) { - var b gapAckBlock - - if len(r.orderedPackets) == 0 { - return []gapAckBlock{} - } - - for i, p := range r.orderedPackets { - if i == 0 { - b.start = uint16(r.orderedPackets[0].tsn - cumulativeTSN) - b.end = b.start - continue - } - diff := uint16(p.tsn - cumulativeTSN) - if b.end+1 == diff { - b.end++ - } else { - gapAckBlocks = append(gapAckBlocks, gapAckBlock{ - start: b.start, - end: b.end, - }) - b.start = diff - b.end = diff - } - } - - gapAckBlocks = append(gapAckBlocks, gapAckBlock{ - start: b.start, - end: b.end, - }) - - return gapAckBlocks -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/reassembly_queue.go b/vendor/github.com/pions/webrtc/internal/sctp/reassembly_queue.go deleted file mode 100644 index 03881d3..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/reassembly_queue.go +++ /dev/null @@ -1,116 +0,0 @@ -package sctp - -import "sort" - -type payloadDataMessageArray []*payloadDataMessage - -func (s payloadDataMessageArray) search(seqNum uint16) (*payloadDataMessage, bool) { - i := sort.Search(len(s), func(i int) bool { - return s[i].seqNum >= seqNum - }) - - if i < len(s) && s[i].seqNum == seqNum { - return s[i], true - } - - return nil, false -} - -func (s payloadDataMessageArray) sort() { - sort.Slice(s, func(i, j int) bool { return s[i].seqNum < s[j].seqNum }) -} - -type payloadDataMessage struct { - seqNum uint16 - payloadType PayloadProtocolIdentifier - fragmentQueue []*chunkPayloadData - length int -} - -func (m *payloadDataMessage) complete() bool { - - if len(m.fragmentQueue) == 0 { - // this should be impossible - return false - } - - firstPacket := m.fragmentQueue[0] - if len(m.fragmentQueue) == 1 { - return firstPacket.beginingFragment && firstPacket.endingFragment - } - - lastPacket := m.fragmentQueue[len(m.fragmentQueue)-1] - return firstPacket.beginingFragment && lastPacket.endingFragment - -} - -func (m *payloadDataMessage) clear() { - m.length = 0 - m.fragmentQueue = []*chunkPayloadData{} -} - -func (m *payloadDataMessage) assemble() ([]byte, bool) { - if m.complete() { - b := make([]byte, m.length) - i := 0 - for _, p := range m.fragmentQueue { - copy(b[i:], p.userData) - i += len(p.userData) - } - - return b, true - } - - return nil, false -} - -type reassemblyQueue struct { - messageQueue payloadDataMessageArray - unorderedMessage payloadDataMessage - expectedSeqNum uint16 -} - -func (r *reassemblyQueue) push(p *chunkPayloadData) { - if p.unordered { - r.unorderedMessage.fragmentQueue = append(r.unorderedMessage.fragmentQueue, p) - r.unorderedMessage.length += len(p.userData) - r.unorderedMessage.payloadType = p.payloadType - return - } - - m, ok := r.messageQueue.search(p.streamSequenceNumber) - if !ok { - m = &payloadDataMessage{seqNum: p.streamSequenceNumber, payloadType: p.payloadType} - r.messageQueue = append(r.messageQueue, m) - r.messageQueue.sort() - } - - m.fragmentQueue = append(m.fragmentQueue, p) - m.length += len(p.userData) -} - -func (r *reassemblyQueue) pop() ([]byte, PayloadProtocolIdentifier, bool) { - b, ok := r.unorderedMessage.assemble() - if ok { - ppi := r.unorderedMessage.payloadType - r.unorderedMessage.clear() - return b, ppi, true - } - - // Is there any chance that if the message was in the queue, it wouldn't be - // the first message in the queue? - if len(r.messageQueue) > 0 { - m := r.messageQueue[0] - // Most likely to be true - if m.seqNum == r.expectedSeqNum { - b, ok := m.assemble() - if ok { - r.messageQueue = r.messageQueue[1:] - r.expectedSeqNum++ - return b, m.payloadType, true - } - - } - } - return nil, PayloadProtocolIdentifier(0), false -} diff --git a/vendor/github.com/pions/webrtc/internal/sctp/sctp.go b/vendor/github.com/pions/webrtc/internal/sctp/sctp.go deleted file mode 100644 index 5b7a8fe..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/sctp.go +++ /dev/null @@ -1 +0,0 @@ -package sctp diff --git a/vendor/github.com/pions/webrtc/internal/sctp/stream.go b/vendor/github.com/pions/webrtc/internal/sctp/stream.go deleted file mode 100644 index 812d7e7..0000000 --- a/vendor/github.com/pions/webrtc/internal/sctp/stream.go +++ /dev/null @@ -1,141 +0,0 @@ -package sctp - -import ( - "math" - "sync" - - "github.com/pkg/errors" -) - -// Stream represents an SCTP stream -type Stream struct { - association *Association - - lock sync.RWMutex - - streamIdentifier uint16 - defaultPayloadType PayloadProtocolIdentifier - - reassemblyQueue *reassemblyQueue - sequenceNumber uint16 - - readNotifier chan struct{} - closeCh chan struct{} -} - -// StreamIdentifier returns the Stream identifier associated to the stream. -func (s *Stream) StreamIdentifier() uint16 { - s.lock.RLock() - defer s.lock.RUnlock() - return s.streamIdentifier -} - -// SetDefaultPayloadType sets the default payload type used by Write. -func (s *Stream) SetDefaultPayloadType(defaultPayloadType PayloadProtocolIdentifier) { - s.lock.Lock() - defer s.lock.Unlock() - - s.setDefaultPayloadType(defaultPayloadType) -} - -// setDefaultPayloadType sets the defaultPayloadType. The caller should hold the lock. -func (s *Stream) setDefaultPayloadType(defaultPayloadType PayloadProtocolIdentifier) { - s.defaultPayloadType = defaultPayloadType -} - -// Read reads a packet of len(p) bytes, dropping the Payload Protocol Identifier -func (s *Stream) Read(p []byte) (int, error) { - n, _, err := s.ReadSCTP(p) - return n, err -} - -// ReadSCTP reads a packet of len(p) bytes and returns the associated Payload Protocol Identifier -func (s *Stream) ReadSCTP(p []byte) (int, PayloadProtocolIdentifier, error) { - for range s.readNotifier { - s.lock.Lock() - userData, ppi, ok := s.reassemblyQueue.pop() // TODO: pop into p? - s.lock.Unlock() - if ok { - n := copy(p, userData) - // TODO: check small buffer - return n, ppi, nil - } - } - - return 0, PayloadProtocolIdentifier(0), errors.New("stream closed") -} - -func (s *Stream) handleData(pd *chunkPayloadData) { - s.lock.Lock() - s.reassemblyQueue.push(pd) - s.lock.Unlock() - - // Notify the reader - select { - case s.readNotifier <- struct{}{}: - case <-s.closeCh: - } -} - -// Write writes len(p) bytes from p with the default Payload Protocol Identifier -func (s *Stream) Write(p []byte) (n int, err error) { - return s.WriteSCTP(p, s.defaultPayloadType) -} - -// WriteSCTP writes len(p) bytes from p to the DTLS connection -func (s *Stream) WriteSCTP(p []byte, ppi PayloadProtocolIdentifier) (n int, err error) { - if len(p) > math.MaxUint16 { - return 0, errors.Errorf("Outbound packet larger than maximum message size %v", math.MaxUint16) - } - - chunks := s.packetize(p, ppi) - - return len(p), s.association.sendPayloadData(chunks) -} - -func (s *Stream) packetize(raw []byte, ppi PayloadProtocolIdentifier) []*chunkPayloadData { - s.lock.Lock() - defer s.lock.Unlock() - - i := uint16(0) - remaining := uint16(len(raw)) - - var chunks []*chunkPayloadData - for remaining != 0 { - l := min(s.association.myMaxMTU, remaining) - chunks = append(chunks, &chunkPayloadData{ - streamIdentifier: s.streamIdentifier, - userData: raw[i : i+l], - beginingFragment: i == 0, - endingFragment: remaining-l == 0, - immediateSack: false, - payloadType: ppi, - streamSequenceNumber: s.sequenceNumber, - }) - remaining -= l - i += l - } - - s.sequenceNumber++ - - return chunks -} - -// Close closes the conn and releases any Read calls -func (s *Stream) Close() error { - s.unregister() - - // TODO: reset stream? - // https://tools.ietf.org/html/rfc6525 - - return nil -} - -func (s *Stream) unregister() { - a := s.association - close(s.closeCh) - a.lock.Lock() - defer a.lock.Unlock() - close(s.readNotifier) - delete(a.streams, s.streamIdentifier) -} diff --git a/vendor/github.com/pions/webrtc/internal/sdp/common_description.go b/vendor/github.com/pions/webrtc/internal/sdp/common_description.go deleted file mode 100644 index 4b46eb9..0000000 --- a/vendor/github.com/pions/webrtc/internal/sdp/common_description.go +++ /dev/null @@ -1,111 +0,0 @@ -package sdp - -import ( - "fmt" - "net" - "strconv" - "strings" -) - -// Information describes the "i=" field which provides textual information -// about the session. -type Information string - -func (i *Information) String() *string { - output := string(*i) - return &output -} - -// ConnectionInformation defines the representation for the "c=" field -// containing connection data. -type ConnectionInformation struct { - NetworkType string - AddressType string - Address *Address -} - -func (c *ConnectionInformation) String() *string { - output := fmt.Sprintf( - "%v %v %v", - c.NetworkType, - c.AddressType, - c.Address.String(), - ) - return &output -} - -// Address desribes a structured address token from within the "c=" field. -type Address struct { - IP net.IP - TTL *int - Range *int -} - -func (c *Address) String() string { - var parts []string - parts = append(parts, c.IP.String()) - if c.TTL != nil { - parts = append(parts, strconv.Itoa(*c.TTL)) - } - - if c.Range != nil { - parts = append(parts, strconv.Itoa(*c.Range)) - } - - return strings.Join(parts, "/") -} - -// Bandwidth describes an optional field which denotes the proposed bandwidth -// to be used by the session or media. -type Bandwidth struct { - Experimental bool - Type string - Bandwidth uint64 -} - -func (b *Bandwidth) String() *string { - var output string - if b.Experimental { - output += "X-" - } - output += b.Type + ":" + strconv.FormatUint(b.Bandwidth, 10) - return &output -} - -// EncryptionKey describes the "k=" which conveys encryption key information. -type EncryptionKey string - -func (s *EncryptionKey) String() *string { - output := string(*s) - return &output -} - -// Attribute describes the "a=" field which represents the primary means for -// extending SDP. -type Attribute struct { - Key string - Value string -} - -// NewPropertyAttribute constructs a new attribute -func NewPropertyAttribute(key string) Attribute { - return Attribute{ - Key: key, - } -} - -// NewAttribute constructs a new attribute -func NewAttribute(key, value string) Attribute { - return Attribute{ - Key: key, - Value: value, - } -} - -func (a *Attribute) String() *string { - output := a.Key - if len(a.Value) > 0 { - output += ":" + a.Value - } - return &output -} diff --git a/vendor/github.com/pions/webrtc/internal/sdp/ice.go b/vendor/github.com/pions/webrtc/internal/sdp/ice.go deleted file mode 100644 index 891b244..0000000 --- a/vendor/github.com/pions/webrtc/internal/sdp/ice.go +++ /dev/null @@ -1,78 +0,0 @@ -package sdp - -import ( - "fmt" - "net" - "strconv" - "strings" - - "github.com/pions/webrtc/pkg/ice" -) - -// ICECandidateUnmarshal takes a candidate strings and returns a ice.Candidate or nil if it fails to parse -// TODO: return error if parsing fails -func ICECandidateUnmarshal(raw string) (*ice.Candidate, error) { - split := strings.Fields(raw) - if len(split) < 8 { - return nil, fmt.Errorf("attribute not long enough to be ICE candidate (%d) %s", len(split), raw) - } - - getValue := func(key string) string { - rtrnNext := false - for _, i := range split { - if rtrnNext { - return i - } else if i == key { - rtrnNext = true - } - } - return "" - } - - port, err := strconv.Atoi(split[5]) - if err != nil { - return nil, err - } - - transport := split[2] - - // TODO verify valid address - ip := net.ParseIP(split[4]) - if ip == nil { - return nil, err - } - - switch getValue("typ") { - case "host": - return ice.NewCandidateHost(transport, ip, port) - case "srflx": - return ice.NewCandidateServerReflexive(transport, ip, port, "", 0) // TODO: parse related address - default: - return nil, fmt.Errorf("Unhandled candidate typ %s", getValue("typ")) - } -} - -func iceCandidateString(c *ice.Candidate, component int) string { - // TODO: calculate foundation - switch c.Type { - case ice.CandidateTypeHost: - return fmt.Sprintf("foundation %d %s %d %s %d typ host generation 0", - component, c.NetworkShort(), c.Priority(c.Type.Preference(), uint16(component)), c.IP, c.Port) - - case ice.CandidateTypeServerReflexive: - return fmt.Sprintf("foundation %d %s %d %s %d typ srflx raddr %s rport %d generation 0", - component, c.NetworkShort(), c.Priority(c.Type.Preference(), uint16(component)), c.IP, c.Port, - c.RelatedAddress.Address, c.RelatedAddress.Port) - } - return "" -} - -// ICECandidateMarshal takes a candidate and returns a string representation -func ICECandidateMarshal(c *ice.Candidate) []string { - out := make([]string, 0) - - out = append(out, iceCandidateString(c, 1)) - out = append(out, iceCandidateString(c, 2)) - - return out -} diff --git a/vendor/github.com/pions/webrtc/internal/sdp/jsep.go b/vendor/github.com/pions/webrtc/internal/sdp/jsep.go deleted file mode 100644 index 0b1fe41..0000000 --- a/vendor/github.com/pions/webrtc/internal/sdp/jsep.go +++ /dev/null @@ -1,159 +0,0 @@ -package sdp - -import ( - "fmt" - "net" - "strconv" - "time" -) - -// Constants for SDP attributes used in JSEP -const ( - AttrKeyIdentity = "identity" - AttrKeyGroup = "group" - AttrKeySsrc = "ssrc" - AttrKeySsrcGroup = "ssrc-group" - AttrKeyMsidSemantic = "msid-semantic" - AttrKeyConnectionSetup = "setup" - AttrKeyMID = "mid" - AttrKeyICELite = "ice-lite" - AttrKeyRtcpMux = "rtcp-mux" - AttrKeyRtcpRsize = "rtcp-rsize" -) - -// Constants for semantic tokens used in JSEP -const ( - SemanticTokenLipSynchronization = "LS" - SemanticTokenFlowIdentification = "FID" - SemanticTokenForwardErrorCorrection = "FEC" - SemanticTokenWebRTCMediaStreams = "WMS" -) - -// API to match draft-ietf-rtcweb-jsep -// Move to webrtc or its own package? - -// NewJSEPSessionDescription creates a new SessionDescription with -// some settings that are required by the JSEP spec. -func NewJSEPSessionDescription(identity bool) *SessionDescription { - d := &SessionDescription{ - Version: 0, - Origin: Origin{ - Username: "-", - SessionID: newSessionID(), - SessionVersion: uint64(time.Now().Unix()), - NetworkType: "IN", - AddressType: "IP4", - UnicastAddress: "0.0.0.0", - }, - SessionName: "-", - TimeDescriptions: []TimeDescription{ - { - Timing: Timing{ - StartTime: 0, - StopTime: 0, - }, - RepeatTimes: nil, - }, - }, - Attributes: []Attribute{ - // "Attribute(ice-options:trickle)", // TODO: implement trickle ICE - }, - } - - if identity { - d.WithPropertyAttribute(AttrKeyIdentity) - } - - return d -} - -// WithPropertyAttribute adds a property attribute 'a=key' to the session description -func (s *SessionDescription) WithPropertyAttribute(key string) *SessionDescription { - s.Attributes = append(s.Attributes, NewPropertyAttribute(key)) - return s -} - -// WithValueAttribute adds a value attribute 'a=key:value' to the session description -func (s *SessionDescription) WithValueAttribute(key, value string) *SessionDescription { - s.Attributes = append(s.Attributes, NewAttribute(key, value)) - return s -} - -// WithFingerprint adds a fingerprint to the session description -func (s *SessionDescription) WithFingerprint(algorithm, value string) *SessionDescription { - return s.WithValueAttribute("fingerprint", algorithm+" "+value) -} - -// WithMedia adds a media description to the session description -func (s *SessionDescription) WithMedia(md *MediaDescription) *SessionDescription { - s.MediaDescriptions = append(s.MediaDescriptions, md) - return s -} - -// NewJSEPMediaDescription creates a new MediaName with -// some settings that are required by the JSEP spec. -func NewJSEPMediaDescription(codecType string, codecPrefs []string) *MediaDescription { - // TODO: handle codecPrefs - d := &MediaDescription{ - MediaName: MediaName{ - Media: codecType, - Port: RangedPort{Value: 9}, - Protos: []string{"UDP", "TLS", "RTP", "SAVPF"}, - }, - ConnectionInformation: &ConnectionInformation{ - NetworkType: "IN", - AddressType: "IP4", - Address: &Address{ - IP: net.ParseIP("0.0.0.0"), - }, - }, - } - return d -} - -// WithPropertyAttribute adds a property attribute 'a=key' to the media description -func (d *MediaDescription) WithPropertyAttribute(key string) *MediaDescription { - d.Attributes = append(d.Attributes, NewPropertyAttribute(key)) - return d -} - -// WithValueAttribute adds a value attribute 'a=key:value' to the media description -func (d *MediaDescription) WithValueAttribute(key, value string) *MediaDescription { - d.Attributes = append(d.Attributes, NewAttribute(key, value)) - return d -} - -// WithICECredentials adds ICE credentials to the media description -func (d *MediaDescription) WithICECredentials(username, password string) *MediaDescription { - return d. - WithValueAttribute("ice-ufrag", username). - WithValueAttribute("ice-pwd", password) -} - -// WithCodec adds codec information to the media description -func (d *MediaDescription) WithCodec(payloadType uint8, name string, clockrate uint32, channels uint16, fmtp string) *MediaDescription { - d.MediaName.Formats = append(d.MediaName.Formats, strconv.Itoa(int(payloadType))) - rtpmap := fmt.Sprintf("%d %s/%d", payloadType, name, clockrate) - if channels > 0 { - rtpmap = rtpmap + fmt.Sprintf("/%d", channels) - } - d.WithValueAttribute("rtpmap", rtpmap) - if fmtp != "" { - d.WithValueAttribute("fmtp", fmt.Sprintf("%d %s", payloadType, fmtp)) - } - return d -} - -// WithMediaSource adds media source information to the media description -func (d *MediaDescription) WithMediaSource(ssrc uint32, cname, streamLabel, label string) *MediaDescription { - return d. - WithValueAttribute("ssrc", fmt.Sprintf("%d cname:%s", ssrc, cname)). // Deprecated but not phased out? - WithValueAttribute("ssrc", fmt.Sprintf("%d msid:%s %s", ssrc, streamLabel, label)). - WithValueAttribute("ssrc", fmt.Sprintf("%d mslabel:%s", ssrc, streamLabel)). // Deprecated but not phased out? - WithValueAttribute("ssrc", fmt.Sprintf("%d label:%s", ssrc, label)) // Deprecated but not phased out? -} - -// WithCandidate adds an ICE candidate to the media description -func (d *MediaDescription) WithCandidate(value string) *MediaDescription { - return d.WithValueAttribute("candidate", value) -} diff --git a/vendor/github.com/pions/webrtc/internal/sdp/marshal.go b/vendor/github.com/pions/webrtc/internal/sdp/marshal.go deleted file mode 100644 index 4b3a66a..0000000 --- a/vendor/github.com/pions/webrtc/internal/sdp/marshal.go +++ /dev/null @@ -1,118 +0,0 @@ -package sdp - -import ( - "strings" -) - -// Marshal takes a SDP struct to text -// https://tools.ietf.org/html/rfc4566#section-5 -// Session description -// v= (protocol version) -// o= (originator and session identifier) -// s= (session name) -// i=* (session information) -// u=* (URI of description) -// e=* (email address) -// p=* (phone number) -// c=* (connection information -- not required if included in -// all media) -// b=* (zero or more bandwidth information lines) -// One or more time descriptions ("t=" and "r=" lines; see below) -// z=* (time zone adjustments) -// k=* (encryption key) -// a=* (zero or more session attribute lines) -// Zero or more media descriptions -// -// Time description -// t= (time the session is active) -// r=* (zero or more repeat times) -// -// Media description, if present -// m= (media name and transport address) -// i=* (media title) -// c=* (connection information -- optional if included at -// session level) -// b=* (zero or more bandwidth information lines) -// k=* (encryption key) -// a=* (zero or more media attribute lines) -func (s *SessionDescription) Marshal() (raw string) { - raw += keyValueBuild("v=", s.Version.String()) - raw += keyValueBuild("o=", s.Origin.String()) - raw += keyValueBuild("s=", s.SessionName.String()) - - if s.SessionInformation != nil { - raw += keyValueBuild("i=", s.SessionInformation.String()) - } - - if s.URI != nil { - uri := s.URI.String() - raw += keyValueBuild("u=", &uri) - } - - if s.EmailAddress != nil { - raw += keyValueBuild("e=", s.EmailAddress.String()) - } - - if s.PhoneNumber != nil { - raw += keyValueBuild("p=", s.PhoneNumber.String()) - } - - if s.ConnectionInformation != nil { - raw += keyValueBuild("c=", s.ConnectionInformation.String()) - } - - for _, b := range s.Bandwidth { - raw += keyValueBuild("b=", b.String()) - } - - for _, td := range s.TimeDescriptions { - raw += keyValueBuild("t=", td.Timing.String()) - for _, r := range td.RepeatTimes { - raw += keyValueBuild("r=", r.String()) - } - } - - rawTimeZones := make([]string, 0) - for _, z := range s.TimeZones { - rawTimeZones = append(rawTimeZones, z.String()) - } - - if len(rawTimeZones) > 0 { - timeZones := strings.Join(rawTimeZones, " ") - raw += keyValueBuild("z=", &timeZones) - } - - if s.EncryptionKey != nil { - raw += keyValueBuild("k=", s.EncryptionKey.String()) - } - - for _, a := range s.Attributes { - raw += keyValueBuild("a=", a.String()) - } - - for _, md := range s.MediaDescriptions { - raw += keyValueBuild("m=", md.MediaName.String()) - - if md.MediaTitle != nil { - raw += keyValueBuild("i=", md.MediaTitle.String()) - } - - if md.ConnectionInformation != nil { - raw += keyValueBuild("c=", md.ConnectionInformation.String()) - } - - for _, b := range md.Bandwidth { - raw += keyValueBuild("b=", b.String()) - } - - if md.EncryptionKey != nil { - raw += keyValueBuild("k=", md.EncryptionKey.String()) - } - - for _, a := range md.Attributes { - raw += keyValueBuild("a=", a.String()) - } - } - - return raw -} diff --git a/vendor/github.com/pions/webrtc/internal/sdp/media_description.go b/vendor/github.com/pions/webrtc/internal/sdp/media_description.go deleted file mode 100644 index c2d3e14..0000000 --- a/vendor/github.com/pions/webrtc/internal/sdp/media_description.go +++ /dev/null @@ -1,81 +0,0 @@ -package sdp - -import ( - "strconv" - "strings" -) - -// MediaDescription represents a media type. -// https://tools.ietf.org/html/rfc4566#section-5.14 -type MediaDescription struct { - // m= / ... - // https://tools.ietf.org/html/rfc4566#section-5.14 - MediaName MediaName - - // i= - // https://tools.ietf.org/html/rfc4566#section-5.4 - MediaTitle *Information - - // c= - // https://tools.ietf.org/html/rfc4566#section-5.7 - ConnectionInformation *ConnectionInformation - - // b=: - // https://tools.ietf.org/html/rfc4566#section-5.8 - Bandwidth []Bandwidth - - // k= - // k=: - // https://tools.ietf.org/html/rfc4566#section-5.12 - EncryptionKey *EncryptionKey - - // a= - // a=: - // https://tools.ietf.org/html/rfc4566#section-5.13 - Attributes []Attribute -} - -// Attribute returns the value of an attribute and if it exists -func (s *MediaDescription) Attribute(key string) (string, bool) { - for _, a := range s.Attributes { - if a.Key == key { - return a.Value, true - } - } - return "", false -} - -// RangedPort supports special format for the media field "m=" port value. If -// it may be necessary to specify multiple transport ports, the protocol allows -// to write it as: / where number of ports is a an -// offsetting range. -type RangedPort struct { - Value int - Range *int -} - -func (p *RangedPort) String() string { - output := strconv.Itoa(p.Value) - if p.Range != nil { - output += "/" + strconv.Itoa(*p.Range) - } - return output -} - -// MediaName describes the "m=" field storage structure. -type MediaName struct { - Media string - Port RangedPort - Protos []string - Formats []string -} - -func (m *MediaName) String() *string { - output := strings.Join([]string{ - m.Media, - m.Port.String(), - strings.Join(m.Protos, "/"), - strings.Join(m.Formats, " "), - }, " ") - return &output -} diff --git a/vendor/github.com/pions/webrtc/internal/sdp/session_description.go b/vendor/github.com/pions/webrtc/internal/sdp/session_description.go deleted file mode 100644 index 0d8d696..0000000 --- a/vendor/github.com/pions/webrtc/internal/sdp/session_description.go +++ /dev/null @@ -1,151 +0,0 @@ -package sdp - -import ( - "fmt" - "net/url" - "strconv" -) - -// SessionDescription is a a well-defined format for conveying sufficient -// information to discover and participate in a multimedia session. -type SessionDescription struct { - // v=0 - // https://tools.ietf.org/html/rfc4566#section-5.1 - Version Version - - // o= - // https://tools.ietf.org/html/rfc4566#section-5.2 - Origin Origin - - // s= - // https://tools.ietf.org/html/rfc4566#section-5.3 - SessionName SessionName - - // i= - // https://tools.ietf.org/html/rfc4566#section-5.4 - SessionInformation *Information - - // u= - // https://tools.ietf.org/html/rfc4566#section-5.5 - URI *url.URL - - // e= - // https://tools.ietf.org/html/rfc4566#section-5.6 - EmailAddress *EmailAddress - - // p= - // https://tools.ietf.org/html/rfc4566#section-5.6 - PhoneNumber *PhoneNumber - - // c= - // https://tools.ietf.org/html/rfc4566#section-5.7 - ConnectionInformation *ConnectionInformation - - // b=: - // https://tools.ietf.org/html/rfc4566#section-5.8 - Bandwidth []Bandwidth - - // https://tools.ietf.org/html/rfc4566#section-5.9 - // https://tools.ietf.org/html/rfc4566#section-5.10 - TimeDescriptions []TimeDescription - - // z= ... - // https://tools.ietf.org/html/rfc4566#section-5.11 - TimeZones []TimeZone - - // k= - // k=: - // https://tools.ietf.org/html/rfc4566#section-5.12 - EncryptionKey *EncryptionKey - - // a= - // a=: - // https://tools.ietf.org/html/rfc4566#section-5.13 - Attributes []Attribute - - // https://tools.ietf.org/html/rfc4566#section-5.14 - MediaDescriptions []*MediaDescription -} - -// Attribute returns the value of an attribute and if it exists -func (s *SessionDescription) Attribute(key string) (string, bool) { - for _, a := range s.Attributes { - if a.Key == key { - return a.Value, true - } - } - return "", false -} - -// Version describes the value provided by the "v=" field which gives -// the version of the Session Description Protocol. -type Version int - -func (v *Version) String() *string { - output := strconv.Itoa(int(*v)) - return &output -} - -// Origin defines the structure for the "o=" field which provides the -// originator of the session plus a session identifier and version number. -type Origin struct { - Username string - SessionID uint64 - SessionVersion uint64 - NetworkType string - AddressType string - UnicastAddress string -} - -func (o *Origin) String() *string { - output := fmt.Sprintf( - "%v %d %d %v %v %v", - o.Username, - o.SessionID, - o.SessionVersion, - o.NetworkType, - o.AddressType, - o.UnicastAddress, - ) - return &output -} - -// SessionName describes a structured representations for the "s=" field -// and is the textual session name. -type SessionName string - -func (s *SessionName) String() *string { - output := string(*s) - return &output -} - -// EmailAddress describes a structured representations for the "e=" line -// which specifies email contact information for the person responsible for -// the conference. -type EmailAddress string - -func (e *EmailAddress) String() *string { - output := string(*e) - return &output -} - -// PhoneNumber describes a structured representations for the "p=" line -// specify phone contact information for the person responsible for the -// conference. -type PhoneNumber string - -func (p *PhoneNumber) String() *string { - output := string(*p) - return &output -} - -// TimeZone defines the structured object for "z=" line which describes -// repeated sessions scheduling. -type TimeZone struct { - AdjustmentTime uint64 - Offset int64 -} - -func (z *TimeZone) String() string { - return strconv.FormatUint(z.AdjustmentTime, 10) + " " + strconv.FormatInt(z.Offset, 10) -} diff --git a/vendor/github.com/pions/webrtc/internal/sdp/time_description.go b/vendor/github.com/pions/webrtc/internal/sdp/time_description.go deleted file mode 100644 index 0edfb1c..0000000 --- a/vendor/github.com/pions/webrtc/internal/sdp/time_description.go +++ /dev/null @@ -1,52 +0,0 @@ -package sdp - -import ( - "strconv" - "strings" -) - -// TimeDescription describes "t=", "r=" fields of the session description -// which are used to specify the start and stop times for a session as well as -// repeat intervals and durations for the scheduled session. -type TimeDescription struct { - // t= - // https://tools.ietf.org/html/rfc4566#section-5.9 - Timing Timing - - // r= - // https://tools.ietf.org/html/rfc4566#section-5.10 - RepeatTimes []RepeatTime -} - -// Timing defines the "t=" field's structured representation for the start and -// stop times. -type Timing struct { - StartTime uint64 - StopTime uint64 -} - -func (t *Timing) String() *string { - output := strconv.FormatUint(t.StartTime, 10) - output += " " + strconv.FormatUint(t.StopTime, 10) - return &output -} - -// RepeatTime describes the "r=" fields of the session description which -// represents the intervals and durations for repeated scheduled sessions. -type RepeatTime struct { - Interval int64 - Duration int64 - Offsets []int64 -} - -func (r *RepeatTime) String() *string { - fields := make([]string, 0) - fields = append(fields, strconv.FormatInt(r.Interval, 10)) - fields = append(fields, strconv.FormatInt(r.Duration, 10)) - for _, value := range r.Offsets { - fields = append(fields, strconv.FormatInt(value, 10)) - } - - output := strings.Join(fields, " ") - return &output -} diff --git a/vendor/github.com/pions/webrtc/internal/sdp/unmarshal.go b/vendor/github.com/pions/webrtc/internal/sdp/unmarshal.go deleted file mode 100644 index 96ad786..0000000 --- a/vendor/github.com/pions/webrtc/internal/sdp/unmarshal.go +++ /dev/null @@ -1,972 +0,0 @@ -package sdp - -import ( - "bufio" - "strings" - - "io" - "net" - "net/url" - "strconv" - - "github.com/pkg/errors" -) - -// Unmarshal is the primary function that deserializes the session description -// message and stores it inside of a structured SessionDescription object. -// -// The States Sransition Table describes the computation flow between functions -// (namely s1, s2, s3, ...) for a parsing procedure that complies with the -// specifications laid out by the rfc4566#section-5 as well as by JavaScript -// Session Establishment Protocol draft. Links: -// https://tools.ietf.org/html/rfc4566#section-5 -// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24 -// -// https://tools.ietf.org/html/rfc4566#section-5 -// Session description -// v= (protocol version) -// o= (originator and session identifier) -// s= (session name) -// i=* (session information) -// u=* (URI of description) -// e=* (email address) -// p=* (phone number) -// c=* (connection information -- not required if included in -// all media) -// b=* (zero or more bandwidth information lines) -// One or more time descriptions ("t=" and "r=" lines; see below) -// z=* (time zone adjustments) -// k=* (encryption key) -// a=* (zero or more session attribute lines) -// Zero or more media descriptions -// -// Time description -// t= (time the session is active) -// r=* (zero or more repeat times) -// -// Media description, if present -// m= (media name and transport address) -// i=* (media title) -// c=* (connection information -- optional if included at -// session level) -// b=* (zero or more bandwidth information lines) -// k=* (encryption key) -// a=* (zero or more media attribute lines) -// -// In order to generate the following state table and draw subsequent -// deterministic finite-state automota ("DFA") the following regex was used to -// derive the DFA: -// vosi?u?e?p?c?b*(tr*)+z?k?a*(mi?c?b*k?a*)* -// -// Please pay close attention to the `k`, and `a` parsing states. In the table -// below in order to distinguish between the states belonging to the media -// description as opposed to the session description, the states are marked -// with an asterisk ("a*", "k*"). -// +--------+----+-------+----+-----+----+-----+---+----+----+---+---+-----+---+---+----+---+----+ -// | STATES | a* | a*,k* | a | a,k | b | b,c | e | i | m | o | p | r,t | s | t | u | v | z | -// +--------+----+-------+----+-----+----+-----+---+----+----+---+---+-----+---+---+----+---+----+ -// | s1 | | | | | | | | | | | | | | | | 2 | | -// | s2 | | | | | | | | | | 3 | | | | | | | | -// | s3 | | | | | | | | | | | | | 4 | | | | | -// | s4 | | | | | | 5 | 6 | 7 | | | 8 | | | 9 | 10 | | | -// | s5 | | | | | 5 | | | | | | | | | 9 | | | | -// | s6 | | | | | | 5 | | | | | 8 | | | 9 | | | | -// | s7 | | | | | | 5 | 6 | | | | 8 | | | 9 | 10 | | | -// | s8 | | | | | | 5 | | | | | | | | 9 | | | | -// | s9 | | | | 11 | | | | | 12 | | | 9 | | | | | 13 | -// | s10 | | | | | | 5 | 6 | | | | 8 | | | 9 | | | | -// | s11 | | | 11 | | | | | | 12 | | | | | | | | | -// | s12 | | 14 | | | | 15 | | 16 | 12 | | | | | | | | | -// | s13 | | | | 11 | | | | | 12 | | | | | | | | | -// | s14 | 14 | | | | | | | | 12 | | | | | | | | | -// | s15 | | 14 | | | 15 | | | | 12 | | | | | | | | | -// | s16 | | 14 | | | | 15 | | | 12 | | | | | | | | | -// +--------+----+-------+----+-----+----+-----+---+----+----+---+---+-----+---+---+----+---+----+ -func (s *SessionDescription) Unmarshal(value string) error { - l := &lexer{ - desc: s, - input: bufio.NewReader(strings.NewReader(value)), - } - for state := s1; state != nil; { - var err error - state, err = state(l) - if err != nil { - return err - } - } - return nil - -} - -func s1(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) - } - - if key == "v=" { - return unmarshalProtocolVersion, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s2(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) - } - - if key == "o=" { - return unmarshalOrigin, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s3(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - return nil, err - } - - if key == "s=" { - return unmarshalSessionName, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s4(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) - } - - switch key { - case "i=": - return unmarshalSessionInformation, nil - case "u=": - return unmarshalURI, nil - case "e=": - return unmarshalEmail, nil - case "p=": - return unmarshalPhone, nil - case "c=": - return unmarshalSessionConnectionInformation, nil - case "b=": - return unmarshalSessionBandwidth, nil - case "t=": - return unmarshalTiming, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s5(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - return nil, err - } - - switch key { - case "b=": - return unmarshalSessionBandwidth, nil - case "t=": - return unmarshalTiming, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s6(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) - } - - switch key { - case "p=": - return unmarshalPhone, nil - case "c=": - return unmarshalSessionConnectionInformation, nil - case "b=": - return unmarshalSessionBandwidth, nil - case "t=": - return unmarshalTiming, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s7(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) - } - - switch key { - case "u=": - return unmarshalURI, nil - case "e=": - return unmarshalEmail, nil - case "p=": - return unmarshalPhone, nil - case "c=": - return unmarshalSessionConnectionInformation, nil - case "b=": - return unmarshalSessionBandwidth, nil - case "t=": - return unmarshalTiming, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s8(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) - } - - switch key { - case "c=": - return unmarshalSessionConnectionInformation, nil - case "b=": - return unmarshalSessionBandwidth, nil - case "t=": - return unmarshalTiming, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s9(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - if err == io.EOF && key == "" { - return nil, nil - } - return nil, err - } - - switch key { - case "z=": - return unmarshalTimeZones, nil - case "k=": - return unmarshalSessionEncryptionKey, nil - case "a=": - return unmarshalSessionAttribute, nil - case "r=": - return unmarshalRepeatTimes, nil - case "t=": - return unmarshalTiming, nil - case "m=": - return unmarshalMediaDescription, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s10(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) - } - - switch key { - case "e=": - return unmarshalEmail, nil - case "p=": - return unmarshalPhone, nil - case "c=": - return unmarshalSessionConnectionInformation, nil - case "b=": - return unmarshalSessionBandwidth, nil - case "t=": - return unmarshalTiming, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s11(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - if err == io.EOF && key == "" { - return nil, nil - } - return nil, err - } - - switch key { - case "a=": - return unmarshalSessionAttribute, nil - case "m=": - return unmarshalMediaDescription, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s12(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - if err == io.EOF && key == "" { - return nil, nil - } - return nil, err - } - - switch key { - case "a=": - return unmarshalMediaAttribute, nil - case "k=": - return unmarshalMediaEncryptionKey, nil - case "b=": - return unmarshalMediaBandwidth, nil - case "c=": - return unmarshalMediaConnectionInformation, nil - case "i=": - return unmarshalMediaTitle, nil - case "m=": - return unmarshalMediaDescription, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s13(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - if err == io.EOF && key == "" { - return nil, nil - } - return nil, err - } - - switch key { - case "a=": - return unmarshalSessionAttribute, nil - case "k=": - return unmarshalSessionEncryptionKey, nil - case "m=": - return unmarshalMediaDescription, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s14(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - if err == io.EOF && key == "" { - return nil, nil - } - return nil, err - } - - switch key { - case "a=": - return unmarshalMediaAttribute, nil - case "m=": - return unmarshalMediaDescription, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s15(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - if err == io.EOF && key == "" { - return nil, nil - } - return nil, err - } - - switch key { - case "a=": - return unmarshalMediaAttribute, nil - case "k=": - return unmarshalMediaEncryptionKey, nil - case "b=": - return unmarshalMediaBandwidth, nil - case "m=": - return unmarshalMediaDescription, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func s16(l *lexer) (stateFn, error) { - key, err := readType(l.input) - if err != nil { - if err == io.EOF && key == "" { - return nil, nil - } - return nil, err - } - - switch key { - case "a=": - return unmarshalMediaAttribute, nil - case "k=": - return unmarshalMediaEncryptionKey, nil - case "c=": - return unmarshalMediaConnectionInformation, nil - case "b=": - return unmarshalMediaBandwidth, nil - case "m=": - return unmarshalMediaDescription, nil - } - - return nil, errors.Errorf("sdp: invalid syntax `%v`", key) -} - -func unmarshalProtocolVersion(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - version, err := strconv.ParseInt(value, 10, 32) - if err != nil { - return nil, errors.Errorf("sdp: invalid numeric value `%v`", version) - } - - // As off the latest draft of the rfc this value is required to be 0. - // https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24#section-5.8.1 - if version != 0 { - return nil, errors.Errorf("sdp: invalid value `%v`", version) - } - - return s2, nil -} - -func unmarshalOrigin(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - fields := strings.Fields(value) - if len(fields) != 6 { - return nil, errors.Errorf("sdp: invalid syntax `o=%v`", fields) - } - - sessionID, err := strconv.ParseUint(fields[1], 10, 64) - if err != nil { - return nil, errors.Errorf("sdp: invalid numeric value `%v`", fields[1]) - } - - sessionVersion, err := strconv.ParseUint(fields[2], 10, 64) - if err != nil { - return nil, errors.Errorf("sdp: invalid numeric value `%v`", fields[2]) - } - - // Set according to currently registered with IANA - // https://tools.ietf.org/html/rfc4566#section-8.2.6 - if i := indexOf(fields[3], []string{"IN"}); i == -1 { - return nil, errors.Errorf("sdp: invalid value `%v`", fields[3]) - } - - // Set according to currently registered with IANA - // https://tools.ietf.org/html/rfc4566#section-8.2.7 - if i := indexOf(fields[4], []string{"IP4", "IP6"}); i == -1 { - return nil, errors.Errorf("sdp: invalid value `%v`", fields[4]) - } - - // TODO validated UnicastAddress - - l.desc.Origin = Origin{ - Username: fields[0], - SessionID: sessionID, - SessionVersion: sessionVersion, - NetworkType: fields[3], - AddressType: fields[4], - UnicastAddress: fields[5], - } - - return s3, nil -} - -func unmarshalSessionName(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - l.desc.SessionName = SessionName(value) - return s4, nil -} - -func unmarshalSessionInformation(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - sessionInformation := Information(value) - l.desc.SessionInformation = &sessionInformation - return s7, nil -} - -func unmarshalURI(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - l.desc.URI, err = url.Parse(value) - if err != nil { - return nil, err - } - - return s10, nil -} - -func unmarshalEmail(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - emailAddress := EmailAddress(value) - l.desc.EmailAddress = &emailAddress - return s6, nil -} - -func unmarshalPhone(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - phoneNumber := PhoneNumber(value) - l.desc.PhoneNumber = &phoneNumber - return s8, nil -} - -func unmarshalSessionConnectionInformation(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - l.desc.ConnectionInformation, err = unmarshalConnectionInformation(value) - if err != nil { - return nil, errors.Errorf("sdp: invalid syntax `c=%v`", value) - } - return s5, nil -} - -func unmarshalConnectionInformation(value string) (*ConnectionInformation, error) { - fields := strings.Fields(value) - if len(fields) < 2 { - return nil, errors.Errorf("sdp: invalid syntax `c=%v`", fields) - } - - // Set according to currently registered with IANA - // https://tools.ietf.org/html/rfc4566#section-8.2.6 - if i := indexOf(fields[0], []string{"IN"}); i == -1 { - return nil, errors.Errorf("sdp: invalid value `%v`", fields[0]) - } - - // Set according to currently registered with IANA - // https://tools.ietf.org/html/rfc4566#section-8.2.7 - if i := indexOf(fields[1], []string{"IP4", "IP6"}); i == -1 { - return nil, errors.Errorf("sdp: invalid value `%v`", fields[1]) - } - - var connAddr *Address - if len(fields) > 2 { - connAddr = &Address{} - - parts := strings.Split(fields[2], "/") - connAddr.IP = net.ParseIP(parts[0]) - if connAddr.IP == nil { - return nil, errors.Errorf("sdp: invalid value `%v`", fields[2]) - } - - isIP6 := connAddr.IP.To4() == nil - if len(parts) > 1 { - val, err := strconv.ParseInt(parts[1], 10, 32) - if err != nil { - return nil, errors.Errorf("sdp: invalid numeric value `%v`", fields[2]) - } - - if isIP6 { - multi := int(val) - connAddr.Range = &multi - } else { - ttl := int(val) - connAddr.TTL = &ttl - } - } - - if len(parts) > 2 { - val, err := strconv.ParseInt(parts[2], 10, 32) - if err != nil { - return nil, errors.Errorf("sdp: invalid numeric value `%v`", fields[2]) - } - - multi := int(val) - connAddr.Range = &multi - } - - } - - return &ConnectionInformation{ - NetworkType: fields[0], - AddressType: fields[1], - Address: connAddr, - }, nil -} - -func unmarshalSessionBandwidth(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - bandwidth, err := unmarshalBandwidth(value) - if err != nil { - return nil, errors.Errorf("sdp: invalid syntax `b=%v`", value) - } - l.desc.Bandwidth = append(l.desc.Bandwidth, *bandwidth) - - return s5, nil -} - -func unmarshalBandwidth(value string) (*Bandwidth, error) { - parts := strings.Split(value, ":") - if len(parts) != 2 { - return nil, errors.Errorf("sdp: invalid syntax `b=%v`", parts) - } - - experimental := strings.HasPrefix(parts[0], "X-") - if experimental { - parts[0] = strings.TrimPrefix(parts[0], "X-") - } else { - // Set according to currently registered with IANA - // https://tools.ietf.org/html/rfc4566#section-5.8 - if i := indexOf(parts[0], []string{"CT", "AS"}); i == -1 { - return nil, errors.Errorf("sdp: invalid value `%v`", parts[0]) - } - } - - bandwidth, err := strconv.ParseUint(parts[1], 10, 64) - if err != nil { - return nil, errors.Errorf("sdp: invalid numeric value `%v`", parts[1]) - } - - return &Bandwidth{ - Experimental: experimental, - Type: parts[0], - Bandwidth: bandwidth, - }, nil -} - -func unmarshalTiming(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - fields := strings.Fields(value) - if len(fields) < 2 { - return nil, errors.Errorf("sdp: invalid syntax `t=%v`", fields) - } - - td := TimeDescription{} - - td.Timing.StartTime, err = strconv.ParseUint(fields[0], 10, 64) - if err != nil { - return nil, errors.Errorf("sdp: invalid numeric value `%v`", fields[1]) - } - - td.Timing.StopTime, err = strconv.ParseUint(fields[1], 10, 64) - if err != nil { - return nil, errors.Errorf("sdp: invalid numeric value `%v`", fields[1]) - } - - l.desc.TimeDescriptions = append(l.desc.TimeDescriptions, td) - - return s9, nil -} - -func unmarshalRepeatTimes(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - fields := strings.Fields(value) - if len(fields) < 3 { - return nil, errors.Errorf("sdp: invalid syntax `r=%v`", fields) - } - - latestTimeDesc := &l.desc.TimeDescriptions[len(l.desc.TimeDescriptions)-1] - - newRepeatTime := RepeatTime{} - newRepeatTime.Interval, err = parseTimeUnits(fields[0]) - if err != nil { - return nil, errors.Errorf("sdp: invalid value `%v`", fields) - } - - newRepeatTime.Duration, err = parseTimeUnits(fields[1]) - if err != nil { - return nil, errors.Errorf("sdp: invalid value `%v`", fields) - } - - for i := 2; i < len(fields); i++ { - offset, err := parseTimeUnits(fields[i]) - if err != nil { - return nil, errors.Errorf("sdp: invalid value `%v`", fields) - } - newRepeatTime.Offsets = append(newRepeatTime.Offsets, offset) - } - latestTimeDesc.RepeatTimes = append(latestTimeDesc.RepeatTimes, newRepeatTime) - - return s9, nil -} - -func unmarshalTimeZones(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - // These fields are transimitted in pairs - // z= .... - // so we are making sure that there are actually multiple of 2 total. - fields := strings.Fields(value) - if len(fields)%2 != 0 { - return nil, errors.Errorf("sdp: invalid syntax `t=%v`", fields) - } - - for i := 0; i < len(fields); i += 2 { - var timeZone TimeZone - - timeZone.AdjustmentTime, err = strconv.ParseUint(fields[i], 10, 64) - if err != nil { - return nil, errors.Errorf("sdp: invalid value `%v`", fields) - } - - timeZone.Offset, err = parseTimeUnits(fields[i+1]) - if err != nil { - return nil, err - } - - l.desc.TimeZones = append(l.desc.TimeZones, timeZone) - } - - return s13, nil -} - -func unmarshalSessionEncryptionKey(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - encryptionKey := EncryptionKey(value) - l.desc.EncryptionKey = &encryptionKey - return s11, nil -} - -func unmarshalSessionAttribute(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - i := strings.IndexRune(value, ':') - var a Attribute - if i > 0 { - a = NewAttribute(value[:i], value[i+1:]) - } else { - a = NewPropertyAttribute(value) - } - - l.desc.Attributes = append(l.desc.Attributes, a) - return s11, nil -} - -func unmarshalMediaDescription(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - fields := strings.Fields(value) - if len(fields) < 4 { - return nil, errors.Errorf("sdp: invalid syntax `m=%v`", fields) - } - - newMediaDesc := &MediaDescription{} - - // - // Set according to currently registered with IANA - // https://tools.ietf.org/html/rfc4566#section-5.14 - if i := indexOf(fields[0], []string{"audio", "video", "text", "application", "message"}); i == -1 { - return nil, errors.Errorf("sdp: invalid value `%v`", fields[0]) - } - newMediaDesc.MediaName.Media = fields[0] - - // - parts := strings.Split(fields[1], "/") - newMediaDesc.MediaName.Port.Value, err = parsePort(parts[0]) - if err != nil { - return nil, errors.Errorf("sdp: invalid port value `%v`", parts[0]) - } - - if len(parts) > 1 { - portRange, err := strconv.Atoi(parts[1]) - if err != nil { - return nil, errors.Errorf("sdp: invalid value `%v`", parts) - } - newMediaDesc.MediaName.Port.Range = &portRange - } - - // - // Set according to currently registered with IANA - // https://tools.ietf.org/html/rfc4566#section-5.14 - for _, proto := range strings.Split(fields[2], "/") { - if i := indexOf(proto, []string{"UDP", "RTP", "AVP", "SAVP", "SAVPF", "TLS", "DTLS", "SCTP"}); i == -1 { - return nil, errors.Errorf("sdp: invalid value `%v`", fields[2]) - } - newMediaDesc.MediaName.Protos = append(newMediaDesc.MediaName.Protos, proto) - } - - // ... - for i := 3; i < len(fields); i++ { - newMediaDesc.MediaName.Formats = append(newMediaDesc.MediaName.Formats, fields[i]) - } - - l.desc.MediaDescriptions = append(l.desc.MediaDescriptions, newMediaDesc) - - return s12, nil -} - -func unmarshalMediaTitle(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - latestMediaDesc := l.desc.MediaDescriptions[len(l.desc.MediaDescriptions)-1] - mediaTitle := Information(value) - latestMediaDesc.MediaTitle = &mediaTitle - return s16, nil -} - -func unmarshalMediaConnectionInformation(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - latestMediaDesc := l.desc.MediaDescriptions[len(l.desc.MediaDescriptions)-1] - latestMediaDesc.ConnectionInformation, err = unmarshalConnectionInformation(value) - if err != nil { - return nil, errors.Errorf("sdp: invalid syntax `c=%v`", value) - } - return s15, nil -} - -func unmarshalMediaBandwidth(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - latestMediaDesc := l.desc.MediaDescriptions[len(l.desc.MediaDescriptions)-1] - bandwidth, err := unmarshalBandwidth(value) - if err != nil { - return nil, errors.Errorf("sdp: invalid syntax `b=%v`", value) - } - latestMediaDesc.Bandwidth = append(latestMediaDesc.Bandwidth, *bandwidth) - return s15, nil -} - -func unmarshalMediaEncryptionKey(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - latestMediaDesc := l.desc.MediaDescriptions[len(l.desc.MediaDescriptions)-1] - encryptionKey := EncryptionKey(value) - latestMediaDesc.EncryptionKey = &encryptionKey - return s14, nil -} - -func unmarshalMediaAttribute(l *lexer) (stateFn, error) { - value, err := readValue(l.input) - if err != nil { - return nil, err - } - - i := strings.IndexRune(value, ':') - var a Attribute - if i > 0 { - a = NewAttribute(value[:i], value[i+1:]) - } else { - a = NewPropertyAttribute(value) - } - - latestMediaDesc := l.desc.MediaDescriptions[len(l.desc.MediaDescriptions)-1] - latestMediaDesc.Attributes = append(latestMediaDesc.Attributes, a) - return s14, nil -} - -func parseTimeUnits(value string) (int64, error) { - // Some time offsets in the protocol can be provided with a shorthand - // notation. This code ensures to convert it to NTP timestamp format. - // d - days (86400 seconds) - // h - hours (3600 seconds) - // m - minutes (60 seconds) - // s - seconds (allowed for completeness) - switch value[len(value)-1:] { - case "d": - num, err := strconv.ParseInt(value[:len(value)-1], 10, 64) - if err != nil { - return 0, errors.Errorf("sdp: invalid value `%v`", value) - } - return num * 86400, nil - case "h": - num, err := strconv.ParseInt(value[:len(value)-1], 10, 64) - if err != nil { - return 0, errors.Errorf("sdp: invalid value `%v`", value) - } - return num * 3600, nil - case "m": - num, err := strconv.ParseInt(value[:len(value)-1], 10, 64) - if err != nil { - return 0, errors.Errorf("sdp: invalid value `%v`", value) - } - return num * 60, nil - } - - num, err := strconv.ParseInt(value, 10, 64) - if err != nil { - return 0, errors.Errorf("sdp: invalid value `%v`", value) - } - - return num, nil -} - -func parsePort(value string) (int, error) { - port, err := strconv.Atoi(value) - if err != nil { - return 0, errors.Errorf("sdp: invalid port value `%v`", port) - } - - if port < 0 || port > 65536 { - return 0, errors.Errorf("sdp: invalid port value -- out of range `%v`", port) - } - - return port, nil -} diff --git a/vendor/github.com/pions/webrtc/internal/sdp/util.go b/vendor/github.com/pions/webrtc/internal/sdp/util.go deleted file mode 100644 index 87a73c0..0000000 --- a/vendor/github.com/pions/webrtc/internal/sdp/util.go +++ /dev/null @@ -1,168 +0,0 @@ -package sdp - -import ( - "bufio" - "fmt" - "io" - "math/rand" - "strconv" - "strings" - - "time" - - "github.com/pkg/errors" -) - -// ConnectionRole indicates which of the end points should initiate the connection establishment -type ConnectionRole int - -const ( - // ConnectionRoleActive indicates the endpoint will initiate an outgoing connection. - ConnectionRoleActive ConnectionRole = iota + 1 - - // ConnectionRolePassive indicates the endpoint will accept an incoming connection. - ConnectionRolePassive - - // ConnectionRoleActpass indicates the endpoint is willing to accept an incoming connection or to initiate an outgoing connection. - ConnectionRoleActpass - - // ConnectionRoleHoldconn indicates the endpoint does not want the connection to be established for the time being. - ConnectionRoleHoldconn -) - -func (t ConnectionRole) String() string { - switch t { - case ConnectionRoleActive: - return "active" - case ConnectionRolePassive: - return "passive" - case ConnectionRoleActpass: - return "actpass" - case ConnectionRoleHoldconn: - return "holdconn" - default: - return "Unknown" - } -} - -func newSessionID() uint64 { - r := rand.New(rand.NewSource(time.Now().UnixNano())) - return uint64(r.Uint32()*2) >> 2 -} - -// Codec represents a codec -type Codec struct { - PayloadType uint8 - Name string - ClockRate uint32 - EncodingParameters string - Fmtp string -} - -func (c Codec) String() string { - return fmt.Sprintf("%d %s/%d/%s", c.PayloadType, c.Name, c.ClockRate, c.EncodingParameters) -} - -// GetCodecForPayloadType scans the SessionDescription for the given payloadType and returns the codec -func (s *SessionDescription) GetCodecForPayloadType(payloadType uint8) (Codec, error) { - codec := Codec{ - PayloadType: payloadType, - } - - found := false - payloadTypeString := strconv.Itoa(int(payloadType)) - rtpmapPrefix := "rtpmap:" + payloadTypeString - fmtpPrefix := "fmtp:" + payloadTypeString - - for _, m := range s.MediaDescriptions { - for _, a := range m.Attributes { - if strings.HasPrefix(*a.String(), rtpmapPrefix) { - found = true - // a=rtpmap: / [/] - split := strings.Split(*a.String(), " ") - if len(split) == 2 { - split = strings.Split(split[1], "/") - codec.Name = split[0] - parts := len(split) - if parts > 1 { - rate, err := strconv.Atoi(split[1]) - if err != nil { - return codec, err - } - codec.ClockRate = uint32(rate) - } - if parts > 2 { - codec.EncodingParameters = split[2] - } - } - } else if strings.HasPrefix(*a.String(), fmtpPrefix) { - // a=fmtp: - split := strings.Split(*a.String(), " ") - if len(split) == 2 { - codec.Fmtp = split[1] - } - } - } - if found { - return codec, nil - } - } - return codec, errors.New("payload type not found") -} - -type lexer struct { - desc *SessionDescription - input *bufio.Reader -} - -type stateFn func(*lexer) (stateFn, error) - -func readType(input *bufio.Reader) (string, error) { - key, err := input.ReadString('=') - if err != nil { - return key, err - } - - if len(key) != 2 { - return key, errors.Errorf("sdp: invalid syntax `%v`", key) - } - - return key, nil -} - -func readValue(input *bufio.Reader) (string, error) { - line, err := input.ReadString('\n') - if err != nil && err != io.EOF { - return line, err - } - - if len(line) == 0 { - return line, nil - } - - if line[len(line)-1] == '\n' { - drop := 1 - if len(line) > 1 && line[len(line)-2] == '\r' { - drop = 2 - } - line = line[:len(line)-drop] - } - - return line, nil -} - -func indexOf(element string, data []string) int { - for k, v := range data { - if element == v { - return k - } - } - return -1 -} - -func keyValueBuild(key string, value *string) string { - if value != nil { - return key + *value + "\r\n" - } - return "" -} diff --git a/vendor/github.com/pions/webrtc/internal/srtp/context.go b/vendor/github.com/pions/webrtc/internal/srtp/context.go deleted file mode 100644 index 8f5e6fd..0000000 --- a/vendor/github.com/pions/webrtc/internal/srtp/context.go +++ /dev/null @@ -1,225 +0,0 @@ -package srtp - -import ( - "bytes" - "crypto/aes" - "crypto/cipher" - "crypto/hmac" - "crypto/sha1" // #nosec - "encoding/binary" - - "github.com/pkg/errors" -) - -const ( - labelSRTPEncryption = 0x00 - labelSRTPAuthenticationTag = 0x01 - labelSRTPSalt = 0x02 - - labelSRTCPEncryption = 0x03 - labelSRTCPAuthenticationTag = 0x04 - labelSRTCPSalt = 0x05 - - keyLen = 16 - saltLen = 14 - - maxROCDisorder = 100 - maxSequenceNumber = 65535 - - authTagSize = 10 - srtcpIndexSize = 4 -) - -// Encode/Decode state for a single SSRC -type ssrcState struct { - ssrc uint32 - rolloverCounter uint32 - rolloverHasProcessed bool - lastSequenceNumber uint16 -} - -// Context represents a SRTP cryptographic context -// Context can only be used for one-way operations -// it must either used ONLY for encryption or ONLY for decryption -type Context struct { - masterKey []byte - masterSalt []byte - - ssrcStates map[uint32]*ssrcState - srtpSessionKey []byte - srtpSessionSalt []byte - srtpSessionAuthTag []byte - srtpBlock cipher.Block - - srtcpSessionKey []byte - srtcpSessionSalt []byte - srtcpSessionAuthTag []byte - srtcpIndex uint32 - srtcpBlock cipher.Block -} - -// CreateContext creates a new SRTP Context -func CreateContext(masterKey, masterSalt []byte, profile string) (c *Context, err error) { - if masterKeyLen := len(masterKey); masterKeyLen != keyLen { - return c, errors.Errorf("SRTP Master Key must be len %d, got %d", masterKey, keyLen) - } else if masterSaltLen := len(masterSalt); masterSaltLen != saltLen { - return c, errors.Errorf("SRTP Salt must be len %d, got %d", saltLen, masterSaltLen) - } - - c = &Context{ - masterKey: masterKey, - masterSalt: masterSalt, - ssrcStates: map[uint32]*ssrcState{}, - } - - if c.srtpSessionKey, err = c.generateSessionKey(labelSRTPEncryption); err != nil { - return nil, err - } else if c.srtpSessionSalt, err = c.generateSessionSalt(labelSRTPSalt); err != nil { - return nil, err - } else if c.srtpSessionAuthTag, err = c.generateSessionAuthTag(labelSRTPAuthenticationTag); err != nil { - return nil, err - } else if c.srtpBlock, err = aes.NewCipher(c.srtpSessionKey); err != nil { - return nil, err - } - - if c.srtcpSessionKey, err = c.generateSessionKey(labelSRTCPEncryption); err != nil { - return nil, err - } else if c.srtcpSessionSalt, err = c.generateSessionSalt(labelSRTCPSalt); err != nil { - return nil, err - } else if c.srtcpSessionAuthTag, err = c.generateSessionAuthTag(labelSRTCPAuthenticationTag); err != nil { - return nil, err - } else if c.srtcpBlock, err = aes.NewCipher(c.srtcpSessionKey); err != nil { - return nil, err - } - - return c, nil -} - -func (c *Context) generateSessionKey(label byte) ([]byte, error) { - // https://tools.ietf.org/html/rfc3711#appendix-B.3 - // The input block for AES-CM is generated by exclusive-oring the master salt with the - // concatenation of the encryption key label 0x00 with (index DIV kdr), - // - index is 'rollover count' and DIV is 'divided by' - sessionKey := make([]byte, len(c.masterSalt)) - copy(sessionKey, c.masterSalt) - - labelAndIndexOverKdr := []byte{label, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - for i, j := len(labelAndIndexOverKdr)-1, len(sessionKey)-1; i >= 0; i, j = i-1, j-1 { - sessionKey[j] = sessionKey[j] ^ labelAndIndexOverKdr[i] - } - - // then padding on the right with two null octets (which implements the multiply-by-2^16 operation, see Section 4.3.3). - sessionKey = append(sessionKey, []byte{0x00, 0x00}...) - - //The resulting value is then AES-CM- encrypted using the master key to get the cipher key. - block, err := aes.NewCipher(c.masterKey) - if err != nil { - return nil, err - } - - block.Encrypt(sessionKey, sessionKey) - return sessionKey, nil -} - -func (c *Context) generateSessionSalt(label byte) ([]byte, error) { - // https://tools.ietf.org/html/rfc3711#appendix-B.3 - // The input block for AES-CM is generated by exclusive-oring the master salt with - // the concatenation of the encryption salt label - sessionSalt := make([]byte, len(c.masterSalt)) - copy(sessionSalt, c.masterSalt) - - labelAndIndexOverKdr := []byte{label, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - for i, j := len(labelAndIndexOverKdr)-1, len(sessionSalt)-1; i >= 0; i, j = i-1, j-1 { - sessionSalt[j] = sessionSalt[j] ^ labelAndIndexOverKdr[i] - } - - // That value is padded and encrypted as above. - sessionSalt = append(sessionSalt, []byte{0x00, 0x00}...) - block, err := aes.NewCipher(c.masterKey) - if err != nil { - return nil, err - } - - block.Encrypt(sessionSalt, sessionSalt) - return sessionSalt[0:saltLen], nil -} -func (c *Context) generateSessionAuthTag(label byte) ([]byte, error) { - // https://tools.ietf.org/html/rfc3711#appendix-B.3 - // We now show how the auth key is generated. The input block for AES- - // CM is generated as above, but using the authentication key label. - sessionAuthTag := make([]byte, len(c.masterSalt)) - copy(sessionAuthTag, c.masterSalt) - - labelAndIndexOverKdr := []byte{label, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - for i, j := len(labelAndIndexOverKdr)-1, len(sessionAuthTag)-1; i >= 0; i, j = i-1, j-1 { - sessionAuthTag[j] = sessionAuthTag[j] ^ labelAndIndexOverKdr[i] - } - - // That value is padded and encrypted as above. - // - We need to do multiple runs at key size (20) is larger then source - firstRun := append(sessionAuthTag, []byte{0x00, 0x00}...) - secondRun := append(sessionAuthTag, []byte{0x00, 0x01}...) - block, err := aes.NewCipher(c.masterKey) - if err != nil { - return nil, err - } - - block.Encrypt(firstRun, firstRun) - block.Encrypt(secondRun, secondRun) - return append(firstRun, secondRun[:4]...), nil -} - -// Generate IV https://tools.ietf.org/html/rfc3711#section-4.1.1 -// where the 128-bit integer value IV SHALL be defined by the SSRC, the -// SRTP packet index i, and the SRTP session salting key k_s, as below. -// - ROC = a 32-bit unsigned rollover counter (ROC), which records how many -// - times the 16-bit RTP sequence number has been reset to zero after -// - passing through 65,535 -// i = 2^16 * ROC + SEQ -// IV = (salt*2 ^ 16) | (ssrc*2 ^ 64) | (i*2 ^ 16) -func (c *Context) generateCounter(sequenceNumber uint16, rolloverCounter uint32, ssrc uint32, sessionSalt []byte) []byte { - counter := make([]byte, 16) - - binary.BigEndian.PutUint32(counter[4:], ssrc) - binary.BigEndian.PutUint32(counter[8:], rolloverCounter) - binary.BigEndian.PutUint32(counter[12:], uint32(sequenceNumber)<<16) - - for i := range sessionSalt { - counter[i] = counter[i] ^ sessionSalt[i] - } - - return counter -} - -func (c *Context) generateAuthTag(buf, sessionAuthTag []byte) ([]byte, error) { - // https://tools.ietf.org/html/rfc3711#section-4.2 - // In the case of SRTP, M SHALL consist of the Authenticated - // Portion of the packet (as specified in Figure 1) concatenated with - // the ROC, M = Authenticated Portion || ROC; - // - // The pre-defined authentication transform for SRTP is HMAC-SHA1 - // [RFC2104]. With HMAC-SHA1, the SRTP_PREFIX_LENGTH (Figure 3) SHALL - // be 0. For SRTP (respectively SRTCP), the HMAC SHALL be applied to - // the session authentication key and M as specified above, i.e., - // HMAC(k_a, M). The HMAC output SHALL then be truncated to the n_tag - // left-most bits. - // - Authenticated portion of the packet is everything BEFORE MKI - // - k_a is the session message authentication key - // - n_tag is the bit-length of the output authentication tag - // - ROC is already added by caller (to allow RTP + RTCP support) - mac := hmac.New(sha1.New, sessionAuthTag) - - if _, err := mac.Write(buf); err != nil { - return nil, err - } - - return mac.Sum(nil)[0:10], nil -} - -func (c *Context) verifyAuthTag(buf, actualAuthTag []byte) (bool, error) { - expectedAuthTag, err := c.generateAuthTag(buf, c.srtpSessionAuthTag) - if err != nil { - return false, err - } - return bytes.Equal(actualAuthTag, expectedAuthTag), nil -} diff --git a/vendor/github.com/pions/webrtc/internal/srtp/srtcp.go b/vendor/github.com/pions/webrtc/internal/srtp/srtcp.go deleted file mode 100644 index 197caa4..0000000 --- a/vendor/github.com/pions/webrtc/internal/srtp/srtcp.go +++ /dev/null @@ -1,56 +0,0 @@ -package srtp - -import ( - "crypto/cipher" - "encoding/binary" -) - -// DecryptRTCP decrypts a buffer that contains a RTCP packet -// We can't pass *rtcp.Packet as the encrypt will obscure significant fields -func (c *Context) DecryptRTCP(encrypted []byte) ([]byte, error) { - tailOffset := len(encrypted) - (authTagSize + srtcpIndexSize) - out := append([]byte{}, encrypted[0:tailOffset]...) - - isEncrypted := encrypted[tailOffset] >> 7 - if isEncrypted == 0 { - return out, nil - } - - srtcpIndexBuffer := append([]byte{}, encrypted[tailOffset:tailOffset+srtcpIndexSize]...) - srtcpIndexBuffer[0] &= 0x7f // unset Encryption bit - - index := binary.BigEndian.Uint32(srtcpIndexBuffer) - ssrc := binary.BigEndian.Uint32(encrypted[4:]) - - stream := cipher.NewCTR(c.srtcpBlock, c.generateCounter(uint16(index&0xffff), index>>16, ssrc, c.srtcpSessionSalt)) - stream.XORKeyStream(out[8:], out[8:]) - - return out, nil -} - -// EncryptRTCP encrypts a buffer that contains a RTCP packet -func (c *Context) EncryptRTCP(decrypted []byte) ([]byte, error) { - out := append([]byte{}, decrypted[:]...) - ssrc := binary.BigEndian.Uint32(decrypted[4:]) - - // We roll over early because MSB is used for marking as encrypted - c.srtcpIndex++ - if c.srtcpIndex >= 2147483647 { - c.srtcpIndex = 0 - } - - // Encrypt everything after header - stream := cipher.NewCTR(c.srtcpBlock, c.generateCounter(uint16(c.srtcpIndex&0xffff), c.srtcpIndex>>16, ssrc, c.srtcpSessionSalt)) - stream.XORKeyStream(out[8:], out[8:]) - - // Add SRTCP Index and set Encryption bit - out = append(out, make([]byte, 4)...) - binary.BigEndian.PutUint32(out[len(out)-4:], c.srtcpIndex) - out[len(out)-4] |= 0x80 - - authTag, err := c.generateAuthTag(out, c.srtcpSessionAuthTag) - if err != nil { - return nil, err - } - return append(out, authTag...), nil -} diff --git a/vendor/github.com/pions/webrtc/internal/srtp/srtp.go b/vendor/github.com/pions/webrtc/internal/srtp/srtp.go deleted file mode 100644 index 0e14be7..0000000 --- a/vendor/github.com/pions/webrtc/internal/srtp/srtp.go +++ /dev/null @@ -1,97 +0,0 @@ -package srtp - -import ( - "crypto/cipher" - "encoding/binary" - - "github.com/pions/webrtc/pkg/rtp" -) - -// DecryptRTP decrypts a RTP packet with an encrypted payload -func (c *Context) DecryptRTP(packet *rtp.Packet) bool { - s := c.getSSRCState(packet.SSRC) - - c.updateRolloverCount(packet.SequenceNumber, s) - - pktWithROC := append([]byte{}, packet.Raw[:len(packet.Raw)-authTagSize]...) - pktWithROC = append(pktWithROC, make([]byte, 4)...) - binary.BigEndian.PutUint32(pktWithROC[len(pktWithROC)-4:], s.rolloverCounter) - - actualAuthTag := packet.Payload[len(packet.Payload)-authTagSize:] - verified, err := c.verifyAuthTag(pktWithROC, actualAuthTag) - if err != nil || !verified { - return false - } - - packet.Payload = packet.Payload[:len(packet.Payload)-authTagSize] - - stream := cipher.NewCTR(c.srtpBlock, c.generateCounter(packet.SequenceNumber, s.rolloverCounter, s.ssrc, c.srtpSessionSalt)) - stream.XORKeyStream(packet.Payload, packet.Payload) - - // Replace payload with decrypted - packet.Raw = append(packet.Raw[0:packet.PayloadOffset], packet.Payload...) - - return true -} - -// EncryptRTP Encrypts a SRTP packet in place -func (c *Context) EncryptRTP(packet *rtp.Packet) bool { - s := c.getSSRCState(packet.SSRC) - - c.updateRolloverCount(packet.SequenceNumber, s) - - stream := cipher.NewCTR(c.srtpBlock, c.generateCounter(packet.SequenceNumber, s.rolloverCounter, s.ssrc, c.srtpSessionSalt)) - stream.XORKeyStream(packet.Payload, packet.Payload) - - fullPkt, err := packet.Marshal() - if err != nil { - return false - } - - fullPkt = append(fullPkt, make([]byte, 4)...) - binary.BigEndian.PutUint32(fullPkt[len(fullPkt)-4:], s.rolloverCounter) - - authTag, err := c.generateAuthTag(fullPkt, c.srtpSessionAuthTag) - if err != nil { - return false - } - - packet.Payload = append(packet.Payload, authTag...) - packet.Raw = append(packet.Raw[0:packet.PayloadOffset], packet.Payload...) - - return true -} - -// https://tools.ietf.org/html/rfc3550#appendix-A.1 -func (c *Context) updateRolloverCount(sequenceNumber uint16, s *ssrcState) { - if !s.rolloverHasProcessed { - s.rolloverHasProcessed = true - } else if sequenceNumber == 0 { // We exactly hit the rollover count - - // Only update rolloverCounter if lastSequenceNumber is greater then maxROCDisorder - // otherwise we already incremented for disorder - if s.lastSequenceNumber > maxROCDisorder { - s.rolloverCounter++ - } - } else if s.lastSequenceNumber < maxROCDisorder && sequenceNumber > (maxSequenceNumber-maxROCDisorder) { - // Our last sequence number incremented because we crossed 0, but then our current number was within maxROCDisorder of the max - // So we fell behind, drop to account for jitter - s.rolloverCounter-- - } else if sequenceNumber < maxROCDisorder && s.lastSequenceNumber > (maxSequenceNumber-maxROCDisorder) { - // our current is within a maxROCDisorder of 0 - // and our last sequence number was a high sequence number, increment to account for jitter - s.rolloverCounter++ - } - s.lastSequenceNumber = sequenceNumber -} - -func (c *Context) getSSRCState(ssrc uint32) *ssrcState { - s, ok := c.ssrcStates[ssrc] - if ok { - return s - } - - s = &ssrcState{ssrc: ssrc} - c.ssrcStates[ssrc] = s - return s -} diff --git a/vendor/github.com/pions/webrtc/internal/util/util.go b/vendor/github.com/pions/webrtc/internal/util/util.go deleted file mode 100644 index aedeb3c..0000000 --- a/vendor/github.com/pions/webrtc/internal/util/util.go +++ /dev/null @@ -1,25 +0,0 @@ -package util - -import ( - "math/rand" - "time" -) - -// RandSeq generates a random alpha numeric sequence of the requested length -func RandSeq(n int) string { - r := rand.New(rand.NewSource(time.Now().UnixNano())) - letters := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") - b := make([]rune, n) - for i := range b { - b[i] = letters[r.Intn(len(letters))] - } - return string(b) -} - -// GetPadding Returns the padding required to make the length a multiple of 4 -func GetPadding(len int) int { - if len%4 == 0 { - return 0 - } - return 4 - (len % 4) -} diff --git a/vendor/github.com/pions/webrtc/media.go b/vendor/github.com/pions/webrtc/media.go deleted file mode 100644 index 5a43d56..0000000 --- a/vendor/github.com/pions/webrtc/media.go +++ /dev/null @@ -1,21 +0,0 @@ -package webrtc - -import ( - "github.com/pions/webrtc/pkg/media" - "github.com/pions/webrtc/pkg/rtcp" - "github.com/pions/webrtc/pkg/rtp" -) - -// RTCTrack represents a track that is communicated -type RTCTrack struct { - ID string - PayloadType uint8 - Kind RTCRtpCodecType - Label string - Ssrc uint32 - Codec *RTCRtpCodec - Packets <-chan *rtp.Packet - RTCPPackets <-chan rtcp.Packet - Samples chan<- media.RTCSample - RawRTP chan<- *rtp.Packet -} diff --git a/vendor/github.com/pions/webrtc/mediaengine.go b/vendor/github.com/pions/webrtc/mediaengine.go deleted file mode 100644 index a5d7636..0000000 --- a/vendor/github.com/pions/webrtc/mediaengine.go +++ /dev/null @@ -1,231 +0,0 @@ -package webrtc - -import ( - "strconv" - - "github.com/pions/webrtc/internal/sdp" - "github.com/pions/webrtc/pkg/rtp" - "github.com/pions/webrtc/pkg/rtp/codecs" - "github.com/pkg/errors" -) - -// RegisterCodec is used to register a codec with the DefaultMediaEngine -func RegisterCodec(codec *RTCRtpCodec) { - DefaultMediaEngine.RegisterCodec(codec) -} - -// TODO: Phase out DefaultPayloadTypes in favor or dynamic assignment in 96-127 range - -// PayloadTypes for the default codecs -const ( - DefaultPayloadTypeG722 = 9 - DefaultPayloadTypeOpus = 111 - DefaultPayloadTypeVP8 = 96 - DefaultPayloadTypeVP9 = 98 - DefaultPayloadTypeH264 = 100 -) - -// RegisterDefaultCodecs is a helper that registers the default codecs supported by pions-webrtc -func RegisterDefaultCodecs() { - RegisterCodec(NewRTCRtpOpusCodec(DefaultPayloadTypeOpus, 48000, 2)) - RegisterCodec(NewRTCRtpG722Codec(DefaultPayloadTypeG722, 8000)) - RegisterCodec(NewRTCRtpVP8Codec(DefaultPayloadTypeVP8, 90000)) - RegisterCodec(NewRTCRtpH264Codec(DefaultPayloadTypeH264, 90000)) - RegisterCodec(NewRTCRtpVP9Codec(DefaultPayloadTypeVP9, 90000)) -} - -// DefaultMediaEngine is the default MediaEngine used by RTCPeerConnections -var DefaultMediaEngine = NewMediaEngine() - -// NewMediaEngine creates a new MediaEngine -func NewMediaEngine() *MediaEngine { - return &MediaEngine{} -} - -// MediaEngine defines the codecs supported by a RTCPeerConnection -type MediaEngine struct { - codecs []*RTCRtpCodec -} - -// RegisterCodec registers a codec to a media engine -func (m *MediaEngine) RegisterCodec(codec *RTCRtpCodec) uint8 { - // TODO: generate PayloadType if not set - m.codecs = append(m.codecs, codec) - return codec.PayloadType -} - -func (m *MediaEngine) getCodec(payloadType uint8) (*RTCRtpCodec, error) { - for _, codec := range m.codecs { - if codec.PayloadType == payloadType { - return codec, nil - } - } - return nil, errors.New("Codec not found") -} - -func (m *MediaEngine) getCodecSDP(sdpCodec sdp.Codec) (*RTCRtpCodec, error) { - for _, codec := range m.codecs { - if codec.Name == sdpCodec.Name && - codec.ClockRate == sdpCodec.ClockRate && - (sdpCodec.EncodingParameters == "" || - strconv.Itoa(int(codec.Channels)) == sdpCodec.EncodingParameters) && - codec.SdpFmtpLine == sdpCodec.Fmtp { // TODO: Protocol specific matching? - return codec, nil - } - } - return nil, errors.New("Codec not found") -} - -func (m *MediaEngine) getCodecsByKind(kind RTCRtpCodecType) []*RTCRtpCodec { - var codecs []*RTCRtpCodec - for _, codec := range m.codecs { - if codec.Type == kind { - codecs = append(codecs, codec) - } - } - return codecs -} - -// Names for the default codecs supported by pions-webrtc -const ( - G722 = "G722" - Opus = "opus" - VP8 = "VP8" - VP9 = "VP9" - H264 = "H264" -) - -// NewRTCRtpG722Codec is a helper to create a G722 codec -func NewRTCRtpG722Codec(payloadType uint8, clockrate uint32) *RTCRtpCodec { - c := NewRTCRtpCodec(RTCRtpCodecTypeAudio, - G722, - clockrate, - 0, - "", - payloadType, - &codecs.G722Payloader{}) - return c -} - -// NewRTCRtpOpusCodec is a helper to create an Opus codec -func NewRTCRtpOpusCodec(payloadType uint8, clockrate uint32, channels uint16) *RTCRtpCodec { - c := NewRTCRtpCodec(RTCRtpCodecTypeAudio, - Opus, - clockrate, - channels, - "minptime=10;useinbandfec=1", - payloadType, - &codecs.OpusPayloader{}) - return c -} - -// NewRTCRtpVP8Codec is a helper to create an VP8 codec -func NewRTCRtpVP8Codec(payloadType uint8, clockrate uint32) *RTCRtpCodec { - c := NewRTCRtpCodec(RTCRtpCodecTypeVideo, - VP8, - clockrate, - 0, - "", - payloadType, - &codecs.VP8Payloader{}) - return c -} - -// NewRTCRtpVP9Codec is a helper to create an VP9 codec -func NewRTCRtpVP9Codec(payloadType uint8, clockrate uint32) *RTCRtpCodec { - c := NewRTCRtpCodec(RTCRtpCodecTypeVideo, - VP9, - clockrate, - 0, - "", - payloadType, - nil) // TODO - return c -} - -// NewRTCRtpH264Codec is a helper to create an H264 codec -func NewRTCRtpH264Codec(payloadType uint8, clockrate uint32) *RTCRtpCodec { - c := NewRTCRtpCodec(RTCRtpCodecTypeVideo, - H264, - clockrate, - 0, - "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f", - payloadType, - &codecs.H264Payloader{}) - return c -} - -// RTCRtpCodecType determines the type of a codec -type RTCRtpCodecType int - -const ( - - // RTCRtpCodecTypeAudio indicates this is an audio codec - RTCRtpCodecTypeAudio RTCRtpCodecType = iota + 1 - - // RTCRtpCodecTypeVideo indicates this is a video codec - RTCRtpCodecTypeVideo -) - -func (t RTCRtpCodecType) String() string { - switch t { - case RTCRtpCodecTypeAudio: - return "audio" - case RTCRtpCodecTypeVideo: - return "video" - default: - return ErrUnknownType.Error() - } -} - -// RTCRtpCodec represents a codec supported by the PeerConnection -type RTCRtpCodec struct { - RTCRtpCodecCapability - Type RTCRtpCodecType - Name string - PayloadType uint8 - Payloader rtp.Payloader -} - -// NewRTCRtpCodec is used to define a new codec -func NewRTCRtpCodec( - codecType RTCRtpCodecType, - name string, - clockrate uint32, - channels uint16, - fmtp string, - payloadType uint8, - payloader rtp.Payloader, -) *RTCRtpCodec { - return &RTCRtpCodec{ - RTCRtpCodecCapability: RTCRtpCodecCapability{ - MimeType: codecType.String() + "/" + name, - ClockRate: clockrate, - Channels: channels, - SdpFmtpLine: fmtp, - }, - PayloadType: payloadType, - Payloader: payloader, - Type: codecType, - Name: name, - } -} - -// RTCRtpCodecCapability provides information about codec capabilities. -type RTCRtpCodecCapability struct { - MimeType string - ClockRate uint32 - Channels uint16 - SdpFmtpLine string -} - -// RTCRtpHeaderExtensionCapability is used to define a RFC5285 RTP header extension supported by the codec. -type RTCRtpHeaderExtensionCapability struct { - URI string -} - -// RTCRtpCapabilities represents the capabilities of a transceiver -type RTCRtpCapabilities struct { - Codecs []RTCRtpCodecCapability - HeaderExtensions []RTCRtpHeaderExtensionCapability -} diff --git a/vendor/github.com/pions/webrtc/pkg/datachannel/payload.go b/vendor/github.com/pions/webrtc/pkg/datachannel/payload.go deleted file mode 100644 index 7c54a1b..0000000 --- a/vendor/github.com/pions/webrtc/pkg/datachannel/payload.go +++ /dev/null @@ -1,49 +0,0 @@ -package datachannel - -import "fmt" - -// PayloadType are the different types of data that can be -// represented in a DataChannel message -type PayloadType int - -// PayloadType enums -const ( - PayloadTypeString = iota + 1 - PayloadTypeBinary -) - -func (p PayloadType) String() string { - switch p { - case PayloadTypeString: - return "Payload Type String" - case PayloadTypeBinary: - return "Payload Type Binary" - default: - return fmt.Sprintf("Invalid PayloadType (%d)", p) - } -} - -// Payload is the body of a DataChannel message -type Payload interface { - PayloadType() PayloadType -} - -// PayloadString is a string DataChannel message -type PayloadString struct { - Data []byte -} - -//PayloadType returns the type of payload -func (p PayloadString) PayloadType() PayloadType { - return PayloadTypeString -} - -// PayloadBinary is a binary DataChannel message -type PayloadBinary struct { - Data []byte -} - -//PayloadType returns the type of payload -func (p PayloadBinary) PayloadType() PayloadType { - return PayloadTypeBinary -} diff --git a/vendor/github.com/pions/webrtc/pkg/ice/agent.go b/vendor/github.com/pions/webrtc/pkg/ice/agent.go deleted file mode 100644 index c6b2346..0000000 --- a/vendor/github.com/pions/webrtc/pkg/ice/agent.go +++ /dev/null @@ -1,602 +0,0 @@ -// Package ice implements the Interactive Connectivity Establishment (ICE) -// protocol defined in rfc5245. -package ice - -import ( - "fmt" - "math/rand" - "net" - "sync" - "time" - - "github.com/pions/pkg/stun" - "github.com/pions/webrtc/internal/util" - "github.com/pkg/errors" -) - -const ( - // taskLoopInterval is the interval at which the agent performs checks - taskLoopInterval = 2 * time.Second - - // keepaliveInterval used to keep candidates alive - keepaliveInterval = 10 * time.Second - - // connectionTimeout used to declare a connection dead - connectionTimeout = 30 * time.Second -) - -// Agent represents the ICE agent -type Agent struct { - notifier func(ConnectionState) - - // Used to block double Dial/Accept - opened bool - - // State owned by the taskLoop - taskChan chan task - onConnected chan struct{} - onConnectedOnce sync.Once - - connectivityTicker *time.Ticker - connectivityChan <-chan time.Time - - tieBreaker uint64 - connectionState ConnectionState - gatheringState GatheringState - - haveStarted bool - isControlling bool - - localUfrag string - localPwd string - localCandidates map[NetworkType][]*Candidate - - remoteUfrag string - remotePwd string - remoteCandidates map[NetworkType][]*Candidate - - selectedPair *candidatePair - validPairs []*candidatePair - - // Channel for reading - rcvCh chan *bufIn - - // State for closing - done chan struct{} - err atomicError -} - -type bufIn struct { - buf []byte - size chan int -} - -func (a *Agent) ok() error { - select { - case <-a.done: - return a.getErr() - default: - } - return nil -} - -func (a *Agent) getErr() error { - err := a.err.Load() - if err != nil { - return err - } - return ErrClosed -} - -// NewAgent creates a new Agent -func NewAgent(urls []*URL, notifier func(ConnectionState)) *Agent { - a := &Agent{ - notifier: notifier, - tieBreaker: rand.New(rand.NewSource(time.Now().UnixNano())).Uint64(), - gatheringState: GatheringStateComplete, // TODO trickle-ice - connectionState: ConnectionStateNew, - localCandidates: make(map[NetworkType][]*Candidate), - remoteCandidates: make(map[NetworkType][]*Candidate), - - localUfrag: util.RandSeq(16), - localPwd: util.RandSeq(32), - taskChan: make(chan task), - onConnected: make(chan struct{}), - rcvCh: make(chan *bufIn), - done: make(chan struct{}), - } - - // Initialize local candidates - a.gatherCandidatesLocal() - a.gatherCandidatesReflective(urls) - - go a.taskLoop() - return a -} - -func (a *Agent) gatherCandidatesLocal() { - localIPs := localInterfaces() - for _, ip := range localIPs { - for _, network := range supportedNetworks { - conn, err := net.ListenUDP(network, &net.UDPAddr{IP: ip, Port: 0}) - if err != nil { - fmt.Printf("could not listen %s %s\n", network, ip) - continue - } - - port := conn.LocalAddr().(*net.UDPAddr).Port - c, err := NewCandidateHost(network, ip, port) - if err != nil { - fmt.Printf("Failed to create host candidate: %s %s %d: %v\n", network, ip, port, err) - continue - } - - networkType := c.NetworkType - set := a.localCandidates[networkType] - set = append(set, c) - a.localCandidates[networkType] = set - - c.start(a, conn) - } - } -} - -func (a *Agent) gatherCandidatesReflective(urls []*URL) { - for _, networkType := range supportedNetworkTypes { - network := networkType.String() - for _, url := range urls { - switch url.Scheme { - case SchemeTypeSTUN: - laddr, xoraddr, err := allocateUDP(network, url) - if err != nil { - fmt.Printf("could not allocate %s %s: %v\n", network, url, err) - continue - } - conn, err := net.ListenUDP(network, laddr) - if err != nil { - fmt.Printf("could not listen %s %s: %v\n", network, laddr, err) - } - - ip := xoraddr.IP - port := xoraddr.Port - relIP := laddr.IP.String() - relPort := laddr.Port - c, err := NewCandidateServerReflexive(network, ip, port, relIP, relPort) - if err != nil { - fmt.Printf("Failed to create server reflexive candidate: %s %s %d: %v\n", network, ip, port, err) - continue - } - - networkType := c.NetworkType - set := a.localCandidates[networkType] - set = append(set, c) - a.localCandidates[networkType] = set - - c.start(a, conn) - - default: - fmt.Printf("scheme %s is not implemented\n", url.Scheme.String()) - continue - } - } - } -} - -func allocateUDP(network string, url *URL) (*net.UDPAddr, *stun.XorAddress, error) { - // TODO Do we want the timeout to be configurable? - client, err := stun.NewClient(network, fmt.Sprintf("%s:%d", url.Host, url.Port), time.Second*5) - if err != nil { - return nil, nil, errors.Wrapf(err, "Failed to create STUN client") - } - localAddr, ok := client.LocalAddr().(*net.UDPAddr) - if !ok { - return nil, nil, errors.Errorf("Failed to cast STUN client to UDPAddr") - } - - resp, err := client.Request() - if err != nil { - return nil, nil, errors.Wrapf(err, "Failed to make STUN request") - } - - if err = client.Close(); err != nil { - return nil, nil, errors.Wrapf(err, "Failed to close STUN client") - } - - attr, ok := resp.GetOneAttribute(stun.AttrXORMappedAddress) - if !ok { - return nil, nil, errors.Errorf("Got respond from STUN server that did not contain XORAddress") - } - - var addr stun.XorAddress - if err = addr.Unpack(resp, attr); err != nil { - return nil, nil, errors.Wrapf(err, "Failed to unpack STUN XorAddress response") - } - - return localAddr, &addr, nil -} - -func (a *Agent) startConnectivityChecks(isControlling bool, remoteUfrag, remotePwd string) error { - if a.haveStarted { - return errors.Errorf("Attempted to start agent twice") - } else if remoteUfrag == "" { - return errors.Errorf("remoteUfrag is empty") - } else if remotePwd == "" { - return errors.Errorf("remotePwd is empty") - } - - return a.run(func(agent *Agent) { - agent.isControlling = isControlling - agent.remoteUfrag = remoteUfrag - agent.remotePwd = remotePwd - - // TODO this should be dynamic, and grow when the connection is stable - t := time.NewTicker(taskLoopInterval) - agent.connectivityTicker = t - agent.connectivityChan = t.C - - agent.updateConnectionState(ConnectionStateChecking) - }) -} - -func (a *Agent) pingCandidate(local, remote *Candidate) { - var msg *stun.Message - var err error - - // The controlling agent MUST include the USE-CANDIDATE attribute in - // order to nominate a candidate pair (Section 8.1.1). The controlled - // agent MUST NOT include the USE-CANDIDATE attribute in a Binding - // request. - - if a.isControlling { - msg, err = stun.Build(stun.ClassRequest, stun.MethodBinding, stun.GenerateTransactionId(), - &stun.Username{Username: a.remoteUfrag + ":" + a.localUfrag}, - &stun.UseCandidate{}, - &stun.IceControlling{TieBreaker: a.tieBreaker}, - &stun.Priority{Priority: uint32(local.Priority(CandidateTypeHost.Preference(), 1))}, - &stun.MessageIntegrity{ - Key: []byte(a.remotePwd), - }, - &stun.Fingerprint{}, - ) - } else { - msg, err = stun.Build(stun.ClassRequest, stun.MethodBinding, stun.GenerateTransactionId(), - &stun.Username{Username: a.remoteUfrag + ":" + a.localUfrag}, - &stun.IceControlled{TieBreaker: a.tieBreaker}, - &stun.Priority{Priority: uint32(local.Priority(CandidateTypeHost.Preference(), 1))}, - &stun.MessageIntegrity{ - Key: []byte(a.remotePwd), - }, - &stun.Fingerprint{}, - ) - } - - if err != nil { - fmt.Println(err) - return - } - - a.sendSTUN(msg, local, remote) -} - -func (a *Agent) updateConnectionState(newState ConnectionState) { - if a.connectionState != newState { - a.connectionState = newState - if a.notifier != nil { - // Call handler async since we may be holding the agent lock - // and the handler may also require it - go a.notifier(a.connectionState) - } - } -} - -func (a *Agent) setValidPair(local, remote *Candidate, selected bool) { - // TODO: avoid duplicates - p := newCandidatePair(local, remote) - - if selected { - a.selectedPair = p - a.validPairs = nil - // TODO: only set state to connected on selecting final pair? - a.updateConnectionState(ConnectionStateConnected) - } else { - // keep track of pairs with succesfull bindings since any of them - // can be used for communication until the final pair is selected: - // https://tools.ietf.org/html/draft-ietf-ice-rfc5245bis-20#section-12 - a.validPairs = append(a.validPairs, p) - } - - // Signal connected - a.onConnectedOnce.Do(func() { close(a.onConnected) }) -} - -// A task is a -type task func(*Agent) - -func (a *Agent) run(t task) error { - err := a.ok() - if err != nil { - return err - } - - select { - case <-a.done: - return a.getErr() - case a.taskChan <- t: - } - return nil -} - -func (a *Agent) taskLoop() { - for { - select { - case <-a.connectivityChan: - if a.validateSelectedPair() { - a.checkKeepalive() - } else { - a.pingAllCandidates() - } - - case t := <-a.taskChan: - // Run the task - t(a) - - case <-a.done: - return - } - } -} - -// validateSelectedPair checks if the selected pair is (still) valid -// Note: the caller should hold the agent lock. -func (a *Agent) validateSelectedPair() bool { - if a.selectedPair == nil { - // Not valid since not selected - return false - } - - if time.Since(a.selectedPair.remote.LastReceived()) > connectionTimeout { - a.selectedPair = nil - a.updateConnectionState(ConnectionStateDisconnected) - return false - } - - return true -} - -// checkKeepalive sends STUN Binding Indications to the selected pair -// if no packet has been sent on that pair in the last keepaliveInterval -// Note: the caller should hold the agent lock. -func (a *Agent) checkKeepalive() { - if a.selectedPair == nil { - return - } - - if time.Since(a.selectedPair.remote.LastSent()) > keepaliveInterval { - a.keepaliveCandidate(a.selectedPair.local, a.selectedPair.remote) - } -} - -// pingAllCandidates sends STUN Binding Requests to all candidates -// Note: the caller should hold the agent lock. -func (a *Agent) pingAllCandidates() { - for networkType, localCandidates := range a.localCandidates { - if remoteCandidates, ok := a.remoteCandidates[networkType]; ok { - - for _, localCandidate := range localCandidates { - for _, remoteCandidate := range remoteCandidates { - a.pingCandidate(localCandidate, remoteCandidate) - } - } - - } - } -} - -// AddRemoteCandidate adds a new remote candidate -func (a *Agent) AddRemoteCandidate(c *Candidate) error { - return a.run(func(agent *Agent) { - networkType := c.NetworkType - set := agent.remoteCandidates[networkType] - - for _, candidate := range set { - if candidate.Equal(c) { - return - } - } - - set = append(set, c) - agent.remoteCandidates[networkType] = set - }) -} - -// GetLocalCandidates returns the local candidates -func (a *Agent) GetLocalCandidates() ([]*Candidate, error) { - res := make(chan []*Candidate) - - err := a.run(func(agent *Agent) { - var candidates []*Candidate - for _, set := range agent.localCandidates { - candidates = append(candidates, set...) - } - res <- candidates - }) - if err != nil { - return nil, err - } - - return <-res, nil -} - -// GetLocalUserCredentials returns the local user credentials -func (a *Agent) GetLocalUserCredentials() (frag string, pwd string) { - return a.localUfrag, a.localPwd -} - -// Close cleans up the Agent -func (a *Agent) Close() error { - done := make(chan struct{}) - err := a.run(func(agent *Agent) { - defer func() { - close(done) - }() - agent.err.Store(ErrClosed) - close(agent.done) - - // Cleanup all candidates - for net, cs := range agent.localCandidates { - for _, c := range cs { - err := c.close() - if err != nil { - fmt.Printf("Failed to close candidate %s: %v", c, err) - } - } - delete(agent.localCandidates, net) - } - for net, cs := range agent.remoteCandidates { - for _, c := range cs { - err := c.close() - if err != nil { - fmt.Printf("Failed to close candidate %s: %v", c, err) - } - } - delete(agent.remoteCandidates, net) - } - }) - if err != nil { - return err - } - - <-done - - return nil -} - -func (a *Agent) findRemoteCandidate(networkType NetworkType, addr net.Addr) *Candidate { - var ip net.IP - var port int - - switch a := addr.(type) { - case *net.UDPAddr: - ip = a.IP - port = a.Port - case *net.TCPAddr: - ip = a.IP - port = a.Port - default: - fmt.Printf("unsupported address type %T", a) - return nil - } - - set := a.remoteCandidates[networkType] - for _, c := range set { - base := c - if base.IP.Equal(ip) && - base.Port == port { - return c - } - } - return nil -} - -func (a *Agent) sendBindingSuccess(m *stun.Message, local, remote *Candidate) { - base := remote - if out, err := stun.Build(stun.ClassSuccessResponse, stun.MethodBinding, m.TransactionID, - &stun.XorMappedAddress{ - XorAddress: stun.XorAddress{ - IP: base.IP, - Port: base.Port, - }, - }, - &stun.MessageIntegrity{ - Key: []byte(a.localPwd), - }, - &stun.Fingerprint{}, - ); err != nil { - fmt.Printf("Failed to handle inbound ICE from: %s to: %s error: %s", local.String(), remote.String(), err.Error()) - } else { - a.sendSTUN(out, local, remote) - } -} - -func (a *Agent) handleInboundControlled(m *stun.Message, localCandidate, remoteCandidate *Candidate) { - if _, isControlled := m.GetOneAttribute(stun.AttrIceControlled); isControlled && !a.isControlling { - fmt.Println("inbound isControlled && a.isControlling == false") - return - } - - successResponse := m.Method == stun.MethodBinding && m.Class == stun.ClassSuccessResponse - _, usepair := m.GetOneAttribute(stun.AttrUseCandidate) - // Remember the working pair and select it when marked with usepair - a.setValidPair(localCandidate, remoteCandidate, usepair) - - if !successResponse { - // Send success response - a.sendBindingSuccess(m, localCandidate, remoteCandidate) - } -} - -func (a *Agent) handleInboundControlling(m *stun.Message, localCandidate, remoteCandidate *Candidate) { - if _, isControlling := m.GetOneAttribute(stun.AttrIceControlling); isControlling && a.isControlling { - fmt.Println("inbound isControlling && a.isControlling == true") - return - } else if _, useCandidate := m.GetOneAttribute(stun.AttrUseCandidate); useCandidate && a.isControlling { - fmt.Println("useCandidate && a.isControlling == true") - return - } - - successResponse := m.Method == stun.MethodBinding && m.Class == stun.ClassSuccessResponse - // Remember the working pair and select it when receiving a success response - a.setValidPair(localCandidate, remoteCandidate, successResponse) - - if !successResponse { - // Send success response - a.sendBindingSuccess(m, localCandidate, remoteCandidate) - - // We received a ping from the controlled agent. We know the pair works so now we ping with use-candidate set: - a.pingCandidate(localCandidate, remoteCandidate) - } -} - -// handleInbound processes traffic from a remote candidate -func (a *Agent) handleInbound(m *stun.Message, local *Candidate, remote net.Addr) { - remoteCandidate := a.findRemoteCandidate(local.NetworkType, remote) - if remoteCandidate == nil { - // TODO debug - // fmt.Printf("Could not find remote candidate for %s:%d ", remote.IP.String(), remote.Port) - return - } - - remoteCandidate.seen(false) - - if m.Class == stun.ClassIndication { - return - } - - if a.isControlling { - a.handleInboundControlling(m, local, remoteCandidate) - } else { - a.handleInboundControlled(m, local, remoteCandidate) - } - -} - -func (a *Agent) getBestPair() (*candidatePair, error) { - res := make(chan *candidatePair) - - err := a.run(func(agent *Agent) { - if agent.selectedPair != nil { - res <- agent.selectedPair - return - } - for _, p := range agent.validPairs { - res <- p - return - } - }) - - if err != nil { - return nil, err - } - - return <-res, nil -} diff --git a/vendor/github.com/pions/webrtc/pkg/ice/candidate.go b/vendor/github.com/pions/webrtc/pkg/ice/candidate.go deleted file mode 100644 index 7a7f9b7..0000000 --- a/vendor/github.com/pions/webrtc/pkg/ice/candidate.go +++ /dev/null @@ -1,207 +0,0 @@ -package ice - -import ( - "fmt" - "math/rand" - "net" - "sync" - "time" - - "github.com/pions/pkg/stun" -) - -const receiveMTU = 8192 - -// Candidate represents an ICE candidate -type Candidate struct { - NetworkType - - Type CandidateType - IP net.IP - Port int - RelatedAddress *CandidateRelatedAddress - - lock sync.RWMutex - lastSent time.Time - lastReceived time.Time - - agent *Agent - conn net.PacketConn - closeCh chan struct{} - closedCh chan struct{} -} - -// NewCandidateHost creates a new host candidate -func NewCandidateHost(network string, ip net.IP, port int) (*Candidate, error) { - networkType, err := determineNetworkType(network, ip) - if err != nil { - return nil, err - } - - return &Candidate{ - Type: CandidateTypeHost, - NetworkType: networkType, - IP: ip, - Port: port, - }, nil -} - -// NewCandidateServerReflexive creates a new server reflective candidate -func NewCandidateServerReflexive(network string, ip net.IP, port int, relAddr string, relPort int) (*Candidate, error) { - networkType, err := determineNetworkType(network, ip) - if err != nil { - return nil, err - } - return &Candidate{ - Type: CandidateTypeServerReflexive, - NetworkType: networkType, - IP: ip, - Port: port, - RelatedAddress: &CandidateRelatedAddress{ - Address: relAddr, - Port: relPort, - }, - }, nil -} - -// start runs the candidate using the provided connection -func (c *Candidate) start(a *Agent, conn net.PacketConn) { - c.agent = a - c.conn = conn - c.closeCh = make(chan struct{}) - c.closedCh = make(chan struct{}) - - go c.recvLoop() -} - -func (c *Candidate) recvLoop() { - defer func() { - close(c.closedCh) - }() - - buffer := make([]byte, receiveMTU) - for { - n, srcAddr, err := c.conn.ReadFrom(buffer) - if err != nil { - return - } - - if stun.IsSTUN(buffer[:n]) { - m, err := stun.NewMessage(buffer[:n]) - if err != nil { - fmt.Println(fmt.Sprintf("Failed to handle decode ICE from %s to %s: %v", c.addr(), srcAddr, err)) - continue - } - err = c.agent.run(func(agent *Agent) { - agent.handleInbound(m, c, srcAddr) - }) - if err != nil { - fmt.Println(fmt.Sprintf("Failed to handle message: %v", err)) - } - - continue - } - - select { - case bufin := <-c.agent.rcvCh: - copy(bufin.buf, buffer[:n]) // TODO: avoid copy in common case? - bufin.size <- n - case <-c.closeCh: - return - } - } -} - -// close stops the recvLoop -func (c *Candidate) close() error { - c.lock.Lock() - defer c.lock.Unlock() - if c.conn != nil { - // Unblock recvLoop - close(c.closeCh) - // Close the conn - err := c.conn.Close() - if err != nil { - return err - } - - // Wait until the recvLoop is closed - <-c.closedCh - } - - return nil -} - -func (c *Candidate) writeTo(raw []byte, dst *Candidate) (int, error) { - n, err := c.conn.WriteTo(raw, dst.addr()) - if err != nil { - return n, fmt.Errorf("failed to send packet: %v", err) - } - c.seen(true) - return n, nil -} - -// Priority computes the priority for this ICE Candidate -func (c *Candidate) Priority(typePreference uint16, component uint16) uint16 { - localPreference := uint16(rand.New(rand.NewSource(time.Now().UnixNano())).Uint32() / 2) - return (2^24)*typePreference + - (2^8)*localPreference + - (2^0)*(256-component) -} - -// Equal is used to compare two CandidateBases -func (c *Candidate) Equal(other *Candidate) bool { - return c.NetworkType == other.NetworkType && - c.Type == other.Type && - c.IP.Equal(other.IP) && - c.Port == other.Port && - c.RelatedAddress.Equal(other.RelatedAddress) -} - -// String makes the CandidateHost printable -func (c *Candidate) String() string { - return fmt.Sprintf("%s %s:%d%s", c.Type, c.IP, c.Port, c.RelatedAddress) -} - -// LastReceived returns a time.Time indicating the last time -// this candidate was received -func (c *Candidate) LastReceived() time.Time { - c.lock.RLock() - defer c.lock.RUnlock() - return c.lastReceived -} - -func (c *Candidate) setLastReceived(t time.Time) { - c.lock.Lock() - defer c.lock.Unlock() - c.lastReceived = t -} - -// LastSent returns a time.Time indicating the last time -// this candidate was sent -func (c *Candidate) LastSent() time.Time { - c.lock.RLock() - defer c.lock.RUnlock() - return c.lastSent -} - -func (c *Candidate) setLastSent(t time.Time) { - c.lock.Lock() - defer c.lock.Unlock() - c.lastSent = t -} - -func (c *Candidate) seen(outbound bool) { - if outbound { - c.setLastSent(time.Now()) - } else { - c.setLastReceived(time.Now()) - } -} - -func (c *Candidate) addr() net.Addr { - return &net.UDPAddr{ - IP: c.IP, - Port: c.Port, - } -} diff --git a/vendor/github.com/pions/webrtc/pkg/ice/candidatepair.go b/vendor/github.com/pions/webrtc/pkg/ice/candidatepair.go deleted file mode 100644 index 2884974..0000000 --- a/vendor/github.com/pions/webrtc/pkg/ice/candidatepair.go +++ /dev/null @@ -1,53 +0,0 @@ -package ice - -import ( - "fmt" - - "github.com/pions/pkg/stun" -) - -func newCandidatePair(local, remote *Candidate) *candidatePair { - return &candidatePair{ - remote: remote, - local: local, - } -} - -// candidatePair represents a combination of a local and remote candidate -type candidatePair struct { - remote *Candidate - local *Candidate -} - -func (p *candidatePair) Write(b []byte) (int, error) { - return p.local.writeTo(b, p.remote) -} - -// keepaliveCandidate sends a STUN Binding Indication to the remote candidate -func (a *Agent) keepaliveCandidate(local, remote *Candidate) { - msg, err := stun.Build(stun.ClassIndication, stun.MethodBinding, stun.GenerateTransactionId(), - &stun.Username{Username: a.remoteUfrag + ":" + a.localUfrag}, - &stun.MessageIntegrity{ - Key: []byte(a.remotePwd), - }, - &stun.Fingerprint{}, - ) - - if err != nil { - fmt.Println(err) - return - } - - a.sendSTUN(msg, local, remote) -} - -func (a *Agent) sendSTUN(msg *stun.Message, local, remote *Candidate) { - _, err := local.writeTo(msg.Pack(), remote) - if err != nil { - // TODO: Determine if we should always drop the err - // E.g.: maybe handle for known valid pairs or to - // discard pairs faster. - _ = err - // fmt.Printf("failed to send STUN message: %v", err) - } -} diff --git a/vendor/github.com/pions/webrtc/pkg/ice/candidaterelatedaddress.go b/vendor/github.com/pions/webrtc/pkg/ice/candidaterelatedaddress.go deleted file mode 100644 index 18cf318..0000000 --- a/vendor/github.com/pions/webrtc/pkg/ice/candidaterelatedaddress.go +++ /dev/null @@ -1,30 +0,0 @@ -package ice - -import "fmt" - -// CandidateRelatedAddress convey transport addresses related to the -// candidate, useful for diagnostics and other purposes. -type CandidateRelatedAddress struct { - Address string - Port int -} - -// String makes CandidateRelatedAddress printable -func (c *CandidateRelatedAddress) String() string { - if c == nil { - return "" - } - - return fmt.Sprintf(" related %s:%d", c.Address, c.Port) -} - -// Equal allows comparing two CandidateRelatedAddresses. -// The CandidateRelatedAddress are allowed to be nil. -func (c *CandidateRelatedAddress) Equal(other *CandidateRelatedAddress) bool { - if c == nil && other == nil { - return true - } - return c != nil && other != nil && - c.Address == other.Address && - c.Port == other.Port -} diff --git a/vendor/github.com/pions/webrtc/pkg/ice/candidatetype.go b/vendor/github.com/pions/webrtc/pkg/ice/candidatetype.go deleted file mode 100644 index 438ebfb..0000000 --- a/vendor/github.com/pions/webrtc/pkg/ice/candidatetype.go +++ /dev/null @@ -1,38 +0,0 @@ -package ice - -// CandidateType represents the type of candidate -type CandidateType byte - -// CandidateType enum -const ( - CandidateTypeHost CandidateType = iota + 1 - CandidateTypeServerReflexive - // CandidateTypePeerReflexive // TODO - // CandidateTypeRelay // TODO -) - -// String makes CandidateType printable -func (c CandidateType) String() string { - switch c { - case CandidateTypeHost: - return "host" - case CandidateTypeServerReflexive: - return "srflx" - // case CandidateTypePeerReflexive: - // return "prflx" - // case CandidateTypeRelay: - // return "relay" - } - return "Unknown candidate type" -} - -// Preference returns the preference weight of a CandidateType -func (c CandidateType) Preference() uint16 { - switch c { - case CandidateTypeHost: - return 126 - case CandidateTypeServerReflexive: - return 100 - } - return 0 -} diff --git a/vendor/github.com/pions/webrtc/pkg/ice/errors.go b/vendor/github.com/pions/webrtc/pkg/ice/errors.go deleted file mode 100644 index dff4a36..0000000 --- a/vendor/github.com/pions/webrtc/pkg/ice/errors.go +++ /dev/null @@ -1,31 +0,0 @@ -package ice - -import ( - "github.com/pkg/errors" -) - -var ( - // ErrUnknownType indicates an error with Unknown info. - ErrUnknownType = errors.New("Unknown") - - // ErrSchemeType indicates the scheme type could not be parsed. - ErrSchemeType = errors.New("unknown scheme type") - - // ErrSTUNQuery indicates query arguments are provided in a STUN URL. - ErrSTUNQuery = errors.New("queries not supported in stun address") - - // ErrInvalidQuery indicates an malformed query is provided. - ErrInvalidQuery = errors.New("invalid query") - - // ErrHost indicates malformed hostname is provided. - ErrHost = errors.New("invalid hostname") - - // ErrPort indicates malformed port is provided. - ErrPort = errors.New("invalid port") - - // ErrProtoType indicates an unsupported transport type was provided. - ErrProtoType = errors.New("invalid transport protocol type") - - // ErrClosed indicates the agent is closed - ErrClosed = errors.New("the agent is closed") -) diff --git a/vendor/github.com/pions/webrtc/pkg/ice/ice.go b/vendor/github.com/pions/webrtc/pkg/ice/ice.go deleted file mode 100644 index d7094f6..0000000 --- a/vendor/github.com/pions/webrtc/pkg/ice/ice.go +++ /dev/null @@ -1,76 +0,0 @@ -package ice - -// ConnectionState is an enum showing the state of a ICE Connection -type ConnectionState int - -// List of supported States -const ( - // ConnectionStateNew ICE agent is gathering addresses - ConnectionStateNew = iota + 1 - - // ConnectionStateChecking ICE agent has been given local and remote candidates, and is attempting to find a match - ConnectionStateChecking - - // ConnectionStateConnected ICE agent has a pairing, but is still checking other pairs - ConnectionStateConnected - - // ConnectionStateCompleted ICE agent has finished - ConnectionStateCompleted - - // ConnectionStateFailed ICE agent never could successfully connect - ConnectionStateFailed - - // ConnectionStateDisconnected ICE agent connected successfully, but has entered a failed state - ConnectionStateDisconnected - - // ConnectionStateClosed ICE agent has finished and is no longer handling requests - ConnectionStateClosed -) - -func (c ConnectionState) String() string { - switch c { - case ConnectionStateNew: - return "New" - case ConnectionStateChecking: - return "Checking" - case ConnectionStateConnected: - return "Connected" - case ConnectionStateCompleted: - return "Completed" - case ConnectionStateFailed: - return "Failed" - case ConnectionStateDisconnected: - return "Disconnected" - case ConnectionStateClosed: - return "Closed" - default: - return "Invalid" - } -} - -// GatheringState describes the state of the candidate gathering process -type GatheringState int - -const ( - // GatheringStateNew indicates candidate gatering is not yet started - GatheringStateNew GatheringState = iota + 1 - - // GatheringStateGathering indicates candidate gatering is ongoing - GatheringStateGathering - - // GatheringStateComplete indicates candidate gatering has been completed - GatheringStateComplete -) - -func (t GatheringState) String() string { - switch t { - case GatheringStateNew: - return "new" - case GatheringStateGathering: - return "gathering" - case GatheringStateComplete: - return "complete" - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/pkg/ice/networktype.go b/vendor/github.com/pions/webrtc/pkg/ice/networktype.go deleted file mode 100644 index 9847995..0000000 --- a/vendor/github.com/pions/webrtc/pkg/ice/networktype.go +++ /dev/null @@ -1,102 +0,0 @@ -package ice - -import ( - "fmt" - "net" - "strings" -) - -const ( - udp = "udp" - tcp = "tcp" -) - -var supportedNetworks = []string{ - udp, - // tcp, // Not supported yet -} - -var supportedNetworkTypes = []NetworkType{ - NetworkTypeUDP4, - NetworkTypeUDP6, - // NetworkTypeTCP4, // Not supported yet - // NetworkTypeTCP6, // Not supported yet -} - -// NetworkType represents the type of network -type NetworkType int - -const ( - // NetworkTypeUDP4 indicates UDP over IPv4. - NetworkTypeUDP4 NetworkType = iota + 1 - - // NetworkTypeUDP6 indicates UDP over IPv4. - NetworkTypeUDP6 - - // NetworkTypeTCP4 indicates TCP over IPv4. - NetworkTypeTCP4 - - // NetworkTypeTCP6 indicates TCP over IPv4. - NetworkTypeTCP6 -) - -func (t NetworkType) String() string { - switch t { - case NetworkTypeUDP4: - return "udp4" - case NetworkTypeUDP6: - return "udp6" - case NetworkTypeTCP4: - return "tcp4" - case NetworkTypeTCP6: - return "tcp6" - default: - return ErrUnknownType.Error() - } -} - -// NetworkShort returns the short network description -func (t NetworkType) NetworkShort() string { - switch t { - case NetworkTypeUDP4, NetworkTypeUDP6: - return udp - case NetworkTypeTCP4, NetworkTypeTCP6: - return tcp - default: - return ErrUnknownType.Error() - } -} - -// IsReliable returns true if the network is reliable -func (t NetworkType) IsReliable() bool { - switch t { - case NetworkTypeUDP4, NetworkTypeUDP6: - return false - case NetworkTypeTCP4, NetworkTypeTCP6: - return true - } - return false -} - -// determineNetworkType determines the type of network based on -// the short network string and an IP address. -func determineNetworkType(network string, ip net.IP) (NetworkType, error) { - ipv4 := ip.To4() != nil - - switch { - case strings.HasPrefix(strings.ToLower(network), udp): - if ipv4 { - return NetworkTypeUDP4, nil - } - return NetworkTypeUDP6, nil - - case strings.HasPrefix(strings.ToLower(network), tcp): - if ipv4 { - return NetworkTypeTCP4, nil - } - return NetworkTypeTCP6, nil - - } - - return NetworkType(0), fmt.Errorf("unable to determine networkType from %s %s", network, ip) -} diff --git a/vendor/github.com/pions/webrtc/pkg/ice/transport.go b/vendor/github.com/pions/webrtc/pkg/ice/transport.go deleted file mode 100644 index 6f2d030..0000000 --- a/vendor/github.com/pions/webrtc/pkg/ice/transport.go +++ /dev/null @@ -1,124 +0,0 @@ -package ice - -import ( - "context" - "errors" - "net" - "time" - - "github.com/pions/pkg/stun" -) - -// Dial connects to the remote agent, acting as the controlling ice agent. -// Dial blocks until at least one ice candidate pair has successfully connected. -func (a *Agent) Dial(ctx context.Context, remoteUfrag, remotePwd string) (*Conn, error) { - return a.connect(ctx, true, remoteUfrag, remotePwd) -} - -// Accept connects to the remote agent, acting as the controlled ice agent. -// Accept blocks until at least one ice candidate pair has successfully connected. -func (a *Agent) Accept(ctx context.Context, remoteUfrag, remotePwd string) (*Conn, error) { - return a.connect(ctx, false, remoteUfrag, remotePwd) -} - -// Conn represents the ICE connection. -// At the moment the lifetime of the Conn is equal to the Agent. -type Conn struct { - agent *Agent -} - -func (a *Agent) connect(ctx context.Context, isControlling bool, remoteUfrag, remotePwd string) (*Conn, error) { - err := a.ok() - if err != nil { - return nil, err - } - if a.opened { - return nil, errors.New("a connection is already opened") - } - err = a.startConnectivityChecks(isControlling, remoteUfrag, remotePwd) - if err != nil { - return nil, err - } - - // block until pair selected - select { - case <-ctx.Done(): - // TODO: Stop connectivity checks? - return nil, errors.New("connecting canceled by caller") - case <-a.onConnected: - } - - return &Conn{ - agent: a, - }, nil - -} - -// Read implements the Conn Read method. -func (c *Conn) Read(p []byte) (int, error) { - err := c.agent.ok() - if err != nil { - return 0, err - } - - resN := make(chan int) - - select { - case c.agent.rcvCh <- &bufIn{p, resN}: - n := <-resN - return n, nil - case <-c.agent.done: - return 0, c.agent.getErr() - } -} - -// Write implements the Conn Write method. -func (c *Conn) Write(p []byte) (int, error) { - err := c.agent.ok() - if err != nil { - return 0, err - } - - if stun.IsSTUN(p) { - return 0, errors.New("The ICE conn can't write STUN messages") - } - - pair, err := c.agent.getBestPair() - if err != nil { - return 0, err - } - return pair.Write(p) -} - -// Close implements the Conn Close method. It is used to close -// the connection. Any calls to Read and Write will be unblocked and return an error. -func (c *Conn) Close() error { - return c.agent.Close() -} - -// TODO: Maybe just switch to using io.ReadWriteCloser? - -// LocalAddr is a stub -func (c *Conn) LocalAddr() net.Addr { - return nil -} - -// RemoteAddr is a stub -func (c *Conn) RemoteAddr() net.Addr { - return nil -} - -// SetDeadline is a stub -func (c *Conn) SetDeadline(t time.Time) error { - return nil -} - -// SetReadDeadline is a stub -func (c *Conn) SetReadDeadline(t time.Time) error { - return nil -} - -// SetWriteDeadline is a stub -func (c *Conn) SetWriteDeadline(t time.Time) error { - return nil -} diff --git a/vendor/github.com/pions/webrtc/pkg/ice/url.go b/vendor/github.com/pions/webrtc/pkg/ice/url.go deleted file mode 100644 index 6f0196e..0000000 --- a/vendor/github.com/pions/webrtc/pkg/ice/url.go +++ /dev/null @@ -1,227 +0,0 @@ -package ice - -import ( - "net" - "net/url" - "strconv" - - "github.com/pions/webrtc/pkg/rtcerr" -) - -// TODO: Migrate address parsing to STUN/TURN - -// SchemeType indicates the type of server used in the ice.URL structure. -type SchemeType int - -// Unknown defines default public constant to use for "enum" like struct -// comparisons when no value was defined. -const Unknown = iota - -const ( - // SchemeTypeSTUN indicates the URL represents a STUN server. - SchemeTypeSTUN SchemeType = iota + 1 - - // SchemeTypeSTUNS indicates the URL represents a STUNS (secure) server. - SchemeTypeSTUNS - - // SchemeTypeTURN indicates the URL represents a TURN server. - SchemeTypeTURN - - // SchemeTypeTURNS indicates the URL represents a TURNS (secure) server. - SchemeTypeTURNS -) - -// NewSchemeType defines a procedure for creating a new SchemeType from a raw -// string naming the scheme type. -func NewSchemeType(raw string) SchemeType { - switch raw { - case "stun": - return SchemeTypeSTUN - case "stuns": - return SchemeTypeSTUNS - case "turn": - return SchemeTypeTURN - case "turns": - return SchemeTypeTURNS - default: - return SchemeType(Unknown) - } -} - -func (t SchemeType) String() string { - switch t { - case SchemeTypeSTUN: - return "stun" - case SchemeTypeSTUNS: - return "stuns" - case SchemeTypeTURN: - return "turn" - case SchemeTypeTURNS: - return "turns" - default: - return ErrUnknownType.Error() - } -} - -// ProtoType indicates the transport protocol type that is used in the ice.URL -// structure. -type ProtoType int - -const ( - // ProtoTypeUDP indicates the URL uses a UDP transport. - ProtoTypeUDP ProtoType = iota + 1 - - // ProtoTypeTCP indicates the URL uses a TCP transport. - ProtoTypeTCP -) - -// NewProtoType defines a procedure for creating a new ProtoType from a raw -// string naming the transport protocol type. -func NewProtoType(raw string) ProtoType { - switch raw { - case "udp": - return ProtoTypeUDP - case "tcp": - return ProtoTypeTCP - default: - return ProtoType(Unknown) - } -} - -func (t ProtoType) String() string { - switch t { - case ProtoTypeUDP: - return "udp" - case ProtoTypeTCP: - return "tcp" - default: - return ErrUnknownType.Error() - } -} - -// URL represents a STUN (rfc7064) or TURN (rfc7065) URL -type URL struct { - Scheme SchemeType - Host string - Port int - Proto ProtoType -} - -// ParseURL parses a STUN or TURN urls following the ABNF syntax described in -// https://tools.ietf.org/html/rfc7064 and https://tools.ietf.org/html/rfc7065 -// respectively. -func ParseURL(raw string) (*URL, error) { - rawParts, err := url.Parse(raw) - if err != nil { - return nil, &rtcerr.UnknownError{Err: err} - } - - var u URL - u.Scheme = NewSchemeType(rawParts.Scheme) - if u.Scheme == SchemeType(Unknown) { - return nil, &rtcerr.SyntaxError{Err: ErrSchemeType} - } - - var rawPort string - if u.Host, rawPort, err = net.SplitHostPort(rawParts.Opaque); err != nil { - if e, ok := err.(*net.AddrError); ok { - if e.Err == "missing port in address" { - nextRawURL := u.Scheme.String() + ":" + rawParts.Opaque - switch { - case u.Scheme == SchemeTypeSTUN || u.Scheme == SchemeTypeTURN: - nextRawURL += ":3478" - if rawParts.RawQuery != "" { - nextRawURL += "?" + rawParts.RawQuery - } - return ParseURL(nextRawURL) - case u.Scheme == SchemeTypeSTUNS || u.Scheme == SchemeTypeTURNS: - nextRawURL += ":5349" - if rawParts.RawQuery != "" { - nextRawURL += "?" + rawParts.RawQuery - } - return ParseURL(nextRawURL) - } - } - } - return nil, &rtcerr.UnknownError{Err: err} - } - - if u.Host == "" { - return nil, &rtcerr.SyntaxError{Err: ErrHost} - } - - if u.Port, err = strconv.Atoi(rawPort); err != nil { - return nil, &rtcerr.SyntaxError{Err: ErrPort} - } - - switch { - case u.Scheme == SchemeTypeSTUN: - qArgs, err := url.ParseQuery(rawParts.RawQuery) - if err != nil || (err == nil && len(qArgs) > 0) { - return nil, &rtcerr.SyntaxError{Err: ErrSTUNQuery} - } - u.Proto = ProtoTypeUDP - case u.Scheme == SchemeTypeSTUNS: - qArgs, err := url.ParseQuery(rawParts.RawQuery) - if err != nil || (err == nil && len(qArgs) > 0) { - return nil, &rtcerr.SyntaxError{Err: ErrSTUNQuery} - } - u.Proto = ProtoTypeTCP - case u.Scheme == SchemeTypeTURN: - proto, err := parseProto(rawParts.RawQuery) - if err != nil { - return nil, err - } - - u.Proto = proto - if u.Proto == ProtoType(Unknown) { - u.Proto = ProtoTypeUDP - } - case u.Scheme == SchemeTypeTURNS: - proto, err := parseProto(rawParts.RawQuery) - if err != nil { - return nil, err - } - - u.Proto = proto - if u.Proto == ProtoType(Unknown) { - u.Proto = ProtoTypeTCP - } - } - - return &u, nil -} - -func parseProto(raw string) (ProtoType, error) { - qArgs, err := url.ParseQuery(raw) - if err != nil || len(qArgs) > 1 { - return ProtoType(Unknown), &rtcerr.SyntaxError{Err: ErrInvalidQuery} - } - - var proto ProtoType - if rawProto := qArgs.Get("transport"); rawProto != "" { - if proto = NewProtoType(rawProto); proto == ProtoType(0) { - return ProtoType(Unknown), &rtcerr.NotSupportedError{Err: ErrProtoType} - } - return proto, nil - } - - if len(qArgs) > 0 { - return ProtoType(Unknown), &rtcerr.SyntaxError{Err: ErrInvalidQuery} - } - - return proto, nil -} - -func (u URL) String() string { - rawURL := u.Scheme.String() + ":" + net.JoinHostPort(u.Host, strconv.Itoa(u.Port)) - if u.Scheme == SchemeTypeTURN || u.Scheme == SchemeTypeTURNS { - rawURL += "?transport=" + u.Proto.String() - } - return rawURL -} - -// IsSecure returns whether the this URL's scheme describes secure scheme or not. -func (u URL) IsSecure() bool { - return u.Scheme == SchemeTypeSTUNS || u.Scheme == SchemeTypeTURNS -} diff --git a/vendor/github.com/pions/webrtc/pkg/ice/util.go b/vendor/github.com/pions/webrtc/pkg/ice/util.go deleted file mode 100644 index 886f17f..0000000 --- a/vendor/github.com/pions/webrtc/pkg/ice/util.go +++ /dev/null @@ -1,50 +0,0 @@ -package ice - -import ( - "net" - "sync/atomic" -) - -func localInterfaces() (ips []net.IP) { - ifaces, err := net.Interfaces() - if err != nil { - return ips - } - - for _, iface := range ifaces { - if iface.Flags&net.FlagUp == 0 { - continue // interface down - } - if iface.Flags&net.FlagLoopback != 0 { - continue // loopback interface - } - addrs, err := iface.Addrs() - if err != nil { - return ips - } - for _, addr := range addrs { - var ip net.IP - switch v := addr.(type) { - case *net.IPNet: - ip = v.IP - case *net.IPAddr: - ip = v.IP - } - if ip == nil || ip.IsLoopback() { - continue - } - ips = append(ips, ip) - } - } - return ips -} - -type atomicError struct{ v atomic.Value } - -func (a *atomicError) Store(err error) { - a.v.Store(struct{ error }{err}) -} -func (a *atomicError) Load() error { - err, _ := a.v.Load().(struct{ error }) - return err.error -} diff --git a/vendor/github.com/pions/webrtc/pkg/media/media.go b/vendor/github.com/pions/webrtc/pkg/media/media.go deleted file mode 100644 index 1237623..0000000 --- a/vendor/github.com/pions/webrtc/pkg/media/media.go +++ /dev/null @@ -1,7 +0,0 @@ -package media - -// RTCSample contains media, and the amount of samples in it -type RTCSample struct { - Data []byte - Samples uint32 -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcerr/errors.go b/vendor/github.com/pions/webrtc/pkg/rtcerr/errors.go deleted file mode 100644 index 61e5656..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcerr/errors.go +++ /dev/null @@ -1,100 +0,0 @@ -// Package rtcerr implements the error wrappers defined throughout the -// WebRTC 1.0 specifications. -package rtcerr - -import ( - "fmt" -) - -// UnknownError indicates the operation failed for an unknown transient reason. -type UnknownError struct { - Err error -} - -func (e *UnknownError) Error() string { - return fmt.Sprintf("UnknownError: %v", e.Err) -} - -// InvalidStateError indicates the object is in an invalid state. -type InvalidStateError struct { - Err error -} - -func (e *InvalidStateError) Error() string { - return fmt.Sprintf("InvalidStateError: %v", e.Err) -} - -// InvalidAccessError indicates the object does not support the operation or -// argument. -type InvalidAccessError struct { - Err error -} - -func (e *InvalidAccessError) Error() string { - return fmt.Sprintf("InvalidAccessError: %v", e.Err) -} - -// NotSupportedError indicates the operation is not supported. -type NotSupportedError struct { - Err error -} - -func (e *NotSupportedError) Error() string { - return fmt.Sprintf("NotSupportedError: %v", e.Err) -} - -// InvalidModificationError indicates the object cannot be modified in this way. -type InvalidModificationError struct { - Err error -} - -func (e *InvalidModificationError) Error() string { - return fmt.Sprintf("InvalidModificationError: %v", e.Err) -} - -// SyntaxError indicates the string did not match the expected pattern. -type SyntaxError struct { - Err error -} - -func (e *SyntaxError) Error() string { - return fmt.Sprintf("SyntaxError: %v", e.Err) -} - -// TypeError indicates an error when a value is not of the expected type. -type TypeError struct { - Err error -} - -func (e *TypeError) Error() string { - return fmt.Sprintf("TypeError: %v", e.Err) -} - -// OperationError indicates the operation failed for an operation-specific -// reason. -type OperationError struct { - Err error -} - -func (e *OperationError) Error() string { - return fmt.Sprintf("OperationError: %v", e.Err) -} - -// NotReadableError indicates the input/output read operation failed. -type NotReadableError struct { - Err error -} - -func (e *NotReadableError) Error() string { - return fmt.Sprintf("NotReadableError: %v", e.Err) -} - -// RangeError indicates an error when a value is not in the set or range -// of allowed values. -type RangeError struct { - Err error -} - -func (e *RangeError) Error() string { - return fmt.Sprintf("RangeError: %v", e.Err) -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/errors.go b/vendor/github.com/pions/webrtc/pkg/rtcp/errors.go deleted file mode 100644 index 5f8ef29..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/errors.go +++ /dev/null @@ -1,17 +0,0 @@ -package rtcp - -import "errors" - -var ( - errInvalidTotalLost = errors.New("rtcp: invalid total lost count") - errInvalidHeader = errors.New("rtcp: invalid header") - errTooManyReports = errors.New("rtcp: too many reports") - errTooManyChunks = errors.New("rtcp: too many chunks") - errTooManySources = errors.New("rtcp: too many sources") - errPacketTooShort = errors.New("rtcp: packet too short") - errWrongType = errors.New("rtcp: wrong packet type") - errSDESTextTooLong = errors.New("rtcp: sdes must be < 255 octets long") - errSDESMissingType = errors.New("rtcp: sdes item missing type") - errReasonTooLong = errors.New("rtcp: reason must be < 255 octets long") - errBadVersion = errors.New("rtcp: invalid packet version") -) diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/fuzz.go b/vendor/github.com/pions/webrtc/pkg/rtcp/fuzz.go deleted file mode 100644 index d05f41a..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/fuzz.go +++ /dev/null @@ -1,51 +0,0 @@ -// +build gofuzz - -package rtcp - -import ( - "bytes" - "io" -) - -// Fuzz implements a randomized fuzz test of the rtcp -// parser using go-fuzz. -// -// To run the fuzzer, first download go-fuzz: -// `go get github.com/dvyukov/go-fuzz/...` -// -// Then build the testing package: -// `go-fuzz-build github.com/pions/webrtc` -// -// And run the fuzzer on the corpus: -// ``` -// mkdir workdir -// -// # optionally add a starter corpus of valid rtcp packets. -// # the corpus should be as compact and diverse as possible. -// cp -r ~/my-rtcp-packets workdir/corpus -// -// go-fuzz -bin=ase-fuzz.zip -workdir=workdir -// ```` -func Fuzz(data []byte) int { - r := NewReader(bytes.NewReader(data)) - for { - _, data, err := r.ReadPacket() - if err == io.EOF { - break - } - if err != nil { - return 0 - } - - packet, _, err := Unmarshal(data) - if err != nil { - return 0 - } - - if _, err := packet.Marshal(); err != nil { - return 0 - } - } - - return 1 -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/goodbye.go b/vendor/github.com/pions/webrtc/pkg/rtcp/goodbye.go deleted file mode 100644 index b77ec62..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/goodbye.go +++ /dev/null @@ -1,147 +0,0 @@ -package rtcp - -import ( - "encoding/binary" - - "github.com/pions/webrtc/internal/util" -) - -// The Goodbye packet indicates that one or more sources are no longer active. -type Goodbye struct { - // The SSRC/CSRC identifiers that are no longer active - Sources []uint32 - // Optional text indicating the reason for leaving, e.g., "camera malfunction" or "RTP loop detected" - Reason string -} - -// Marshal encodes the Goodbye packet in binary -func (g Goodbye) Marshal() ([]byte, error) { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * |V=2|P| SC | PT=BYE=203 | length | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | SSRC/CSRC | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * : ... : - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * (opt) | length | reason for leaving ... - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - - rawPacket := make([]byte, g.len()) - packetBody := rawPacket[headerLength:] - - if len(g.Sources) > countMax { - return nil, errTooManySources - } - - for i, s := range g.Sources { - binary.BigEndian.PutUint32(packetBody[i*ssrcLength:], s) - } - - if g.Reason != "" { - reason := []byte(g.Reason) - - if len(reason) > sdesMaxOctetCount { - return nil, errReasonTooLong - } - - reasonOffset := len(g.Sources) * ssrcLength - packetBody[reasonOffset] = uint8(len(reason)) - copy(packetBody[reasonOffset+1:], reason) - } - - hData, err := g.Header().Marshal() - if err != nil { - return nil, err - } - copy(rawPacket, hData) - - return rawPacket, nil -} - -// Unmarshal decodes the Goodbye packet from binary -func (g *Goodbye) Unmarshal(rawPacket []byte) error { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * |V=2|P| SC | PT=BYE=203 | length | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | SSRC/CSRC | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * : ... : - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * (opt) | length | reason for leaving ... - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - - var header Header - if err := header.Unmarshal(rawPacket); err != nil { - return err - } - - if header.Type != TypeGoodbye { - return errWrongType - } - - if util.GetPadding(len(rawPacket)) != 0 { - return errPacketTooShort - } - - g.Sources = make([]uint32, header.Count) - - reasonOffset := int(headerLength + header.Count*ssrcLength) - if reasonOffset > len(rawPacket) { - return errPacketTooShort - } - - for i := 0; i < int(header.Count); i++ { - offset := headerLength + i*ssrcLength - - g.Sources[i] = binary.BigEndian.Uint32(rawPacket[offset:]) - } - - if reasonOffset < len(rawPacket) { - reasonLen := int(rawPacket[reasonOffset]) - reasonEnd := reasonOffset + 1 + reasonLen - - if reasonEnd > len(rawPacket) { - return errPacketTooShort - } - - g.Reason = string(rawPacket[reasonOffset+1 : reasonEnd]) - - } - - return nil -} - -// Header returns the Header associated with this packet. -func (g *Goodbye) Header() Header { - return Header{ - Padding: false, - Count: uint8(len(g.Sources)), - Type: TypeGoodbye, - Length: uint16((g.len() / 4) - 1), - } -} - -func (g *Goodbye) len() int { - srcsLength := len(g.Sources) * ssrcLength - reasonLength := len(g.Reason) + 1 - - l := headerLength + srcsLength + reasonLength - - // align to 32-bit boundary - return l + util.GetPadding(l) -} - -// DestinationSSRC returns an array of SSRC values that this packet refers to. -func (g *Goodbye) DestinationSSRC() []uint32 { - out := make([]uint32, len(g.Sources)) - copy(out, g.Sources) - return out -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/header.go b/vendor/github.com/pions/webrtc/pkg/rtcp/header.go deleted file mode 100644 index 08964a6..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/header.go +++ /dev/null @@ -1,135 +0,0 @@ -package rtcp - -import ( - "encoding/binary" -) - -// PacketType specifies the type of an RTCP packet -type PacketType uint8 - -// RTCP packet types registered with IANA. See: https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-4 -const ( - TypeSenderReport PacketType = 200 // RFC 3550, 6.4.1 - TypeReceiverReport PacketType = 201 // RFC 3550, 6.4.2 - TypeSourceDescription PacketType = 202 // RFC 3550, 6.5 - TypeGoodbye PacketType = 203 // RFC 3550, 6.6 - TypeApplicationDefined PacketType = 204 // RFC 3550, 6.7 (unimplemented) - TypeTransportSpecificFeedback PacketType = 205 // RFC 4585, 6051 - TypePayloadSpecificFeedback PacketType = 206 // RFC 4585, 6.3 - -) - -// Transport and Payload specific feedback messages overload the count field to act as a message type. those are listed here -const ( - FormatSLI uint8 = 2 - FormatPLI uint8 = 1 - FormatTLN uint8 = 1 - FormatRRR uint8 = 5 -) - -func (p PacketType) String() string { - switch p { - case TypeSenderReport: - return "SR" - case TypeReceiverReport: - return "RR" - case TypeSourceDescription: - return "SDES" - case TypeGoodbye: - return "BYE" - case TypeApplicationDefined: - return "APP" - case TypeTransportSpecificFeedback: - return "TSFB" - case TypePayloadSpecificFeedback: - return "PSFB" - default: - return string(p) - } -} - -const rtpVersion = 2 - -// A Header is the common header shared by all RTCP packets -type Header struct { - // If the padding bit is set, this individual RTCP packet contains - // some additional padding octets at the end which are not part of - // the control information but are included in the length field. - Padding bool - // The number of reception reports, sources contained or FMT in this packet (depending on the Type) - Count uint8 - // The RTCP packet type for this packet - Type PacketType - // The length of this RTCP packet in 32-bit words minus one, - // including the header and any padding. - Length uint16 -} - -const ( - headerLength = 4 - versionShift = 6 - versionMask = 0x3 - paddingShift = 5 - paddingMask = 0x1 - countShift = 0 - countMask = 0x1f - countMax = (1 << 5) - 1 -) - -// Marshal encodes the Header in binary -func (h Header) Marshal() ([]byte, error) { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * |V=2|P| RC | PT=SR=200 | length | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - rawPacket := make([]byte, headerLength) - - rawPacket[0] |= rtpVersion << versionShift - - if h.Padding { - rawPacket[0] |= 1 << paddingShift - } - - if h.Count > 31 { - return nil, errInvalidHeader - } - rawPacket[0] |= h.Count << countShift - - rawPacket[1] = uint8(h.Type) - - binary.BigEndian.PutUint16(rawPacket[2:], h.Length) - - return rawPacket, nil -} - -// Unmarshal decodes the Header from binary -func (h *Header) Unmarshal(rawPacket []byte) error { - if len(rawPacket) < headerLength { - return errInvalidHeader - } - - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * |V=2|P| RC | PT | length | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - - version := rawPacket[0] >> versionShift & versionMask - if version != rtpVersion { - return errBadVersion - } - - h.Padding = (rawPacket[0] >> paddingShift & paddingMask) > 0 - h.Count = rawPacket[0] >> countShift & countMask - - h.Type = PacketType(rawPacket[1]) - - h.Length = binary.BigEndian.Uint16(rawPacket[2:]) - - return nil -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/packet.go b/vendor/github.com/pions/webrtc/pkg/rtcp/packet.go deleted file mode 100644 index 0c5e1a2..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/packet.go +++ /dev/null @@ -1,62 +0,0 @@ -package rtcp - -// Packet represents an RTCP packet, a protocol used for out-of-band statistics and control information for an RTP session -type Packet interface { - Header() Header - // DestinationSSRC returns an array of SSRC values that this packet refers to. - DestinationSSRC() []uint32 - - Marshal() ([]byte, error) - Unmarshal(rawPacket []byte) error -} - -// Unmarshal is a factory a polymorphic RTCP packet, and its header, -func Unmarshal(rawPacket []byte) (Packet, Header, error) { - var h Header - var p Packet - - err := h.Unmarshal(rawPacket) - if err != nil { - return nil, h, err - } - - switch h.Type { - case TypeSenderReport: - p = new(SenderReport) - - case TypeReceiverReport: - p = new(ReceiverReport) - - case TypeSourceDescription: - p = new(SourceDescription) - - case TypeGoodbye: - p = new(Goodbye) - - case TypeTransportSpecificFeedback: - switch h.Count { - case FormatTLN: - p = new(TransportLayerNack) - case FormatRRR: - p = new(RapidResynchronizationRequest) - default: - p = new(RawPacket) - } - - case TypePayloadSpecificFeedback: - switch h.Count { - case FormatPLI: - p = new(PictureLossIndication) - case FormatSLI: - p = new(SliceLossIndication) - default: - p = new(RawPacket) - } - - default: - p = new(RawPacket) - } - - err = p.Unmarshal(rawPacket) - return p, h, err -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/picture_loss_indication.go b/vendor/github.com/pions/webrtc/pkg/rtcp/picture_loss_indication.go deleted file mode 100644 index 7625e9f..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/picture_loss_indication.go +++ /dev/null @@ -1,87 +0,0 @@ -package rtcp - -import ( - "encoding/binary" - "fmt" -) - -// The PictureLossIndication packet informs the encoder about the loss of an undefined amount of coded video data belonging to one or more pictures -type PictureLossIndication struct { - // SSRC of sender - SenderSSRC uint32 - - // SSRC where the loss was experienced - MediaSSRC uint32 - - header Header -} - -const ( - pliLength = 2 -) - -// Marshal encodes the PictureLossIndication in binary -func (p PictureLossIndication) Marshal() ([]byte, error) { - /* - * PLI does not require parameters. Therefore, the length field MUST be - * 2, and there MUST NOT be any Feedback Control Information. - * - * The semantics of this FB message is independent of the payload type. - */ - rawPacket := make([]byte, p.len()) - packetBody := rawPacket[headerLength:] - - binary.BigEndian.PutUint32(packetBody, p.SenderSSRC) - binary.BigEndian.PutUint32(packetBody[4:], p.MediaSSRC) - - h := Header{ - Count: FormatPLI, - Type: TypePayloadSpecificFeedback, - Length: pliLength, - } - hData, err := h.Marshal() - if err != nil { - return nil, err - } - copy(rawPacket, hData) - - return rawPacket, nil -} - -// Unmarshal decodes the PictureLossIndication from binary -func (p *PictureLossIndication) Unmarshal(rawPacket []byte) error { - if len(rawPacket) < (headerLength + (ssrcLength * 2)) { - return errPacketTooShort - } - - var h Header - if err := h.Unmarshal(rawPacket); err != nil { - return err - } - - if h.Type != TypePayloadSpecificFeedback || h.Count != FormatPLI { - return errWrongType - } - - p.SenderSSRC = binary.BigEndian.Uint32(rawPacket[headerLength:]) - p.MediaSSRC = binary.BigEndian.Uint32(rawPacket[headerLength+ssrcLength:]) - return nil -} - -// Header returns the Header associated with this packet. -func (p *PictureLossIndication) Header() Header { - return p.header -} - -func (p *PictureLossIndication) len() int { - return headerLength + ssrcLength*2 -} - -func (p *PictureLossIndication) String() string { - return fmt.Sprintf("PictureLossIndication %x %x", p.SenderSSRC, p.MediaSSRC) -} - -// DestinationSSRC returns an array of SSRC values that this packet refers to. -func (p *PictureLossIndication) DestinationSSRC() []uint32 { - return []uint32{p.MediaSSRC} -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/rapid_resynchronization_request.go b/vendor/github.com/pions/webrtc/pkg/rtcp/rapid_resynchronization_request.go deleted file mode 100644 index e1aa2e6..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/rapid_resynchronization_request.go +++ /dev/null @@ -1,87 +0,0 @@ -package rtcp - -import ( - "encoding/binary" - "fmt" -) - -// The RapidResynchronizationRequest packet informs the encoder about the loss of an undefined amount of coded video data belonging to one or more pictures -type RapidResynchronizationRequest struct { - // SSRC of sender - SenderSSRC uint32 - - // SSRC of the media source - MediaSSRC uint32 -} - -const ( - rrrLength = 2 - rrrHeaderLength = ssrcLength * 2 - rrrMediaOffset = 4 -) - -// Marshal encodes the RapidResynchronizationRequest in binary -func (p RapidResynchronizationRequest) Marshal() ([]byte, error) { - /* - * RRR does not require parameters. Therefore, the length field MUST be - * 2, and there MUST NOT be any Feedback Control Information. - * - * The semantics of this FB message is independent of the payload type. - */ - rawPacket := make([]byte, p.len()) - packetBody := rawPacket[headerLength:] - - binary.BigEndian.PutUint32(packetBody, p.SenderSSRC) - binary.BigEndian.PutUint32(packetBody[rrrMediaOffset:], p.MediaSSRC) - - hData, err := p.Header().Marshal() - if err != nil { - return nil, err - } - copy(rawPacket, hData) - - return rawPacket, nil -} - -// Unmarshal decodes the RapidResynchronizationRequest from binary -func (p *RapidResynchronizationRequest) Unmarshal(rawPacket []byte) error { - - if len(rawPacket) < (headerLength + (ssrcLength * 2)) { - return errPacketTooShort - } - - var h Header - if err := h.Unmarshal(rawPacket); err != nil { - return err - } - - if h.Type != TypeTransportSpecificFeedback || h.Count != FormatRRR { - return errWrongType - } - - p.SenderSSRC = binary.BigEndian.Uint32(rawPacket[headerLength:]) - p.MediaSSRC = binary.BigEndian.Uint32(rawPacket[headerLength+ssrcLength:]) - return nil -} - -func (p *RapidResynchronizationRequest) len() int { - return headerLength + rrrHeaderLength -} - -// Header returns the Header associated with this packet. -func (p *RapidResynchronizationRequest) Header() Header { - return Header{ - Count: FormatRRR, - Type: TypeTransportSpecificFeedback, - Length: rrrLength, - } -} - -// DestinationSSRC returns an array of SSRC values that this packet refers to. -func (p *RapidResynchronizationRequest) DestinationSSRC() []uint32 { - return []uint32{p.MediaSSRC} -} - -func (p *RapidResynchronizationRequest) String() string { - return fmt.Sprintf("RapidResynchronizationRequest %x %x", p.SenderSSRC, p.MediaSSRC) -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/raw_packet.go b/vendor/github.com/pions/webrtc/pkg/rtcp/raw_packet.go deleted file mode 100644 index 8412ea7..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/raw_packet.go +++ /dev/null @@ -1,39 +0,0 @@ -package rtcp - -// RawPacket represents an unparsed RTCP packet. It's returned by Unmarshal when -// a packet with an unknown type is encountered. -type RawPacket []byte - -// Marshal encodes the packet in binary. -func (r RawPacket) Marshal() ([]byte, error) { - return r, nil -} - -// Unmarshal decodes the packet from binary. -func (r *RawPacket) Unmarshal(b []byte) error { - if len(b) < (headerLength) { - return errPacketTooShort - } - *r = b - - var h Header - if err := h.Unmarshal(b); err != nil { - return err - } - - return nil -} - -// Header returns the Header associated with this packet. -func (r RawPacket) Header() Header { - var h Header - if err := h.Unmarshal(r); err != nil { - return Header{} - } - return h -} - -// DestinationSSRC returns an array of SSRC values that this packet refers to. -func (r *RawPacket) DestinationSSRC() []uint32 { - return []uint32{} -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/reader.go b/vendor/github.com/pions/webrtc/pkg/rtcp/reader.go deleted file mode 100644 index 428d50d..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/reader.go +++ /dev/null @@ -1,41 +0,0 @@ -package rtcp - -import "io" - -// A Reader reads packets from an RTCP combined packet. -type Reader struct { - r io.Reader -} - -// NewReader creates a new Reader reading from r. -func NewReader(r io.Reader) *Reader { - return &Reader{r} -} - -// ReadPacket reads one packet from r. -// -// It returns the parsed packet Header and a byte slice containing the encoded -// packet data (including the header). How the packet data is parsed depends on -// the Type field contained in the Header. -func (r *Reader) ReadPacket() (header Header, data []byte, err error) { - // First grab the header - headerBuf := make([]byte, headerLength) - if _, err := io.ReadFull(r.r, headerBuf); err != nil { - return header, data, err - } - if err := header.Unmarshal(headerBuf); err != nil { - return header, data, err - } - - packetLen := (header.Length + 1) * 4 - - // Then grab the rest - bodyBuf := make([]byte, packetLen-headerLength) - if _, err := io.ReadFull(r.r, bodyBuf); err != nil { - return header, data, err - } - - data = append(headerBuf, bodyBuf...) - - return header, data, nil -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/receiver_report.go b/vendor/github.com/pions/webrtc/pkg/rtcp/receiver_report.go deleted file mode 100644 index 0da6ff6..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/receiver_report.go +++ /dev/null @@ -1,193 +0,0 @@ -package rtcp - -import ( - "encoding/binary" - "fmt" - - "github.com/pions/webrtc/internal/util" -) - -// A ReceiverReport (RR) packet provides reception quality feedback for an RTP stream -type ReceiverReport struct { - // The synchronization source identifier for the originator of this RR packet. - SSRC uint32 - // Zero or more reception report blocks depending on the number of other - // sources heard by this sender since the last report. Each reception report - // block conveys statistics on the reception of RTP packets from a - // single synchronization source. - Reports []ReceptionReport - // extra data from the end of the packet; the application can parse this if needed. - ProfileExtensions []byte -} - -const ( - ssrcLength = 4 - rrSSRCOffset = headerLength - rrReportOffset = rrSSRCOffset + ssrcLength -) - -// Marshal encodes the ReceiverReport in binary -func (r ReceiverReport) Marshal() ([]byte, error) { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * header |V=2|P| RC | PT=RR=201 | length | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | SSRC of packet sender | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * report | SSRC_1 (SSRC of first source) | - * block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * 1 | fraction lost | cumulative number of packets lost | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | extended highest sequence number received | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | interarrival jitter | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | last SR (LSR) | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | delay since last SR (DLSR) | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * report | SSRC_2 (SSRC of second source) | - * block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * 2 : ... : - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * | profile-specific extensions | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - - rawPacket := make([]byte, r.len()) - packetBody := rawPacket[headerLength:] - - binary.BigEndian.PutUint32(packetBody, r.SSRC) - - for i, rp := range r.Reports { - data, err := rp.Marshal() - if err != nil { - return nil, err - } - offset := ssrcLength + receptionReportLength*i - copy(packetBody[offset:], data) - } - - if len(r.Reports) > countMax { - return nil, errTooManyReports - } - - pe := make([]byte, len(r.ProfileExtensions)) - copy(pe, r.ProfileExtensions) - - //if the length of the profile extensions isn't devisible - //by 4, we need to pad the end. - for (len(pe) & 0x3) != 0 { - pe = append(pe, 0) - } - - rawPacket = append(rawPacket, pe...) - - hData, err := r.Header().Marshal() - - if err != nil { - return nil, err - } - copy(rawPacket, hData) - - return rawPacket, nil -} - -// Unmarshal decodes the ReceiverReport from binary -func (r *ReceiverReport) Unmarshal(rawPacket []byte) error { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * header |V=2|P| RC | PT=RR=201 | length | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | SSRC of packet sender | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * report | SSRC_1 (SSRC of first source) | - * block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * 1 | fraction lost | cumulative number of packets lost | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | extended highest sequence number received | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | interarrival jitter | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | last SR (LSR) | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | delay since last SR (DLSR) | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * report | SSRC_2 (SSRC of second source) | - * block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * 2 : ... : - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * | profile-specific extensions | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - - if len(rawPacket) < (headerLength + ssrcLength) { - return errPacketTooShort - } - - var h Header - if err := h.Unmarshal(rawPacket); err != nil { - return err - } - - if h.Type != TypeReceiverReport { - return errWrongType - } - - r.SSRC = binary.BigEndian.Uint32(rawPacket[rrSSRCOffset:]) - - for i := rrReportOffset; i < len(rawPacket) && len(r.Reports) < int(h.Count); i += receptionReportLength { - var rr ReceptionReport - if err := rr.Unmarshal(rawPacket[i:]); err != nil { - return err - } - r.Reports = append(r.Reports, rr) - } - r.ProfileExtensions = rawPacket[rrReportOffset+(len(r.Reports)*receptionReportLength):] - - if uint8(len(r.Reports)) != h.Count { - return errInvalidHeader - } - - return nil -} - -func (r *ReceiverReport) len() int { - repsLength := 0 - for _, rep := range r.Reports { - repsLength += rep.len() - } - return headerLength + ssrcLength + repsLength -} - -// Header returns the Header associated with this packet. -func (r *ReceiverReport) Header() Header { - return Header{ - Count: uint8(len(r.Reports)), - Type: TypeReceiverReport, - Length: uint16((r.len()/4)-1) + uint16(util.GetPadding(len(r.ProfileExtensions))), - } -} - -// DestinationSSRC returns an array of SSRC values that this packet refers to. -func (r *ReceiverReport) DestinationSSRC() []uint32 { - out := make([]uint32, len(r.Reports)) - for i, v := range r.Reports { - out[i] = v.SSRC - } - return out -} - -func (r ReceiverReport) String() string { - out := fmt.Sprintf("ReceiverReport from %x\n", r.SSRC) - out += fmt.Sprintf("\tSSRC \tLost\tLastSequence\n") - for _, i := range r.Reports { - out += fmt.Sprintf("\t%x\t%d/%d\t%d\n", i.SSRC, i.FractionLost, i.TotalLost, i.LastSequenceNumber) - } - out += fmt.Sprintf("\tProfile Extension Data: %v\n", r.ProfileExtensions) - return out -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/reception_report.go b/vendor/github.com/pions/webrtc/pkg/rtcp/reception_report.go deleted file mode 100644 index 96e1403..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/reception_report.go +++ /dev/null @@ -1,130 +0,0 @@ -package rtcp - -import "encoding/binary" - -// A ReceptionReport block conveys statistics on the reception of RTP packets -// from a single synchronization source. -type ReceptionReport struct { - // The SSRC identifier of the source to which the information in this - // reception report block pertains. - SSRC uint32 - // The fraction of RTP data packets from source SSRC lost since the - // previous SR or RR packet was sent, expressed as a fixed point - // number with the binary point at the left edge of the field. - FractionLost uint8 - // The total number of RTP data packets from source SSRC that have - // been lost since the beginning of reception. - TotalLost uint32 - // The low 16 bits contain the highest sequence number received in an - // RTP data packet from source SSRC, and the most significant 16 - // bits extend that sequence number with the corresponding count of - // sequence number cycles. - LastSequenceNumber uint32 - // An estimate of the statistical variance of the RTP data packet - // interarrival time, measured in timestamp units and expressed as an - // unsigned integer. - Jitter uint32 - // The middle 32 bits out of 64 in the NTP timestamp received as part of - // the most recent RTCP sender report (SR) packet from source SSRC. If no - // SR has been received yet, the field is set to zero. - LastSenderReport uint32 - // The delay, expressed in units of 1/65536 seconds, between receiving the - // last SR packet from source SSRC and sending this reception report block. - // If no SR packet has been received yet from SSRC, the field is set to zero. - Delay uint32 -} - -var ( - receptionReportLength = 24 - fractionLostOffset = 4 - totalLostOffset = 5 - lastSeqOffset = 8 - jitterOffset = 12 - lastSROffset = 16 - delayOffset = 20 -) - -// Marshal encodes the ReceptionReport in binary -func (r ReceptionReport) Marshal() ([]byte, error) { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * | SSRC | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | fraction lost | cumulative number of packets lost | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | extended highest sequence number received | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | interarrival jitter | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | last SR (LSR) | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | delay since last SR (DLSR) | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - */ - - rawPacket := make([]byte, receptionReportLength) - - binary.BigEndian.PutUint32(rawPacket, r.SSRC) - - rawPacket[fractionLostOffset] = r.FractionLost - - // pack TotalLost into 24 bits - if r.TotalLost >= (1 << 25) { - return nil, errInvalidTotalLost - } - tlBytes := rawPacket[totalLostOffset:] - tlBytes[0] = byte(r.TotalLost >> 16) - tlBytes[1] = byte(r.TotalLost >> 8) - tlBytes[2] = byte(r.TotalLost) - - binary.BigEndian.PutUint32(rawPacket[lastSeqOffset:], r.LastSequenceNumber) - binary.BigEndian.PutUint32(rawPacket[jitterOffset:], r.Jitter) - binary.BigEndian.PutUint32(rawPacket[lastSROffset:], r.LastSenderReport) - binary.BigEndian.PutUint32(rawPacket[delayOffset:], r.Delay) - - return rawPacket, nil -} - -// Unmarshal decodes the ReceptionReport from binary -func (r *ReceptionReport) Unmarshal(rawPacket []byte) error { - if len(rawPacket) < receptionReportLength { - return errPacketTooShort - } - - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * | SSRC | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | fraction lost | cumulative number of packets lost | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | extended highest sequence number received | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | interarrival jitter | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | last SR (LSR) | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | delay since last SR (DLSR) | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - */ - - r.SSRC = binary.BigEndian.Uint32(rawPacket) - r.FractionLost = rawPacket[fractionLostOffset] - - tlBytes := rawPacket[totalLostOffset:] - r.TotalLost = uint32(tlBytes[2]) | uint32(tlBytes[1])<<8 | uint32(tlBytes[0])<<16 - - r.LastSequenceNumber = binary.BigEndian.Uint32(rawPacket[lastSeqOffset:]) - r.Jitter = binary.BigEndian.Uint32(rawPacket[jitterOffset:]) - r.LastSenderReport = binary.BigEndian.Uint32(rawPacket[lastSROffset:]) - r.Delay = binary.BigEndian.Uint32(rawPacket[delayOffset:]) - - return nil -} - -func (r *ReceptionReport) len() int { - return receptionReportLength -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/sender_report.go b/vendor/github.com/pions/webrtc/pkg/rtcp/sender_report.go deleted file mode 100644 index 2cf51e0..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/sender_report.go +++ /dev/null @@ -1,221 +0,0 @@ -package rtcp - -import "encoding/binary" - -// A SenderReport (SR) packet provides reception quality feedback for an RTP stream -type SenderReport struct { - // The synchronization source identifier for the originator of this SR packet. - SSRC uint32 - // The wallclock time when this report was sent so that it may be used in - // combination with timestamps returned in reception reports from other - // receivers to measure round-trip propagation to those receivers. - NTPTime uint64 - // Corresponds to the same time as the NTP timestamp (above), but in - // the same units and with the same random offset as the RTP - // timestamps in data packets. This correspondence may be used for - // intra- and inter-media synchronization for sources whose NTP - // timestamps are synchronized, and may be used by media-independent - // receivers to estimate the nominal RTP clock frequency. - RTPTime uint32 - // The total number of RTP data packets transmitted by the sender - // since starting transmission up until the time this SR packet was - // generated. - PacketCount uint32 - // The total number of payload octets (i.e., not including header or - // padding) transmitted in RTP data packets by the sender since - // starting transmission up until the time this SR packet was - // generated. - OctetCount uint32 - // Zero or more reception report blocks depending on the number of other - // sources heard by this sender since the last report. Each reception report - // block conveys statistics on the reception of RTP packets from a - // single synchronization source. - Reports []ReceptionReport -} - -var ( - srHeaderLength = 24 - srSSRCOffset = 0 - srNTPOffset = srSSRCOffset + ssrcLength - ntpTimeLength = 8 - srRTPOffset = srNTPOffset + ntpTimeLength - rtpTimeLength = 4 - srPacketCountOffset = srRTPOffset + rtpTimeLength - srPacketCountLength = 4 - srOctetCountOffset = srPacketCountOffset + srPacketCountLength - srOctetCountLength = 4 - srReportOffset = srOctetCountOffset + srOctetCountLength -) - -// Marshal encodes the SenderReport in binary -func (r SenderReport) Marshal() ([]byte, error) { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * header |V=2|P| RC | PT=SR=200 | length | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | SSRC of sender | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * sender | NTP timestamp, most significant word | - * info +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | NTP timestamp, least significant word | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | RTP timestamp | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | sender's packet count | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | sender's octet count | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * report | SSRC_1 (SSRC of first source) | - * block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * 1 | fraction lost | cumulative number of packets lost | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | extended highest sequence number received | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | interarrival jitter | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | last SR (LSR) | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | delay since last SR (DLSR) | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * report | SSRC_2 (SSRC of second source) | - * block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * 2 : ... : - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * | profile-specific extensions | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - - rawPacket := make([]byte, r.len()) - packetBody := rawPacket[headerLength:] - - binary.BigEndian.PutUint32(packetBody[srSSRCOffset:], r.SSRC) - binary.BigEndian.PutUint64(packetBody[srNTPOffset:], r.NTPTime) - binary.BigEndian.PutUint32(packetBody[srRTPOffset:], r.RTPTime) - binary.BigEndian.PutUint32(packetBody[srPacketCountOffset:], r.PacketCount) - binary.BigEndian.PutUint32(packetBody[srOctetCountOffset:], r.OctetCount) - - for i, rp := range r.Reports { - data, err := rp.Marshal() - if err != nil { - return nil, err - } - offset := srHeaderLength + receptionReportLength*i - copy(packetBody[offset:], data) - } - - if len(r.Reports) > countMax { - return nil, errTooManyReports - } - - hData, err := r.Header().Marshal() - if err != nil { - return nil, err - } - copy(rawPacket, hData) - - return rawPacket, nil -} - -// Unmarshal decodes the SenderReport from binary -func (r *SenderReport) Unmarshal(rawPacket []byte) error { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * header |V=2|P| RC | PT=SR=200 | length | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | SSRC of sender | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * sender | NTP timestamp, most significant word | - * info +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | NTP timestamp, least significant word | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | RTP timestamp | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | sender's packet count | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | sender's octet count | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * report | SSRC_1 (SSRC of first source) | - * block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * 1 | fraction lost | cumulative number of packets lost | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | extended highest sequence number received | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | interarrival jitter | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | last SR (LSR) | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | delay since last SR (DLSR) | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * report | SSRC_2 (SSRC of second source) | - * block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * 2 : ... : - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * | profile-specific extensions | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - - if len(rawPacket) < (headerLength + srHeaderLength) { - return errPacketTooShort - } - - var h Header - if err := h.Unmarshal(rawPacket); err != nil { - return err - } - - if h.Type != TypeSenderReport { - return errWrongType - } - - packetBody := rawPacket[headerLength:] - - r.SSRC = binary.BigEndian.Uint32(packetBody[srSSRCOffset:]) - r.NTPTime = binary.BigEndian.Uint64(packetBody[srNTPOffset:]) - r.RTPTime = binary.BigEndian.Uint32(packetBody[srRTPOffset:]) - r.PacketCount = binary.BigEndian.Uint32(packetBody[srPacketCountOffset:]) - r.OctetCount = binary.BigEndian.Uint32(packetBody[srOctetCountOffset:]) - - for i := srReportOffset; i < len(packetBody); i += receptionReportLength { - var rr ReceptionReport - if err := rr.Unmarshal(packetBody[i:]); err != nil { - return err - } - r.Reports = append(r.Reports, rr) - } - - if uint8(len(r.Reports)) != h.Count { - return errInvalidHeader - } - - return nil -} - -// DestinationSSRC returns an array of SSRC values that this packet refers to. -func (r *SenderReport) DestinationSSRC() []uint32 { - out := make([]uint32, len(r.Reports)) - for i, v := range r.Reports { - out[i] = v.SSRC - } - return out -} - -func (r *SenderReport) len() int { - repsLength := 0 - for _, rep := range r.Reports { - repsLength += rep.len() - } - return headerLength + srHeaderLength + repsLength -} - -// Header returns the Header associated with this packet. -func (r *SenderReport) Header() Header { - return Header{ - Count: uint8(len(r.Reports)), - Type: TypeSenderReport, - Length: uint16((r.len() / 4) - 1), - } -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/slice_loss_indication.go b/vendor/github.com/pions/webrtc/pkg/rtcp/slice_loss_indication.go deleted file mode 100644 index c6b6346..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/slice_loss_indication.go +++ /dev/null @@ -1,113 +0,0 @@ -package rtcp - -import ( - "encoding/binary" - "fmt" - "math" -) - -// SLIEntry represents a single entry to the SLI packet's -// list of lost slices. -type SLIEntry struct { - // ID of first lost slice - First uint16 - - // Number of lost slices - Number uint16 - - // ID of related picture - Picture uint8 -} - -// The SliceLossIndication packet informs the encoder about the loss of a picture slice -type SliceLossIndication struct { - // SSRC of sender - SenderSSRC uint32 - - // SSRC of the media source - MediaSSRC uint32 - - SLI []SLIEntry -} - -const ( - sliLength = 2 - sliOffset = 8 -) - -// Marshal encodes the SliceLossIndication in binary -func (p SliceLossIndication) Marshal() ([]byte, error) { - - if len(p.SLI)+sliLength > math.MaxUint8 { - return nil, errTooManyReports - } - - rawPacket := make([]byte, sliOffset+(len(p.SLI)*4)) - binary.BigEndian.PutUint32(rawPacket, p.SenderSSRC) - binary.BigEndian.PutUint32(rawPacket[4:], p.MediaSSRC) - for i, s := range p.SLI { - sli := ((uint32(s.First) & 0x1FFF) << 19) | - ((uint32(s.Number) & 0x1FFF) << 6) | - (uint32(s.Picture) & 0x3F) - binary.BigEndian.PutUint32(rawPacket[sliOffset+(4*i):], sli) - } - hData, err := p.Header().Marshal() - if err != nil { - return nil, err - } - - return append(hData, rawPacket...), nil -} - -// Unmarshal decodes the SliceLossIndication from binary -func (p *SliceLossIndication) Unmarshal(rawPacket []byte) error { - if len(rawPacket) < (headerLength + ssrcLength) { - return errPacketTooShort - } - - var h Header - if err := h.Unmarshal(rawPacket); err != nil { - return err - } - - if len(rawPacket) < (headerLength + int(4*h.Length)) { - return errPacketTooShort - } - - if h.Type != TypeTransportSpecificFeedback || h.Count != FormatSLI { - return errWrongType - } - - p.SenderSSRC = binary.BigEndian.Uint32(rawPacket[headerLength:]) - p.MediaSSRC = binary.BigEndian.Uint32(rawPacket[headerLength+ssrcLength:]) - for i := headerLength + sliOffset; i < (headerLength + int(h.Length*4)); i += 4 { - sli := binary.BigEndian.Uint32(rawPacket[i:]) - p.SLI = append(p.SLI, SLIEntry{ - uint16((sli >> 19) & 0x1FFF), - uint16((sli >> 6) & 0x1FFF), - uint8(sli & 0x3F)}) - } - return nil -} - -func (p *SliceLossIndication) len() int { - return headerLength + sliOffset + (len(p.SLI) * 4) -} - -// Header returns the Header associated with this packet. -func (p *SliceLossIndication) Header() Header { - return Header{ - Count: FormatSLI, - Type: TypeTransportSpecificFeedback, - Length: uint16((p.len() / 4) - 1), - } -} - -func (p *SliceLossIndication) String() string { - return fmt.Sprintf("SliceLossIndication %x %x %+v", p.SenderSSRC, p.MediaSSRC, p.SLI) -} - -// DestinationSSRC returns an array of SSRC values that this packet refers to. -func (p *SliceLossIndication) DestinationSSRC() []uint32 { - return []uint32{p.MediaSSRC} -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/source_description.go b/vendor/github.com/pions/webrtc/pkg/rtcp/source_description.go deleted file mode 100644 index 3217b12..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/source_description.go +++ /dev/null @@ -1,343 +0,0 @@ -package rtcp - -import ( - "encoding/binary" - - "github.com/pions/webrtc/internal/util" -) - -// SDESType is the item type used in the RTCP SDES control packet. -type SDESType uint8 - -// RTP SDES item types registered with IANA. See: https://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-5 -const ( - SDESEnd SDESType = iota // end of SDES list RFC 3550, 6.5 - SDESCNAME // canonical name RFC 3550, 6.5.1 - SDESName // user name RFC 3550, 6.5.2 - SDESEmail // user's electronic mail address RFC 3550, 6.5.3 - SDESPhone // user's phone number RFC 3550, 6.5.4 - SDESLocation // geographic user location RFC 3550, 6.5.5 - SDESTool // name of application or tool RFC 3550, 6.5.6 - SDESNote // notice about the source RFC 3550, 6.5.7 - SDESPrivate // private extensions RFC 3550, 6.5.8 (not implemented) -) - -func (s SDESType) String() string { - switch s { - case SDESEnd: - return "END" - case SDESCNAME: - return "CNAME" - case SDESName: - return "NAME" - case SDESEmail: - return "EMAIL" - case SDESPhone: - return "PHONE" - case SDESLocation: - return "LOC" - case SDESTool: - return "TOOL" - case SDESNote: - return "NOTE" - case SDESPrivate: - return "PRIV" - default: - return string(s) - } -} - -const ( - sdesSourceLen = 4 - sdesTypeLen = 1 - sdesTypeOffset = 0 - sdesOctetCountLen = 1 - sdesOctetCountOffset = 1 - sdesMaxOctetCount = (1 << 8) - 1 - sdesTextOffset = 2 -) - -// A SourceDescription (SDES) packet describes the sources in an RTP stream. -type SourceDescription struct { - Chunks []SourceDescriptionChunk -} - -// Marshal encodes the SourceDescription in binary -func (s SourceDescription) Marshal() ([]byte, error) { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * header |V=2|P| SC | PT=SDES=202 | length | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * chunk | SSRC/CSRC_1 | - * 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | SDES items | - * | ... | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * chunk | SSRC/CSRC_2 | - * 2 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | SDES items | - * | ... | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - */ - - rawPacket := make([]byte, s.len()) - packetBody := rawPacket[headerLength:] - - chunkOffset := 0 - for _, c := range s.Chunks { - data, err := c.Marshal() - if err != nil { - return nil, err - } - copy(packetBody[chunkOffset:], data) - chunkOffset += len(data) - } - - if len(s.Chunks) > countMax { - return nil, errTooManyChunks - } - - hData, err := s.Header().Marshal() - if err != nil { - return nil, err - } - copy(rawPacket, hData) - - return rawPacket, nil -} - -// Unmarshal decodes the SourceDescription from binary -func (s *SourceDescription) Unmarshal(rawPacket []byte) error { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * header |V=2|P| SC | PT=SDES=202 | length | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * chunk | SSRC/CSRC_1 | - * 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | SDES items | - * | ... | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * chunk | SSRC/CSRC_2 | - * 2 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | SDES items | - * | ... | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - */ - - var h Header - if err := h.Unmarshal(rawPacket); err != nil { - return err - } - - if h.Type != TypeSourceDescription { - return errWrongType - } - - for i := headerLength; i < len(rawPacket); { - var chunk SourceDescriptionChunk - if err := chunk.Unmarshal(rawPacket[i:]); err != nil { - return err - } - s.Chunks = append(s.Chunks, chunk) - - i += chunk.len() - } - - if len(s.Chunks) != int(h.Count) { - return errInvalidHeader - } - - return nil -} - -func (s *SourceDescription) len() int { - chunksLength := 0 - for _, c := range s.Chunks { - chunksLength += c.len() - } - return headerLength + chunksLength -} - -// Header returns the Header associated with this packet. -func (s *SourceDescription) Header() Header { - return Header{ - Count: uint8(len(s.Chunks)), - Type: TypeSourceDescription, - Length: uint16((s.len() / 4) - 1), - } -} - -// A SourceDescriptionChunk contains items describing a single RTP source -type SourceDescriptionChunk struct { - // The source (ssrc) or contributing source (csrc) identifier this packet describes - Source uint32 - Items []SourceDescriptionItem -} - -// Marshal encodes the SourceDescriptionChunk in binary -func (s SourceDescriptionChunk) Marshal() ([]byte, error) { - /* - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * | SSRC/CSRC_1 | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | SDES items | - * | ... | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - */ - - rawPacket := make([]byte, sdesSourceLen) - binary.BigEndian.PutUint32(rawPacket, s.Source) - - for _, it := range s.Items { - data, err := it.Marshal() - if err != nil { - return nil, err - } - rawPacket = append(rawPacket, data...) - } - - // The list of items in each chunk MUST be terminated by one or more null octets - rawPacket = append(rawPacket, uint8(SDESEnd)) - - // additional null octets MUST be included if needed to pad until the next 32-bit boundary - rawPacket = append(rawPacket, make([]byte, util.GetPadding(len(rawPacket)))...) - - return rawPacket, nil -} - -// Unmarshal decodes the SourceDescriptionChunk from binary -func (s *SourceDescriptionChunk) Unmarshal(rawPacket []byte) error { - /* - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * | SSRC/CSRC_1 | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | SDES items | - * | ... | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - */ - - if len(rawPacket) < (sdesSourceLen + sdesTypeLen) { - return errPacketTooShort - } - - s.Source = binary.BigEndian.Uint32(rawPacket) - - for i := 4; i < len(rawPacket); { - if pktType := SDESType(rawPacket[i]); pktType == SDESEnd { - return nil - } - - var it SourceDescriptionItem - if err := it.Unmarshal(rawPacket[i:]); err != nil { - return err - } - s.Items = append(s.Items, it) - i += it.len() - } - - return errPacketTooShort -} - -func (s SourceDescriptionChunk) len() int { - len := sdesSourceLen - for _, it := range s.Items { - len += it.len() - } - len += sdesTypeLen // for terminating null octet - - // align to 32-bit boundary - len += util.GetPadding(len) - - return len -} - -// A SourceDescriptionItem is a part of a SourceDescription that describes a stream. -type SourceDescriptionItem struct { - // The type identifier for this item. eg, SDESCNAME for canonical name description. - // - // Type zero or SDESEnd is interpreted as the end of an item list and cannot be used. - Type SDESType - // Text is a unicode text blob associated with the item. Its meaning varies based on the item's Type. - Text string -} - -func (s SourceDescriptionItem) len() int { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | CNAME=1 | length | user and domain name ... - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - return sdesTypeLen + sdesOctetCountLen + len([]byte(s.Text)) -} - -// Marshal encodes the SourceDescriptionItem in binary -func (s SourceDescriptionItem) Marshal() ([]byte, error) { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | CNAME=1 | length | user and domain name ... - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - - if s.Type == SDESEnd { - return nil, errSDESMissingType - } - - rawPacket := make([]byte, sdesTypeLen+sdesOctetCountLen) - - rawPacket[sdesTypeOffset] = uint8(s.Type) - - txtBytes := []byte(s.Text) - octetCount := len(txtBytes) - if octetCount > sdesMaxOctetCount { - return nil, errSDESTextTooLong - } - rawPacket[sdesOctetCountOffset] = uint8(octetCount) - - rawPacket = append(rawPacket, txtBytes...) - - return rawPacket, nil -} - -// Unmarshal decodes the SourceDescriptionItem from binary -func (s *SourceDescriptionItem) Unmarshal(rawPacket []byte) error { - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | CNAME=1 | length | user and domain name ... - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - - if len(rawPacket) < (sdesTypeLen + sdesOctetCountLen) { - return errPacketTooShort - } - - s.Type = SDESType(rawPacket[sdesTypeOffset]) - - octetCount := int(rawPacket[sdesOctetCountOffset]) - if sdesTextOffset+octetCount > len(rawPacket) { - return errPacketTooShort - } - - txtBytes := rawPacket[sdesTextOffset : sdesTextOffset+octetCount] - s.Text = string(txtBytes) - - return nil -} - -// DestinationSSRC returns an array of SSRC values that this packet refers to. -func (s *SourceDescription) DestinationSSRC() []uint32 { - out := make([]uint32, len(s.Chunks)) - for i, v := range s.Chunks { - out[i] = v.Source - } - return out -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtcp/transport_layer_nack.go b/vendor/github.com/pions/webrtc/pkg/rtcp/transport_layer_nack.go deleted file mode 100644 index 68b2689..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtcp/transport_layer_nack.go +++ /dev/null @@ -1,134 +0,0 @@ -package rtcp - -import ( - "encoding/binary" - "fmt" - "math" -) - -// PacketBitmap shouldn't be used like a normal integral, -// so it's type is masked here. Access it with PacketList(). -type PacketBitmap uint16 - -// NackPair is a wire-representation of a collection of -// Lost RTP packets -type NackPair struct { - // ID of lost packets - PacketID uint16 - - // Bitmask of following lost packets - LostPackets PacketBitmap -} - -// The TransportLayerNack packet informs the encoder about the loss of a transport packet -// IETF RFC 4585, Section 6.2.1 -// https://tools.ietf.org/html/rfc4585#section-6.2.1 -type TransportLayerNack struct { - // SSRC of sender - SenderSSRC uint32 - - // SSRC of the media source - MediaSSRC uint32 - - Nacks []NackPair -} - -// PacketList returns a list of Nack'd packets that's referenced by a NackPair -func (n *NackPair) PacketList() []uint16 { - out := make([]uint16, 1, 17) - out[0] = n.PacketID - b := n.LostPackets - for i := uint16(0); b != 0; i++ { - if (b & (1 << i)) != 0 { - b &^= (1 << i) - out = append(out, n.PacketID+i+1) - } - } - return out -} - -const ( - tlnLength = 2 - nackOffset = 8 -) - -// Marshal encodes the TransportLayerNack in binary -func (p TransportLayerNack) Marshal() ([]byte, error) { - - if len(p.Nacks)+tlnLength > math.MaxUint8 { - return nil, errTooManyReports - } - - rawPacket := make([]byte, nackOffset+(len(p.Nacks)*4)) - binary.BigEndian.PutUint32(rawPacket, p.SenderSSRC) - binary.BigEndian.PutUint32(rawPacket[4:], p.MediaSSRC) - for i := 0; i < len(p.Nacks); i++ { - binary.BigEndian.PutUint16(rawPacket[nackOffset+(4*i):], p.Nacks[i].PacketID) - binary.BigEndian.PutUint16(rawPacket[nackOffset+(4*i)+2:], uint16(p.Nacks[i].LostPackets)) - } - h := p.Header() - hData, err := h.Marshal() - if err != nil { - return nil, err - } - - return append(hData, rawPacket...), nil -} - -// Unmarshal decodes the TransportLayerNack from binary -func (p *TransportLayerNack) Unmarshal(rawPacket []byte) error { - if len(rawPacket) < (headerLength + ssrcLength) { - return errPacketTooShort - } - - var h Header - if err := h.Unmarshal(rawPacket); err != nil { - return err - } - - if len(rawPacket) < (headerLength + int(4*h.Length)) { - return errPacketTooShort - } - - if h.Type != TypeTransportSpecificFeedback || h.Count != FormatTLN { - return errWrongType - } - - p.SenderSSRC = binary.BigEndian.Uint32(rawPacket[headerLength:]) - p.MediaSSRC = binary.BigEndian.Uint32(rawPacket[headerLength+ssrcLength:]) - for i := headerLength + nackOffset; i < (headerLength + int(h.Length*4)); i += 4 { - p.Nacks = append(p.Nacks, NackPair{ - binary.BigEndian.Uint16(rawPacket[i:]), - PacketBitmap(binary.BigEndian.Uint16(rawPacket[i+2:])), - }) - } - return nil -} - -func (p *TransportLayerNack) len() int { - return headerLength + nackOffset + (len(p.Nacks) * 4) -} - -// Header returns the Header associated with this packet. -func (p *TransportLayerNack) Header() Header { - return Header{ - Count: FormatTLN, - Type: TypeTransportSpecificFeedback, - Length: uint16((p.len() / 4) - 1), - } -} - -func (p *TransportLayerNack) String() string { - o := "Packets Lost:\n" - for _, n := range p.Nacks { - for _, m := range n.PacketList() { - o += fmt.Sprintf("\t%d\n", m) - } - } - return o -} - -// DestinationSSRC returns an array of SSRC values that this packet refers to. -func (p *TransportLayerNack) DestinationSSRC() []uint32 { - return []uint32{p.MediaSSRC} -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtp/codecs/common.go b/vendor/github.com/pions/webrtc/pkg/rtp/codecs/common.go deleted file mode 100644 index 39336d2..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtp/codecs/common.go +++ /dev/null @@ -1,8 +0,0 @@ -package codecs - -func min(a, b int) int { - if a < b { - return a - } - return b -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtp/codecs/g722_packet.go b/vendor/github.com/pions/webrtc/pkg/rtp/codecs/g722_packet.go deleted file mode 100644 index 3771cdd..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtp/codecs/g722_packet.go +++ /dev/null @@ -1,18 +0,0 @@ -package codecs - -// G722Payloader payloads G722 packets -type G722Payloader struct{} - -// Payload fragments an G722 packet across one or more byte arrays -func (p *G722Payloader) Payload(mtu int, payload []byte) [][]byte { - var out [][]byte - for len(payload) > mtu { - o := make([]byte, mtu) - copy(o, payload[:mtu]) - payload = payload[mtu:] - out = append(out, o) - } - o := make([]byte, len(payload)) - copy(o, payload) - return append(out, o) -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtp/codecs/h264_packet.go b/vendor/github.com/pions/webrtc/pkg/rtp/codecs/h264_packet.go deleted file mode 100644 index 3343a57..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtp/codecs/h264_packet.go +++ /dev/null @@ -1,123 +0,0 @@ -package codecs - -// H264Payloader payloads H264 packets -type H264Payloader struct{} - -const ( - fuaHeaderSize = 2 -) - -func emitNalus(nals []byte, emit func([]byte)) { - nextInd := func(nalu []byte, start int) (indStart int, indLen int) { - zeroCount := 0 - - for i, b := range nalu[start:] { - if b == 0 { - zeroCount++ - continue - } else if b == 1 { - if zeroCount >= 2 { - return start + i - zeroCount, zeroCount + 1 - } - } - zeroCount = 0 - } - return -1, -1 - } - - nextIndStart, nextIndLen := nextInd(nals, 0) - if nextIndStart == -1 { - emit(nals) - } else { - for nextIndStart != -1 { - prevStart := nextIndStart + nextIndLen - nextIndStart, nextIndLen = nextInd(nals, prevStart) - if nextIndStart != -1 { - emit(nals[prevStart:nextIndStart]) - } else { - // Emit until end of stream, no end indicator found - emit(nals[prevStart:]) - } - } - } -} - -// Payload fragments a H264 packet across one or more byte arrays -func (p *H264Payloader) Payload(mtu int, payload []byte) [][]byte { - - var payloads [][]byte - - emitNalus(payload, func(nalu []byte) { - naluType := nalu[0] & 0x1F - naluRefIdc := nalu[0] & 0x60 - - if naluType == 9 || naluType == 12 { - return - } - - // Single NALU - if len(nalu) <= mtu { - out := make([]byte, len(nalu)) - copy(out, nalu) - payloads = append(payloads, out) - return - } - - // FU-A - maxFragmentSize := mtu - fuaHeaderSize - - // The FU payload consists of fragments of the payload of the fragmented - // NAL unit so that if the fragmentation unit payloads of consecutive - // FUs are sequentially concatenated, the payload of the fragmented NAL - // unit can be reconstructed. The NAL unit type octet of the fragmented - // NAL unit is not included as such in the fragmentation unit payload, - // but rather the information of the NAL unit type octet of the - // fragmented NAL unit is conveyed in the F and NRI fields of the FU - // indicator octet of the fragmentation unit and in the type field of - // the FU header. An FU payload MAY have any number of octets and MAY - // be empty. - - naluData := nalu - // According to the RFC, the first octet is skipped due to redundant information - naluDataIndex := 1 - naluDataLength := len(nalu) - naluDataIndex - naluDataRemaining := naluDataLength - - for naluDataRemaining > 0 { - currentFragmentSize := min(maxFragmentSize, naluDataRemaining) - out := make([]byte, fuaHeaderSize+currentFragmentSize) - - // +---------------+ - // |0|1|2|3|4|5|6|7| - // +-+-+-+-+-+-+-+-+ - // |F|NRI| Type | - // +---------------+ - out[0] = 28 - out[0] |= naluRefIdc - - // +---------------+ - //|0|1|2|3|4|5|6|7| - //+-+-+-+-+-+-+-+-+ - //|S|E|R| Type | - //+---------------+ - - out[1] = naluType - if naluDataRemaining == naluDataLength { - // Set start bit - out[1] |= 1 << 7 - } else if naluDataRemaining-currentFragmentSize == 0 { - // Set end bit - out[1] |= 1 << 6 - } - - copy(out[fuaHeaderSize:], naluData[naluDataIndex:naluDataIndex+currentFragmentSize]) - payloads = append(payloads, out) - - naluDataRemaining -= currentFragmentSize - naluDataIndex += currentFragmentSize - } - - }) - - return payloads -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtp/codecs/opus_packet.go b/vendor/github.com/pions/webrtc/pkg/rtp/codecs/opus_packet.go deleted file mode 100644 index 2049a4c..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtp/codecs/opus_packet.go +++ /dev/null @@ -1,24 +0,0 @@ -package codecs - -import "github.com/pions/webrtc/pkg/rtp" - -// OpusPayloader payloads Opus packets -type OpusPayloader struct{} - -// Payload fragments an Opus packet across one or more byte arrays -func (p *OpusPayloader) Payload(mtu int, payload []byte) [][]byte { - out := make([]byte, len(payload)) - copy(out, payload) - return [][]byte{out} -} - -// OpusPacket represents the VP8 header that is stored in the payload of an RTP Packet -type OpusPacket struct { - Payload []byte -} - -// Unmarshal parses the passed byte slice and stores the result in the OpusPacket this method is called upon -func (p *OpusPacket) Unmarshal(packet *rtp.Packet) ([]byte, error) { - p.Payload = packet.Payload - return p.Payload, nil -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtp/codecs/vp8_packet.go b/vendor/github.com/pions/webrtc/pkg/rtp/codecs/vp8_packet.go deleted file mode 100644 index ab21550..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtp/codecs/vp8_packet.go +++ /dev/null @@ -1,117 +0,0 @@ -package codecs - -import "github.com/pions/webrtc/pkg/rtp" - -// VP8Payloader payloads VP8 packets -type VP8Payloader struct{} - -const ( - vp8HeaderSize = 1 -) - -// Payload fragments a VP8 packet across one or more byte arrays -func (p *VP8Payloader) Payload(mtu int, payload []byte) [][]byte { - - /* - * https://tools.ietf.org/html/rfc7741#section-4.2 - * - * 0 1 2 3 4 5 6 7 - * +-+-+-+-+-+-+-+-+ - * |X|R|N|S|R| PID | (REQUIRED) - * +-+-+-+-+-+-+-+-+ - * X: |I|L|T|K| RSV | (OPTIONAL) - * +-+-+-+-+-+-+-+-+ - * I: |M| PictureID | (OPTIONAL) - * +-+-+-+-+-+-+-+-+ - * L: | TL0PICIDX | (OPTIONAL) - * +-+-+-+-+-+-+-+-+ - * T/K: |TID|Y| KEYIDX | (OPTIONAL) - * +-+-+-+-+-+-+-+-+ - * S: Start of VP8 partition. SHOULD be set to 1 when the first payload - * octet of the RTP packet is the beginning of a new VP8 partition, - * and MUST NOT be 1 otherwise. The S bit MUST be set to 1 for the - * first packet of each encoded frame. - */ - - maxFragmentSize := mtu - vp8HeaderSize - - payloadData := payload - payloadDataRemaining := len(payload) - payloadDataIndex := 0 - var payloads [][]byte - for payloadDataRemaining > 0 { - currentFragmentSize := min(maxFragmentSize, payloadDataRemaining) - out := make([]byte, vp8HeaderSize+currentFragmentSize) - if payloadDataRemaining == len(payload) { - out[0] = 0x10 - } - - copy(out[vp8HeaderSize:], payloadData[payloadDataIndex:payloadDataIndex+currentFragmentSize]) - payloads = append(payloads, out) - - payloadDataRemaining -= currentFragmentSize - payloadDataIndex += currentFragmentSize - } - - return payloads -} - -// VP8Packet represents the VP8 header that is stored in the payload of an RTP Packet -type VP8Packet struct { - // Required Header - X uint8 /* extended controlbits present */ - N uint8 /* (non-reference frame) when set to 1 this frame can be discarded */ - S uint8 /* start of VP8 partition */ - PID uint8 /* partition index */ - - // Optional Header - I uint8 /* 1 if PictureID is present */ - L uint8 /* 1 if TL0PICIDX is present */ - T uint8 /* 1 if TID is present */ - K uint8 /* 1 if KEYIDX is present */ - PictureID uint16 /* 8 or 16 bits, picture ID */ - TL0PICIDX uint8 /* 8 bits temporal level zero index */ - - Payload []byte -} - -// Unmarshal parses the passed byte slice and stores the result in the VP8Packet this method is called upon -func (p *VP8Packet) Unmarshal(packet *rtp.Packet) ([]byte, error) { - payload := packet.Payload - - payloadIndex := 0 - - p.X = (payload[payloadIndex] & 0x80) >> 7 - p.N = (payload[payloadIndex] & 0x20) >> 5 - p.S = (payload[payloadIndex] & 0x10) >> 4 - p.PID = payload[payloadIndex] & 0x07 - - payloadIndex++ - - if p.X == 1 { - p.I = (payload[payloadIndex] & 0x80) >> 7 - p.L = (payload[payloadIndex] & 0x40) >> 6 - p.T = (payload[payloadIndex] & 0x20) >> 5 - p.K = (payload[payloadIndex] & 0x10) >> 4 - payloadIndex++ - } - - if p.I == 1 { // PID present? - if payload[payloadIndex]&0x80 > 0 { // M == 1, PID is 16bit - payloadIndex += 2 - } else { - payloadIndex++ - } - } - - if p.L == 1 { - payloadIndex++ - } - - if p.T == 1 || p.K == 1 { - payloadIndex++ - } - - p.Payload = payload[payloadIndex:] - return p.Payload, nil -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtp/depacketizer.go b/vendor/github.com/pions/webrtc/pkg/rtp/depacketizer.go deleted file mode 100644 index b66fde4..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtp/depacketizer.go +++ /dev/null @@ -1,6 +0,0 @@ -package rtp - -// Depacketizer depacketizes a RTP payload, removing any RTP specific data from the payload -type Depacketizer interface { - Unmarshal(packet *Packet) ([]byte, error) -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtp/packet.go b/vendor/github.com/pions/webrtc/pkg/rtp/packet.go deleted file mode 100644 index b1419a5..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtp/packet.go +++ /dev/null @@ -1,200 +0,0 @@ -package rtp - -import ( - "encoding/binary" - "fmt" - - "github.com/pkg/errors" -) - -// Packet represents an RTP Packet -// RTP is a network protocol for delivering audio and video over IP networks. -type Packet struct { - Raw []byte - Version uint8 - Padding bool - Extension bool - Marker bool - PayloadOffset int - PayloadType uint8 - SequenceNumber uint16 - Timestamp uint32 - SSRC uint32 - CSRC []uint32 - ExtensionProfile uint16 - ExtensionPayload []byte - Payload []byte -} - -const ( - headerLength = 4 - versionShift = 6 - versionMask = 0x3 - paddingShift = 5 - paddingMask = 0x1 - extensionShift = 4 - extensionMask = 0x1 - ccMask = 0xF - markerShift = 7 - markerMask = 0x1 - ptMask = 0x7F - seqNumOffset = 2 - seqNumLength = 2 - timestampOffset = 4 - timestampLength = 4 - ssrcOffset = 8 - ssrcLength = 4 - csrcOffset = 12 - csrcLength = 4 -) - -// String helps with debugging by printing packet information in a readable way -func (p Packet) String() string { - out := "RTP PACKET:\n" - - out += fmt.Sprintf("\tVersion: %v\n", p.Version) - out += fmt.Sprintf("\tMarker: %v\n", p.Marker) - out += fmt.Sprintf("\tPayload Type: %d\n", p.PayloadType) - out += fmt.Sprintf("\tSequence Number: %d\n", p.SequenceNumber) - out += fmt.Sprintf("\tTimestamp: %d\n", p.Timestamp) - out += fmt.Sprintf("\tSSRC: %d (%x)\n", p.SSRC, p.SSRC) - out += fmt.Sprintf("\tPayload Length: %d\n", len(p.Payload)) - - return out -} - -// Unmarshal parses the passed byte slice and stores the result in the Packet this method is called upon -func (p *Packet) Unmarshal(rawPacket []byte) error { - if len(rawPacket) < headerLength { - return errors.Errorf("RTP header size insufficient; %d < %d", len(rawPacket), headerLength) - } - - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * |V=2|P|X| CC |M| PT | sequence number | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | timestamp | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | synchronization source (SSRC) identifier | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * | contributing source (CSRC) identifiers | - * | .... | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - - p.Version = rawPacket[0] >> versionShift & versionMask - p.Padding = (rawPacket[0] >> paddingShift & paddingMask) > 0 - p.Extension = (rawPacket[0] >> extensionShift & extensionMask) > 0 - p.CSRC = make([]uint32, rawPacket[0]&ccMask) - - p.Marker = (rawPacket[1] >> markerShift & markerMask) > 0 - p.PayloadType = rawPacket[1] & ptMask - - p.SequenceNumber = binary.BigEndian.Uint16(rawPacket[seqNumOffset : seqNumOffset+seqNumLength]) - p.Timestamp = binary.BigEndian.Uint32(rawPacket[timestampOffset : timestampOffset+timestampLength]) - p.SSRC = binary.BigEndian.Uint32(rawPacket[ssrcOffset : ssrcOffset+ssrcLength]) - - currOffset := csrcOffset + (len(p.CSRC) * csrcLength) - if len(rawPacket) < currOffset { - return errors.Errorf("RTP header size insufficient; %d < %d", len(rawPacket), currOffset) - } - - for i := range p.CSRC { - offset := csrcOffset + (i * csrcLength) - p.CSRC[i] = binary.BigEndian.Uint32(rawPacket[offset:]) - } - - if p.Extension { - if len(rawPacket) < currOffset+4 { - return errors.Errorf("RTP header size insufficient for extension; %d < %d", len(rawPacket), currOffset) - } - - p.ExtensionProfile = binary.BigEndian.Uint16(rawPacket[currOffset:]) - currOffset += 2 - extensionLength := int(binary.BigEndian.Uint16(rawPacket[currOffset:])) * 4 - currOffset += 2 - - if len(rawPacket) < currOffset+extensionLength { - return errors.Errorf("RTP header size insufficient for extension length; %d < %d", len(rawPacket), currOffset+extensionLength) - } - - p.ExtensionPayload = rawPacket[currOffset : currOffset+extensionLength] - currOffset += len(p.ExtensionPayload) - } - - p.Payload = rawPacket[currOffset:] - p.PayloadOffset = currOffset - p.Raw = rawPacket - return nil -} - -// Marshal returns a raw RTP packet for the instance it is called upon -func (p *Packet) Marshal() ([]byte, error) { - - /* - * 0 1 2 3 - * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * |V=2|P|X| CC |M| PT | sequence number | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | timestamp | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | synchronization source (SSRC) identifier | - * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * | contributing source (CSRC) identifiers | - * | .... | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - */ - - rawPacketLength := 12 + (len(p.CSRC) * csrcLength) - if p.Extension { - rawPacketLength += 4 + len(p.ExtensionPayload) - } - rawPacket := make([]byte, rawPacketLength) - - rawPacket[0] |= p.Version << versionShift - if p.Padding { - rawPacket[0] |= 1 << paddingShift - } - if p.Extension { - rawPacket[0] |= 1 << extensionShift - } - rawPacket[0] |= uint8(len(p.CSRC)) - - if p.Marker { - rawPacket[1] |= 1 << markerShift - } - rawPacket[1] |= p.PayloadType - - binary.BigEndian.PutUint16(rawPacket[seqNumOffset:], p.SequenceNumber) - binary.BigEndian.PutUint32(rawPacket[timestampOffset:], p.Timestamp) - binary.BigEndian.PutUint32(rawPacket[ssrcOffset:], p.SSRC) - - for i, csrc := range p.CSRC { - binary.BigEndian.PutUint32(rawPacket[csrcOffset+(i*csrcLength):], csrc) - } - - currOffset := csrcOffset + (len(p.CSRC) * csrcLength) - - for i := range p.CSRC { - offset := csrcOffset + (i * csrcLength) - p.CSRC[i] = binary.BigEndian.Uint32(rawPacket[offset:]) - } - - if p.Extension { - binary.BigEndian.PutUint16(rawPacket[currOffset:], p.ExtensionProfile) - currOffset += 2 - binary.BigEndian.PutUint16(rawPacket[currOffset:], uint16(len(p.ExtensionPayload))/4) - currOffset += 2 - copy(rawPacket[currOffset:], p.ExtensionPayload) - } - - p.PayloadOffset = csrcOffset + (len(p.CSRC) * csrcLength) - - rawPacket = append(rawPacket, p.Payload...) - p.Raw = rawPacket - - return rawPacket, nil -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtp/packetizer.go b/vendor/github.com/pions/webrtc/pkg/rtp/packetizer.go deleted file mode 100644 index 216c62d..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtp/packetizer.go +++ /dev/null @@ -1,70 +0,0 @@ -package rtp - -import ( - "math/rand" - "time" -) - -// Payloader payloads a byte array for use as rtp.Packet payloads -type Payloader interface { - Payload(mtu int, payload []byte) [][]byte -} - -// Packetizer packetizes a payload -type Packetizer interface { - Packetize(payload []byte, samples uint32) []*Packet -} - -type packetizer struct { - MTU int - PayloadType uint8 - SSRC uint32 - Payloader Payloader - Sequencer Sequencer - Timestamp uint32 - ClockRate uint32 -} - -// NewPacketizer returns a new instance of a Packetizer for a specific payloader -func NewPacketizer(mtu int, pt uint8, ssrc uint32, payloader Payloader, sequencer Sequencer, clockRate uint32) Packetizer { - rs := rand.NewSource(time.Now().UnixNano()) - r := rand.New(rs) - - return &packetizer{ - MTU: mtu, - PayloadType: pt, - SSRC: ssrc, - Payloader: payloader, - Sequencer: sequencer, - Timestamp: r.Uint32(), - ClockRate: clockRate, - } -} - -// Packetize packetizes the payload of an RTP packet and returns one or more RTP packets -func (p *packetizer) Packetize(payload []byte, samples uint32) []*Packet { - // Guard against an empty payload - if len(payload) == 0 { - return nil - } - - payloads := p.Payloader.Payload(p.MTU-12, payload) - packets := make([]*Packet, len(payloads)) - - for i, pp := range payloads { - packets[i] = &Packet{ - Version: 2, - Padding: false, - Extension: false, - Marker: i == len(payloads)-1, - PayloadType: p.PayloadType, - SequenceNumber: p.Sequencer.NextSequenceNumber(), - Timestamp: p.Timestamp, // Figure out how to do timestamps - SSRC: p.SSRC, - Payload: pp, - } - } - p.Timestamp += samples - - return packets -} diff --git a/vendor/github.com/pions/webrtc/pkg/rtp/sequencer.go b/vendor/github.com/pions/webrtc/pkg/rtp/sequencer.go deleted file mode 100644 index 6c5233f..0000000 --- a/vendor/github.com/pions/webrtc/pkg/rtp/sequencer.go +++ /dev/null @@ -1,62 +0,0 @@ -package rtp - -import ( - "math" - "math/rand" - "sync" - "time" -) - -// Sequencer generates sequential sequence numbers for building RTP packets -type Sequencer interface { - NextSequenceNumber() uint16 - RollOverCount() uint64 -} - -// NewRandomSequencer returns a new sequencer starting from a random sequence -// number -func NewRandomSequencer() Sequencer { - rs := rand.NewSource(time.Now().UnixNano()) - r := rand.New(rs) - - return &sequencer{ - sequenceNumber: uint16(r.Uint32() % math.MaxUint16), - } -} - -// NewFixedSequencer returns a new sequencer starting from a specific -// sequence number -func NewFixedSequencer(s uint16) Sequencer { - return &sequencer{ - sequenceNumber: s - 1, // -1 because the first sequence number prepends 1 - } -} - -type sequencer struct { - sequenceNumber uint16 - rollOverCount uint64 - mutex sync.Mutex -} - -// NextSequenceNumber increment and returns a new sequence number for -// building RTP packets -func (s *sequencer) NextSequenceNumber() uint16 { - s.mutex.Lock() - defer s.mutex.Unlock() - - s.sequenceNumber++ - if s.sequenceNumber == 0 { - s.rollOverCount++ - } - - return s.sequenceNumber -} - -// RollOverCount returns the amount of times the 16bit sequence number -// has wrapped -func (s *sequencer) RollOverCount() uint64 { - s.mutex.Lock() - defer s.mutex.Unlock() - - return s.rollOverCount -} diff --git a/vendor/github.com/pions/webrtc/rtcbundlepolicy.go b/vendor/github.com/pions/webrtc/rtcbundlepolicy.go deleted file mode 100644 index ffb0c25..0000000 --- a/vendor/github.com/pions/webrtc/rtcbundlepolicy.go +++ /dev/null @@ -1,58 +0,0 @@ -package webrtc - -// RTCBundlePolicy affects which media tracks are negotiated if the remote -// endpoint is not bundle-aware, and what ICE candidates are gathered. If the -// remote endpoint is bundle-aware, all media tracks and data channels are -// bundled onto the same transport. -type RTCBundlePolicy int - -const ( - // RTCBundlePolicyBalanced indicates to gather ICE candidates for each - // media type in use (audio, video, and data). If the remote endpoint is - // not bundle-aware, negotiate only one audio and video track on separate - // transports. - RTCBundlePolicyBalanced RTCBundlePolicy = iota + 1 - - // RTCBundlePolicyMaxCompat indicates to gather ICE candidates for each - // track. If the remote endpoint is not bundle-aware, negotiate all media - // tracks on separate transports. - RTCBundlePolicyMaxCompat - - // RTCBundlePolicyMaxBundle indicates to gather ICE candidates for only - // one track. If the remote endpoint is not bundle-aware, negotiate only - // one media track. - RTCBundlePolicyMaxBundle -) - -// This is done this way because of a linter. -const ( - rtcBundlePolicyBalancedStr = "balanced" - rtcBundlePolicyMaxCompatStr = "max-compat" - rtcBundlePolicyMaxBundleStr = "max-bundle" -) - -func newRTCBundlePolicy(raw string) RTCBundlePolicy { - switch raw { - case rtcBundlePolicyBalancedStr: - return RTCBundlePolicyBalanced - case rtcBundlePolicyMaxCompatStr: - return RTCBundlePolicyMaxCompat - case rtcBundlePolicyMaxBundleStr: - return RTCBundlePolicyMaxBundle - default: - return RTCBundlePolicy(Unknown) - } -} - -func (t RTCBundlePolicy) String() string { - switch t { - case RTCBundlePolicyBalanced: - return rtcBundlePolicyBalancedStr - case RTCBundlePolicyMaxCompat: - return rtcBundlePolicyMaxCompatStr - case RTCBundlePolicyMaxBundle: - return rtcBundlePolicyMaxBundleStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtccertificate.go b/vendor/github.com/pions/webrtc/rtccertificate.go deleted file mode 100644 index 2dfd8d8..0000000 --- a/vendor/github.com/pions/webrtc/rtccertificate.go +++ /dev/null @@ -1,148 +0,0 @@ -package webrtc - -import ( - "crypto" - "crypto/ecdsa" - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "crypto/x509/pkix" - "encoding/hex" - "fmt" - "math/big" - "time" - - "github.com/pions/dtls/pkg/dtls" - "github.com/pions/webrtc/pkg/rtcerr" -) - -// RTCCertificate represents a x509Cert used to authenticate WebRTC communications. -type RTCCertificate struct { - privateKey crypto.PrivateKey - x509Cert *x509.Certificate -} - -// NewRTCCertificate generates a new x509 compliant RTCCertificate to be used -// by DTLS for encrypting data sent over the wire. This method differs from -// GenerateCertificate by allowing to specify a template x509.Certificate to -// be used in order to define certificate parameters. -func NewRTCCertificate(key crypto.PrivateKey, tpl x509.Certificate) (*RTCCertificate, error) { - var err error - var certDER []byte - switch sk := key.(type) { - case *rsa.PrivateKey: - pk := sk.Public() - tpl.SignatureAlgorithm = x509.SHA256WithRSA - certDER, err = x509.CreateCertificate(rand.Reader, &tpl, &tpl, pk, sk) - if err != nil { - return nil, &rtcerr.UnknownError{Err: err} - } - case *ecdsa.PrivateKey: - pk := sk.Public() - tpl.SignatureAlgorithm = x509.ECDSAWithSHA256 - certDER, err = x509.CreateCertificate(rand.Reader, &tpl, &tpl, pk, sk) - if err != nil { - return nil, &rtcerr.UnknownError{Err: err} - } - default: - return nil, &rtcerr.NotSupportedError{Err: ErrPrivateKeyType} - } - - cert, err := x509.ParseCertificate(certDER) - if err != nil { - return nil, &rtcerr.UnknownError{Err: err} - } - - return &RTCCertificate{privateKey: key, x509Cert: cert}, nil -} - -// Equals determines if two certificates are identical by comparing both the -// secretKeys and x509Certificates. -func (c RTCCertificate) Equals(o RTCCertificate) bool { - switch cSK := c.privateKey.(type) { - case *rsa.PrivateKey: - if oSK, ok := o.privateKey.(*rsa.PrivateKey); ok { - if cSK.N.Cmp(oSK.N) != 0 { - return false - } - return c.x509Cert.Equal(o.x509Cert) - } - return false - case *ecdsa.PrivateKey: - if oSK, ok := o.privateKey.(*ecdsa.PrivateKey); ok { - if cSK.X.Cmp(oSK.X) != 0 || cSK.Y.Cmp(oSK.Y) != 0 { - return false - } - return c.x509Cert.Equal(o.x509Cert) - } - return false - default: - return false - } -} - -// Expires returns the timestamp after which this certificate is no longer valid. -func (c RTCCertificate) Expires() time.Time { - if c.x509Cert == nil { - return time.Time{} - } - return c.x509Cert.NotAfter -} - -var fingerprintAlgorithms = []dtls.HashAlgorithm{dtls.HashAlgorithmSHA256} - -// GetFingerprints returns the list of certificate fingerprints, one of which -// is computed with the digest algorithm used in the certificate signature. -func (c RTCCertificate) GetFingerprints() []RTCDtlsFingerprint { - res := make([]RTCDtlsFingerprint, len(fingerprintAlgorithms)) - - i := 0 - for _, algo := range fingerprintAlgorithms { - value, err := dtls.Fingerprint(c.x509Cert, algo) - if err != nil { - fmt.Printf("Failed to create fingerprint: %v\n", err) - continue - } - res[i] = RTCDtlsFingerprint{ - Algorithm: algo.String(), - Value: value, - } - } - - return res[:i+1] -} - -// GenerateCertificate causes the creation of an X.509 certificate and -// corresponding private key. -func GenerateCertificate(secretKey crypto.PrivateKey) (*RTCCertificate, error) { - origin := make([]byte, 16) - /* #nosec */ - if _, err := rand.Read(origin); err != nil { - return nil, &rtcerr.UnknownError{Err: err} - } - - // Max random value, a 130-bits integer, i.e 2^130 - 1 - maxBigInt := new(big.Int) - /* #nosec */ - maxBigInt.Exp(big.NewInt(2), big.NewInt(130), nil).Sub(maxBigInt, big.NewInt(1)) - /* #nosec */ - serialNumber, err := rand.Int(rand.Reader, maxBigInt) - if err != nil { - return nil, &rtcerr.UnknownError{Err: err} - } - - return NewRTCCertificate(secretKey, x509.Certificate{ - ExtKeyUsage: []x509.ExtKeyUsage{ - x509.ExtKeyUsageClientAuth, - x509.ExtKeyUsageServerAuth, - }, - BasicConstraintsValid: true, - NotBefore: time.Now(), - KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, - NotAfter: time.Now().AddDate(0, 1, 0), - SerialNumber: serialNumber, - Version: 2, - Subject: pkix.Name{CommonName: hex.EncodeToString(origin)}, - IsCA: true, - }) -} diff --git a/vendor/github.com/pions/webrtc/rtcconfiguration.go b/vendor/github.com/pions/webrtc/rtcconfiguration.go deleted file mode 100644 index b35a91a..0000000 --- a/vendor/github.com/pions/webrtc/rtcconfiguration.go +++ /dev/null @@ -1,61 +0,0 @@ -package webrtc - -import ( - "github.com/pions/webrtc/pkg/ice" -) - -// RTCConfiguration defines a set of parameters to configure how the -// peer-to-peer communication via RTCPeerConnection is established or -// re-established. -type RTCConfiguration struct { - // IceServers defines a slice describing servers available to be used by - // ICE, such as STUN and TURN servers. - IceServers []RTCIceServer - - // IceTransportPolicy indicates which candidates the IceAgent is allowed - // to use. - IceTransportPolicy RTCIceTransportPolicy - - // BundlePolicy indicates which media-bundling policy to use when gathering - // ICE candidates. - BundlePolicy RTCBundlePolicy - - // RtcpMuxPolicy indicates which rtcp-mux policy to use when gathering ICE - // candidates. - RtcpMuxPolicy RTCRtcpMuxPolicy - - // PeerIdentity sets the target peer identity for the RTCPeerConnection. - // The RTCPeerConnection will not establish a connection to a remote peer - // unless it can be successfully authenticated with the provided name. - PeerIdentity string - - // Certificates describes a set of certificates that the RTCPeerConnection - // uses to authenticate. Valid values for this parameter are created - // through calls to the GenerateCertificate function. Although any given - // DTLS connection will use only one certificate, this attribute allows the - // caller to provide multiple certificates that support different - // algorithms. The final certificate will be selected based on the DTLS - // handshake, which establishes which certificates are allowed. The - // RTCPeerConnection implementation selects which of the certificates is - // used for a given connection; how certificates are selected is outside - // the scope of this specification. If this value is absent, then a default - // set of certificates is generated for each RTCPeerConnection instance. - Certificates []RTCCertificate - - // IceCandidatePoolSize describes the size of the prefetched ICE pool. - IceCandidatePoolSize uint8 -} - -func (c RTCConfiguration) getIceServers() (*[]*ice.URL, error) { - var iceServers []*ice.URL - for _, server := range c.IceServers { - for _, rawURL := range server.URLs { - url, err := ice.ParseURL(rawURL) - if err != nil { - return nil, err - } - iceServers = append(iceServers, url) - } - } - return &iceServers, nil -} diff --git a/vendor/github.com/pions/webrtc/rtcdatachannel.go b/vendor/github.com/pions/webrtc/rtcdatachannel.go deleted file mode 100644 index 00bba5a..0000000 --- a/vendor/github.com/pions/webrtc/rtcdatachannel.go +++ /dev/null @@ -1,226 +0,0 @@ -package webrtc - -import ( - "fmt" - "sync" - - "github.com/pions/webrtc/internal/datachannel" - sugar "github.com/pions/webrtc/pkg/datachannel" - "github.com/pkg/errors" -) - -const receiveMTU = 8192 - -// RTCDataChannel represents a WebRTC DataChannel -// The RTCDataChannel interface represents a network channel -// which can be used for bidirectional peer-to-peer transfers of arbitrary data -type RTCDataChannel struct { - sync.RWMutex - - // Transport represents the associated underlying data transport that is - // used to transport actual data to the other peer. - Transport *RTCSctpTransport - - // Label represents a label that can be used to distinguish this - // RTCDataChannel object from other RTCDataChannel objects. Scripts are - // allowed to create multiple RTCDataChannel objects with the same label. - Label string - - // Ordered represents if the RTCDataChannel is ordered, and false if - // out-of-order delivery is allowed. - Ordered bool - - // MaxPacketLifeTime represents the length of the time window (msec) during - // which transmissions and retransmissions may occur in unreliable mode. - MaxPacketLifeTime *uint16 - - // MaxRetransmits represents the maximum number of retransmissions that are - // attempted in unreliable mode. - MaxRetransmits *uint16 - - // Protocol represents the name of the sub-protocol used with this - // RTCDataChannel. - Protocol string - - // Negotiated represents whether this RTCDataChannel was negotiated by the - // application (true), or not (false). - Negotiated bool - - // ID represents the ID for this RTCDataChannel. The value is initially - // null, which is what will be returned if the ID was not provided at - // channel creation time, and the DTLS role of the SCTP transport has not - // yet been negotiated. Otherwise, it will return the ID that was either - // selected by the script or generated. After the ID is set to a non-null - // value, it will not change. - ID *uint16 - - // Priority represents the priority for this RTCDataChannel. The priority is - // assigned at channel creation time. - Priority RTCPriorityType - - // ReadyState represents the state of the RTCDataChannel object. - ReadyState RTCDataChannelState - - // BufferedAmount represents the number of bytes of application data - // (UTF-8 text and binary data) that have been queued using send(). Even - // though the data transmission can occur in parallel, the returned value - // MUST NOT be decreased before the current task yielded back to the event - // loop to prevent race conditions. The value does not include framing - // overhead incurred by the protocol, or buffering done by the operating - // system or network hardware. The value of BufferedAmount slot will only - // increase with each call to the send() method as long as the ReadyState is - // open; however, BufferedAmount does not reset to zero once the channel - // closes. - BufferedAmount uint64 - - // BufferedAmountLowThreshold represents the threshold at which the - // bufferedAmount is considered to be low. When the bufferedAmount decreases - // from above this threshold to equal or below it, the bufferedamountlow - // event fires. BufferedAmountLowThreshold is initially zero on each new - // RTCDataChannel, but the application may change its value at any time. - BufferedAmountLowThreshold uint64 - - // The binaryType represents attribute MUST, on getting, return the value to - // which it was last set. On setting, if the new value is either the string - // "blob" or the string "arraybuffer", then set the IDL attribute to this - // new value. Otherwise, throw a SyntaxError. When an RTCDataChannel object - // is created, the binaryType attribute MUST be initialized to the string - // "blob". This attribute controls how binary data is exposed to scripts. - // binaryType string - - // OnOpen func() - // OnBufferedAmountLow func() - // OnError func() - // OnClose func() - - onMessageHandler func(sugar.Payload) - onOpenHandler func() - - // Deprecated: Will be removed when networkManager is deprecated. - rtcPeerConnection *RTCPeerConnection - - dataChannel *datachannel.DataChannel -} - -// OnOpen sets an event handler which is invoked when -// the underlying data transport has been established (or re-established). -func (d *RTCDataChannel) OnOpen(f func()) { - d.Lock() - defer d.Unlock() - d.onOpenHandler = f -} - -func (d *RTCDataChannel) onOpen() (done chan struct{}) { - d.RLock() - hdlr := d.onOpenHandler - d.RUnlock() - - done = make(chan struct{}) - if hdlr == nil { - close(done) - return - } - - go func() { - hdlr() - close(done) - }() - - return -} - -// OnMessage sets an event handler which is invoked on a message -// arrival over the sctp transport from a remote peer. -func (d *RTCDataChannel) OnMessage(f func(p sugar.Payload)) { - d.Lock() - defer d.Unlock() - d.onMessageHandler = f -} - -func (d *RTCDataChannel) onMessage(p sugar.Payload) { - d.RLock() - hdlr := d.onMessageHandler - d.RUnlock() - - if hdlr == nil || p == nil { - return - } - hdlr(p) -} - -// Onmessage sets an event handler which is invoked on a message -// arrival over the sctp transport from a remote peer. -// -// Deprecated: use OnMessage instead. -func (d *RTCDataChannel) Onmessage(f func(p sugar.Payload)) { - d.OnMessage(f) -} - -// func (d *RTCDataChannel) generateID() error { -// // TODO: base on DTLS role, currently static at "true". -// client := true -// -// var id uint16 -// if !client { -// id++ -// } -// -// for ; id < *d.Transport.MaxChannels-1; id += 2 { -// _, ok := d.rtcPeerConnection.dataChannels[id] -// if !ok { -// d.ID = &id -// return nil -// } -// } -// return &rtcerr.OperationError{Err: ErrMaxDataChannelID} -// } - -func (d *RTCDataChannel) handleOpen(dc *datachannel.DataChannel) { - d.dataChannel = dc - - // Ensure on - d.onOpen() - - go d.readLoop() -} - -func (d *RTCDataChannel) readLoop() { - for { - buffer := make([]byte, receiveMTU) - n, isString, err := d.dataChannel.ReadDataChannel(buffer) - if err != nil { - fmt.Println("Failed to read from data channel", err) - // TODO: Kill DataChannel/PeerConnection? - return - } - - if isString { - d.onMessage(&sugar.PayloadString{Data: buffer[:n]}) - continue - } - d.onMessage(&sugar.PayloadBinary{Data: buffer[:n]}) - } -} - -// Send sends the passed message to the DataChannel peer -func (d *RTCDataChannel) Send(payload sugar.Payload) error { - var data []byte - isString := false - - switch p := payload.(type) { - case sugar.PayloadString: - data = p.Data - isString = true - case sugar.PayloadBinary: - data = p.Data - default: - return errors.Errorf("unknown DataChannel Payload (%s)", payload.PayloadType()) - } - - if len(data) == 0 { - data = []byte{0} - } - - _, err := d.dataChannel.WriteDataChannel(data, isString) - return err -} diff --git a/vendor/github.com/pions/webrtc/rtcdatachannelinit.go b/vendor/github.com/pions/webrtc/rtcdatachannelinit.go deleted file mode 100644 index 1e8cc71..0000000 --- a/vendor/github.com/pions/webrtc/rtcdatachannelinit.go +++ /dev/null @@ -1,36 +0,0 @@ -package webrtc - -// RTCDataChannelInit can be used to configure properties of the underlying -// channel such as data reliability. -type RTCDataChannelInit struct { - // Ordered indicates if data is allowed to be delivered out of order. The - // default value of true, guarantees that data will be delivered in order. - Ordered *bool - - // MaxPacketLifeTime limits the time (in milliseconds) during which the - // channel will transmit or retransmit data if not acknowledged. This value - // may be clamped if it exceeds the maximum value supported. - MaxPacketLifeTime *uint16 - - // MaxRetransmits limits the number of times a channel will retransmit data - // if not successfully delivered. This value may be clamped if it exceeds - // the maximum value supported. - MaxRetransmits *uint16 - - // Protocol describes the subprotocol name used for this channel. - Protocol *string - - // Negotiated describes if the data channel is created by the local peer or - // the remote peer. The default value of false tells the user agent to - // announce the channel in-band and instruct the other peer to dispatch a - // corresponding RTCDataChannel. If set to true, it is up to the application - // to negotiate the channel and create an RTCDataChannel with the same id - // at the other peer. - Negotiated *bool - - // ID overrides the default selection of ID for this channel. - ID *uint16 - - // Priority describes the priority of this channel. - Priority *RTCPriorityType -} diff --git a/vendor/github.com/pions/webrtc/rtcdatachannelstate.go b/vendor/github.com/pions/webrtc/rtcdatachannelstate.go deleted file mode 100644 index 732e3f8..0000000 --- a/vendor/github.com/pions/webrtc/rtcdatachannelstate.go +++ /dev/null @@ -1,61 +0,0 @@ -package webrtc - -// RTCDataChannelState indicates the state of a data channel. -type RTCDataChannelState int - -const ( - // RTCDataChannelStateConnecting indicates that the data channel is being - // established. This is the initial state of RTCDataChannel, whether created - // with CreateDataChannel, or dispatched as a part of an RTCDataChannelEvent. - RTCDataChannelStateConnecting RTCDataChannelState = iota + 1 - - // RTCDataChannelStateOpen indicates that the underlying data transport is - // established and communication is possible. - RTCDataChannelStateOpen - - // RTCDataChannelStateClosing indicates that the procedure to close down the - // underlying data transport has started. - RTCDataChannelStateClosing - - // RTCDataChannelStateClosed indicates that the underlying data transport - // has been closed or could not be established. - RTCDataChannelStateClosed -) - -// This is done this way because of a linter. -const ( - rtcDataChannelStateConnectingStr = "connecting" - rtcDataChannelStateOpenStr = "open" - rtcDataChannelStateClosingStr = "closing" - rtcDataChannelStateClosedStr = "closed" -) - -func newRTCDataChannelState(raw string) RTCDataChannelState { - switch raw { - case rtcDataChannelStateConnectingStr: - return RTCDataChannelStateConnecting - case rtcDataChannelStateOpenStr: - return RTCDataChannelStateOpen - case rtcDataChannelStateClosingStr: - return RTCDataChannelStateClosing - case rtcDataChannelStateClosedStr: - return RTCDataChannelStateClosed - default: - return RTCDataChannelState(Unknown) - } -} - -func (t RTCDataChannelState) String() string { - switch t { - case RTCDataChannelStateConnecting: - return rtcDataChannelStateConnectingStr - case RTCDataChannelStateOpen: - return rtcDataChannelStateOpenStr - case RTCDataChannelStateClosing: - return rtcDataChannelStateClosingStr - case RTCDataChannelStateClosed: - return rtcDataChannelStateClosedStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtcdtlsfingerprint.go b/vendor/github.com/pions/webrtc/rtcdtlsfingerprint.go deleted file mode 100644 index 1f117f6..0000000 --- a/vendor/github.com/pions/webrtc/rtcdtlsfingerprint.go +++ /dev/null @@ -1,14 +0,0 @@ -package webrtc - -// RTCDtlsFingerprint specifies the hash function algorithm and certificate -// fingerprint as described in https://tools.ietf.org/html/rfc4572. -type RTCDtlsFingerprint struct { - // Algorithm specifies one of the the hash function algorithms defined in - // the 'Hash function Textual Names' registry. - Algorithm string - - // Value specifies the value of the certificate fingerprint in lowercase - // hex string as expressed utilizing the syntax of 'fingerprint' in - // https://tools.ietf.org/html/rfc4572#section-5. - Value string -} diff --git a/vendor/github.com/pions/webrtc/rtcdtlstransport.go b/vendor/github.com/pions/webrtc/rtcdtlstransport.go deleted file mode 100644 index aa5a318..0000000 --- a/vendor/github.com/pions/webrtc/rtcdtlstransport.go +++ /dev/null @@ -1,13 +0,0 @@ -package webrtc - -// RTCDtlsTransport allows an application access to information about the DTLS -// transport over which RTP and RTCP packets are sent and received by -// RTCRtpSender and RTCRtpReceiver, as well other data such as SCTP packets sent -// and received by data channels. -type RTCDtlsTransport struct { - // Transport RTCIceTransport - // State RTCDtlsTransportState - - // OnStateChange func() - // OnError func() -} diff --git a/vendor/github.com/pions/webrtc/rtcdtlstransportstate.go b/vendor/github.com/pions/webrtc/rtcdtlstransportstate.go deleted file mode 100644 index 529ab95..0000000 --- a/vendor/github.com/pions/webrtc/rtcdtlstransportstate.go +++ /dev/null @@ -1,71 +0,0 @@ -package webrtc - -// RTCDtlsTransportState indicates the dtsl transport establishment state. -type RTCDtlsTransportState int - -const ( - // RTCDtlsTransportStateNew indicates that DTLS has not started negotiating - // yet. - RTCDtlsTransportStateNew RTCDtlsTransportState = iota + 1 - - // RTCDtlsTransportStateConnecting indicates that DTLS is in the process of - // negotiating a secure connection and verifying the remote fingerprint. - RTCDtlsTransportStateConnecting - - // RTCDtlsTransportStateConnected indicates that DTLS has completed - // negotiation of a secure connection and verified the remote fingerprint. - RTCDtlsTransportStateConnected - - // RTCDtlsTransportStateClosed indicates that the transport has been closed - // intentionally as the result of receipt of a close_notify alert, or - // calling close(). - RTCDtlsTransportStateClosed - - // RTCDtlsTransportStateFailed indicates that the transport has failed as - // the result of an error (such as receipt of an error alert or failure to - // validate the remote fingerprint). - RTCDtlsTransportStateFailed -) - -// This is done this way because of a linter. -const ( - rtcDtlsTransportStateNewStr = "new" - rtcDtlsTransportStateConnectingStr = "connecting" - rtcDtlsTransportStateConnectedStr = "connected" - rtcDtlsTransportStateClosedStr = "closed" - rtcDtlsTransportStateFailedStr = "failed" -) - -func newRTCDtlsTransportState(raw string) RTCDtlsTransportState { - switch raw { - case rtcDtlsTransportStateNewStr: - return RTCDtlsTransportStateNew - case rtcDtlsTransportStateConnectingStr: - return RTCDtlsTransportStateConnecting - case rtcDtlsTransportStateConnectedStr: - return RTCDtlsTransportStateConnected - case rtcDtlsTransportStateClosedStr: - return RTCDtlsTransportStateClosed - case rtcDtlsTransportStateFailedStr: - return RTCDtlsTransportStateFailed - default: - return RTCDtlsTransportState(Unknown) - } -} - -func (t RTCDtlsTransportState) String() string { - switch t { - case RTCDtlsTransportStateNew: - return rtcDtlsTransportStateNewStr - case RTCDtlsTransportStateConnecting: - return rtcDtlsTransportStateConnectingStr - case RTCDtlsTransportStateConnected: - return rtcDtlsTransportStateConnectedStr - case RTCDtlsTransportStateClosed: - return rtcDtlsTransportStateClosedStr - case RTCDtlsTransportStateFailed: - return rtcDtlsTransportStateFailedStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtcicecandidatetype.go b/vendor/github.com/pions/webrtc/rtcicecandidatetype.go deleted file mode 100644 index 1995ebd..0000000 --- a/vendor/github.com/pions/webrtc/rtcicecandidatetype.go +++ /dev/null @@ -1,70 +0,0 @@ -package webrtc - -// RTCIceCandidateType represents the type of the ICE candidate used. -type RTCIceCandidateType int - -const ( - // RTCIceCandidateTypeHost indicates that the candidate is of Host type as - // described in https://tools.ietf.org/html/rfc8445#section-5.1.1.1. A - // candidate obtained by binding to a specific port from an IP address on - // the host. This includes IP addresses on physical interfaces and logical - // ones, such as ones obtained through VPNs. - RTCIceCandidateTypeHost RTCIceCandidateType = iota + 1 - - // RTCIceCandidateTypeSrflx indicates the the candidate is of Server - // Reflexive type as described - // https://tools.ietf.org/html/rfc8445#section-5.1.1.2. A candidate type - // whose IP address and port are a binding allocated by a NAT for an ICE - // agent after it sends a packet through the NAT to a server, such as a - // STUN server. - RTCIceCandidateTypeSrflx - - // RTCIceCandidateTypePrflx indicates that the candidate is of Peer - // Reflexive type. A candidate type whose IP address and port are a binding - // allocated by a NAT for an ICE agent after it sends a packet through the - // NAT to its peer. - RTCIceCandidateTypePrflx - - // RTCIceCandidateTypeRelay indicates the the candidate is of Relay type as - // described in https://tools.ietf.org/html/rfc8445#section-5.1.1.2. A - // candidate type obtained from a relay server, such as a TURN server. - RTCIceCandidateTypeRelay -) - -// This is done this way because of a linter. -const ( - rtcIceCandidateTypeHostStr = "host" - rtcIceCandidateTypeSrflxStr = "srflx" - rtcIceCandidateTypePrflxStr = "prflx" - rtcIceCandidateTypeRelayStr = "relay" -) - -func newRTCIceCandidateType(raw string) RTCIceCandidateType { - switch raw { - case rtcIceCandidateTypeHostStr: - return RTCIceCandidateTypeHost - case rtcIceCandidateTypeSrflxStr: - return RTCIceCandidateTypeSrflx - case rtcIceCandidateTypePrflxStr: - return RTCIceCandidateTypePrflx - case rtcIceCandidateTypeRelayStr: - return RTCIceCandidateTypeRelay - default: - return RTCIceCandidateType(Unknown) - } -} - -func (t RTCIceCandidateType) String() string { - switch t { - case RTCIceCandidateTypeHost: - return rtcIceCandidateTypeHostStr - case RTCIceCandidateTypeSrflx: - return rtcIceCandidateTypeSrflxStr - case RTCIceCandidateTypePrflx: - return rtcIceCandidateTypePrflxStr - case RTCIceCandidateTypeRelay: - return rtcIceCandidateTypeRelayStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtcicecomponent.go b/vendor/github.com/pions/webrtc/rtcicecomponent.go deleted file mode 100644 index 0740af4..0000000 --- a/vendor/github.com/pions/webrtc/rtcicecomponent.go +++ /dev/null @@ -1,47 +0,0 @@ -package webrtc - -// RTCIceComponent describes if the ice transport is used for RTP -// (or RTCP multiplexing). -type RTCIceComponent int - -const ( - // RTCIceComponentRtp indicates that the ICE Transport is used for RTP (or - // RTCP multiplexing), as defined in - // https://tools.ietf.org/html/rfc5245#section-4.1.1.1. Protocols - // multiplexed with RTP (e.g. data channel) share its component ID. This - // represents the component-id value 1 when encoded in candidate-attribute. - RTCIceComponentRtp RTCIceComponent = iota + 1 - - // RTCIceComponentRtcp indicates that the ICE Transport is used for RTCP as - // defined by https://tools.ietf.org/html/rfc5245#section-4.1.1.1. This - // represents the component-id value 2 when encoded in candidate-attribute. - RTCIceComponentRtcp -) - -// This is done this way because of a linter. -const ( - rtcIceComponentRtpStr = "rtp" - rtcIceComponentRtcpStr = "rtcp" -) - -func newRTCIceComponent(raw string) RTCIceComponent { - switch raw { - case rtcIceComponentRtpStr: - return RTCIceComponentRtp - case rtcIceComponentRtcpStr: - return RTCIceComponentRtcp - default: - return RTCIceComponent(Unknown) - } -} - -func (t RTCIceComponent) String() string { - switch t { - case RTCIceComponentRtp: - return rtcIceComponentRtpStr - case RTCIceComponentRtcp: - return rtcIceComponentRtcpStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtciceconnectionstate.go b/vendor/github.com/pions/webrtc/rtciceconnectionstate.go deleted file mode 100644 index 651a6c6..0000000 --- a/vendor/github.com/pions/webrtc/rtciceconnectionstate.go +++ /dev/null @@ -1,93 +0,0 @@ -package webrtc - -// RTCIceConnectionState indicates signaling state of the Ice Connection. -type RTCIceConnectionState int - -const ( - // RTCIceConnectionStateNew indicates that any of the RTCIceTransports are - // in the "new" state and none of them are in the "checking", "disconnected" - // or "failed" state, or all RTCIceTransports are in the "closed" state, or - // there are no transports. - RTCIceConnectionStateNew RTCIceConnectionState = iota + 1 - - // RTCIceConnectionStateChecking indicates that any of the RTCIceTransports - // are in the "checking" state and none of them are in the "disconnected" - // or "failed" state. - RTCIceConnectionStateChecking - - // RTCIceConnectionStateConnected indicates that all RTCIceTransports are - // in the "connected", "completed" or "closed" state and at least one of - // them is in the "connected" state. - RTCIceConnectionStateConnected - - // RTCIceConnectionStateCompleted indicates that all RTCIceTransports are - // in the "completed" or "closed" state and at least one of them is in the - // "completed" state. - RTCIceConnectionStateCompleted - - // RTCIceConnectionStateDisconnected indicates that any of the - // RTCIceTransports are in the "disconnected" state and none of them are - // in the "failed" state. - RTCIceConnectionStateDisconnected - - // RTCIceConnectionStateFailed indicates that any of the RTCIceTransports - // are in the "failed" state. - RTCIceConnectionStateFailed - - // RTCIceConnectionStateClosed indicates that the RTCPeerConnection's - // isClosed is true. - RTCIceConnectionStateClosed -) - -// This is done this way because of a linter. -const ( - rtcIceConnectionStateNewStr = "new" - rtcIceConnectionStateCheckingStr = "checking" - rtcIceConnectionStateConnectedStr = "connected" - rtcIceConnectionStateCompletedStr = "completed" - rtcIceConnectionStateDisconnectedStr = "disconnected" - rtcIceConnectionStateFailedStr = "failed" - rtcIceConnectionStateClosedStr = "closed" -) - -func newRTCIceConnectionState(raw string) RTCIceConnectionState { - switch raw { - case rtcIceConnectionStateNewStr: - return RTCIceConnectionStateNew - case rtcIceConnectionStateCheckingStr: - return RTCIceConnectionStateChecking - case rtcIceConnectionStateConnectedStr: - return RTCIceConnectionStateConnected - case rtcIceConnectionStateCompletedStr: - return RTCIceConnectionStateCompleted - case rtcIceConnectionStateDisconnectedStr: - return RTCIceConnectionStateDisconnected - case rtcIceConnectionStateFailedStr: - return RTCIceConnectionStateFailed - case rtcIceConnectionStateClosedStr: - return RTCIceConnectionStateClosed - default: - return RTCIceConnectionState(Unknown) - } -} - -func (c RTCIceConnectionState) String() string { - switch c { - case RTCIceConnectionStateNew: - return rtcIceConnectionStateNewStr - case RTCIceConnectionStateChecking: - return rtcIceConnectionStateCheckingStr - case RTCIceConnectionStateConnected: - return rtcIceConnectionStateConnectedStr - case RTCIceConnectionStateCompleted: - return rtcIceConnectionStateCompletedStr - case RTCIceConnectionStateDisconnected: - return rtcIceConnectionStateDisconnectedStr - case RTCIceConnectionStateFailed: - return rtcIceConnectionStateFailedStr - case RTCIceConnectionStateClosed: - return rtcIceConnectionStateClosedStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtcicecredentialtype.go b/vendor/github.com/pions/webrtc/rtcicecredentialtype.go deleted file mode 100644 index 8e58b9e..0000000 --- a/vendor/github.com/pions/webrtc/rtcicecredentialtype.go +++ /dev/null @@ -1,43 +0,0 @@ -package webrtc - -// RTCIceCredentialType indicates the type of credentials used to connect to -// an ICE server. -type RTCIceCredentialType int - -const ( - // RTCIceCredentialTypePassword describes username and pasword based - // credentials as described in https://tools.ietf.org/html/rfc5389. - RTCIceCredentialTypePassword RTCIceCredentialType = iota + 1 - - // RTCIceCredentialTypeOauth describes token based credential as described - // in https://tools.ietf.org/html/rfc7635. - RTCIceCredentialTypeOauth -) - -// This is done this way because of a linter. -const ( - rtcIceCredentialTypePasswordStr = "password" - rtcIceCredentialTypeOauthStr = "oauth" -) - -func newRTCIceCredentialType(raw string) RTCIceCredentialType { - switch raw { - case rtcIceCredentialTypePasswordStr: - return RTCIceCredentialTypePassword - case rtcIceCredentialTypeOauthStr: - return RTCIceCredentialTypeOauth - default: - return RTCIceCredentialType(Unknown) - } -} - -func (t RTCIceCredentialType) String() string { - switch t { - case RTCIceCredentialTypePassword: - return rtcIceCredentialTypePasswordStr - case RTCIceCredentialTypeOauth: - return rtcIceCredentialTypeOauthStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtcicegatheringstate.go b/vendor/github.com/pions/webrtc/rtcicegatheringstate.go deleted file mode 100644 index ea002da..0000000 --- a/vendor/github.com/pions/webrtc/rtcicegatheringstate.go +++ /dev/null @@ -1,52 +0,0 @@ -package webrtc - -// RTCIceGatheringState describes the state of the candidate gathering process. -type RTCIceGatheringState int - -const ( - // RTCIceGatheringStateNew indicates that any of the RTCIceTransports are - // in the "new" gathering state and none of the transports are in the - // "gathering" state, or there are no transports. - RTCIceGatheringStateNew RTCIceGatheringState = iota + 1 - - // RTCIceGatheringStateGathering indicates that any of the RTCIceTransports - // are in the "gathering" state. - RTCIceGatheringStateGathering - - // RTCIceGatheringStateComplete indicates that at least one RTCIceTransport - // exists, and all RTCIceTransports are in the "completed" gathering state. - RTCIceGatheringStateComplete -) - -// This is done this way because of a linter. -const ( - rtcIceGatheringStateNewStr = "new" - rtcIceGatheringStateGatheringStr = "gathering" - rtcIceGatheringStateCompleteStr = "complete" -) - -func newRTCIceGatheringState(raw string) RTCIceGatheringState { - switch raw { - case rtcIceGatheringStateNewStr: - return RTCIceGatheringStateNew - case rtcIceGatheringStateGatheringStr: - return RTCIceGatheringStateGathering - case rtcIceGatheringStateCompleteStr: - return RTCIceGatheringStateComplete - default: - return RTCIceGatheringState(Unknown) - } -} - -func (t RTCIceGatheringState) String() string { - switch t { - case RTCIceGatheringStateNew: - return rtcIceGatheringStateNewStr - case RTCIceGatheringStateGathering: - return rtcIceGatheringStateGatheringStr - case RTCIceGatheringStateComplete: - return rtcIceGatheringStateCompleteStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtciceprotocol.go b/vendor/github.com/pions/webrtc/rtciceprotocol.go deleted file mode 100644 index 0cf34d1..0000000 --- a/vendor/github.com/pions/webrtc/rtciceprotocol.go +++ /dev/null @@ -1,41 +0,0 @@ -package webrtc - -// RTCIceProtocol indicates the transport protocol type that is used in the -// ice.URL structure. -type RTCIceProtocol int - -const ( - // RTCIceProtocolUDP indicates the URL uses a UDP transport. - RTCIceProtocolUDP RTCIceProtocol = iota + 1 - - // RTCIceProtocolTCP indicates the URL uses a TCP transport. - RTCIceProtocolTCP -) - -// This is done this way because of a linter. -const ( - rtcIceProtocolUDPStr = "udp" - rtcIceProtocolTCPStr = "tcp" -) - -func newRTCIceProtocol(raw string) RTCIceProtocol { - switch raw { - case rtcIceProtocolUDPStr: - return RTCIceProtocolUDP - case rtcIceProtocolTCPStr: - return RTCIceProtocolTCP - default: - return RTCIceProtocol(Unknown) - } -} - -func (t RTCIceProtocol) String() string { - switch t { - case RTCIceProtocolUDP: - return rtcIceProtocolUDPStr - case RTCIceProtocolTCP: - return rtcIceProtocolTCPStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtcicerole.go b/vendor/github.com/pions/webrtc/rtcicerole.go deleted file mode 100644 index 54e6e54..0000000 --- a/vendor/github.com/pions/webrtc/rtcicerole.go +++ /dev/null @@ -1,45 +0,0 @@ -package webrtc - -// RTCIceRole describes the role ice.Agent is playing in selecting the -// preferred the candidate pair. -type RTCIceRole int - -const ( - // RTCIceRoleControlling indicates that the ICE agent that is responsible - // for selecting the final choice of candidate pairs and signaling them - // through STUN and an updated offer, if needed. In any session, one agent - // is always controlling. The other is the controlled agent. - RTCIceRoleControlling RTCIceRole = iota + 1 - - // RTCIceRoleControlled indicates that an ICE agent that waits for the - // controlling agent to select the final choice of candidate pairs. - RTCIceRoleControlled -) - -// This is done this way because of a linter. -const ( - rtcIceRoleControllingStr = "controlling" - rtcIceRoleControlledStr = "controlled" -) - -func newRTCIceRole(raw string) RTCIceRole { - switch raw { - case rtcIceRoleControllingStr: - return RTCIceRoleControlling - case rtcIceRoleControlledStr: - return RTCIceRoleControlled - default: - return RTCIceRole(Unknown) - } -} - -func (t RTCIceRole) String() string { - switch t { - case RTCIceRoleControlling: - return rtcIceRoleControllingStr - case RTCIceRoleControlled: - return rtcIceRoleControlledStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtciceserver.go b/vendor/github.com/pions/webrtc/rtciceserver.go deleted file mode 100644 index a1e200c..0000000 --- a/vendor/github.com/pions/webrtc/rtciceserver.go +++ /dev/null @@ -1,52 +0,0 @@ -package webrtc - -import ( - "github.com/pions/webrtc/pkg/ice" - "github.com/pions/webrtc/pkg/rtcerr" -) - -// RTCIceServer describes a single STUN and TURN server that can be used by -// the IceAgent to establish a connection with a peer. -type RTCIceServer struct { - URLs []string - Username string - Credential interface{} - CredentialType RTCIceCredentialType -} - -func (s RTCIceServer) parseURL(i int) (*ice.URL, error) { - return ice.ParseURL(s.URLs[i]) -} - -func (s RTCIceServer) validate() error { - for i := range s.URLs { - url, err := s.parseURL(i) - if err != nil { - return err - } - - if url.Scheme == ice.SchemeTypeTURN || url.Scheme == ice.SchemeTypeTURNS { - // https://www.w3.org/TR/webrtc/#set-the-configuration (step #11.3.2) - if s.Username == "" || s.Credential == nil { - return &rtcerr.InvalidAccessError{Err: ErrNoTurnCredencials} - } - - switch s.CredentialType { - case RTCIceCredentialTypePassword: - // https://www.w3.org/TR/webrtc/#set-the-configuration (step #11.3.3) - if _, ok := s.Credential.(string); !ok { - return &rtcerr.InvalidAccessError{Err: ErrTurnCredencials} - } - case RTCIceCredentialTypeOauth: - // https://www.w3.org/TR/webrtc/#set-the-configuration (step #11.3.4) - if _, ok := s.Credential.(RTCOAuthCredential); !ok { - return &rtcerr.InvalidAccessError{Err: ErrTurnCredencials} - } - - default: - return &rtcerr.InvalidAccessError{Err: ErrTurnCredencials} - } - } - } - return nil -} diff --git a/vendor/github.com/pions/webrtc/rtcicetransport.go b/vendor/github.com/pions/webrtc/rtcicetransport.go deleted file mode 100644 index 84440a8..0000000 --- a/vendor/github.com/pions/webrtc/rtcicetransport.go +++ /dev/null @@ -1,30 +0,0 @@ -package webrtc - -// RTCIceTransport allows an application access to information about the ICE -// transport over which packets are sent and received. -type RTCIceTransport struct { - // Role RTCIceRole - // Component RTCIceComponent - // State RTCIceTransportState - // gatheringState RTCIceGathererState -} - -// func (t *RTCIceTransport) GetLocalCandidates() []RTCIceCandidate { -// -// } -// -// func (t *RTCIceTransport) GetRemoteCandidates() []RTCIceCandidate { -// -// } -// -// func (t *RTCIceTransport) GetSelectedCandidatePair() RTCIceCandidatePair { -// -// } -// -// func (t *RTCIceTransport) GetLocalParameters() RTCIceParameters { -// -// } -// -// func (t *RTCIceTransport) GetRemoteParameters() RTCIceParameters { -// -// } diff --git a/vendor/github.com/pions/webrtc/rtcicetransportpolicy.go b/vendor/github.com/pions/webrtc/rtcicetransportpolicy.go deleted file mode 100644 index 96e5af4..0000000 --- a/vendor/github.com/pions/webrtc/rtcicetransportpolicy.go +++ /dev/null @@ -1,42 +0,0 @@ -package webrtc - -// RTCIceTransportPolicy defines the ICE candidate policy surface the -// permitted candidates. Only these candidates are used for connectivity checks. -type RTCIceTransportPolicy int - -const ( - // RTCIceTransportPolicyRelay indicates only media relay candidates such - // as candidates passing through a TURN server are used. - RTCIceTransportPolicyRelay RTCIceTransportPolicy = iota + 1 - - // RTCIceTransportPolicyAll indicates any type of candidate is used. - RTCIceTransportPolicyAll -) - -// This is done this way because of a linter. -const ( - rtcIceTransportPolicyRelayStr = "relay" - rtcIceTransportPolicyAllStr = "all" -) - -func newRTCIceTransportPolicy(raw string) RTCIceTransportPolicy { - switch raw { - case rtcIceTransportPolicyRelayStr: - return RTCIceTransportPolicyRelay - case rtcIceTransportPolicyAllStr: - return RTCIceTransportPolicyAll - default: - return RTCIceTransportPolicy(Unknown) - } -} - -func (t RTCIceTransportPolicy) String() string { - switch t { - case RTCIceTransportPolicyRelay: - return rtcIceTransportPolicyRelayStr - case RTCIceTransportPolicyAll: - return rtcIceTransportPolicyAllStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtcoauthcredential.go b/vendor/github.com/pions/webrtc/rtcoauthcredential.go deleted file mode 100644 index ece9560..0000000 --- a/vendor/github.com/pions/webrtc/rtcoauthcredential.go +++ /dev/null @@ -1,15 +0,0 @@ -package webrtc - -// RTCOAuthCredential represents OAuth credential information which is used by -// the STUN/TURN client to connect to an ICE server as defined in -// https://tools.ietf.org/html/rfc7635. Note that the kid parameter is not -// located in RTCOAuthCredential, but in RTCIceServer's username member. -type RTCOAuthCredential struct { - // MacKey is a base64-url encoded format. It is used in STUN message - // integrity hash calculation. - MacKey string - - // AccessToken is a base64-encoded format. This is an encrypted - // self-contained token that is opaque to the application. - AccessToken string -} diff --git a/vendor/github.com/pions/webrtc/rtcofferansweroptions.go b/vendor/github.com/pions/webrtc/rtcofferansweroptions.go deleted file mode 100644 index 7c6bfa3..0000000 --- a/vendor/github.com/pions/webrtc/rtcofferansweroptions.go +++ /dev/null @@ -1,26 +0,0 @@ -package webrtc - -// RTCOfferAnswerOptions is a base structure which describes the options that -// can be used to control the offer/answer creation process. -type RTCOfferAnswerOptions struct { - // VoiceActivityDetection allows the application to provide information - // about whether it wishes voice detection feature to be enabled or disabled. - VoiceActivityDetection bool -} - -// RTCAnswerOptions structure describes the options used to control the answer -// creation process. -type RTCAnswerOptions struct { - RTCOfferAnswerOptions -} - -// RTCOfferOptions structure describes the options used to control the offer -// creation process -type RTCOfferOptions struct { - RTCOfferAnswerOptions - - // IceRestart forces the underlying ice gathering process to be restarted. - // When this value is true, the generated description will have ICE - // credentials that are different from the current credentials - IceRestart bool -} diff --git a/vendor/github.com/pions/webrtc/rtcpeerconnection.go b/vendor/github.com/pions/webrtc/rtcpeerconnection.go deleted file mode 100644 index 84ae0f5..0000000 --- a/vendor/github.com/pions/webrtc/rtcpeerconnection.go +++ /dev/null @@ -1,1351 +0,0 @@ -// Package webrtc implements the WebRTC 1.0 as defined in W3C WebRTC specification document. -package webrtc - -import ( - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "fmt" - "net" - "strings" - "sync" - "time" - - "encoding/binary" - - "github.com/pions/webrtc/internal/datachannel" - "github.com/pions/webrtc/internal/network" - "github.com/pions/webrtc/internal/sdp" - "github.com/pions/webrtc/pkg/ice" - "github.com/pions/webrtc/pkg/media" - "github.com/pions/webrtc/pkg/rtcerr" - "github.com/pions/webrtc/pkg/rtcp" - "github.com/pions/webrtc/pkg/rtp" - "github.com/pkg/errors" -) - -// Unknown defines default public constant to use for "enum" like struct -// comparisons when no value was defined. -const Unknown = iota - -// RTCPeerConnection represents a WebRTC connection that establishes a -// peer-to-peer communications with another RTCPeerConnection instance in a -// browser, or to another endpoint implementing the required protocols. -type RTCPeerConnection struct { - sync.RWMutex - - configuration RTCConfiguration - - // CurrentLocalDescription represents the local description that was - // successfully negotiated the last time the RTCPeerConnection transitioned - // into the stable state plus any local candidates that have been generated - // by the IceAgent since the offer or answer was created. - CurrentLocalDescription *RTCSessionDescription - - // PendingLocalDescription represents a local description that is in the - // process of being negotiated plus any local candidates that have been - // generated by the IceAgent since the offer or answer was created. If the - // RTCPeerConnection is in the stable state, the value is null. - PendingLocalDescription *RTCSessionDescription - - // CurrentRemoteDescription represents the last remote description that was - // successfully negotiated the last time the RTCPeerConnection transitioned - // into the stable state plus any remote candidates that have been supplied - // via AddIceCandidate() since the offer or answer was created. - CurrentRemoteDescription *RTCSessionDescription - - // PendingRemoteDescription represents a remote description that is in the - // process of being negotiated, complete with any remote candidates that - // have been supplied via AddIceCandidate() since the offer or answer was - // created. If the RTCPeerConnection is in the stable state, the value is - // null. - PendingRemoteDescription *RTCSessionDescription - - // SignalingState attribute returns the signaling state of the - // RTCPeerConnection instance. - SignalingState RTCSignalingState - - // IceGatheringState attribute returns the ICE gathering state of the - // RTCPeerConnection instance. - IceGatheringState RTCIceGatheringState // FIXME NOT-USED - - // IceConnectionState attribute returns the ICE connection state of the - // RTCPeerConnection instance. - // IceConnectionState RTCIceConnectionState // FIXME SWAP-FOR-THIS - IceConnectionState ice.ConnectionState // FIXME REMOVE - - // ConnectionState attribute returns the connection state of the - // RTCPeerConnection instance. - ConnectionState RTCPeerConnectionState - - idpLoginURL *string - - isClosed bool - negotiationNeeded bool - - lastOffer string - lastAnswer string - - // Media - mediaEngine *MediaEngine - rtpTransceivers []*RTCRtpTransceiver - - // sctpTransport - sctpTransport *RTCSctpTransport - - // DataChannels - dataChannels map[uint16]*RTCDataChannel - - // OnNegotiationNeeded func() // FIXME NOT-USED - // OnIceCandidate func() // FIXME NOT-USED - // OnIceCandidateError func() // FIXME NOT-USED - - // OnIceGatheringStateChange func() // FIXME NOT-USED - // OnConnectionStateChange func() // FIXME NOT-USED - - onSignalingStateChangeHandler func(RTCSignalingState) - onICEConnectionStateChangeHandler func(ice.ConnectionState) - onTrackHandler func(*RTCTrack) - onDataChannelHandler func(*RTCDataChannel) - - // Deprecated: Internal mechanism which will be removed. - networkManager *network.Manager -} - -// New creates a new RTCPeerConfiguration with the provided configuration -func New(configuration RTCConfiguration) (*RTCPeerConnection, error) { - // https://w3c.github.io/webrtc-pc/#constructor (Step #2) - // Some variables defined explicitly despite their implicit zero values to - // allow better readability to understand what is happening. - pc := RTCPeerConnection{ - configuration: RTCConfiguration{ - IceServers: []RTCIceServer{}, - IceTransportPolicy: RTCIceTransportPolicyAll, - BundlePolicy: RTCBundlePolicyBalanced, - RtcpMuxPolicy: RTCRtcpMuxPolicyRequire, - Certificates: []RTCCertificate{}, - IceCandidatePoolSize: 0, - }, - isClosed: false, - negotiationNeeded: false, - lastOffer: "", - lastAnswer: "", - SignalingState: RTCSignalingStateStable, - // IceConnectionState: RTCIceConnectionStateNew, // FIXME SWAP-FOR-THIS - IceConnectionState: ice.ConnectionStateNew, // FIXME REMOVE - IceGatheringState: RTCIceGatheringStateNew, - ConnectionState: RTCPeerConnectionStateNew, - mediaEngine: DefaultMediaEngine, - sctpTransport: newRTCSctpTransport(), - dataChannels: make(map[uint16]*RTCDataChannel), - } - - var err error - if err = pc.initConfiguration(configuration); err != nil { - return nil, err - } - - var urls []*ice.URL - for _, server := range pc.configuration.IceServers { - for _, rawURL := range server.URLs { - var url *ice.URL - url, err = ice.ParseURL(rawURL) - if err != nil { - return nil, err - } - - urls = append(urls, url) - } - } - - pc.networkManager = network.NewManager(urls, pc.generateChannel, pc.iceStateChange) - - return &pc, nil -} - -// initConfiguration defines validation of the specified RTCConfiguration and -// its assignment to the internal configuration variable. This function differs -// from its SetConfiguration counterpart because most of the checks do not -// include verification statements related to the existing state. Thus the -// function describes only minor verification of some the struct variables. -func (pc *RTCPeerConnection) initConfiguration(configuration RTCConfiguration) error { - if configuration.PeerIdentity != "" { - pc.configuration.PeerIdentity = configuration.PeerIdentity - } - - // https://www.w3.org/TR/webrtc/#constructor (step #3) - if len(configuration.Certificates) > 0 { - now := time.Now() - for _, x509Cert := range configuration.Certificates { - if !x509Cert.Expires().IsZero() && now.After(x509Cert.Expires()) { - return &rtcerr.InvalidAccessError{Err: ErrCertificateExpired} - } - pc.configuration.Certificates = append(pc.configuration.Certificates, x509Cert) - } - } else { - sk, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) - if err != nil { - return &rtcerr.UnknownError{Err: err} - } - certificate, err := GenerateCertificate(sk) - if err != nil { - return err - } - pc.configuration.Certificates = []RTCCertificate{*certificate} - } - - if configuration.BundlePolicy != RTCBundlePolicy(Unknown) { - pc.configuration.BundlePolicy = configuration.BundlePolicy - } - - if configuration.RtcpMuxPolicy != RTCRtcpMuxPolicy(Unknown) { - pc.configuration.RtcpMuxPolicy = configuration.RtcpMuxPolicy - } - - if configuration.IceCandidatePoolSize != 0 { - pc.configuration.IceCandidatePoolSize = configuration.IceCandidatePoolSize - } - - if configuration.IceTransportPolicy != RTCIceTransportPolicy(Unknown) { - pc.configuration.IceTransportPolicy = configuration.IceTransportPolicy - } - - if len(configuration.IceServers) > 0 { - for _, server := range configuration.IceServers { - if err := server.validate(); err != nil { - return err - } - } - pc.configuration.IceServers = configuration.IceServers - } - return nil -} - -// OnSignalingStateChange sets an event handler which is invoked when the -// peer connection's signaling state changes -func (pc *RTCPeerConnection) OnSignalingStateChange(f func(RTCSignalingState)) { - pc.Lock() - defer pc.Unlock() - pc.onSignalingStateChangeHandler = f -} - -func (pc *RTCPeerConnection) onSignalingStateChange(newState RTCSignalingState) (done chan struct{}) { - pc.RLock() - hdlr := pc.onSignalingStateChangeHandler - pc.RUnlock() - - done = make(chan struct{}) - if hdlr == nil { - close(done) - return - } - - go func() { - hdlr(newState) - close(done) - }() - - return -} - -// OnDataChannel sets an event handler which is invoked when a data -// channel message arrives from a remote peer. -func (pc *RTCPeerConnection) OnDataChannel(f func(*RTCDataChannel)) { - pc.Lock() - defer pc.Unlock() - pc.onDataChannelHandler = f -} - -func (pc *RTCPeerConnection) onDataChannel(dc *RTCDataChannel) (done chan struct{}) { - pc.RLock() - hdlr := pc.onDataChannelHandler - pc.RUnlock() - - done = make(chan struct{}) - if hdlr == nil || dc == nil { - close(done) - return - } - - // Run this synchronously to allow setup done in onDataChannelFn() - // to complete before datachannel event handlers might be called. - go func() { - hdlr(dc) - close(done) - }() - - return -} - -// OnTrack sets an event handler which is called when remote track -// arrives from a remote peer. -func (pc *RTCPeerConnection) OnTrack(f func(*RTCTrack)) { - pc.Lock() - defer pc.Unlock() - pc.onTrackHandler = f -} - -func (pc *RTCPeerConnection) onTrack(t *RTCTrack) (done chan struct{}) { - pc.RLock() - hdlr := pc.onTrackHandler - pc.RUnlock() - - done = make(chan struct{}) - if hdlr == nil || t == nil { - close(done) - return - } - - go func() { - hdlr(t) - close(done) - }() - - return -} - -// OnICEConnectionStateChange sets an event handler which is called -// when an ICE connection state is changed. -func (pc *RTCPeerConnection) OnICEConnectionStateChange(f func(ice.ConnectionState)) { - pc.Lock() - defer pc.Unlock() - pc.onICEConnectionStateChangeHandler = f -} - -func (pc *RTCPeerConnection) onICEConnectionStateChange(cs ice.ConnectionState) (done chan struct{}) { - pc.RLock() - hdlr := pc.onICEConnectionStateChangeHandler - pc.RUnlock() - - done = make(chan struct{}) - if hdlr == nil { - close(done) - return - } - - go func() { - hdlr(cs) - close(done) - }() - - return -} - -// SetConfiguration updates the configuration of this RTCPeerConnection object. -func (pc *RTCPeerConnection) SetConfiguration(configuration RTCConfiguration) error { - // https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-setconfiguration (step #2) - if pc.isClosed { - return &rtcerr.InvalidStateError{Err: ErrConnectionClosed} - } - - // https://www.w3.org/TR/webrtc/#set-the-configuration (step #3) - if configuration.PeerIdentity != "" { - if configuration.PeerIdentity != pc.configuration.PeerIdentity { - return &rtcerr.InvalidModificationError{Err: ErrModifyingPeerIdentity} - } - pc.configuration.PeerIdentity = configuration.PeerIdentity - } - - // https://www.w3.org/TR/webrtc/#set-the-configuration (step #4) - if len(configuration.Certificates) > 0 { - if len(configuration.Certificates) != len(pc.configuration.Certificates) { - return &rtcerr.InvalidModificationError{Err: ErrModifyingCertificates} - } - - for i, certificate := range configuration.Certificates { - if !pc.configuration.Certificates[i].Equals(certificate) { - return &rtcerr.InvalidModificationError{Err: ErrModifyingCertificates} - } - } - pc.configuration.Certificates = configuration.Certificates - } - - // https://www.w3.org/TR/webrtc/#set-the-configuration (step #5) - if configuration.BundlePolicy != RTCBundlePolicy(Unknown) { - if configuration.BundlePolicy != pc.configuration.BundlePolicy { - return &rtcerr.InvalidModificationError{Err: ErrModifyingBundlePolicy} - } - pc.configuration.BundlePolicy = configuration.BundlePolicy - } - - // https://www.w3.org/TR/webrtc/#set-the-configuration (step #6) - if configuration.RtcpMuxPolicy != RTCRtcpMuxPolicy(Unknown) { - if configuration.RtcpMuxPolicy != pc.configuration.RtcpMuxPolicy { - return &rtcerr.InvalidModificationError{Err: ErrModifyingRtcpMuxPolicy} - } - pc.configuration.RtcpMuxPolicy = configuration.RtcpMuxPolicy - } - - // https://www.w3.org/TR/webrtc/#set-the-configuration (step #7) - if configuration.IceCandidatePoolSize != 0 { - if pc.configuration.IceCandidatePoolSize != configuration.IceCandidatePoolSize && - pc.LocalDescription() != nil { - return &rtcerr.InvalidModificationError{Err: ErrModifyingIceCandidatePoolSize} - } - pc.configuration.IceCandidatePoolSize = configuration.IceCandidatePoolSize - } - - // https://www.w3.org/TR/webrtc/#set-the-configuration (step #8) - if configuration.IceTransportPolicy != RTCIceTransportPolicy(Unknown) { - pc.configuration.IceTransportPolicy = configuration.IceTransportPolicy - } - - // https://www.w3.org/TR/webrtc/#set-the-configuration (step #11) - if len(configuration.IceServers) > 0 { - // https://www.w3.org/TR/webrtc/#set-the-configuration (step #11.3) - for _, server := range configuration.IceServers { - if err := server.validate(); err != nil { - return err - } - } - pc.configuration.IceServers = configuration.IceServers - } - return nil -} - -// GetConfiguration returns an RTCConfiguration object representing the current -// configuration of this RTCPeerConnection object. The returned object is a -// copy and direct mutation on it will not take affect until SetConfiguration -// has been called with RTCConfiguration passed as its only argument. -// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-getconfiguration -func (pc *RTCPeerConnection) GetConfiguration() RTCConfiguration { - return pc.configuration -} - -// ------------------------------------------------------------------------ -// --- FIXME - BELOW CODE NEEDS REVIEW/CLEANUP -// ------------------------------------------------------------------------ - -// CreateOffer starts the RTCPeerConnection and generates the localDescription -func (pc *RTCPeerConnection) CreateOffer(options *RTCOfferOptions) (RTCSessionDescription, error) { - useIdentity := pc.idpLoginURL != nil - if options != nil { - return RTCSessionDescription{}, errors.Errorf("TODO handle options") - } else if useIdentity { - return RTCSessionDescription{}, errors.Errorf("TODO handle identity provider") - } else if pc.isClosed { - return RTCSessionDescription{}, &rtcerr.InvalidStateError{Err: ErrConnectionClosed} - } - - d := sdp.NewJSEPSessionDescription(useIdentity) - pc.addFingerprint(d) - candidates, err := pc.generateLocalCandidates() - if err != nil { - return RTCSessionDescription{}, err - } - - bundleValue := "BUNDLE" - - if pc.addRTPMediaSection(d, RTCRtpCodecTypeAudio, "audio", RTCRtpTransceiverDirectionSendrecv, candidates, sdp.ConnectionRoleActpass) { - bundleValue += " audio" - } - if pc.addRTPMediaSection(d, RTCRtpCodecTypeVideo, "video", RTCRtpTransceiverDirectionSendrecv, candidates, sdp.ConnectionRoleActpass) { - bundleValue += " video" - } - - pc.addDataMediaSection(d, "data", candidates, sdp.ConnectionRoleActpass) - d = d.WithValueAttribute(sdp.AttrKeyGroup, bundleValue+" data") - - for _, m := range d.MediaDescriptions { - m.WithPropertyAttribute("setup:actpass") - } - - desc := RTCSessionDescription{ - Type: RTCSdpTypeOffer, - Sdp: d.Marshal(), - parsed: d, - } - pc.lastOffer = desc.Sdp - - // FIXME: This doesn't follow the JS API spec, but removing it - // would mean our examples and existing code have to change - if err := pc.SetLocalDescription(desc); err != nil { - return RTCSessionDescription{}, err - } - return desc, nil -} - -// CreateAnswer starts the RTCPeerConnection and generates the localDescription -func (pc *RTCPeerConnection) CreateAnswer(options *RTCAnswerOptions) (RTCSessionDescription, error) { - useIdentity := pc.idpLoginURL != nil - if options != nil { - return RTCSessionDescription{}, errors.Errorf("TODO handle options") - } else if useIdentity { - return RTCSessionDescription{}, errors.Errorf("TODO handle identity provider") - } else if pc.isClosed { - return RTCSessionDescription{}, &rtcerr.InvalidStateError{Err: ErrConnectionClosed} - } - - candidates, err := pc.generateLocalCandidates() - if err != nil { - return RTCSessionDescription{}, err - } - d := sdp.NewJSEPSessionDescription(useIdentity) - pc.addFingerprint(d) - - bundleValue := "BUNDLE" - for _, remoteMedia := range pc.RemoteDescription().parsed.MediaDescriptions { - // TODO @trivigy better SDP parser - var peerDirection RTCRtpTransceiverDirection - midValue := "" - for _, a := range remoteMedia.Attributes { - if strings.HasPrefix(*a.String(), "mid") { - midValue = (*a.String())[len("mid:"):] - } else if strings.HasPrefix(*a.String(), "sendrecv") { - peerDirection = RTCRtpTransceiverDirectionSendrecv - } else if strings.HasPrefix(*a.String(), "sendonly") { - peerDirection = RTCRtpTransceiverDirectionSendonly - } else if strings.HasPrefix(*a.String(), "recvonly") { - peerDirection = RTCRtpTransceiverDirectionRecvonly - } - } - - appendBundle := func() { - bundleValue += " " + midValue - } - - if strings.HasPrefix(*remoteMedia.MediaName.String(), "audio") { - if pc.addRTPMediaSection(d, RTCRtpCodecTypeAudio, midValue, peerDirection, candidates, sdp.ConnectionRoleActive) { - appendBundle() - } - } else if strings.HasPrefix(*remoteMedia.MediaName.String(), "video") { - if pc.addRTPMediaSection(d, RTCRtpCodecTypeVideo, midValue, peerDirection, candidates, sdp.ConnectionRoleActive) { - appendBundle() - } - } else if strings.HasPrefix(*remoteMedia.MediaName.String(), "application") { - pc.addDataMediaSection(d, midValue, candidates, sdp.ConnectionRoleActive) - appendBundle() - } - } - - d = d.WithValueAttribute(sdp.AttrKeyGroup, bundleValue) - - desc := RTCSessionDescription{ - Type: RTCSdpTypeAnswer, - Sdp: d.Marshal(), - parsed: d, - } - pc.lastAnswer = desc.Sdp - - // FIXME: This doesn't follow the JS API spec, but removing it - // would mean our examples and existing code have to change - if err := pc.SetLocalDescription(desc); err != nil { - return RTCSessionDescription{}, err - } - return desc, nil -} - -// 4.4.1.6 Set the RTCSessionDescription -func (pc *RTCPeerConnection) setDescription(sd *RTCSessionDescription, op rtcStateChangeOp) error { - if pc.isClosed { - return &rtcerr.InvalidStateError{Err: ErrConnectionClosed} - } - - cur := pc.SignalingState - setLocal := rtcStateChangeOpSetLocal - setRemote := rtcStateChangeOpSetRemote - newSdpDoesNotMatchOffer := &rtcerr.InvalidModificationError{Err: errors.New("New sdp does not match previous offer")} - newSdpDoesNotMatchAnswer := &rtcerr.InvalidModificationError{Err: errors.New("New sdp does not match previous answer")} - - var nextState RTCSignalingState - var err error - switch op { - case setLocal: - switch sd.Type { - // stable->SetLocal(offer)->have-local-offer - case RTCSdpTypeOffer: - if sd.Sdp != pc.lastOffer { - return newSdpDoesNotMatchOffer - } - nextState, err = checkNextSignalingState(cur, RTCSignalingStateHaveLocalOffer, setLocal, sd.Type) - if err == nil { - pc.PendingLocalDescription = sd - } - // have-remote-offer->SetLocal(answer)->stable - // have-local-pranswer->SetLocal(answer)->stable - case RTCSdpTypeAnswer: - if sd.Sdp != pc.lastAnswer { - return newSdpDoesNotMatchAnswer - } - nextState, err = checkNextSignalingState(cur, RTCSignalingStateStable, setLocal, sd.Type) - if err == nil { - pc.CurrentLocalDescription = sd - pc.CurrentRemoteDescription = pc.PendingRemoteDescription - pc.PendingRemoteDescription = nil - pc.PendingLocalDescription = nil - } - case RTCSdpTypeRollback: - nextState, err = checkNextSignalingState(cur, RTCSignalingStateStable, setLocal, sd.Type) - if err == nil { - pc.PendingLocalDescription = nil - } - // have-remote-offer->SetLocal(pranswer)->have-local-pranswer - case RTCSdpTypePranswer: - if sd.Sdp != pc.lastAnswer { - return newSdpDoesNotMatchAnswer - } - nextState, err = checkNextSignalingState(cur, RTCSignalingStateHaveLocalPranswer, setLocal, sd.Type) - if err == nil { - pc.PendingLocalDescription = sd - } - default: - return &rtcerr.OperationError{Err: fmt.Errorf("Invalid state change op: %s(%s)", op, sd.Type)} - } - case setRemote: - switch sd.Type { - // stable->SetRemote(offer)->have-remote-offer - case RTCSdpTypeOffer: - nextState, err = checkNextSignalingState(cur, RTCSignalingStateHaveRemoteOffer, setRemote, sd.Type) - if err == nil { - pc.PendingRemoteDescription = sd - } - // have-local-offer->SetRemote(answer)->stable - // have-remote-pranswer->SetRemote(answer)->stable - case RTCSdpTypeAnswer: - nextState, err = checkNextSignalingState(cur, RTCSignalingStateStable, setRemote, sd.Type) - if err == nil { - pc.CurrentRemoteDescription = sd - pc.CurrentLocalDescription = pc.PendingLocalDescription - pc.PendingRemoteDescription = nil - pc.PendingLocalDescription = nil - } - case RTCSdpTypeRollback: - nextState, err = checkNextSignalingState(cur, RTCSignalingStateStable, setRemote, sd.Type) - if err == nil { - pc.PendingRemoteDescription = nil - } - // have-local-offer->SetRemote(pranswer)->have-remote-pranswer - case RTCSdpTypePranswer: - nextState, err = checkNextSignalingState(cur, RTCSignalingStateHaveRemotePranswer, setRemote, sd.Type) - if err == nil { - pc.PendingRemoteDescription = sd - } - default: - return &rtcerr.OperationError{Err: fmt.Errorf("Invalid state change op: %s(%s)", op, sd.Type)} - } - default: - return &rtcerr.OperationError{Err: fmt.Errorf("Unhandled state change op: %q", op)} - } - - if err == nil { - pc.SignalingState = nextState - pc.onSignalingStateChange(nextState) - } - return err -} - -// SetLocalDescription sets the SessionDescription of the local peer -func (pc *RTCPeerConnection) SetLocalDescription(desc RTCSessionDescription) error { - if pc.isClosed { - return &rtcerr.InvalidStateError{Err: ErrConnectionClosed} - } - - // JSEP 5.4 - if desc.Sdp == "" { - switch desc.Type { - case RTCSdpTypeAnswer, RTCSdpTypePranswer: - desc.Sdp = pc.lastAnswer - case RTCSdpTypeOffer: - desc.Sdp = pc.lastOffer - default: - return &rtcerr.InvalidModificationError{ - Err: fmt.Errorf("Invalid SDP type supplied to SetLocalDescription(): %s", desc.Type), - } - } - } - - // TODO: Initiate ICE candidate gathering? - - desc.parsed = &sdp.SessionDescription{} - if err := desc.parsed.Unmarshal(desc.Sdp); err != nil { - return err - } - return pc.setDescription(&desc, rtcStateChangeOpSetLocal) -} - -// LocalDescription returns PendingLocalDescription if it is not null and -// otherwise it returns CurrentLocalDescription. This property is used to -// determine if setLocalDescription has already been called. -// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-localdescription -func (pc *RTCPeerConnection) LocalDescription() *RTCSessionDescription { - if pc.PendingLocalDescription != nil { - return pc.PendingLocalDescription - } - return pc.CurrentLocalDescription -} - -// SetRemoteDescription sets the SessionDescription of the remote peer -func (pc *RTCPeerConnection) SetRemoteDescription(desc RTCSessionDescription) error { - // FIXME: Remove this when renegotiation is supported - if pc.CurrentRemoteDescription != nil { - return errors.Errorf("remoteDescription is already defined, SetRemoteDescription can only be called once") - } - if pc.isClosed { - return &rtcerr.InvalidStateError{Err: ErrConnectionClosed} - } - - desc.parsed = &sdp.SessionDescription{} - if err := desc.parsed.Unmarshal(desc.Sdp); err != nil { - return err - } - if err := pc.setDescription(&desc, rtcStateChangeOpSetRemote); err != nil { - return err - } - - weOffer := true - remoteUfrag := "" - remotePwd := "" - if desc.Type == RTCSdpTypeOffer { - weOffer = false - } - - for _, m := range pc.RemoteDescription().parsed.MediaDescriptions { - for _, a := range m.Attributes { - if strings.HasPrefix(*a.String(), "candidate") { - c, err := sdp.ICECandidateUnmarshal(*a.String()) - if err != nil { - return err - } - - if err := pc.networkManager.IceAgent.AddRemoteCandidate(c); err != nil { - return err - } - } else if strings.HasPrefix(*a.String(), "ice-ufrag") { - remoteUfrag = (*a.String())[len("ice-ufrag:"):] - } else if strings.HasPrefix(*a.String(), "ice-pwd") { - remotePwd = (*a.String())[len("ice-pwd:"):] - } - } - } - - fingerprint, ok := desc.parsed.Attribute("fingerprint") - if !ok { - fingerprint, ok = desc.parsed.MediaDescriptions[0].Attribute("fingerprint") - if !ok { - return errors.New("could not find fingerprint") - } - } - var fingerprintHash string - parts := strings.Split(fingerprint, " ") - if len(parts) != 2 { - return errors.New("invalid fingerprint") - } - fingerprint = parts[1] - fingerprintHash = parts[0] - - go func() { - cert := pc.configuration.Certificates[0] // TODO: handle multiple certs - err := pc.networkManager.Start(weOffer, - remoteUfrag, remotePwd, - cert.x509Cert, cert.privateKey, fingerprint, fingerprintHash) - if err != nil { - fmt.Println("Failed to start manager", err) - } - - // Temporary data channel glue - pc.openDataChannels() - pc.acceptDataChannels() - }() - - return nil -} - -// openDataChannels opens the existing data channels -// TODO: Move to RTCDataChannel -func (pc *RTCPeerConnection) openDataChannels() { - pc.RLock() - defer pc.RUnlock() - for _, rtcDC := range pc.dataChannels { - dc, err := pc.networkManager.OpenDataChannel( - *rtcDC.ID, - &datachannel.Config{ - ChannelType: datachannel.ChannelTypeReliable, // TODO: Wiring - Priority: datachannel.ChannelPriorityNormal, // TODO: Wiring - ReliabilityParameter: 0, // TODO: Wiring - Label: rtcDC.Label, - }) - if err != nil { - fmt.Println("failed to open data channel", err) - continue - } - rtcDC.ReadyState = RTCDataChannelStateOpen - rtcDC.handleOpen(dc) - } -} - -// acceptDataChannels accepts data channels -// TODO: Move to RTCSctpTransport -func (pc *RTCPeerConnection) acceptDataChannels() { - for { - dc, err := pc.networkManager.AcceptDataChannel() - if err != nil { - fmt.Println("Failed to accept data channel:", err) - // TODO: Kill DataChannel/PeerConnection? - return - } - - sid := dc.StreamIdentifier() - rtcDC := &RTCDataChannel{ - ID: &sid, - Label: dc.Config.Label, - rtcPeerConnection: pc, - ReadyState: RTCDataChannelStateOpen, - } - - pc.Lock() - pc.dataChannels[sid] = rtcDC - pc.Unlock() - - <-pc.onDataChannel(rtcDC) - rtcDC.handleOpen(dc) - } -} - -// RemoteDescription returns PendingRemoteDescription if it is not null and -// otherwise it returns CurrentRemoteDescription. This property is used to -// determine if setRemoteDescription has already been called. -// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-remotedescription -func (pc *RTCPeerConnection) RemoteDescription() *RTCSessionDescription { - if pc.PendingRemoteDescription != nil { - return pc.PendingRemoteDescription - } - return pc.CurrentRemoteDescription -} - -// AddIceCandidate accepts an ICE candidate string and adds it -// to the existing set of candidates -func (pc *RTCPeerConnection) AddIceCandidate(s string) error { - c, err := sdp.ICECandidateUnmarshal(s) - if err != nil { - return err - } - - return pc.networkManager.IceAgent.AddRemoteCandidate(c) -} - -// ------------------------------------------------------------------------ -// --- FIXME - BELOW CODE NEEDS RE-ORGANIZATION - https://w3c.github.io/webrtc-pc/#rtp-media-api -// ------------------------------------------------------------------------ - -// GetSenders returns the RTCRtpSender that are currently attached to this RTCPeerConnection -func (pc *RTCPeerConnection) GetSenders() []RTCRtpSender { - result := make([]RTCRtpSender, len(pc.rtpTransceivers)) - for i, tranceiver := range pc.rtpTransceivers { - result[i] = *tranceiver.Sender - } - return result -} - -// GetReceivers returns the RTCRtpReceivers that are currently attached to this RTCPeerConnection -func (pc *RTCPeerConnection) GetReceivers() []RTCRtpReceiver { - result := make([]RTCRtpReceiver, len(pc.rtpTransceivers)) - for i, tranceiver := range pc.rtpTransceivers { - result[i] = *tranceiver.Receiver - } - return result -} - -// GetTransceivers returns the RTCRtpTransceiver that are currently attached to this RTCPeerConnection -func (pc *RTCPeerConnection) GetTransceivers() []RTCRtpTransceiver { - result := make([]RTCRtpTransceiver, len(pc.rtpTransceivers)) - for i, tranceiver := range pc.rtpTransceivers { - result[i] = *tranceiver - } - return result -} - -// AddTrack adds a RTCTrack to the RTCPeerConnection -func (pc *RTCPeerConnection) AddTrack(track *RTCTrack) (*RTCRtpSender, error) { - if pc.isClosed { - return nil, &rtcerr.InvalidStateError{Err: ErrConnectionClosed} - } - for _, transceiver := range pc.rtpTransceivers { - if transceiver.Sender.Track == nil { - continue - } - if track.ID == transceiver.Sender.Track.ID { - return nil, &rtcerr.InvalidAccessError{Err: ErrExistingTrack} - } - } - var transceiver *RTCRtpTransceiver - for _, t := range pc.rtpTransceivers { - if !t.stopped && - // t.Sender == nil && // TODO: check that the sender has never sent - t.Sender.Track == nil && - t.Receiver.Track != nil && - t.Receiver.Track.Kind == track.Kind { - transceiver = t - break - } - } - if transceiver != nil { - if err := transceiver.setSendingTrack(track); err != nil { - return nil, err - } - } else { - var receiver *RTCRtpReceiver - sender := newRTCRtpSender(track) - transceiver = pc.newRTCRtpTransceiver( - receiver, - sender, - RTCRtpTransceiverDirectionSendonly, - ) - } - - transceiver.Mid = track.Kind.String() // TODO: Mid generation - - return transceiver.Sender, nil -} - -// func (pc *RTCPeerConnection) RemoveTrack() { -// panic("not implemented yet") // FIXME NOT-IMPLEMENTED nolint -// } - -// func (pc *RTCPeerConnection) AddTransceiver() RTCRtpTransceiver { -// panic("not implemented yet") // FIXME NOT-IMPLEMENTED nolint -// } - -// ------------------------------------------------------------------------ -// --- FIXME - BELOW CODE NEEDS RE-ORGANIZATION - https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api -// ------------------------------------------------------------------------ - -// CreateDataChannel creates a new RTCDataChannel object with the given label -// and optitional RTCDataChannelInit used to configure properties of the -// underlying channel such as data reliability. -func (pc *RTCPeerConnection) CreateDataChannel(label string, options *RTCDataChannelInit) (*RTCDataChannel, error) { - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #2) - if pc.isClosed { - return nil, &rtcerr.InvalidStateError{Err: ErrConnectionClosed} - } - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #5) - if len(label) > 65535 { - return nil, &rtcerr.TypeError{Err: ErrStringSizeLimit} - } - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #3) - // Some variables defined explicitly despite their implicit zero values to - // allow better readability to understand what is happening. Additionally, - // some members are set to a non zero value default due to the default - // definitions in https://w3c.github.io/webrtc-pc/#dom-rtcdatachannelinit - // which are later overwriten by the options if any were specified. - channel := RTCDataChannel{ - rtcPeerConnection: pc, - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #4) - Label: label, - Ordered: true, - MaxPacketLifeTime: nil, - MaxRetransmits: nil, - Protocol: "", - Negotiated: false, - ID: nil, - Priority: RTCPriorityTypeLow, - // https://w3c.github.io/webrtc-pc/#dfn-create-an-rtcdatachannel (Step #2) - ReadyState: RTCDataChannelStateConnecting, - // https://w3c.github.io/webrtc-pc/#dfn-create-an-rtcdatachannel (Step #3) - BufferedAmount: 0, - } - - if options != nil { - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #7) - if options.MaxPacketLifeTime != nil { - channel.MaxPacketLifeTime = options.MaxPacketLifeTime - } - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #8) - if options.MaxRetransmits != nil { - channel.MaxRetransmits = options.MaxRetransmits - } - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #9) - if options.Ordered != nil { - channel.Ordered = *options.Ordered - } - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #10) - if options.Protocol != nil { - channel.Protocol = *options.Protocol - } - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-da ta-api (Step #12) - if options.Negotiated != nil { - channel.Negotiated = *options.Negotiated - } - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #13) - if options.ID != nil && channel.Negotiated { - channel.ID = options.ID - } - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #15) - if options.Priority != nil { - channel.Priority = *options.Priority - } - } - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #11) - if len(channel.Protocol) > 65535 { - return nil, &rtcerr.TypeError{Err: ErrStringSizeLimit} - } - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #14) - if channel.Negotiated && channel.ID == nil { - return nil, &rtcerr.TypeError{Err: ErrNegotiatedWithoutID} - } - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #16) - if channel.MaxPacketLifeTime != nil && channel.MaxRetransmits != nil { - return nil, &rtcerr.TypeError{Err: ErrRetransmitsOrPacketLifeTime} - } - - // FIXME https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createdatachannel (Step #17) - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #20) - channel.Transport = pc.sctpTransport - - // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #19) - if channel.ID == nil { - var err error - if channel.ID, err = pc.generateDataChannelID(true); err != nil { - return nil, err - } - // if err := channel.generateID(); err != nil { - // return nil, err - // } - } - - // // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #18) - if *channel.ID > 65534 { - return nil, &rtcerr.TypeError{Err: ErrMaxDataChannelID} - } - - if pc.sctpTransport.State == RTCSctpTransportStateConnected && - *channel.ID >= *pc.sctpTransport.MaxChannels { - return nil, &rtcerr.OperationError{Err: ErrMaxDataChannelID} - } - - // Remember datachannel - pc.dataChannels[*channel.ID] = &channel - - // Send opening message - // pc.networkManager.SendOpenChannelMessage(id, label) - - return &channel, nil -} - -func (pc *RTCPeerConnection) generateDataChannelID(client bool) (*uint16, error) { - var id uint16 - if !client { - id++ - } - - for ; id < *pc.sctpTransport.MaxChannels-1; id += 2 { - _, ok := pc.dataChannels[id] - if !ok { - return &id, nil - } - } - return nil, &rtcerr.OperationError{Err: ErrMaxDataChannelID} -} - -// SetMediaEngine allows overwriting the default media engine used by the RTCPeerConnection -// This enables RTCPeerConnection with support for different codecs -func (pc *RTCPeerConnection) SetMediaEngine(m *MediaEngine) { - pc.mediaEngine = m -} - -// SetIdentityProvider is used to configure an identity provider to generate identity assertions -func (pc *RTCPeerConnection) SetIdentityProvider(provider string) error { - return errors.Errorf("TODO SetIdentityProvider") -} - -// SendRTCP sends a user provided RTCP packet to the connected peer -// If no peer is connected the packet is discarded -func (pc *RTCPeerConnection) SendRTCP(pkt rtcp.Packet) error { - raw, err := pkt.Marshal() - if err != nil { - return err - } - pc.networkManager.SendRTCP(raw) - return nil -} - -// Close ends the RTCPeerConnection -func (pc *RTCPeerConnection) Close() error { - // https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #2) - if pc.isClosed { - return nil - } - - err := pc.networkManager.Close() - - // https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #3) - pc.isClosed = true - - // https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #4) - pc.SignalingState = RTCSignalingStateClosed - - // https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #11) - // pc.IceConnectionState = RTCIceConnectionStateClosed - pc.IceConnectionState = ice.ConnectionStateClosed // FIXME REMOVE - - // https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #12) - pc.ConnectionState = RTCPeerConnectionStateClosed - - return err -} - -/* Everything below is private */ -func (pc *RTCPeerConnection) generateChannel(ssrc uint32, payloadType uint8) (tpair *network.TransportPair) { - pc.RLock() - if pc.onTrackHandler == nil { - pc.RUnlock() - return nil - } - pc.RUnlock() - - sdpCodec, err := pc.CurrentLocalDescription.parsed.GetCodecForPayloadType(payloadType) - if err != nil { - fmt.Printf("No codec could be found in RemoteDescription for payloadType %d \n", payloadType) - return nil - } - - codec, err := pc.mediaEngine.getCodecSDP(sdpCodec) - if err != nil { - fmt.Printf("Codec %s in not registered\n", sdpCodec) - return nil - } - - rtpTransport := make(chan *rtp.Packet, 15) - rtcpTransport := make(chan rtcp.Packet, 15) - - track := &RTCTrack{ - PayloadType: payloadType, - Kind: codec.Type, - ID: "0", // TODO extract from remoteDescription - Label: "", // TODO extract from remoteDescription - Ssrc: ssrc, - Codec: codec, - Packets: rtpTransport, - RTCPPackets: rtcpTransport, - } - - // TODO: Register the receiving Track - - pc.onTrack(track) - return &network.TransportPair{RTP: rtpTransport, RTCP: rtcpTransport} -} - -func (pc *RTCPeerConnection) iceStateChange(newState ice.ConnectionState) { - pc.Lock() - pc.IceConnectionState = newState - pc.Unlock() - - pc.onICEConnectionStateChange(newState) -} - -func (pc *RTCPeerConnection) generateLocalCandidates() ([]string, error) { - candidates, err := pc.networkManager.IceAgent.GetLocalCandidates() - if err != nil { - return nil, err - } - - res := make([]string, 0) - for _, c := range candidates { - res = append(res, sdp.ICECandidateMarshal(c)...) - } - return res, nil -} - -func localDirection(weSend bool, peerDirection RTCRtpTransceiverDirection) RTCRtpTransceiverDirection { - theySend := (peerDirection == RTCRtpTransceiverDirectionSendrecv || peerDirection == RTCRtpTransceiverDirectionSendonly) - if weSend && theySend { - return RTCRtpTransceiverDirectionSendrecv - } else if weSend && !theySend { - return RTCRtpTransceiverDirectionSendonly - } else if !weSend && theySend { - return RTCRtpTransceiverDirectionRecvonly - } - - return RTCRtpTransceiverDirectionInactive -} - -func (pc *RTCPeerConnection) addFingerprint(d *sdp.SessionDescription) { - // TODO: Handle multiple certificates - for _, fingerprint := range pc.configuration.Certificates[0].GetFingerprints() { - d.WithFingerprint(fingerprint.Algorithm, strings.ToUpper(fingerprint.Value)) - } -} - -func (pc *RTCPeerConnection) addRTPMediaSection(d *sdp.SessionDescription, codecType RTCRtpCodecType, midValue string, peerDirection RTCRtpTransceiverDirection, candidates []string, dtlsRole sdp.ConnectionRole) bool { - if codecs := pc.mediaEngine.getCodecsByKind(codecType); len(codecs) == 0 { - return false - } - media := sdp.NewJSEPMediaDescription(codecType.String(), []string{}). - WithValueAttribute(sdp.AttrKeyConnectionSetup, dtlsRole.String()). // TODO: Support other connection types - WithValueAttribute(sdp.AttrKeyMID, midValue). - WithICECredentials(pc.networkManager.IceAgent.GetLocalUserCredentials()). - WithPropertyAttribute(sdp.AttrKeyRtcpMux). // TODO: support RTCP fallback - WithPropertyAttribute(sdp.AttrKeyRtcpRsize) // TODO: Support Reduced-Size RTCP? - - for _, codec := range pc.mediaEngine.getCodecsByKind(codecType) { - media.WithCodec(codec.PayloadType, codec.Name, codec.ClockRate, codec.Channels, codec.SdpFmtpLine) - } - - weSend := false - for _, transceiver := range pc.rtpTransceivers { - if transceiver.Sender == nil || - transceiver.Sender.Track == nil || - transceiver.Sender.Track.Kind != codecType { - continue - } - weSend = true - track := transceiver.Sender.Track - media = media.WithMediaSource(track.Ssrc, track.Label /* cname */, track.Label /* streamLabel */, track.Label) - } - media = media.WithPropertyAttribute(localDirection(weSend, peerDirection).String()) - - for _, c := range candidates { - media.WithCandidate(c) - } - media.WithPropertyAttribute("end-of-candidates") - d.WithMedia(media) - return true -} - -func (pc *RTCPeerConnection) addDataMediaSection(d *sdp.SessionDescription, midValue string, candidates []string, dtlsRole sdp.ConnectionRole) { - media := (&sdp.MediaDescription{ - MediaName: sdp.MediaName{ - Media: "application", - Port: sdp.RangedPort{Value: 9}, - Protos: []string{"DTLS", "SCTP"}, - Formats: []string{"5000"}, - }, - ConnectionInformation: &sdp.ConnectionInformation{ - NetworkType: "IN", - AddressType: "IP4", - Address: &sdp.Address{ - IP: net.ParseIP("0.0.0.0"), - }, - }, - }). - WithValueAttribute(sdp.AttrKeyConnectionSetup, dtlsRole.String()). // TODO: Support other connection types - WithValueAttribute(sdp.AttrKeyMID, midValue). - WithPropertyAttribute(RTCRtpTransceiverDirectionSendrecv.String()). - WithPropertyAttribute("sctpmap:5000 webrtc-datachannel 1024"). - WithICECredentials(pc.networkManager.IceAgent.GetLocalUserCredentials()) - - for _, c := range candidates { - media.WithCandidate(c) - } - media.WithPropertyAttribute("end-of-candidates") - - d.WithMedia(media) -} - -func (pc *RTCPeerConnection) newRTCTrack(payloadType uint8, ssrc uint32, id, label string) (*RTCTrack, error) { - codec, err := pc.mediaEngine.getCodec(payloadType) - if err != nil { - return nil, err - } - - if codec.Payloader == nil { - return nil, errors.New("codec payloader not set") - } - - trackInput := make(chan media.RTCSample, 15) // Is the buffering needed? - rawPackets := make(chan *rtp.Packet) - rtcpPackets := make(chan rtcp.Packet) - if ssrc == 0 { - buf := make([]byte, 4) - _, err = rand.Read(buf) - if err != nil { - return nil, errors.New("failed to generate random value") - } - ssrc = binary.LittleEndian.Uint32(buf) - - go func() { - packetizer := rtp.NewPacketizer( - 1400, - payloadType, - ssrc, - codec.Payloader, - rtp.NewRandomSequencer(), - codec.ClockRate, - ) - - for { - in := <-trackInput - packets := packetizer.Packetize(in.Data, in.Samples) - for _, p := range packets { - pc.networkManager.SendRTP(p) - } - } - }() - close(rawPackets) - } else { - // If SSRC is not 0, then we are working with an established RTP stream - // and need to accept raw RTP packets for forwarding. - go func() { - for { - p := <-rawPackets - pc.networkManager.SendRTP(p) - } - }() - close(trackInput) - } - - t := &RTCTrack{ - PayloadType: payloadType, - Kind: codec.Type, - ID: id, - Label: label, - Ssrc: ssrc, - Codec: codec, - RTCPPackets: rtcpPackets, - Samples: trackInput, - RawRTP: rawPackets, - } - - pc.networkManager.AddTransportPair(ssrc, nil, rtcpPackets) - - return t, nil -} - -// NewRawRTPTrack initializes a new *RTCTrack configured to accept raw *rtp.Packet -// -// NB: If the source RTP stream is being broadcast to multiple tracks, each track -// must receive its own copies of the source packets in order to avoid packet corruption. -func (pc *RTCPeerConnection) NewRawRTPTrack(payloadType uint8, ssrc uint32, id, label string) (*RTCTrack, error) { - if ssrc == 0 { - return nil, errors.New("SSRC supplied to NewRawRTPTrack() must be non-zero") - } - return pc.newRTCTrack(payloadType, ssrc, id, label) -} - -// NewRTCSampleTrack initializes a new *RTCTrack configured to accept media.RTCSample -func (pc *RTCPeerConnection) NewRTCSampleTrack(payloadType uint8, id, label string) (*RTCTrack, error) { - return pc.newRTCTrack(payloadType, 0, id, label) -} - -// NewRTCTrack is used to create a new RTCTrack -// -// Deprecated: Use NewRTCSampleTrack() instead -func (pc *RTCPeerConnection) NewRTCTrack(payloadType uint8, id, label string) (*RTCTrack, error) { - return pc.NewRTCSampleTrack(payloadType, id, label) -} - -func (pc *RTCPeerConnection) newRTCRtpTransceiver( - receiver *RTCRtpReceiver, - sender *RTCRtpSender, - direction RTCRtpTransceiverDirection, -) *RTCRtpTransceiver { - - t := &RTCRtpTransceiver{ - Receiver: receiver, - Sender: sender, - Direction: direction, - } - pc.rtpTransceivers = append(pc.rtpTransceivers, t) - return t -} diff --git a/vendor/github.com/pions/webrtc/rtcpeerconnectionstate.go b/vendor/github.com/pions/webrtc/rtcpeerconnectionstate.go deleted file mode 100644 index 084920e..0000000 --- a/vendor/github.com/pions/webrtc/rtcpeerconnectionstate.go +++ /dev/null @@ -1,83 +0,0 @@ -package webrtc - -// RTCPeerConnectionState indicates the state of the RTCPeerConnection. -type RTCPeerConnectionState int - -const ( - // RTCPeerConnectionStateNew indicates that any of the RTCIceTransports or - // RTCDtlsTransports are in the "new" state and none of the transports are - // in the "connecting", "checking", "failed" or "disconnected" state, or - // all transports are in the "closed" state, or there are no transports. - RTCPeerConnectionStateNew RTCPeerConnectionState = iota + 1 - - // RTCPeerConnectionStateConnecting indicates that any of the - // RTCIceTransports or RTCDtlsTransports are in the "connecting" or - // "checking" state and none of them is in the "failed" state. - RTCPeerConnectionStateConnecting - - // RTCPeerConnectionStateConnected indicates that all RTCIceTransports and - // RTCDtlsTransports are in the "connected", "completed" or "closed" state - // and at least one of them is in the "connected" or "completed" state. - RTCPeerConnectionStateConnected - - // RTCPeerConnectionStateDisconnected indicates that any of the - // RTCIceTransports or RTCDtlsTransports are in the "disconnected" state - // and none of them are in the "failed" or "connecting" or "checking" state. - RTCPeerConnectionStateDisconnected - - // RTCPeerConnectionStateFailed indicates that any of the RTCIceTransports - // or RTCDtlsTransports are in a "failed" state. - RTCPeerConnectionStateFailed - - // RTCPeerConnectionStateClosed indicates the peer connection is closed - // and the isClosed member variable of RTCPeerConnection is true. - RTCPeerConnectionStateClosed -) - -// This is done this way because of a linter. -const ( - rtcPeerConnectionStateNewStr = "new" - rtcPeerConnectionStateConnectingStr = "connecting" - rtcPeerConnectionStateConnectedStr = "connected" - rtcPeerConnectionStateDisconnectedStr = "disconnected" - rtcPeerConnectionStateFailedStr = "failed" - rtcPeerConnectionStateClosedStr = "closed" -) - -func newRTCPeerConnectionState(raw string) RTCPeerConnectionState { - switch raw { - case rtcPeerConnectionStateNewStr: - return RTCPeerConnectionStateNew - case rtcPeerConnectionStateConnectingStr: - return RTCPeerConnectionStateConnecting - case rtcPeerConnectionStateConnectedStr: - return RTCPeerConnectionStateConnected - case rtcPeerConnectionStateDisconnectedStr: - return RTCPeerConnectionStateDisconnected - case rtcPeerConnectionStateFailedStr: - return RTCPeerConnectionStateFailed - case rtcPeerConnectionStateClosedStr: - return RTCPeerConnectionStateClosed - default: - return RTCPeerConnectionState(Unknown) - } -} - -func (t RTCPeerConnectionState) String() string { - switch t { - case RTCPeerConnectionStateNew: - return rtcPeerConnectionStateNewStr - case RTCPeerConnectionStateConnecting: - return rtcPeerConnectionStateConnectingStr - case RTCPeerConnectionStateConnected: - return rtcPeerConnectionStateConnectedStr - case RTCPeerConnectionStateDisconnected: - return rtcPeerConnectionStateDisconnectedStr - case RTCPeerConnectionStateFailed: - return rtcPeerConnectionStateFailedStr - case RTCPeerConnectionStateClosed: - return rtcPeerConnectionStateClosedStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtcprioritytype.go b/vendor/github.com/pions/webrtc/rtcprioritytype.go deleted file mode 100644 index 5466c73..0000000 --- a/vendor/github.com/pions/webrtc/rtcprioritytype.go +++ /dev/null @@ -1,71 +0,0 @@ -package webrtc - -// RTCPriorityType determines the priority type of a data channel. -type RTCPriorityType int - -const ( - // RTCPriorityTypeVeryLow corresponds to "below normal". - RTCPriorityTypeVeryLow RTCPriorityType = iota + 1 - - // RTCPriorityTypeLow corresponds to "normal". - RTCPriorityTypeLow - - // RTCPriorityTypeMedium corresponds to "high". - RTCPriorityTypeMedium - - // RTCPriorityTypeHigh corresponds to "extra high". - RTCPriorityTypeHigh -) - -// This is done this way because of a linter. -const ( - rtcPriorityTypeVeryLowStr = "very-low" - rtcPriorityTypeLowStr = "low" - rtcPriorityTypeMediumStr = "medium" - rtcPriorityTypeHighStr = "high" -) - -func newRTCPriorityTypeFromString(raw string) RTCPriorityType { - switch raw { - case rtcPriorityTypeVeryLowStr: - return RTCPriorityTypeVeryLow - case rtcPriorityTypeLowStr: - return RTCPriorityTypeLow - case rtcPriorityTypeMediumStr: - return RTCPriorityTypeMedium - case rtcPriorityTypeHighStr: - return RTCPriorityTypeHigh - default: - return RTCPriorityType(Unknown) - } -} - -func newRTCPriorityTypeFromUint16(raw uint16) RTCPriorityType { - switch { - case raw <= 128: - return RTCPriorityTypeVeryLow - case 129 <= raw && raw <= 256: - return RTCPriorityTypeLow - case 257 <= raw && raw <= 512: - return RTCPriorityTypeMedium - case 513 <= raw: - return RTCPriorityTypeHigh - default: - return RTCPriorityType(Unknown) - } -} - -func (p RTCPriorityType) String() string { - switch p { - case RTCPriorityTypeVeryLow: - return rtcPriorityTypeVeryLowStr - case RTCPriorityTypeLow: - return rtcPriorityTypeLowStr - case RTCPriorityTypeMedium: - return rtcPriorityTypeMediumStr - case RTCPriorityTypeHigh: - return rtcPriorityTypeHighStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtcrtcpmuxpolicy.go b/vendor/github.com/pions/webrtc/rtcrtcpmuxpolicy.go deleted file mode 100644 index 9e08465..0000000 --- a/vendor/github.com/pions/webrtc/rtcrtcpmuxpolicy.go +++ /dev/null @@ -1,46 +0,0 @@ -package webrtc - -// RTCRtcpMuxPolicy affects what ICE candidates are gathered to support -// non-multiplexed RTCP. -type RTCRtcpMuxPolicy int - -const ( - // RTCRtcpMuxPolicyNegotiate indicates to gather ICE candidates for both - // RTP and RTCP candidates. If the remote-endpoint is capable of - // multiplexing RTCP, multiplex RTCP on the RTP candidates. If it is not, - // use both the RTP and RTCP candidates separately. - RTCRtcpMuxPolicyNegotiate RTCRtcpMuxPolicy = iota + 1 - - // RTCRtcpMuxPolicyRequire indicates to gather ICE candidates only for - // RTP and multiplex RTCP on the RTP candidates. If the remote endpoint is - // not capable of rtcp-mux, session negotiation will fail. - RTCRtcpMuxPolicyRequire -) - -// This is done this way because of a linter. -const ( - rtcRtcpMuxPolicyNegotiateStr = "negotiate" - rtcRtcpMuxPolicyRequireStr = "require" -) - -func newRTCRtcpMuxPolicy(raw string) RTCRtcpMuxPolicy { - switch raw { - case rtcRtcpMuxPolicyNegotiateStr: - return RTCRtcpMuxPolicyNegotiate - case rtcRtcpMuxPolicyRequireStr: - return RTCRtcpMuxPolicyRequire - default: - return RTCRtcpMuxPolicy(Unknown) - } -} - -func (t RTCRtcpMuxPolicy) String() string { - switch t { - case RTCRtcpMuxPolicyNegotiate: - return rtcRtcpMuxPolicyNegotiateStr - case RTCRtcpMuxPolicyRequire: - return rtcRtcpMuxPolicyRequireStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtcrtpreceiver.go b/vendor/github.com/pions/webrtc/rtcrtpreceiver.go deleted file mode 100644 index 63fadfd..0000000 --- a/vendor/github.com/pions/webrtc/rtcrtpreceiver.go +++ /dev/null @@ -1,14 +0,0 @@ -package webrtc - -// RTCRtpReceiver allows an application to inspect the receipt of a RTCTrack -type RTCRtpReceiver struct { - Track *RTCTrack - // receiverTrack *RTCTrack - // receiverTransport - // receiverRtcpTransport -} - -// TODO: receiving side -// func newRTCRtpReceiver(kind, id string) { -// -// } diff --git a/vendor/github.com/pions/webrtc/rtcrtpsender.go b/vendor/github.com/pions/webrtc/rtcrtpsender.go deleted file mode 100644 index 1a5500a..0000000 --- a/vendor/github.com/pions/webrtc/rtcrtpsender.go +++ /dev/null @@ -1,16 +0,0 @@ -package webrtc - -// RTCRtpSender allows an application to control how a given RTCTrack is encoded and transmitted to a remote peer -type RTCRtpSender struct { - Track *RTCTrack - // senderTrack *RTCTrack - // senderTransport - // senderRtcpTransport -} - -func newRTCRtpSender(track *RTCTrack) *RTCRtpSender { - s := &RTCRtpSender{ - Track: track, - } - return s -} diff --git a/vendor/github.com/pions/webrtc/rtcrtptranceiver.go b/vendor/github.com/pions/webrtc/rtcrtptranceiver.go deleted file mode 100644 index c202e56..0000000 --- a/vendor/github.com/pions/webrtc/rtcrtptranceiver.go +++ /dev/null @@ -1,36 +0,0 @@ -package webrtc - -import ( - "github.com/pkg/errors" -) - -// RTCRtpTransceiver represents a combination of an RTCRtpSender and an RTCRtpReceiver that share a common mid. -type RTCRtpTransceiver struct { - Mid string - Sender *RTCRtpSender - Receiver *RTCRtpReceiver - Direction RTCRtpTransceiverDirection - // currentDirection RTCRtpTransceiverDirection - // firedDirection RTCRtpTransceiverDirection - // receptive bool - stopped bool -} - -func (t *RTCRtpTransceiver) setSendingTrack(track *RTCTrack) error { - t.Sender.Track = track - - switch t.Direction { - case RTCRtpTransceiverDirectionRecvonly: - t.Direction = RTCRtpTransceiverDirectionSendrecv - case RTCRtpTransceiverDirectionInactive: - t.Direction = RTCRtpTransceiverDirectionSendonly - default: - return errors.Errorf("Invalid state change in RTCRtpTransceiver.setSending") - } - return nil -} - -// Stop irreversibly stops the RTCRtpTransceiver -func (t *RTCRtpTransceiver) Stop() error { - return errors.Errorf("TODO") -} diff --git a/vendor/github.com/pions/webrtc/rtcrtptransceiverdirection.go b/vendor/github.com/pions/webrtc/rtcrtptransceiverdirection.go deleted file mode 100644 index 3dac393..0000000 --- a/vendor/github.com/pions/webrtc/rtcrtptransceiverdirection.go +++ /dev/null @@ -1,62 +0,0 @@ -package webrtc - -// RTCRtpTransceiverDirection indicates the direction of the RTCRtpTransceiver. -type RTCRtpTransceiverDirection int - -const ( - // RTCRtpTransceiverDirectionSendrecv indicates the RTCRtpSender will offer - // to send RTP and RTCRtpReceiver the will offer to receive RTP. - RTCRtpTransceiverDirectionSendrecv RTCRtpTransceiverDirection = iota + 1 - - // RTCRtpTransceiverDirectionSendonly indicates the RTCRtpSender will offer - // to send RTP. - RTCRtpTransceiverDirectionSendonly - - // RTCRtpTransceiverDirectionRecvonly indicates the RTCRtpReceiver the will - // offer to receive RTP. - RTCRtpTransceiverDirectionRecvonly - - // RTCRtpTransceiverDirectionInactive indicates the RTCRtpSender won't offer - // to send RTP and RTCRtpReceiver the won't offer to receive RTP. - RTCRtpTransceiverDirectionInactive -) - -// This is done this way because of a linter. -const ( - rtcRtpTransceiverDirectionSendrecvStr = "sendrecv" - rtcRtpTransceiverDirectionSendonlyStr = "sendonly" - rtcRtpTransceiverDirectionRecvonlyStr = "recvonly" - rtcRtpTransceiverDirectionInactiveStr = "inactive" -) - -// NewRTCRtpTransceiverDirection defines a procedure for creating a new -// RTCRtpTransceiverDirection from a raw string naming the transceiver direction. -func NewRTCRtpTransceiverDirection(raw string) RTCRtpTransceiverDirection { - switch raw { - case rtcRtpTransceiverDirectionSendrecvStr: - return RTCRtpTransceiverDirectionSendrecv - case rtcRtpTransceiverDirectionSendonlyStr: - return RTCRtpTransceiverDirectionSendonly - case rtcRtpTransceiverDirectionRecvonlyStr: - return RTCRtpTransceiverDirectionRecvonly - case rtcRtpTransceiverDirectionInactiveStr: - return RTCRtpTransceiverDirectionInactive - default: - return RTCRtpTransceiverDirection(Unknown) - } -} - -func (t RTCRtpTransceiverDirection) String() string { - switch t { - case RTCRtpTransceiverDirectionSendrecv: - return rtcRtpTransceiverDirectionSendrecvStr - case RTCRtpTransceiverDirectionSendonly: - return rtcRtpTransceiverDirectionSendonlyStr - case RTCRtpTransceiverDirectionRecvonly: - return rtcRtpTransceiverDirectionRecvonlyStr - case RTCRtpTransceiverDirectionInactive: - return rtcRtpTransceiverDirectionInactiveStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtcsctptransport.go b/vendor/github.com/pions/webrtc/rtcsctptransport.go deleted file mode 100644 index fde152d..0000000 --- a/vendor/github.com/pions/webrtc/rtcsctptransport.go +++ /dev/null @@ -1,71 +0,0 @@ -package webrtc - -import ( - "math" -) - -// RTCSctpTransport provides details about the SCTP transport. -type RTCSctpTransport struct { - // Transport represents the transport over which all SCTP packets for data - // channels will be sent and received. - Transport *RTCDtlsTransport - - // State represents the current state of the SCTP transport. - State RTCSctpTransportState - - // MaxMessageSize represents the maximum size of data that can be passed to - // RTCDataChannel's send() method. - MaxMessageSize float64 - - // MaxChannels represents the maximum amount of RTCDataChannel's that can - // be used simultaneously. - MaxChannels *uint16 - - // OnStateChange func() - - // dataChannels - // dataChannels map[uint16]*RTCDataChannel -} - -func newRTCSctpTransport() *RTCSctpTransport { - res := &RTCSctpTransport{ - State: RTCSctpTransportStateConnecting, - } - - res.updateMessageSize() - res.updateMaxChannels() - - return res -} - -func (r *RTCSctpTransport) updateMessageSize() { - var remoteMaxMessageSize float64 = 65536 // TODO: get from SDP - var canSendSize float64 = 65536 // TODO: Get from SCTP implementation - - r.MaxMessageSize = r.calcMessageSize(remoteMaxMessageSize, canSendSize) -} - -func (r *RTCSctpTransport) calcMessageSize(remoteMaxMessageSize, canSendSize float64) float64 { - switch { - case remoteMaxMessageSize == 0 && - canSendSize == 0: - return math.Inf(1) - - case remoteMaxMessageSize == 0: - return canSendSize - - case canSendSize == 0: - return remoteMaxMessageSize - - case canSendSize > remoteMaxMessageSize: - return remoteMaxMessageSize - - default: - return canSendSize - } -} - -func (r *RTCSctpTransport) updateMaxChannels() { - val := uint16(65535) - r.MaxChannels = &val // TODO: Get from implementation -} diff --git a/vendor/github.com/pions/webrtc/rtcsctptransportstate.go b/vendor/github.com/pions/webrtc/rtcsctptransportstate.go deleted file mode 100644 index 903bc92..0000000 --- a/vendor/github.com/pions/webrtc/rtcsctptransportstate.go +++ /dev/null @@ -1,54 +0,0 @@ -package webrtc - -// RTCSctpTransportState indicates the state of the SCTP transport. -type RTCSctpTransportState int - -const ( - // RTCSctpTransportStateConnecting indicates the RTCSctpTransport is in the - // process of negotiating an association. This is the initial state of the - // SctpTransportState when an RTCSctpTransport is created. - RTCSctpTransportStateConnecting RTCSctpTransportState = iota + 1 - - // RTCSctpTransportStateConnected indicates the negotiation of an - // association is completed. - RTCSctpTransportStateConnected - - // RTCSctpTransportStateClosed indicates a SHUTDOWN or ABORT chunk is - // received or when the SCTP association has been closed intentionally, - // such as by closing the peer connection or applying a remote description - // that rejects data or changes the SCTP port. - RTCSctpTransportStateClosed -) - -// This is done this way because of a linter. -const ( - rtcSctpTransportStateConnectingStr = "connecting" - rtcSctpTransportStateConnectedStr = "connected" - rtcSctpTransportStateClosedStr = "closed" -) - -func newRTCSctpTransportState(raw string) RTCSctpTransportState { - switch raw { - case rtcSctpTransportStateConnectingStr: - return RTCSctpTransportStateConnecting - case rtcSctpTransportStateConnectedStr: - return RTCSctpTransportStateConnected - case rtcSctpTransportStateClosedStr: - return RTCSctpTransportStateClosed - default: - return RTCSctpTransportState(Unknown) - } -} - -func (s RTCSctpTransportState) String() string { - switch s { - case RTCSctpTransportStateConnecting: - return rtcSctpTransportStateConnectingStr - case RTCSctpTransportStateConnected: - return rtcSctpTransportStateConnectedStr - case RTCSctpTransportStateClosed: - return rtcSctpTransportStateClosedStr - default: - return ErrUnknownType.Error() - } -} diff --git a/vendor/github.com/pions/webrtc/rtcsdptype.go b/vendor/github.com/pions/webrtc/rtcsdptype.go deleted file mode 100644 index 6542279..0000000 --- a/vendor/github.com/pions/webrtc/rtcsdptype.go +++ /dev/null @@ -1,99 +0,0 @@ -package webrtc - -import ( - "encoding/json" - "strings" -) - -// RTCSdpType describes the type of an RTCSessionDescription. -type RTCSdpType int - -const ( - // RTCSdpTypeOffer indicates that a description MUST be treated as an SDP - // offer. - RTCSdpTypeOffer RTCSdpType = iota + 1 - - // RTCSdpTypePranswer indicates that a description MUST be treated as an - // SDP answer, but not a final answer. A description used as an SDP - // pranswer may be applied as a response to an SDP offer, or an update to - // a previously sent SDP pranswer. - RTCSdpTypePranswer - - // RTCSdpTypeAnswer indicates that a description MUST be treated as an SDP - // final answer, and the offer-answer exchange MUST be considered complete. - // A description used as an SDP answer may be applied as a response to an - // SDP offer or as an update to a previously sent SDP pranswer. - RTCSdpTypeAnswer - - // RTCSdpTypeRollback indicates that a description MUST be treated as - // canceling the current SDP negotiation and moving the SDP offer and - // answer back to what it was in the previous stable state. Note the - // local or remote SDP descriptions in the previous stable state could be - // null if there has not yet been a successful offer-answer negotiation. - RTCSdpTypeRollback -) - -// This is done this way because of a linter. -const ( - rtcSdpTypeOfferStr = "offer" - rtcSdpTypePranswerStr = "pranswer" - rtcSdpTypeAnswerStr = "answer" - rtcSdpTypeRollbackStr = "rollback" -) - -func newRTCSdpType(raw string) RTCSdpType { - switch raw { - case rtcSdpTypeOfferStr: - return RTCSdpTypeOffer - case rtcSdpTypePranswerStr: - return RTCSdpTypePranswer - case rtcSdpTypeAnswerStr: - return RTCSdpTypeAnswer - case rtcSdpTypeRollbackStr: - return RTCSdpTypeRollback - default: - return RTCSdpType(Unknown) - } -} - -func (t RTCSdpType) String() string { - switch t { - case RTCSdpTypeOffer: - return rtcSdpTypeOfferStr - case RTCSdpTypePranswer: - return rtcSdpTypePranswerStr - case RTCSdpTypeAnswer: - return rtcSdpTypeAnswerStr - case RTCSdpTypeRollback: - return rtcSdpTypeRollbackStr - default: - return ErrUnknownType.Error() - } -} - -// MarshalJSON enables JSON marshaling of a RTCSdpType -func (t RTCSdpType) MarshalJSON() ([]byte, error) { - return json.Marshal(t.String()) -} - -// UnmarshalJSON enables JSON unmarshaling of a RTCSdpType -func (t *RTCSdpType) UnmarshalJSON(b []byte) error { - var s string - if err := json.Unmarshal(b, &s); err != nil { - return err - } - switch strings.ToLower(s) { - default: - return ErrUnknownType - case "offer": - *t = RTCSdpTypeOffer - case "pranswer": - *t = RTCSdpTypePranswer - case "answer": - *t = RTCSdpTypeAnswer - case "rollback": - *t = RTCSdpTypeRollback - } - - return nil -} diff --git a/vendor/github.com/pions/webrtc/rtcsessiondescription.go b/vendor/github.com/pions/webrtc/rtcsessiondescription.go deleted file mode 100644 index 5c5cd5f..0000000 --- a/vendor/github.com/pions/webrtc/rtcsessiondescription.go +++ /dev/null @@ -1,14 +0,0 @@ -package webrtc - -import ( - "github.com/pions/webrtc/internal/sdp" -) - -// RTCSessionDescription is used to expose local and remote session descriptions. -type RTCSessionDescription struct { - Type RTCSdpType `json:"type"` - Sdp string `json:"sdp"` - - // This will never be initialized by callers, internal use only - parsed *sdp.SessionDescription -} diff --git a/vendor/github.com/pions/webrtc/rtcsignalingstate.go b/vendor/github.com/pions/webrtc/rtcsignalingstate.go deleted file mode 100644 index 0ca1346..0000000 --- a/vendor/github.com/pions/webrtc/rtcsignalingstate.go +++ /dev/null @@ -1,179 +0,0 @@ -package webrtc - -import ( - "fmt" - - "github.com/pions/webrtc/pkg/rtcerr" - "github.com/pkg/errors" -) - -type rtcStateChangeOp int - -const ( - rtcStateChangeOpSetLocal rtcStateChangeOp = iota + 1 - rtcStateChangeOpSetRemote -) - -func (op rtcStateChangeOp) String() string { - switch op { - case rtcStateChangeOpSetLocal: - return "SetLocal" - case rtcStateChangeOpSetRemote: - return "SetRemote" - default: - return "Unknown State Change Operation" - } -} - -// RTCSignalingState indicates the signaling state of the offer/answer process. -type RTCSignalingState int - -const ( - // RTCSignalingStateStable indicates there is no offer/answer exchange in - // progress. This is also the initial state, in which case the local and - // remote descriptions are nil. - RTCSignalingStateStable RTCSignalingState = iota + 1 - - // RTCSignalingStateHaveLocalOffer indicates that a local description, of - // type "offer", has been successfully applied. - RTCSignalingStateHaveLocalOffer - - // RTCSignalingStateHaveRemoteOffer indicates that a remote description, of - // type "offer", has been successfully applied. - RTCSignalingStateHaveRemoteOffer - - // RTCSignalingStateHaveLocalPranswer indicates that a remote description - // of type "offer" has been successfully applied and a local description - // of type "pranswer" has been successfully applied. - RTCSignalingStateHaveLocalPranswer - - // RTCSignalingStateHaveRemotePranswer indicates that a local description - // of type "offer" has been successfully applied and a remote description - // of type "pranswer" has been successfully applied. - RTCSignalingStateHaveRemotePranswer - - // RTCSignalingStateClosed indicates The RTCPeerConnection has been closed. - RTCSignalingStateClosed -) - -// This is done this way because of a linter. -const ( - rtcSignalingStateStableStr = "stable" - rtcSignalingStateHaveLocalOfferStr = "have-local-offer" - rtcSignalingStateHaveRemoteOfferStr = "have-remote-offer" - rtcSignalingStateHaveLocalPranswerStr = "have-local-pranswer" - rtcSignalingStateHaveRemotePranswerStr = "have-remote-pranswer" - rtcSignalingStateClosedStr = "closed" -) - -func newRTCSignalingState(raw string) RTCSignalingState { - switch raw { - case rtcSignalingStateStableStr: - return RTCSignalingStateStable - case rtcSignalingStateHaveLocalOfferStr: - return RTCSignalingStateHaveLocalOffer - case rtcSignalingStateHaveRemoteOfferStr: - return RTCSignalingStateHaveRemoteOffer - case rtcSignalingStateHaveLocalPranswerStr: - return RTCSignalingStateHaveLocalPranswer - case rtcSignalingStateHaveRemotePranswerStr: - return RTCSignalingStateHaveRemotePranswer - case rtcSignalingStateClosedStr: - return RTCSignalingStateClosed - default: - return RTCSignalingState(Unknown) - } -} - -func (t RTCSignalingState) String() string { - switch t { - case RTCSignalingStateStable: - return rtcSignalingStateStableStr - case RTCSignalingStateHaveLocalOffer: - return rtcSignalingStateHaveLocalOfferStr - case RTCSignalingStateHaveRemoteOffer: - return rtcSignalingStateHaveRemoteOfferStr - case RTCSignalingStateHaveLocalPranswer: - return rtcSignalingStateHaveLocalPranswerStr - case RTCSignalingStateHaveRemotePranswer: - return rtcSignalingStateHaveRemotePranswerStr - case RTCSignalingStateClosed: - return rtcSignalingStateClosedStr - default: - return ErrUnknownType.Error() - } -} - -func checkNextSignalingState(cur, next RTCSignalingState, op rtcStateChangeOp, sdpType RTCSdpType) (RTCSignalingState, error) { - // Special case for rollbacks - if sdpType == RTCSdpTypeRollback && cur == RTCSignalingStateStable { - return cur, &rtcerr.InvalidModificationError{ - Err: errors.New("Can't rollback from stable state"), - } - } - - // 4.3.1 valid state transitions - switch cur { - case RTCSignalingStateStable: - switch op { - case rtcStateChangeOpSetLocal: - // stable->SetLocal(offer)->have-local-offer - if sdpType == RTCSdpTypeOffer && next == RTCSignalingStateHaveLocalOffer { - return next, nil - } - case rtcStateChangeOpSetRemote: - // stable->SetRemote(offer)->have-remote-offer - if sdpType == RTCSdpTypeOffer && next == RTCSignalingStateHaveRemoteOffer { - return next, nil - } - } - case RTCSignalingStateHaveLocalOffer: - if op == rtcStateChangeOpSetRemote { - switch sdpType { - // have-local-offer->SetRemote(answer)->stable - case RTCSdpTypeAnswer: - if next == RTCSignalingStateStable { - return next, nil - } - // have-local-offer->SetRemote(pranswer)->have-remote-pranswer - case RTCSdpTypePranswer: - if next == RTCSignalingStateHaveRemotePranswer { - return next, nil - } - } - } - case RTCSignalingStateHaveRemotePranswer: - if op == rtcStateChangeOpSetRemote && sdpType == RTCSdpTypeAnswer { - // have-remote-pranswer->SetRemote(answer)->stable - if next == RTCSignalingStateStable { - return next, nil - } - } - case RTCSignalingStateHaveRemoteOffer: - if op == rtcStateChangeOpSetLocal { - switch sdpType { - // have-remote-offer->SetLocal(answer)->stable - case RTCSdpTypeAnswer: - if next == RTCSignalingStateStable { - return next, nil - } - // have-remote-offer->SetLocal(pranswer)->have-local-pranswer - case RTCSdpTypePranswer: - if next == RTCSignalingStateHaveLocalPranswer { - return next, nil - } - } - } - case RTCSignalingStateHaveLocalPranswer: - if op == rtcStateChangeOpSetLocal && sdpType == RTCSdpTypeAnswer { - // have-local-pranswer->SetLocal(answer)->stable - if next == RTCSignalingStateStable { - return next, nil - } - } - } - - return cur, &rtcerr.InvalidModificationError{ - Err: fmt.Errorf("Invalid proposed signaling state transition %s->%s(%s)->%s", cur, op, sdpType, next), - } -} diff --git a/vendor/github.com/pkg/errors/.gitignore b/vendor/github.com/pkg/errors/.gitignore deleted file mode 100644 index daf913b..0000000 --- a/vendor/github.com/pkg/errors/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/vendor/github.com/pkg/errors/.travis.yml b/vendor/github.com/pkg/errors/.travis.yml deleted file mode 100644 index 588ceca..0000000 --- a/vendor/github.com/pkg/errors/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: go -go_import_path: github.com/pkg/errors -go: - - 1.4.3 - - 1.5.4 - - 1.6.2 - - 1.7.1 - - tip - -script: - - go test -v ./... diff --git a/vendor/github.com/pkg/errors/LICENSE b/vendor/github.com/pkg/errors/LICENSE deleted file mode 100644 index 835ba3e..0000000 --- a/vendor/github.com/pkg/errors/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2015, Dave Cheney -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/pkg/errors/README.md b/vendor/github.com/pkg/errors/README.md deleted file mode 100644 index 273db3c..0000000 --- a/vendor/github.com/pkg/errors/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) - -Package errors provides simple error handling primitives. - -`go get github.com/pkg/errors` - -The traditional error handling idiom in Go is roughly akin to -```go -if err != nil { - return err -} -``` -which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. - -## Adding context to an error - -The errors.Wrap function returns a new error that adds context to the original error. For example -```go -_, err := ioutil.ReadAll(r) -if err != nil { - return errors.Wrap(err, "read failed") -} -``` -## Retrieving the cause of an error - -Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`. -```go -type causer interface { - Cause() error -} -``` -`errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example: -```go -switch err := errors.Cause(err).(type) { -case *MyError: - // handle specifically -default: - // unknown error -} -``` - -[Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). - -## Contributing - -We welcome pull requests, bug fixes and issue reports. With that said, the bar for adding new symbols to this package is intentionally set high. - -Before proposing a change, please discuss your change by raising an issue. - -## Licence - -BSD-2-Clause diff --git a/vendor/github.com/pkg/errors/appveyor.yml b/vendor/github.com/pkg/errors/appveyor.yml deleted file mode 100644 index a932ead..0000000 --- a/vendor/github.com/pkg/errors/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: build-{build}.{branch} - -clone_folder: C:\gopath\src\github.com\pkg\errors -shallow_clone: true # for startup speed - -environment: - GOPATH: C:\gopath - -platform: - - x64 - -# http://www.appveyor.com/docs/installed-software -install: - # some helpful output for debugging builds - - go version - - go env - # pre-installed MinGW at C:\MinGW is 32bit only - # but MSYS2 at C:\msys64 has mingw64 - - set PATH=C:\msys64\mingw64\bin;%PATH% - - gcc --version - - g++ --version - -build_script: - - go install -v ./... - -test_script: - - set PATH=C:\gopath\bin;%PATH% - - go test -v ./... - -#artifacts: -# - path: '%GOPATH%\bin\*.exe' -deploy: off diff --git a/vendor/github.com/pkg/errors/errors.go b/vendor/github.com/pkg/errors/errors.go deleted file mode 100644 index 842ee80..0000000 --- a/vendor/github.com/pkg/errors/errors.go +++ /dev/null @@ -1,269 +0,0 @@ -// Package errors provides simple error handling primitives. -// -// The traditional error handling idiom in Go is roughly akin to -// -// if err != nil { -// return err -// } -// -// which applied recursively up the call stack results in error reports -// without context or debugging information. The errors package allows -// programmers to add context to the failure path in their code in a way -// that does not destroy the original value of the error. -// -// Adding context to an error -// -// The errors.Wrap function returns a new error that adds context to the -// original error by recording a stack trace at the point Wrap is called, -// and the supplied message. For example -// -// _, err := ioutil.ReadAll(r) -// if err != nil { -// return errors.Wrap(err, "read failed") -// } -// -// If additional control is required the errors.WithStack and errors.WithMessage -// functions destructure errors.Wrap into its component operations of annotating -// an error with a stack trace and an a message, respectively. -// -// Retrieving the cause of an error -// -// Using errors.Wrap constructs a stack of errors, adding context to the -// preceding error. Depending on the nature of the error it may be necessary -// to reverse the operation of errors.Wrap to retrieve the original error -// for inspection. Any error value which implements this interface -// -// type causer interface { -// Cause() error -// } -// -// can be inspected by errors.Cause. errors.Cause will recursively retrieve -// the topmost error which does not implement causer, which is assumed to be -// the original cause. For example: -// -// switch err := errors.Cause(err).(type) { -// case *MyError: -// // handle specifically -// default: -// // unknown error -// } -// -// causer interface is not exported by this package, but is considered a part -// of stable public API. -// -// Formatted printing of errors -// -// All error values returned from this package implement fmt.Formatter and can -// be formatted by the fmt package. The following verbs are supported -// -// %s print the error. If the error has a Cause it will be -// printed recursively -// %v see %s -// %+v extended format. Each Frame of the error's StackTrace will -// be printed in detail. -// -// Retrieving the stack trace of an error or wrapper -// -// New, Errorf, Wrap, and Wrapf record a stack trace at the point they are -// invoked. This information can be retrieved with the following interface. -// -// type stackTracer interface { -// StackTrace() errors.StackTrace -// } -// -// Where errors.StackTrace is defined as -// -// type StackTrace []Frame -// -// The Frame type represents a call site in the stack trace. Frame supports -// the fmt.Formatter interface that can be used for printing information about -// the stack trace of this error. For example: -// -// if err, ok := err.(stackTracer); ok { -// for _, f := range err.StackTrace() { -// fmt.Printf("%+s:%d", f) -// } -// } -// -// stackTracer interface is not exported by this package, but is considered a part -// of stable public API. -// -// See the documentation for Frame.Format for more details. -package errors - -import ( - "fmt" - "io" -) - -// New returns an error with the supplied message. -// New also records the stack trace at the point it was called. -func New(message string) error { - return &fundamental{ - msg: message, - stack: callers(), - } -} - -// Errorf formats according to a format specifier and returns the string -// as a value that satisfies error. -// Errorf also records the stack trace at the point it was called. -func Errorf(format string, args ...interface{}) error { - return &fundamental{ - msg: fmt.Sprintf(format, args...), - stack: callers(), - } -} - -// fundamental is an error that has a message and a stack, but no caller. -type fundamental struct { - msg string - *stack -} - -func (f *fundamental) Error() string { return f.msg } - -func (f *fundamental) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - io.WriteString(s, f.msg) - f.stack.Format(s, verb) - return - } - fallthrough - case 's': - io.WriteString(s, f.msg) - case 'q': - fmt.Fprintf(s, "%q", f.msg) - } -} - -// WithStack annotates err with a stack trace at the point WithStack was called. -// If err is nil, WithStack returns nil. -func WithStack(err error) error { - if err == nil { - return nil - } - return &withStack{ - err, - callers(), - } -} - -type withStack struct { - error - *stack -} - -func (w *withStack) Cause() error { return w.error } - -func (w *withStack) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - fmt.Fprintf(s, "%+v", w.Cause()) - w.stack.Format(s, verb) - return - } - fallthrough - case 's': - io.WriteString(s, w.Error()) - case 'q': - fmt.Fprintf(s, "%q", w.Error()) - } -} - -// Wrap returns an error annotating err with a stack trace -// at the point Wrap is called, and the supplied message. -// If err is nil, Wrap returns nil. -func Wrap(err error, message string) error { - if err == nil { - return nil - } - err = &withMessage{ - cause: err, - msg: message, - } - return &withStack{ - err, - callers(), - } -} - -// Wrapf returns an error annotating err with a stack trace -// at the point Wrapf is call, and the format specifier. -// If err is nil, Wrapf returns nil. -func Wrapf(err error, format string, args ...interface{}) error { - if err == nil { - return nil - } - err = &withMessage{ - cause: err, - msg: fmt.Sprintf(format, args...), - } - return &withStack{ - err, - callers(), - } -} - -// WithMessage annotates err with a new message. -// If err is nil, WithMessage returns nil. -func WithMessage(err error, message string) error { - if err == nil { - return nil - } - return &withMessage{ - cause: err, - msg: message, - } -} - -type withMessage struct { - cause error - msg string -} - -func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() } -func (w *withMessage) Cause() error { return w.cause } - -func (w *withMessage) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - fmt.Fprintf(s, "%+v\n", w.Cause()) - io.WriteString(s, w.msg) - return - } - fallthrough - case 's', 'q': - io.WriteString(s, w.Error()) - } -} - -// Cause returns the underlying cause of the error, if possible. -// An error value has a cause if it implements the following -// interface: -// -// type causer interface { -// Cause() error -// } -// -// If the error does not implement Cause, the original error will -// be returned. If the error is nil, nil will be returned without further -// investigation. -func Cause(err error) error { - type causer interface { - Cause() error - } - - for err != nil { - cause, ok := err.(causer) - if !ok { - break - } - err = cause.Cause() - } - return err -} diff --git a/vendor/github.com/pkg/errors/stack.go b/vendor/github.com/pkg/errors/stack.go deleted file mode 100644 index 6b1f289..0000000 --- a/vendor/github.com/pkg/errors/stack.go +++ /dev/null @@ -1,178 +0,0 @@ -package errors - -import ( - "fmt" - "io" - "path" - "runtime" - "strings" -) - -// Frame represents a program counter inside a stack frame. -type Frame uintptr - -// pc returns the program counter for this frame; -// multiple frames may have the same PC value. -func (f Frame) pc() uintptr { return uintptr(f) - 1 } - -// file returns the full path to the file that contains the -// function for this Frame's pc. -func (f Frame) file() string { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return "unknown" - } - file, _ := fn.FileLine(f.pc()) - return file -} - -// line returns the line number of source code of the -// function for this Frame's pc. -func (f Frame) line() int { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return 0 - } - _, line := fn.FileLine(f.pc()) - return line -} - -// Format formats the frame according to the fmt.Formatter interface. -// -// %s source file -// %d source line -// %n function name -// %v equivalent to %s:%d -// -// Format accepts flags that alter the printing of some verbs, as follows: -// -// %+s path of source file relative to the compile time GOPATH -// %+v equivalent to %+s:%d -func (f Frame) Format(s fmt.State, verb rune) { - switch verb { - case 's': - switch { - case s.Flag('+'): - pc := f.pc() - fn := runtime.FuncForPC(pc) - if fn == nil { - io.WriteString(s, "unknown") - } else { - file, _ := fn.FileLine(pc) - fmt.Fprintf(s, "%s\n\t%s", fn.Name(), file) - } - default: - io.WriteString(s, path.Base(f.file())) - } - case 'd': - fmt.Fprintf(s, "%d", f.line()) - case 'n': - name := runtime.FuncForPC(f.pc()).Name() - io.WriteString(s, funcname(name)) - case 'v': - f.Format(s, 's') - io.WriteString(s, ":") - f.Format(s, 'd') - } -} - -// StackTrace is stack of Frames from innermost (newest) to outermost (oldest). -type StackTrace []Frame - -func (st StackTrace) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - switch { - case s.Flag('+'): - for _, f := range st { - fmt.Fprintf(s, "\n%+v", f) - } - case s.Flag('#'): - fmt.Fprintf(s, "%#v", []Frame(st)) - default: - fmt.Fprintf(s, "%v", []Frame(st)) - } - case 's': - fmt.Fprintf(s, "%s", []Frame(st)) - } -} - -// stack represents a stack of program counters. -type stack []uintptr - -func (s *stack) Format(st fmt.State, verb rune) { - switch verb { - case 'v': - switch { - case st.Flag('+'): - for _, pc := range *s { - f := Frame(pc) - fmt.Fprintf(st, "\n%+v", f) - } - } - } -} - -func (s *stack) StackTrace() StackTrace { - f := make([]Frame, len(*s)) - for i := 0; i < len(f); i++ { - f[i] = Frame((*s)[i]) - } - return f -} - -func callers() *stack { - const depth = 32 - var pcs [depth]uintptr - n := runtime.Callers(3, pcs[:]) - var st stack = pcs[0:n] - return &st -} - -// funcname removes the path prefix component of a function's name reported by func.Name(). -func funcname(name string) string { - i := strings.LastIndex(name, "/") - name = name[i+1:] - i = strings.Index(name, ".") - return name[i+1:] -} - -func trimGOPATH(name, file string) string { - // Here we want to get the source file path relative to the compile time - // GOPATH. As of Go 1.6.x there is no direct way to know the compiled - // GOPATH at runtime, but we can infer the number of path segments in the - // GOPATH. We note that fn.Name() returns the function name qualified by - // the import path, which does not include the GOPATH. Thus we can trim - // segments from the beginning of the file path until the number of path - // separators remaining is one more than the number of path separators in - // the function name. For example, given: - // - // GOPATH /home/user - // file /home/user/src/pkg/sub/file.go - // fn.Name() pkg/sub.Type.Method - // - // We want to produce: - // - // pkg/sub/file.go - // - // From this we can easily see that fn.Name() has one less path separator - // than our desired output. We count separators from the end of the file - // path until it finds two more than in the function name and then move - // one character forward to preserve the initial path segment without a - // leading separator. - const sep = "/" - goal := strings.Count(name, sep) + 2 - i := len(file) - for n := 0; n < goal; n++ { - i = strings.LastIndex(file[:i], sep) - if i == -1 { - // not enough separators found, set i so that the slice expression - // below leaves file unmodified - i = -len(sep) - break - } - } - // get back to 0 or trim the leading separator - file = file[i+len(sep):] - return file -} diff --git a/vendor/golang.org/x/crypto/AUTHORS b/vendor/golang.org/x/crypto/AUTHORS deleted file mode 100644 index 2b00ddb..0000000 --- a/vendor/golang.org/x/crypto/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The Go Authors for copyright purposes. -# The master list of authors is in the main Go distribution, -# visible at https://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/crypto/CONTRIBUTORS b/vendor/golang.org/x/crypto/CONTRIBUTORS deleted file mode 100644 index 1fbd3e9..0000000 --- a/vendor/golang.org/x/crypto/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the Go contributors. -# The master list of contributors is in the main Go distribution, -# visible at https://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/crypto/LICENSE b/vendor/golang.org/x/crypto/LICENSE deleted file mode 100644 index 6a66aea..0000000 --- a/vendor/golang.org/x/crypto/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/crypto/PATENTS b/vendor/golang.org/x/crypto/PATENTS deleted file mode 100644 index 7330990..0000000 --- a/vendor/golang.org/x/crypto/PATENTS +++ /dev/null @@ -1,22 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Go project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Go, where such license applies only to those patent -claims, both currently owned or controlled by Google and acquired in -the future, licensable by Google that are necessarily infringed by this -implementation of Go. This grant does not include claims that would be -infringed only as a consequence of further modification of this -implementation. If you or your agent or exclusive licensee institute or -order or agree to the institution of patent litigation against any -entity (including a cross-claim or counterclaim in a lawsuit) alleging -that this implementation of Go or any code incorporated within this -implementation of Go constitutes direct or contributory patent -infringement, or inducement of patent infringement, then any patent -rights granted to you under this License for this implementation of Go -shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/crypto/curve25519/const_amd64.h b/vendor/golang.org/x/crypto/curve25519/const_amd64.h deleted file mode 100644 index b3f7416..0000000 --- a/vendor/golang.org/x/crypto/curve25519/const_amd64.h +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code was translated into a form compatible with 6a from the public -// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html - -#define REDMASK51 0x0007FFFFFFFFFFFF diff --git a/vendor/golang.org/x/crypto/curve25519/const_amd64.s b/vendor/golang.org/x/crypto/curve25519/const_amd64.s deleted file mode 100644 index ee7b4bd..0000000 --- a/vendor/golang.org/x/crypto/curve25519/const_amd64.s +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code was translated into a form compatible with 6a from the public -// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html - -// +build amd64,!gccgo,!appengine - -// These constants cannot be encoded in non-MOVQ immediates. -// We access them directly from memory instead. - -DATA ·_121666_213(SB)/8, $996687872 -GLOBL ·_121666_213(SB), 8, $8 - -DATA ·_2P0(SB)/8, $0xFFFFFFFFFFFDA -GLOBL ·_2P0(SB), 8, $8 - -DATA ·_2P1234(SB)/8, $0xFFFFFFFFFFFFE -GLOBL ·_2P1234(SB), 8, $8 diff --git a/vendor/golang.org/x/crypto/curve25519/cswap_amd64.s b/vendor/golang.org/x/crypto/curve25519/cswap_amd64.s deleted file mode 100644 index cd793a5..0000000 --- a/vendor/golang.org/x/crypto/curve25519/cswap_amd64.s +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build amd64,!gccgo,!appengine - -// func cswap(inout *[4][5]uint64, v uint64) -TEXT ·cswap(SB),7,$0 - MOVQ inout+0(FP),DI - MOVQ v+8(FP),SI - - SUBQ $1, SI - NOTQ SI - MOVQ SI, X15 - PSHUFD $0x44, X15, X15 - - MOVOU 0(DI), X0 - MOVOU 16(DI), X2 - MOVOU 32(DI), X4 - MOVOU 48(DI), X6 - MOVOU 64(DI), X8 - MOVOU 80(DI), X1 - MOVOU 96(DI), X3 - MOVOU 112(DI), X5 - MOVOU 128(DI), X7 - MOVOU 144(DI), X9 - - MOVO X1, X10 - MOVO X3, X11 - MOVO X5, X12 - MOVO X7, X13 - MOVO X9, X14 - - PXOR X0, X10 - PXOR X2, X11 - PXOR X4, X12 - PXOR X6, X13 - PXOR X8, X14 - PAND X15, X10 - PAND X15, X11 - PAND X15, X12 - PAND X15, X13 - PAND X15, X14 - PXOR X10, X0 - PXOR X10, X1 - PXOR X11, X2 - PXOR X11, X3 - PXOR X12, X4 - PXOR X12, X5 - PXOR X13, X6 - PXOR X13, X7 - PXOR X14, X8 - PXOR X14, X9 - - MOVOU X0, 0(DI) - MOVOU X2, 16(DI) - MOVOU X4, 32(DI) - MOVOU X6, 48(DI) - MOVOU X8, 64(DI) - MOVOU X1, 80(DI) - MOVOU X3, 96(DI) - MOVOU X5, 112(DI) - MOVOU X7, 128(DI) - MOVOU X9, 144(DI) - RET diff --git a/vendor/golang.org/x/crypto/curve25519/curve25519.go b/vendor/golang.org/x/crypto/curve25519/curve25519.go deleted file mode 100644 index cb8fbc5..0000000 --- a/vendor/golang.org/x/crypto/curve25519/curve25519.go +++ /dev/null @@ -1,834 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// We have an implementation in amd64 assembly so this code is only run on -// non-amd64 platforms. The amd64 assembly does not support gccgo. -// +build !amd64 gccgo appengine - -package curve25519 - -import ( - "encoding/binary" -) - -// This code is a port of the public domain, "ref10" implementation of -// curve25519 from SUPERCOP 20130419 by D. J. Bernstein. - -// fieldElement represents an element of the field GF(2^255 - 19). An element -// t, entries t[0]...t[9], represents the integer t[0]+2^26 t[1]+2^51 t[2]+2^77 -// t[3]+2^102 t[4]+...+2^230 t[9]. Bounds on each t[i] vary depending on -// context. -type fieldElement [10]int32 - -func feZero(fe *fieldElement) { - for i := range fe { - fe[i] = 0 - } -} - -func feOne(fe *fieldElement) { - feZero(fe) - fe[0] = 1 -} - -func feAdd(dst, a, b *fieldElement) { - for i := range dst { - dst[i] = a[i] + b[i] - } -} - -func feSub(dst, a, b *fieldElement) { - for i := range dst { - dst[i] = a[i] - b[i] - } -} - -func feCopy(dst, src *fieldElement) { - for i := range dst { - dst[i] = src[i] - } -} - -// feCSwap replaces (f,g) with (g,f) if b == 1; replaces (f,g) with (f,g) if b == 0. -// -// Preconditions: b in {0,1}. -func feCSwap(f, g *fieldElement, b int32) { - b = -b - for i := range f { - t := b & (f[i] ^ g[i]) - f[i] ^= t - g[i] ^= t - } -} - -// load3 reads a 24-bit, little-endian value from in. -func load3(in []byte) int64 { - var r int64 - r = int64(in[0]) - r |= int64(in[1]) << 8 - r |= int64(in[2]) << 16 - return r -} - -// load4 reads a 32-bit, little-endian value from in. -func load4(in []byte) int64 { - return int64(binary.LittleEndian.Uint32(in)) -} - -func feFromBytes(dst *fieldElement, src *[32]byte) { - h0 := load4(src[:]) - h1 := load3(src[4:]) << 6 - h2 := load3(src[7:]) << 5 - h3 := load3(src[10:]) << 3 - h4 := load3(src[13:]) << 2 - h5 := load4(src[16:]) - h6 := load3(src[20:]) << 7 - h7 := load3(src[23:]) << 5 - h8 := load3(src[26:]) << 4 - h9 := load3(src[29:]) << 2 - - var carry [10]int64 - carry[9] = (h9 + 1<<24) >> 25 - h0 += carry[9] * 19 - h9 -= carry[9] << 25 - carry[1] = (h1 + 1<<24) >> 25 - h2 += carry[1] - h1 -= carry[1] << 25 - carry[3] = (h3 + 1<<24) >> 25 - h4 += carry[3] - h3 -= carry[3] << 25 - carry[5] = (h5 + 1<<24) >> 25 - h6 += carry[5] - h5 -= carry[5] << 25 - carry[7] = (h7 + 1<<24) >> 25 - h8 += carry[7] - h7 -= carry[7] << 25 - - carry[0] = (h0 + 1<<25) >> 26 - h1 += carry[0] - h0 -= carry[0] << 26 - carry[2] = (h2 + 1<<25) >> 26 - h3 += carry[2] - h2 -= carry[2] << 26 - carry[4] = (h4 + 1<<25) >> 26 - h5 += carry[4] - h4 -= carry[4] << 26 - carry[6] = (h6 + 1<<25) >> 26 - h7 += carry[6] - h6 -= carry[6] << 26 - carry[8] = (h8 + 1<<25) >> 26 - h9 += carry[8] - h8 -= carry[8] << 26 - - dst[0] = int32(h0) - dst[1] = int32(h1) - dst[2] = int32(h2) - dst[3] = int32(h3) - dst[4] = int32(h4) - dst[5] = int32(h5) - dst[6] = int32(h6) - dst[7] = int32(h7) - dst[8] = int32(h8) - dst[9] = int32(h9) -} - -// feToBytes marshals h to s. -// Preconditions: -// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. -// -// Write p=2^255-19; q=floor(h/p). -// Basic claim: q = floor(2^(-255)(h + 19 2^(-25)h9 + 2^(-1))). -// -// Proof: -// Have |h|<=p so |q|<=1 so |19^2 2^(-255) q|<1/4. -// Also have |h-2^230 h9|<2^230 so |19 2^(-255)(h-2^230 h9)|<1/4. -// -// Write y=2^(-1)-19^2 2^(-255)q-19 2^(-255)(h-2^230 h9). -// Then 0> 25 - q = (h[0] + q) >> 26 - q = (h[1] + q) >> 25 - q = (h[2] + q) >> 26 - q = (h[3] + q) >> 25 - q = (h[4] + q) >> 26 - q = (h[5] + q) >> 25 - q = (h[6] + q) >> 26 - q = (h[7] + q) >> 25 - q = (h[8] + q) >> 26 - q = (h[9] + q) >> 25 - - // Goal: Output h-(2^255-19)q, which is between 0 and 2^255-20. - h[0] += 19 * q - // Goal: Output h-2^255 q, which is between 0 and 2^255-20. - - carry[0] = h[0] >> 26 - h[1] += carry[0] - h[0] -= carry[0] << 26 - carry[1] = h[1] >> 25 - h[2] += carry[1] - h[1] -= carry[1] << 25 - carry[2] = h[2] >> 26 - h[3] += carry[2] - h[2] -= carry[2] << 26 - carry[3] = h[3] >> 25 - h[4] += carry[3] - h[3] -= carry[3] << 25 - carry[4] = h[4] >> 26 - h[5] += carry[4] - h[4] -= carry[4] << 26 - carry[5] = h[5] >> 25 - h[6] += carry[5] - h[5] -= carry[5] << 25 - carry[6] = h[6] >> 26 - h[7] += carry[6] - h[6] -= carry[6] << 26 - carry[7] = h[7] >> 25 - h[8] += carry[7] - h[7] -= carry[7] << 25 - carry[8] = h[8] >> 26 - h[9] += carry[8] - h[8] -= carry[8] << 26 - carry[9] = h[9] >> 25 - h[9] -= carry[9] << 25 - // h10 = carry9 - - // Goal: Output h[0]+...+2^255 h10-2^255 q, which is between 0 and 2^255-20. - // Have h[0]+...+2^230 h[9] between 0 and 2^255-1; - // evidently 2^255 h10-2^255 q = 0. - // Goal: Output h[0]+...+2^230 h[9]. - - s[0] = byte(h[0] >> 0) - s[1] = byte(h[0] >> 8) - s[2] = byte(h[0] >> 16) - s[3] = byte((h[0] >> 24) | (h[1] << 2)) - s[4] = byte(h[1] >> 6) - s[5] = byte(h[1] >> 14) - s[6] = byte((h[1] >> 22) | (h[2] << 3)) - s[7] = byte(h[2] >> 5) - s[8] = byte(h[2] >> 13) - s[9] = byte((h[2] >> 21) | (h[3] << 5)) - s[10] = byte(h[3] >> 3) - s[11] = byte(h[3] >> 11) - s[12] = byte((h[3] >> 19) | (h[4] << 6)) - s[13] = byte(h[4] >> 2) - s[14] = byte(h[4] >> 10) - s[15] = byte(h[4] >> 18) - s[16] = byte(h[5] >> 0) - s[17] = byte(h[5] >> 8) - s[18] = byte(h[5] >> 16) - s[19] = byte((h[5] >> 24) | (h[6] << 1)) - s[20] = byte(h[6] >> 7) - s[21] = byte(h[6] >> 15) - s[22] = byte((h[6] >> 23) | (h[7] << 3)) - s[23] = byte(h[7] >> 5) - s[24] = byte(h[7] >> 13) - s[25] = byte((h[7] >> 21) | (h[8] << 4)) - s[26] = byte(h[8] >> 4) - s[27] = byte(h[8] >> 12) - s[28] = byte((h[8] >> 20) | (h[9] << 6)) - s[29] = byte(h[9] >> 2) - s[30] = byte(h[9] >> 10) - s[31] = byte(h[9] >> 18) -} - -// feMul calculates h = f * g -// Can overlap h with f or g. -// -// Preconditions: -// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. -// |g| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. -// -// Postconditions: -// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. -// -// Notes on implementation strategy: -// -// Using schoolbook multiplication. -// Karatsuba would save a little in some cost models. -// -// Most multiplications by 2 and 19 are 32-bit precomputations; -// cheaper than 64-bit postcomputations. -// -// There is one remaining multiplication by 19 in the carry chain; -// one *19 precomputation can be merged into this, -// but the resulting data flow is considerably less clean. -// -// There are 12 carries below. -// 10 of them are 2-way parallelizable and vectorizable. -// Can get away with 11 carries, but then data flow is much deeper. -// -// With tighter constraints on inputs can squeeze carries into int32. -func feMul(h, f, g *fieldElement) { - f0 := f[0] - f1 := f[1] - f2 := f[2] - f3 := f[3] - f4 := f[4] - f5 := f[5] - f6 := f[6] - f7 := f[7] - f8 := f[8] - f9 := f[9] - g0 := g[0] - g1 := g[1] - g2 := g[2] - g3 := g[3] - g4 := g[4] - g5 := g[5] - g6 := g[6] - g7 := g[7] - g8 := g[8] - g9 := g[9] - g1_19 := 19 * g1 // 1.4*2^29 - g2_19 := 19 * g2 // 1.4*2^30; still ok - g3_19 := 19 * g3 - g4_19 := 19 * g4 - g5_19 := 19 * g5 - g6_19 := 19 * g6 - g7_19 := 19 * g7 - g8_19 := 19 * g8 - g9_19 := 19 * g9 - f1_2 := 2 * f1 - f3_2 := 2 * f3 - f5_2 := 2 * f5 - f7_2 := 2 * f7 - f9_2 := 2 * f9 - f0g0 := int64(f0) * int64(g0) - f0g1 := int64(f0) * int64(g1) - f0g2 := int64(f0) * int64(g2) - f0g3 := int64(f0) * int64(g3) - f0g4 := int64(f0) * int64(g4) - f0g5 := int64(f0) * int64(g5) - f0g6 := int64(f0) * int64(g6) - f0g7 := int64(f0) * int64(g7) - f0g8 := int64(f0) * int64(g8) - f0g9 := int64(f0) * int64(g9) - f1g0 := int64(f1) * int64(g0) - f1g1_2 := int64(f1_2) * int64(g1) - f1g2 := int64(f1) * int64(g2) - f1g3_2 := int64(f1_2) * int64(g3) - f1g4 := int64(f1) * int64(g4) - f1g5_2 := int64(f1_2) * int64(g5) - f1g6 := int64(f1) * int64(g6) - f1g7_2 := int64(f1_2) * int64(g7) - f1g8 := int64(f1) * int64(g8) - f1g9_38 := int64(f1_2) * int64(g9_19) - f2g0 := int64(f2) * int64(g0) - f2g1 := int64(f2) * int64(g1) - f2g2 := int64(f2) * int64(g2) - f2g3 := int64(f2) * int64(g3) - f2g4 := int64(f2) * int64(g4) - f2g5 := int64(f2) * int64(g5) - f2g6 := int64(f2) * int64(g6) - f2g7 := int64(f2) * int64(g7) - f2g8_19 := int64(f2) * int64(g8_19) - f2g9_19 := int64(f2) * int64(g9_19) - f3g0 := int64(f3) * int64(g0) - f3g1_2 := int64(f3_2) * int64(g1) - f3g2 := int64(f3) * int64(g2) - f3g3_2 := int64(f3_2) * int64(g3) - f3g4 := int64(f3) * int64(g4) - f3g5_2 := int64(f3_2) * int64(g5) - f3g6 := int64(f3) * int64(g6) - f3g7_38 := int64(f3_2) * int64(g7_19) - f3g8_19 := int64(f3) * int64(g8_19) - f3g9_38 := int64(f3_2) * int64(g9_19) - f4g0 := int64(f4) * int64(g0) - f4g1 := int64(f4) * int64(g1) - f4g2 := int64(f4) * int64(g2) - f4g3 := int64(f4) * int64(g3) - f4g4 := int64(f4) * int64(g4) - f4g5 := int64(f4) * int64(g5) - f4g6_19 := int64(f4) * int64(g6_19) - f4g7_19 := int64(f4) * int64(g7_19) - f4g8_19 := int64(f4) * int64(g8_19) - f4g9_19 := int64(f4) * int64(g9_19) - f5g0 := int64(f5) * int64(g0) - f5g1_2 := int64(f5_2) * int64(g1) - f5g2 := int64(f5) * int64(g2) - f5g3_2 := int64(f5_2) * int64(g3) - f5g4 := int64(f5) * int64(g4) - f5g5_38 := int64(f5_2) * int64(g5_19) - f5g6_19 := int64(f5) * int64(g6_19) - f5g7_38 := int64(f5_2) * int64(g7_19) - f5g8_19 := int64(f5) * int64(g8_19) - f5g9_38 := int64(f5_2) * int64(g9_19) - f6g0 := int64(f6) * int64(g0) - f6g1 := int64(f6) * int64(g1) - f6g2 := int64(f6) * int64(g2) - f6g3 := int64(f6) * int64(g3) - f6g4_19 := int64(f6) * int64(g4_19) - f6g5_19 := int64(f6) * int64(g5_19) - f6g6_19 := int64(f6) * int64(g6_19) - f6g7_19 := int64(f6) * int64(g7_19) - f6g8_19 := int64(f6) * int64(g8_19) - f6g9_19 := int64(f6) * int64(g9_19) - f7g0 := int64(f7) * int64(g0) - f7g1_2 := int64(f7_2) * int64(g1) - f7g2 := int64(f7) * int64(g2) - f7g3_38 := int64(f7_2) * int64(g3_19) - f7g4_19 := int64(f7) * int64(g4_19) - f7g5_38 := int64(f7_2) * int64(g5_19) - f7g6_19 := int64(f7) * int64(g6_19) - f7g7_38 := int64(f7_2) * int64(g7_19) - f7g8_19 := int64(f7) * int64(g8_19) - f7g9_38 := int64(f7_2) * int64(g9_19) - f8g0 := int64(f8) * int64(g0) - f8g1 := int64(f8) * int64(g1) - f8g2_19 := int64(f8) * int64(g2_19) - f8g3_19 := int64(f8) * int64(g3_19) - f8g4_19 := int64(f8) * int64(g4_19) - f8g5_19 := int64(f8) * int64(g5_19) - f8g6_19 := int64(f8) * int64(g6_19) - f8g7_19 := int64(f8) * int64(g7_19) - f8g8_19 := int64(f8) * int64(g8_19) - f8g9_19 := int64(f8) * int64(g9_19) - f9g0 := int64(f9) * int64(g0) - f9g1_38 := int64(f9_2) * int64(g1_19) - f9g2_19 := int64(f9) * int64(g2_19) - f9g3_38 := int64(f9_2) * int64(g3_19) - f9g4_19 := int64(f9) * int64(g4_19) - f9g5_38 := int64(f9_2) * int64(g5_19) - f9g6_19 := int64(f9) * int64(g6_19) - f9g7_38 := int64(f9_2) * int64(g7_19) - f9g8_19 := int64(f9) * int64(g8_19) - f9g9_38 := int64(f9_2) * int64(g9_19) - h0 := f0g0 + f1g9_38 + f2g8_19 + f3g7_38 + f4g6_19 + f5g5_38 + f6g4_19 + f7g3_38 + f8g2_19 + f9g1_38 - h1 := f0g1 + f1g0 + f2g9_19 + f3g8_19 + f4g7_19 + f5g6_19 + f6g5_19 + f7g4_19 + f8g3_19 + f9g2_19 - h2 := f0g2 + f1g1_2 + f2g0 + f3g9_38 + f4g8_19 + f5g7_38 + f6g6_19 + f7g5_38 + f8g4_19 + f9g3_38 - h3 := f0g3 + f1g2 + f2g1 + f3g0 + f4g9_19 + f5g8_19 + f6g7_19 + f7g6_19 + f8g5_19 + f9g4_19 - h4 := f0g4 + f1g3_2 + f2g2 + f3g1_2 + f4g0 + f5g9_38 + f6g8_19 + f7g7_38 + f8g6_19 + f9g5_38 - h5 := f0g5 + f1g4 + f2g3 + f3g2 + f4g1 + f5g0 + f6g9_19 + f7g8_19 + f8g7_19 + f9g6_19 - h6 := f0g6 + f1g5_2 + f2g4 + f3g3_2 + f4g2 + f5g1_2 + f6g0 + f7g9_38 + f8g8_19 + f9g7_38 - h7 := f0g7 + f1g6 + f2g5 + f3g4 + f4g3 + f5g2 + f6g1 + f7g0 + f8g9_19 + f9g8_19 - h8 := f0g8 + f1g7_2 + f2g6 + f3g5_2 + f4g4 + f5g3_2 + f6g2 + f7g1_2 + f8g0 + f9g9_38 - h9 := f0g9 + f1g8 + f2g7 + f3g6 + f4g5 + f5g4 + f6g3 + f7g2 + f8g1 + f9g0 - var carry [10]int64 - - // |h0| <= (1.1*1.1*2^52*(1+19+19+19+19)+1.1*1.1*2^50*(38+38+38+38+38)) - // i.e. |h0| <= 1.2*2^59; narrower ranges for h2, h4, h6, h8 - // |h1| <= (1.1*1.1*2^51*(1+1+19+19+19+19+19+19+19+19)) - // i.e. |h1| <= 1.5*2^58; narrower ranges for h3, h5, h7, h9 - - carry[0] = (h0 + (1 << 25)) >> 26 - h1 += carry[0] - h0 -= carry[0] << 26 - carry[4] = (h4 + (1 << 25)) >> 26 - h5 += carry[4] - h4 -= carry[4] << 26 - // |h0| <= 2^25 - // |h4| <= 2^25 - // |h1| <= 1.51*2^58 - // |h5| <= 1.51*2^58 - - carry[1] = (h1 + (1 << 24)) >> 25 - h2 += carry[1] - h1 -= carry[1] << 25 - carry[5] = (h5 + (1 << 24)) >> 25 - h6 += carry[5] - h5 -= carry[5] << 25 - // |h1| <= 2^24; from now on fits into int32 - // |h5| <= 2^24; from now on fits into int32 - // |h2| <= 1.21*2^59 - // |h6| <= 1.21*2^59 - - carry[2] = (h2 + (1 << 25)) >> 26 - h3 += carry[2] - h2 -= carry[2] << 26 - carry[6] = (h6 + (1 << 25)) >> 26 - h7 += carry[6] - h6 -= carry[6] << 26 - // |h2| <= 2^25; from now on fits into int32 unchanged - // |h6| <= 2^25; from now on fits into int32 unchanged - // |h3| <= 1.51*2^58 - // |h7| <= 1.51*2^58 - - carry[3] = (h3 + (1 << 24)) >> 25 - h4 += carry[3] - h3 -= carry[3] << 25 - carry[7] = (h7 + (1 << 24)) >> 25 - h8 += carry[7] - h7 -= carry[7] << 25 - // |h3| <= 2^24; from now on fits into int32 unchanged - // |h7| <= 2^24; from now on fits into int32 unchanged - // |h4| <= 1.52*2^33 - // |h8| <= 1.52*2^33 - - carry[4] = (h4 + (1 << 25)) >> 26 - h5 += carry[4] - h4 -= carry[4] << 26 - carry[8] = (h8 + (1 << 25)) >> 26 - h9 += carry[8] - h8 -= carry[8] << 26 - // |h4| <= 2^25; from now on fits into int32 unchanged - // |h8| <= 2^25; from now on fits into int32 unchanged - // |h5| <= 1.01*2^24 - // |h9| <= 1.51*2^58 - - carry[9] = (h9 + (1 << 24)) >> 25 - h0 += carry[9] * 19 - h9 -= carry[9] << 25 - // |h9| <= 2^24; from now on fits into int32 unchanged - // |h0| <= 1.8*2^37 - - carry[0] = (h0 + (1 << 25)) >> 26 - h1 += carry[0] - h0 -= carry[0] << 26 - // |h0| <= 2^25; from now on fits into int32 unchanged - // |h1| <= 1.01*2^24 - - h[0] = int32(h0) - h[1] = int32(h1) - h[2] = int32(h2) - h[3] = int32(h3) - h[4] = int32(h4) - h[5] = int32(h5) - h[6] = int32(h6) - h[7] = int32(h7) - h[8] = int32(h8) - h[9] = int32(h9) -} - -// feSquare calculates h = f*f. Can overlap h with f. -// -// Preconditions: -// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. -// -// Postconditions: -// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. -func feSquare(h, f *fieldElement) { - f0 := f[0] - f1 := f[1] - f2 := f[2] - f3 := f[3] - f4 := f[4] - f5 := f[5] - f6 := f[6] - f7 := f[7] - f8 := f[8] - f9 := f[9] - f0_2 := 2 * f0 - f1_2 := 2 * f1 - f2_2 := 2 * f2 - f3_2 := 2 * f3 - f4_2 := 2 * f4 - f5_2 := 2 * f5 - f6_2 := 2 * f6 - f7_2 := 2 * f7 - f5_38 := 38 * f5 // 1.31*2^30 - f6_19 := 19 * f6 // 1.31*2^30 - f7_38 := 38 * f7 // 1.31*2^30 - f8_19 := 19 * f8 // 1.31*2^30 - f9_38 := 38 * f9 // 1.31*2^30 - f0f0 := int64(f0) * int64(f0) - f0f1_2 := int64(f0_2) * int64(f1) - f0f2_2 := int64(f0_2) * int64(f2) - f0f3_2 := int64(f0_2) * int64(f3) - f0f4_2 := int64(f0_2) * int64(f4) - f0f5_2 := int64(f0_2) * int64(f5) - f0f6_2 := int64(f0_2) * int64(f6) - f0f7_2 := int64(f0_2) * int64(f7) - f0f8_2 := int64(f0_2) * int64(f8) - f0f9_2 := int64(f0_2) * int64(f9) - f1f1_2 := int64(f1_2) * int64(f1) - f1f2_2 := int64(f1_2) * int64(f2) - f1f3_4 := int64(f1_2) * int64(f3_2) - f1f4_2 := int64(f1_2) * int64(f4) - f1f5_4 := int64(f1_2) * int64(f5_2) - f1f6_2 := int64(f1_2) * int64(f6) - f1f7_4 := int64(f1_2) * int64(f7_2) - f1f8_2 := int64(f1_2) * int64(f8) - f1f9_76 := int64(f1_2) * int64(f9_38) - f2f2 := int64(f2) * int64(f2) - f2f3_2 := int64(f2_2) * int64(f3) - f2f4_2 := int64(f2_2) * int64(f4) - f2f5_2 := int64(f2_2) * int64(f5) - f2f6_2 := int64(f2_2) * int64(f6) - f2f7_2 := int64(f2_2) * int64(f7) - f2f8_38 := int64(f2_2) * int64(f8_19) - f2f9_38 := int64(f2) * int64(f9_38) - f3f3_2 := int64(f3_2) * int64(f3) - f3f4_2 := int64(f3_2) * int64(f4) - f3f5_4 := int64(f3_2) * int64(f5_2) - f3f6_2 := int64(f3_2) * int64(f6) - f3f7_76 := int64(f3_2) * int64(f7_38) - f3f8_38 := int64(f3_2) * int64(f8_19) - f3f9_76 := int64(f3_2) * int64(f9_38) - f4f4 := int64(f4) * int64(f4) - f4f5_2 := int64(f4_2) * int64(f5) - f4f6_38 := int64(f4_2) * int64(f6_19) - f4f7_38 := int64(f4) * int64(f7_38) - f4f8_38 := int64(f4_2) * int64(f8_19) - f4f9_38 := int64(f4) * int64(f9_38) - f5f5_38 := int64(f5) * int64(f5_38) - f5f6_38 := int64(f5_2) * int64(f6_19) - f5f7_76 := int64(f5_2) * int64(f7_38) - f5f8_38 := int64(f5_2) * int64(f8_19) - f5f9_76 := int64(f5_2) * int64(f9_38) - f6f6_19 := int64(f6) * int64(f6_19) - f6f7_38 := int64(f6) * int64(f7_38) - f6f8_38 := int64(f6_2) * int64(f8_19) - f6f9_38 := int64(f6) * int64(f9_38) - f7f7_38 := int64(f7) * int64(f7_38) - f7f8_38 := int64(f7_2) * int64(f8_19) - f7f9_76 := int64(f7_2) * int64(f9_38) - f8f8_19 := int64(f8) * int64(f8_19) - f8f9_38 := int64(f8) * int64(f9_38) - f9f9_38 := int64(f9) * int64(f9_38) - h0 := f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38 - h1 := f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38 - h2 := f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19 - h3 := f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38 - h4 := f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38 - h5 := f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38 - h6 := f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19 - h7 := f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38 - h8 := f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38 - h9 := f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2 - var carry [10]int64 - - carry[0] = (h0 + (1 << 25)) >> 26 - h1 += carry[0] - h0 -= carry[0] << 26 - carry[4] = (h4 + (1 << 25)) >> 26 - h5 += carry[4] - h4 -= carry[4] << 26 - - carry[1] = (h1 + (1 << 24)) >> 25 - h2 += carry[1] - h1 -= carry[1] << 25 - carry[5] = (h5 + (1 << 24)) >> 25 - h6 += carry[5] - h5 -= carry[5] << 25 - - carry[2] = (h2 + (1 << 25)) >> 26 - h3 += carry[2] - h2 -= carry[2] << 26 - carry[6] = (h6 + (1 << 25)) >> 26 - h7 += carry[6] - h6 -= carry[6] << 26 - - carry[3] = (h3 + (1 << 24)) >> 25 - h4 += carry[3] - h3 -= carry[3] << 25 - carry[7] = (h7 + (1 << 24)) >> 25 - h8 += carry[7] - h7 -= carry[7] << 25 - - carry[4] = (h4 + (1 << 25)) >> 26 - h5 += carry[4] - h4 -= carry[4] << 26 - carry[8] = (h8 + (1 << 25)) >> 26 - h9 += carry[8] - h8 -= carry[8] << 26 - - carry[9] = (h9 + (1 << 24)) >> 25 - h0 += carry[9] * 19 - h9 -= carry[9] << 25 - - carry[0] = (h0 + (1 << 25)) >> 26 - h1 += carry[0] - h0 -= carry[0] << 26 - - h[0] = int32(h0) - h[1] = int32(h1) - h[2] = int32(h2) - h[3] = int32(h3) - h[4] = int32(h4) - h[5] = int32(h5) - h[6] = int32(h6) - h[7] = int32(h7) - h[8] = int32(h8) - h[9] = int32(h9) -} - -// feMul121666 calculates h = f * 121666. Can overlap h with f. -// -// Preconditions: -// |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. -// -// Postconditions: -// |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. -func feMul121666(h, f *fieldElement) { - h0 := int64(f[0]) * 121666 - h1 := int64(f[1]) * 121666 - h2 := int64(f[2]) * 121666 - h3 := int64(f[3]) * 121666 - h4 := int64(f[4]) * 121666 - h5 := int64(f[5]) * 121666 - h6 := int64(f[6]) * 121666 - h7 := int64(f[7]) * 121666 - h8 := int64(f[8]) * 121666 - h9 := int64(f[9]) * 121666 - var carry [10]int64 - - carry[9] = (h9 + (1 << 24)) >> 25 - h0 += carry[9] * 19 - h9 -= carry[9] << 25 - carry[1] = (h1 + (1 << 24)) >> 25 - h2 += carry[1] - h1 -= carry[1] << 25 - carry[3] = (h3 + (1 << 24)) >> 25 - h4 += carry[3] - h3 -= carry[3] << 25 - carry[5] = (h5 + (1 << 24)) >> 25 - h6 += carry[5] - h5 -= carry[5] << 25 - carry[7] = (h7 + (1 << 24)) >> 25 - h8 += carry[7] - h7 -= carry[7] << 25 - - carry[0] = (h0 + (1 << 25)) >> 26 - h1 += carry[0] - h0 -= carry[0] << 26 - carry[2] = (h2 + (1 << 25)) >> 26 - h3 += carry[2] - h2 -= carry[2] << 26 - carry[4] = (h4 + (1 << 25)) >> 26 - h5 += carry[4] - h4 -= carry[4] << 26 - carry[6] = (h6 + (1 << 25)) >> 26 - h7 += carry[6] - h6 -= carry[6] << 26 - carry[8] = (h8 + (1 << 25)) >> 26 - h9 += carry[8] - h8 -= carry[8] << 26 - - h[0] = int32(h0) - h[1] = int32(h1) - h[2] = int32(h2) - h[3] = int32(h3) - h[4] = int32(h4) - h[5] = int32(h5) - h[6] = int32(h6) - h[7] = int32(h7) - h[8] = int32(h8) - h[9] = int32(h9) -} - -// feInvert sets out = z^-1. -func feInvert(out, z *fieldElement) { - var t0, t1, t2, t3 fieldElement - var i int - - feSquare(&t0, z) - for i = 1; i < 1; i++ { - feSquare(&t0, &t0) - } - feSquare(&t1, &t0) - for i = 1; i < 2; i++ { - feSquare(&t1, &t1) - } - feMul(&t1, z, &t1) - feMul(&t0, &t0, &t1) - feSquare(&t2, &t0) - for i = 1; i < 1; i++ { - feSquare(&t2, &t2) - } - feMul(&t1, &t1, &t2) - feSquare(&t2, &t1) - for i = 1; i < 5; i++ { - feSquare(&t2, &t2) - } - feMul(&t1, &t2, &t1) - feSquare(&t2, &t1) - for i = 1; i < 10; i++ { - feSquare(&t2, &t2) - } - feMul(&t2, &t2, &t1) - feSquare(&t3, &t2) - for i = 1; i < 20; i++ { - feSquare(&t3, &t3) - } - feMul(&t2, &t3, &t2) - feSquare(&t2, &t2) - for i = 1; i < 10; i++ { - feSquare(&t2, &t2) - } - feMul(&t1, &t2, &t1) - feSquare(&t2, &t1) - for i = 1; i < 50; i++ { - feSquare(&t2, &t2) - } - feMul(&t2, &t2, &t1) - feSquare(&t3, &t2) - for i = 1; i < 100; i++ { - feSquare(&t3, &t3) - } - feMul(&t2, &t3, &t2) - feSquare(&t2, &t2) - for i = 1; i < 50; i++ { - feSquare(&t2, &t2) - } - feMul(&t1, &t2, &t1) - feSquare(&t1, &t1) - for i = 1; i < 5; i++ { - feSquare(&t1, &t1) - } - feMul(out, &t1, &t0) -} - -func scalarMult(out, in, base *[32]byte) { - var e [32]byte - - copy(e[:], in[:]) - e[0] &= 248 - e[31] &= 127 - e[31] |= 64 - - var x1, x2, z2, x3, z3, tmp0, tmp1 fieldElement - feFromBytes(&x1, base) - feOne(&x2) - feCopy(&x3, &x1) - feOne(&z3) - - swap := int32(0) - for pos := 254; pos >= 0; pos-- { - b := e[pos/8] >> uint(pos&7) - b &= 1 - swap ^= int32(b) - feCSwap(&x2, &x3, swap) - feCSwap(&z2, &z3, swap) - swap = int32(b) - - feSub(&tmp0, &x3, &z3) - feSub(&tmp1, &x2, &z2) - feAdd(&x2, &x2, &z2) - feAdd(&z2, &x3, &z3) - feMul(&z3, &tmp0, &x2) - feMul(&z2, &z2, &tmp1) - feSquare(&tmp0, &tmp1) - feSquare(&tmp1, &x2) - feAdd(&x3, &z3, &z2) - feSub(&z2, &z3, &z2) - feMul(&x2, &tmp1, &tmp0) - feSub(&tmp1, &tmp1, &tmp0) - feSquare(&z2, &z2) - feMul121666(&z3, &tmp1) - feSquare(&x3, &x3) - feAdd(&tmp0, &tmp0, &z3) - feMul(&z3, &x1, &z2) - feMul(&z2, &tmp1, &tmp0) - } - - feCSwap(&x2, &x3, swap) - feCSwap(&z2, &z3, swap) - - feInvert(&z2, &z2) - feMul(&x2, &x2, &z2) - feToBytes(out, &x2) -} diff --git a/vendor/golang.org/x/crypto/curve25519/doc.go b/vendor/golang.org/x/crypto/curve25519/doc.go deleted file mode 100644 index da9b10d..0000000 --- a/vendor/golang.org/x/crypto/curve25519/doc.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package curve25519 provides an implementation of scalar multiplication on -// the elliptic curve known as curve25519. See https://cr.yp.to/ecdh.html -package curve25519 // import "golang.org/x/crypto/curve25519" - -// basePoint is the x coordinate of the generator of the curve. -var basePoint = [32]byte{9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - -// ScalarMult sets dst to the product in*base where dst and base are the x -// coordinates of group points and all values are in little-endian form. -func ScalarMult(dst, in, base *[32]byte) { - scalarMult(dst, in, base) -} - -// ScalarBaseMult sets dst to the product in*base where dst and base are the x -// coordinates of group points, base is the standard generator and all values -// are in little-endian form. -func ScalarBaseMult(dst, in *[32]byte) { - ScalarMult(dst, in, &basePoint) -} diff --git a/vendor/golang.org/x/crypto/curve25519/freeze_amd64.s b/vendor/golang.org/x/crypto/curve25519/freeze_amd64.s deleted file mode 100644 index 3908161..0000000 --- a/vendor/golang.org/x/crypto/curve25519/freeze_amd64.s +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code was translated into a form compatible with 6a from the public -// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html - -// +build amd64,!gccgo,!appengine - -#include "const_amd64.h" - -// func freeze(inout *[5]uint64) -TEXT ·freeze(SB),7,$0-8 - MOVQ inout+0(FP), DI - - MOVQ 0(DI),SI - MOVQ 8(DI),DX - MOVQ 16(DI),CX - MOVQ 24(DI),R8 - MOVQ 32(DI),R9 - MOVQ $REDMASK51,AX - MOVQ AX,R10 - SUBQ $18,R10 - MOVQ $3,R11 -REDUCELOOP: - MOVQ SI,R12 - SHRQ $51,R12 - ANDQ AX,SI - ADDQ R12,DX - MOVQ DX,R12 - SHRQ $51,R12 - ANDQ AX,DX - ADDQ R12,CX - MOVQ CX,R12 - SHRQ $51,R12 - ANDQ AX,CX - ADDQ R12,R8 - MOVQ R8,R12 - SHRQ $51,R12 - ANDQ AX,R8 - ADDQ R12,R9 - MOVQ R9,R12 - SHRQ $51,R12 - ANDQ AX,R9 - IMUL3Q $19,R12,R12 - ADDQ R12,SI - SUBQ $1,R11 - JA REDUCELOOP - MOVQ $1,R12 - CMPQ R10,SI - CMOVQLT R11,R12 - CMPQ AX,DX - CMOVQNE R11,R12 - CMPQ AX,CX - CMOVQNE R11,R12 - CMPQ AX,R8 - CMOVQNE R11,R12 - CMPQ AX,R9 - CMOVQNE R11,R12 - NEGQ R12 - ANDQ R12,AX - ANDQ R12,R10 - SUBQ R10,SI - SUBQ AX,DX - SUBQ AX,CX - SUBQ AX,R8 - SUBQ AX,R9 - MOVQ SI,0(DI) - MOVQ DX,8(DI) - MOVQ CX,16(DI) - MOVQ R8,24(DI) - MOVQ R9,32(DI) - RET diff --git a/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s b/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s deleted file mode 100644 index 9e9040b..0000000 --- a/vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s +++ /dev/null @@ -1,1377 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code was translated into a form compatible with 6a from the public -// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html - -// +build amd64,!gccgo,!appengine - -#include "const_amd64.h" - -// func ladderstep(inout *[5][5]uint64) -TEXT ·ladderstep(SB),0,$296-8 - MOVQ inout+0(FP),DI - - MOVQ 40(DI),SI - MOVQ 48(DI),DX - MOVQ 56(DI),CX - MOVQ 64(DI),R8 - MOVQ 72(DI),R9 - MOVQ SI,AX - MOVQ DX,R10 - MOVQ CX,R11 - MOVQ R8,R12 - MOVQ R9,R13 - ADDQ ·_2P0(SB),AX - ADDQ ·_2P1234(SB),R10 - ADDQ ·_2P1234(SB),R11 - ADDQ ·_2P1234(SB),R12 - ADDQ ·_2P1234(SB),R13 - ADDQ 80(DI),SI - ADDQ 88(DI),DX - ADDQ 96(DI),CX - ADDQ 104(DI),R8 - ADDQ 112(DI),R9 - SUBQ 80(DI),AX - SUBQ 88(DI),R10 - SUBQ 96(DI),R11 - SUBQ 104(DI),R12 - SUBQ 112(DI),R13 - MOVQ SI,0(SP) - MOVQ DX,8(SP) - MOVQ CX,16(SP) - MOVQ R8,24(SP) - MOVQ R9,32(SP) - MOVQ AX,40(SP) - MOVQ R10,48(SP) - MOVQ R11,56(SP) - MOVQ R12,64(SP) - MOVQ R13,72(SP) - MOVQ 40(SP),AX - MULQ 40(SP) - MOVQ AX,SI - MOVQ DX,CX - MOVQ 40(SP),AX - SHLQ $1,AX - MULQ 48(SP) - MOVQ AX,R8 - MOVQ DX,R9 - MOVQ 40(SP),AX - SHLQ $1,AX - MULQ 56(SP) - MOVQ AX,R10 - MOVQ DX,R11 - MOVQ 40(SP),AX - SHLQ $1,AX - MULQ 64(SP) - MOVQ AX,R12 - MOVQ DX,R13 - MOVQ 40(SP),AX - SHLQ $1,AX - MULQ 72(SP) - MOVQ AX,R14 - MOVQ DX,R15 - MOVQ 48(SP),AX - MULQ 48(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 48(SP),AX - SHLQ $1,AX - MULQ 56(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 48(SP),AX - SHLQ $1,AX - MULQ 64(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 48(SP),DX - IMUL3Q $38,DX,AX - MULQ 72(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 56(SP),AX - MULQ 56(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 56(SP),DX - IMUL3Q $38,DX,AX - MULQ 64(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 56(SP),DX - IMUL3Q $38,DX,AX - MULQ 72(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 64(SP),DX - IMUL3Q $19,DX,AX - MULQ 64(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 64(SP),DX - IMUL3Q $38,DX,AX - MULQ 72(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 72(SP),DX - IMUL3Q $19,DX,AX - MULQ 72(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ $REDMASK51,DX - SHLQ $13,CX:SI - ANDQ DX,SI - SHLQ $13,R9:R8 - ANDQ DX,R8 - ADDQ CX,R8 - SHLQ $13,R11:R10 - ANDQ DX,R10 - ADDQ R9,R10 - SHLQ $13,R13:R12 - ANDQ DX,R12 - ADDQ R11,R12 - SHLQ $13,R15:R14 - ANDQ DX,R14 - ADDQ R13,R14 - IMUL3Q $19,R15,CX - ADDQ CX,SI - MOVQ SI,CX - SHRQ $51,CX - ADDQ R8,CX - ANDQ DX,SI - MOVQ CX,R8 - SHRQ $51,CX - ADDQ R10,CX - ANDQ DX,R8 - MOVQ CX,R9 - SHRQ $51,CX - ADDQ R12,CX - ANDQ DX,R9 - MOVQ CX,AX - SHRQ $51,CX - ADDQ R14,CX - ANDQ DX,AX - MOVQ CX,R10 - SHRQ $51,CX - IMUL3Q $19,CX,CX - ADDQ CX,SI - ANDQ DX,R10 - MOVQ SI,80(SP) - MOVQ R8,88(SP) - MOVQ R9,96(SP) - MOVQ AX,104(SP) - MOVQ R10,112(SP) - MOVQ 0(SP),AX - MULQ 0(SP) - MOVQ AX,SI - MOVQ DX,CX - MOVQ 0(SP),AX - SHLQ $1,AX - MULQ 8(SP) - MOVQ AX,R8 - MOVQ DX,R9 - MOVQ 0(SP),AX - SHLQ $1,AX - MULQ 16(SP) - MOVQ AX,R10 - MOVQ DX,R11 - MOVQ 0(SP),AX - SHLQ $1,AX - MULQ 24(SP) - MOVQ AX,R12 - MOVQ DX,R13 - MOVQ 0(SP),AX - SHLQ $1,AX - MULQ 32(SP) - MOVQ AX,R14 - MOVQ DX,R15 - MOVQ 8(SP),AX - MULQ 8(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 8(SP),AX - SHLQ $1,AX - MULQ 16(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 8(SP),AX - SHLQ $1,AX - MULQ 24(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 8(SP),DX - IMUL3Q $38,DX,AX - MULQ 32(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 16(SP),AX - MULQ 16(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 16(SP),DX - IMUL3Q $38,DX,AX - MULQ 24(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 16(SP),DX - IMUL3Q $38,DX,AX - MULQ 32(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 24(SP),DX - IMUL3Q $19,DX,AX - MULQ 24(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 24(SP),DX - IMUL3Q $38,DX,AX - MULQ 32(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 32(SP),DX - IMUL3Q $19,DX,AX - MULQ 32(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ $REDMASK51,DX - SHLQ $13,CX:SI - ANDQ DX,SI - SHLQ $13,R9:R8 - ANDQ DX,R8 - ADDQ CX,R8 - SHLQ $13,R11:R10 - ANDQ DX,R10 - ADDQ R9,R10 - SHLQ $13,R13:R12 - ANDQ DX,R12 - ADDQ R11,R12 - SHLQ $13,R15:R14 - ANDQ DX,R14 - ADDQ R13,R14 - IMUL3Q $19,R15,CX - ADDQ CX,SI - MOVQ SI,CX - SHRQ $51,CX - ADDQ R8,CX - ANDQ DX,SI - MOVQ CX,R8 - SHRQ $51,CX - ADDQ R10,CX - ANDQ DX,R8 - MOVQ CX,R9 - SHRQ $51,CX - ADDQ R12,CX - ANDQ DX,R9 - MOVQ CX,AX - SHRQ $51,CX - ADDQ R14,CX - ANDQ DX,AX - MOVQ CX,R10 - SHRQ $51,CX - IMUL3Q $19,CX,CX - ADDQ CX,SI - ANDQ DX,R10 - MOVQ SI,120(SP) - MOVQ R8,128(SP) - MOVQ R9,136(SP) - MOVQ AX,144(SP) - MOVQ R10,152(SP) - MOVQ SI,SI - MOVQ R8,DX - MOVQ R9,CX - MOVQ AX,R8 - MOVQ R10,R9 - ADDQ ·_2P0(SB),SI - ADDQ ·_2P1234(SB),DX - ADDQ ·_2P1234(SB),CX - ADDQ ·_2P1234(SB),R8 - ADDQ ·_2P1234(SB),R9 - SUBQ 80(SP),SI - SUBQ 88(SP),DX - SUBQ 96(SP),CX - SUBQ 104(SP),R8 - SUBQ 112(SP),R9 - MOVQ SI,160(SP) - MOVQ DX,168(SP) - MOVQ CX,176(SP) - MOVQ R8,184(SP) - MOVQ R9,192(SP) - MOVQ 120(DI),SI - MOVQ 128(DI),DX - MOVQ 136(DI),CX - MOVQ 144(DI),R8 - MOVQ 152(DI),R9 - MOVQ SI,AX - MOVQ DX,R10 - MOVQ CX,R11 - MOVQ R8,R12 - MOVQ R9,R13 - ADDQ ·_2P0(SB),AX - ADDQ ·_2P1234(SB),R10 - ADDQ ·_2P1234(SB),R11 - ADDQ ·_2P1234(SB),R12 - ADDQ ·_2P1234(SB),R13 - ADDQ 160(DI),SI - ADDQ 168(DI),DX - ADDQ 176(DI),CX - ADDQ 184(DI),R8 - ADDQ 192(DI),R9 - SUBQ 160(DI),AX - SUBQ 168(DI),R10 - SUBQ 176(DI),R11 - SUBQ 184(DI),R12 - SUBQ 192(DI),R13 - MOVQ SI,200(SP) - MOVQ DX,208(SP) - MOVQ CX,216(SP) - MOVQ R8,224(SP) - MOVQ R9,232(SP) - MOVQ AX,240(SP) - MOVQ R10,248(SP) - MOVQ R11,256(SP) - MOVQ R12,264(SP) - MOVQ R13,272(SP) - MOVQ 224(SP),SI - IMUL3Q $19,SI,AX - MOVQ AX,280(SP) - MULQ 56(SP) - MOVQ AX,SI - MOVQ DX,CX - MOVQ 232(SP),DX - IMUL3Q $19,DX,AX - MOVQ AX,288(SP) - MULQ 48(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 200(SP),AX - MULQ 40(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 200(SP),AX - MULQ 48(SP) - MOVQ AX,R8 - MOVQ DX,R9 - MOVQ 200(SP),AX - MULQ 56(SP) - MOVQ AX,R10 - MOVQ DX,R11 - MOVQ 200(SP),AX - MULQ 64(SP) - MOVQ AX,R12 - MOVQ DX,R13 - MOVQ 200(SP),AX - MULQ 72(SP) - MOVQ AX,R14 - MOVQ DX,R15 - MOVQ 208(SP),AX - MULQ 40(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 208(SP),AX - MULQ 48(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 208(SP),AX - MULQ 56(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 208(SP),AX - MULQ 64(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 208(SP),DX - IMUL3Q $19,DX,AX - MULQ 72(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 216(SP),AX - MULQ 40(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 216(SP),AX - MULQ 48(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 216(SP),AX - MULQ 56(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 216(SP),DX - IMUL3Q $19,DX,AX - MULQ 64(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 216(SP),DX - IMUL3Q $19,DX,AX - MULQ 72(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 224(SP),AX - MULQ 40(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 224(SP),AX - MULQ 48(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 280(SP),AX - MULQ 64(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 280(SP),AX - MULQ 72(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 232(SP),AX - MULQ 40(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 288(SP),AX - MULQ 56(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 288(SP),AX - MULQ 64(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 288(SP),AX - MULQ 72(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ $REDMASK51,DX - SHLQ $13,CX:SI - ANDQ DX,SI - SHLQ $13,R9:R8 - ANDQ DX,R8 - ADDQ CX,R8 - SHLQ $13,R11:R10 - ANDQ DX,R10 - ADDQ R9,R10 - SHLQ $13,R13:R12 - ANDQ DX,R12 - ADDQ R11,R12 - SHLQ $13,R15:R14 - ANDQ DX,R14 - ADDQ R13,R14 - IMUL3Q $19,R15,CX - ADDQ CX,SI - MOVQ SI,CX - SHRQ $51,CX - ADDQ R8,CX - MOVQ CX,R8 - SHRQ $51,CX - ANDQ DX,SI - ADDQ R10,CX - MOVQ CX,R9 - SHRQ $51,CX - ANDQ DX,R8 - ADDQ R12,CX - MOVQ CX,AX - SHRQ $51,CX - ANDQ DX,R9 - ADDQ R14,CX - MOVQ CX,R10 - SHRQ $51,CX - ANDQ DX,AX - IMUL3Q $19,CX,CX - ADDQ CX,SI - ANDQ DX,R10 - MOVQ SI,40(SP) - MOVQ R8,48(SP) - MOVQ R9,56(SP) - MOVQ AX,64(SP) - MOVQ R10,72(SP) - MOVQ 264(SP),SI - IMUL3Q $19,SI,AX - MOVQ AX,200(SP) - MULQ 16(SP) - MOVQ AX,SI - MOVQ DX,CX - MOVQ 272(SP),DX - IMUL3Q $19,DX,AX - MOVQ AX,208(SP) - MULQ 8(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 240(SP),AX - MULQ 0(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 240(SP),AX - MULQ 8(SP) - MOVQ AX,R8 - MOVQ DX,R9 - MOVQ 240(SP),AX - MULQ 16(SP) - MOVQ AX,R10 - MOVQ DX,R11 - MOVQ 240(SP),AX - MULQ 24(SP) - MOVQ AX,R12 - MOVQ DX,R13 - MOVQ 240(SP),AX - MULQ 32(SP) - MOVQ AX,R14 - MOVQ DX,R15 - MOVQ 248(SP),AX - MULQ 0(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 248(SP),AX - MULQ 8(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 248(SP),AX - MULQ 16(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 248(SP),AX - MULQ 24(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 248(SP),DX - IMUL3Q $19,DX,AX - MULQ 32(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 256(SP),AX - MULQ 0(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 256(SP),AX - MULQ 8(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 256(SP),AX - MULQ 16(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 256(SP),DX - IMUL3Q $19,DX,AX - MULQ 24(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 256(SP),DX - IMUL3Q $19,DX,AX - MULQ 32(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 264(SP),AX - MULQ 0(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 264(SP),AX - MULQ 8(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 200(SP),AX - MULQ 24(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 200(SP),AX - MULQ 32(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 272(SP),AX - MULQ 0(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 208(SP),AX - MULQ 16(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 208(SP),AX - MULQ 24(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 208(SP),AX - MULQ 32(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ $REDMASK51,DX - SHLQ $13,CX:SI - ANDQ DX,SI - SHLQ $13,R9:R8 - ANDQ DX,R8 - ADDQ CX,R8 - SHLQ $13,R11:R10 - ANDQ DX,R10 - ADDQ R9,R10 - SHLQ $13,R13:R12 - ANDQ DX,R12 - ADDQ R11,R12 - SHLQ $13,R15:R14 - ANDQ DX,R14 - ADDQ R13,R14 - IMUL3Q $19,R15,CX - ADDQ CX,SI - MOVQ SI,CX - SHRQ $51,CX - ADDQ R8,CX - MOVQ CX,R8 - SHRQ $51,CX - ANDQ DX,SI - ADDQ R10,CX - MOVQ CX,R9 - SHRQ $51,CX - ANDQ DX,R8 - ADDQ R12,CX - MOVQ CX,AX - SHRQ $51,CX - ANDQ DX,R9 - ADDQ R14,CX - MOVQ CX,R10 - SHRQ $51,CX - ANDQ DX,AX - IMUL3Q $19,CX,CX - ADDQ CX,SI - ANDQ DX,R10 - MOVQ SI,DX - MOVQ R8,CX - MOVQ R9,R11 - MOVQ AX,R12 - MOVQ R10,R13 - ADDQ ·_2P0(SB),DX - ADDQ ·_2P1234(SB),CX - ADDQ ·_2P1234(SB),R11 - ADDQ ·_2P1234(SB),R12 - ADDQ ·_2P1234(SB),R13 - ADDQ 40(SP),SI - ADDQ 48(SP),R8 - ADDQ 56(SP),R9 - ADDQ 64(SP),AX - ADDQ 72(SP),R10 - SUBQ 40(SP),DX - SUBQ 48(SP),CX - SUBQ 56(SP),R11 - SUBQ 64(SP),R12 - SUBQ 72(SP),R13 - MOVQ SI,120(DI) - MOVQ R8,128(DI) - MOVQ R9,136(DI) - MOVQ AX,144(DI) - MOVQ R10,152(DI) - MOVQ DX,160(DI) - MOVQ CX,168(DI) - MOVQ R11,176(DI) - MOVQ R12,184(DI) - MOVQ R13,192(DI) - MOVQ 120(DI),AX - MULQ 120(DI) - MOVQ AX,SI - MOVQ DX,CX - MOVQ 120(DI),AX - SHLQ $1,AX - MULQ 128(DI) - MOVQ AX,R8 - MOVQ DX,R9 - MOVQ 120(DI),AX - SHLQ $1,AX - MULQ 136(DI) - MOVQ AX,R10 - MOVQ DX,R11 - MOVQ 120(DI),AX - SHLQ $1,AX - MULQ 144(DI) - MOVQ AX,R12 - MOVQ DX,R13 - MOVQ 120(DI),AX - SHLQ $1,AX - MULQ 152(DI) - MOVQ AX,R14 - MOVQ DX,R15 - MOVQ 128(DI),AX - MULQ 128(DI) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 128(DI),AX - SHLQ $1,AX - MULQ 136(DI) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 128(DI),AX - SHLQ $1,AX - MULQ 144(DI) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 128(DI),DX - IMUL3Q $38,DX,AX - MULQ 152(DI) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 136(DI),AX - MULQ 136(DI) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 136(DI),DX - IMUL3Q $38,DX,AX - MULQ 144(DI) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 136(DI),DX - IMUL3Q $38,DX,AX - MULQ 152(DI) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 144(DI),DX - IMUL3Q $19,DX,AX - MULQ 144(DI) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 144(DI),DX - IMUL3Q $38,DX,AX - MULQ 152(DI) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 152(DI),DX - IMUL3Q $19,DX,AX - MULQ 152(DI) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ $REDMASK51,DX - SHLQ $13,CX:SI - ANDQ DX,SI - SHLQ $13,R9:R8 - ANDQ DX,R8 - ADDQ CX,R8 - SHLQ $13,R11:R10 - ANDQ DX,R10 - ADDQ R9,R10 - SHLQ $13,R13:R12 - ANDQ DX,R12 - ADDQ R11,R12 - SHLQ $13,R15:R14 - ANDQ DX,R14 - ADDQ R13,R14 - IMUL3Q $19,R15,CX - ADDQ CX,SI - MOVQ SI,CX - SHRQ $51,CX - ADDQ R8,CX - ANDQ DX,SI - MOVQ CX,R8 - SHRQ $51,CX - ADDQ R10,CX - ANDQ DX,R8 - MOVQ CX,R9 - SHRQ $51,CX - ADDQ R12,CX - ANDQ DX,R9 - MOVQ CX,AX - SHRQ $51,CX - ADDQ R14,CX - ANDQ DX,AX - MOVQ CX,R10 - SHRQ $51,CX - IMUL3Q $19,CX,CX - ADDQ CX,SI - ANDQ DX,R10 - MOVQ SI,120(DI) - MOVQ R8,128(DI) - MOVQ R9,136(DI) - MOVQ AX,144(DI) - MOVQ R10,152(DI) - MOVQ 160(DI),AX - MULQ 160(DI) - MOVQ AX,SI - MOVQ DX,CX - MOVQ 160(DI),AX - SHLQ $1,AX - MULQ 168(DI) - MOVQ AX,R8 - MOVQ DX,R9 - MOVQ 160(DI),AX - SHLQ $1,AX - MULQ 176(DI) - MOVQ AX,R10 - MOVQ DX,R11 - MOVQ 160(DI),AX - SHLQ $1,AX - MULQ 184(DI) - MOVQ AX,R12 - MOVQ DX,R13 - MOVQ 160(DI),AX - SHLQ $1,AX - MULQ 192(DI) - MOVQ AX,R14 - MOVQ DX,R15 - MOVQ 168(DI),AX - MULQ 168(DI) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 168(DI),AX - SHLQ $1,AX - MULQ 176(DI) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 168(DI),AX - SHLQ $1,AX - MULQ 184(DI) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 168(DI),DX - IMUL3Q $38,DX,AX - MULQ 192(DI) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 176(DI),AX - MULQ 176(DI) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 176(DI),DX - IMUL3Q $38,DX,AX - MULQ 184(DI) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 176(DI),DX - IMUL3Q $38,DX,AX - MULQ 192(DI) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 184(DI),DX - IMUL3Q $19,DX,AX - MULQ 184(DI) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 184(DI),DX - IMUL3Q $38,DX,AX - MULQ 192(DI) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 192(DI),DX - IMUL3Q $19,DX,AX - MULQ 192(DI) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ $REDMASK51,DX - SHLQ $13,CX:SI - ANDQ DX,SI - SHLQ $13,R9:R8 - ANDQ DX,R8 - ADDQ CX,R8 - SHLQ $13,R11:R10 - ANDQ DX,R10 - ADDQ R9,R10 - SHLQ $13,R13:R12 - ANDQ DX,R12 - ADDQ R11,R12 - SHLQ $13,R15:R14 - ANDQ DX,R14 - ADDQ R13,R14 - IMUL3Q $19,R15,CX - ADDQ CX,SI - MOVQ SI,CX - SHRQ $51,CX - ADDQ R8,CX - ANDQ DX,SI - MOVQ CX,R8 - SHRQ $51,CX - ADDQ R10,CX - ANDQ DX,R8 - MOVQ CX,R9 - SHRQ $51,CX - ADDQ R12,CX - ANDQ DX,R9 - MOVQ CX,AX - SHRQ $51,CX - ADDQ R14,CX - ANDQ DX,AX - MOVQ CX,R10 - SHRQ $51,CX - IMUL3Q $19,CX,CX - ADDQ CX,SI - ANDQ DX,R10 - MOVQ SI,160(DI) - MOVQ R8,168(DI) - MOVQ R9,176(DI) - MOVQ AX,184(DI) - MOVQ R10,192(DI) - MOVQ 184(DI),SI - IMUL3Q $19,SI,AX - MOVQ AX,0(SP) - MULQ 16(DI) - MOVQ AX,SI - MOVQ DX,CX - MOVQ 192(DI),DX - IMUL3Q $19,DX,AX - MOVQ AX,8(SP) - MULQ 8(DI) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 160(DI),AX - MULQ 0(DI) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 160(DI),AX - MULQ 8(DI) - MOVQ AX,R8 - MOVQ DX,R9 - MOVQ 160(DI),AX - MULQ 16(DI) - MOVQ AX,R10 - MOVQ DX,R11 - MOVQ 160(DI),AX - MULQ 24(DI) - MOVQ AX,R12 - MOVQ DX,R13 - MOVQ 160(DI),AX - MULQ 32(DI) - MOVQ AX,R14 - MOVQ DX,R15 - MOVQ 168(DI),AX - MULQ 0(DI) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 168(DI),AX - MULQ 8(DI) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 168(DI),AX - MULQ 16(DI) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 168(DI),AX - MULQ 24(DI) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 168(DI),DX - IMUL3Q $19,DX,AX - MULQ 32(DI) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 176(DI),AX - MULQ 0(DI) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 176(DI),AX - MULQ 8(DI) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 176(DI),AX - MULQ 16(DI) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 176(DI),DX - IMUL3Q $19,DX,AX - MULQ 24(DI) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 176(DI),DX - IMUL3Q $19,DX,AX - MULQ 32(DI) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 184(DI),AX - MULQ 0(DI) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 184(DI),AX - MULQ 8(DI) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 0(SP),AX - MULQ 24(DI) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 0(SP),AX - MULQ 32(DI) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 192(DI),AX - MULQ 0(DI) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 8(SP),AX - MULQ 16(DI) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 8(SP),AX - MULQ 24(DI) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 8(SP),AX - MULQ 32(DI) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ $REDMASK51,DX - SHLQ $13,CX:SI - ANDQ DX,SI - SHLQ $13,R9:R8 - ANDQ DX,R8 - ADDQ CX,R8 - SHLQ $13,R11:R10 - ANDQ DX,R10 - ADDQ R9,R10 - SHLQ $13,R13:R12 - ANDQ DX,R12 - ADDQ R11,R12 - SHLQ $13,R15:R14 - ANDQ DX,R14 - ADDQ R13,R14 - IMUL3Q $19,R15,CX - ADDQ CX,SI - MOVQ SI,CX - SHRQ $51,CX - ADDQ R8,CX - MOVQ CX,R8 - SHRQ $51,CX - ANDQ DX,SI - ADDQ R10,CX - MOVQ CX,R9 - SHRQ $51,CX - ANDQ DX,R8 - ADDQ R12,CX - MOVQ CX,AX - SHRQ $51,CX - ANDQ DX,R9 - ADDQ R14,CX - MOVQ CX,R10 - SHRQ $51,CX - ANDQ DX,AX - IMUL3Q $19,CX,CX - ADDQ CX,SI - ANDQ DX,R10 - MOVQ SI,160(DI) - MOVQ R8,168(DI) - MOVQ R9,176(DI) - MOVQ AX,184(DI) - MOVQ R10,192(DI) - MOVQ 144(SP),SI - IMUL3Q $19,SI,AX - MOVQ AX,0(SP) - MULQ 96(SP) - MOVQ AX,SI - MOVQ DX,CX - MOVQ 152(SP),DX - IMUL3Q $19,DX,AX - MOVQ AX,8(SP) - MULQ 88(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 120(SP),AX - MULQ 80(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 120(SP),AX - MULQ 88(SP) - MOVQ AX,R8 - MOVQ DX,R9 - MOVQ 120(SP),AX - MULQ 96(SP) - MOVQ AX,R10 - MOVQ DX,R11 - MOVQ 120(SP),AX - MULQ 104(SP) - MOVQ AX,R12 - MOVQ DX,R13 - MOVQ 120(SP),AX - MULQ 112(SP) - MOVQ AX,R14 - MOVQ DX,R15 - MOVQ 128(SP),AX - MULQ 80(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 128(SP),AX - MULQ 88(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 128(SP),AX - MULQ 96(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 128(SP),AX - MULQ 104(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 128(SP),DX - IMUL3Q $19,DX,AX - MULQ 112(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 136(SP),AX - MULQ 80(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 136(SP),AX - MULQ 88(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 136(SP),AX - MULQ 96(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 136(SP),DX - IMUL3Q $19,DX,AX - MULQ 104(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 136(SP),DX - IMUL3Q $19,DX,AX - MULQ 112(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 144(SP),AX - MULQ 80(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 144(SP),AX - MULQ 88(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 0(SP),AX - MULQ 104(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 0(SP),AX - MULQ 112(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 152(SP),AX - MULQ 80(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 8(SP),AX - MULQ 96(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 8(SP),AX - MULQ 104(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 8(SP),AX - MULQ 112(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ $REDMASK51,DX - SHLQ $13,CX:SI - ANDQ DX,SI - SHLQ $13,R9:R8 - ANDQ DX,R8 - ADDQ CX,R8 - SHLQ $13,R11:R10 - ANDQ DX,R10 - ADDQ R9,R10 - SHLQ $13,R13:R12 - ANDQ DX,R12 - ADDQ R11,R12 - SHLQ $13,R15:R14 - ANDQ DX,R14 - ADDQ R13,R14 - IMUL3Q $19,R15,CX - ADDQ CX,SI - MOVQ SI,CX - SHRQ $51,CX - ADDQ R8,CX - MOVQ CX,R8 - SHRQ $51,CX - ANDQ DX,SI - ADDQ R10,CX - MOVQ CX,R9 - SHRQ $51,CX - ANDQ DX,R8 - ADDQ R12,CX - MOVQ CX,AX - SHRQ $51,CX - ANDQ DX,R9 - ADDQ R14,CX - MOVQ CX,R10 - SHRQ $51,CX - ANDQ DX,AX - IMUL3Q $19,CX,CX - ADDQ CX,SI - ANDQ DX,R10 - MOVQ SI,40(DI) - MOVQ R8,48(DI) - MOVQ R9,56(DI) - MOVQ AX,64(DI) - MOVQ R10,72(DI) - MOVQ 160(SP),AX - MULQ ·_121666_213(SB) - SHRQ $13,AX - MOVQ AX,SI - MOVQ DX,CX - MOVQ 168(SP),AX - MULQ ·_121666_213(SB) - SHRQ $13,AX - ADDQ AX,CX - MOVQ DX,R8 - MOVQ 176(SP),AX - MULQ ·_121666_213(SB) - SHRQ $13,AX - ADDQ AX,R8 - MOVQ DX,R9 - MOVQ 184(SP),AX - MULQ ·_121666_213(SB) - SHRQ $13,AX - ADDQ AX,R9 - MOVQ DX,R10 - MOVQ 192(SP),AX - MULQ ·_121666_213(SB) - SHRQ $13,AX - ADDQ AX,R10 - IMUL3Q $19,DX,DX - ADDQ DX,SI - ADDQ 80(SP),SI - ADDQ 88(SP),CX - ADDQ 96(SP),R8 - ADDQ 104(SP),R9 - ADDQ 112(SP),R10 - MOVQ SI,80(DI) - MOVQ CX,88(DI) - MOVQ R8,96(DI) - MOVQ R9,104(DI) - MOVQ R10,112(DI) - MOVQ 104(DI),SI - IMUL3Q $19,SI,AX - MOVQ AX,0(SP) - MULQ 176(SP) - MOVQ AX,SI - MOVQ DX,CX - MOVQ 112(DI),DX - IMUL3Q $19,DX,AX - MOVQ AX,8(SP) - MULQ 168(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 80(DI),AX - MULQ 160(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 80(DI),AX - MULQ 168(SP) - MOVQ AX,R8 - MOVQ DX,R9 - MOVQ 80(DI),AX - MULQ 176(SP) - MOVQ AX,R10 - MOVQ DX,R11 - MOVQ 80(DI),AX - MULQ 184(SP) - MOVQ AX,R12 - MOVQ DX,R13 - MOVQ 80(DI),AX - MULQ 192(SP) - MOVQ AX,R14 - MOVQ DX,R15 - MOVQ 88(DI),AX - MULQ 160(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 88(DI),AX - MULQ 168(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 88(DI),AX - MULQ 176(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 88(DI),AX - MULQ 184(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 88(DI),DX - IMUL3Q $19,DX,AX - MULQ 192(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 96(DI),AX - MULQ 160(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 96(DI),AX - MULQ 168(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 96(DI),AX - MULQ 176(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 96(DI),DX - IMUL3Q $19,DX,AX - MULQ 184(SP) - ADDQ AX,SI - ADCQ DX,CX - MOVQ 96(DI),DX - IMUL3Q $19,DX,AX - MULQ 192(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 104(DI),AX - MULQ 160(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 104(DI),AX - MULQ 168(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 0(SP),AX - MULQ 184(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 0(SP),AX - MULQ 192(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 112(DI),AX - MULQ 160(SP) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 8(SP),AX - MULQ 176(SP) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 8(SP),AX - MULQ 184(SP) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 8(SP),AX - MULQ 192(SP) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ $REDMASK51,DX - SHLQ $13,CX:SI - ANDQ DX,SI - SHLQ $13,R9:R8 - ANDQ DX,R8 - ADDQ CX,R8 - SHLQ $13,R11:R10 - ANDQ DX,R10 - ADDQ R9,R10 - SHLQ $13,R13:R12 - ANDQ DX,R12 - ADDQ R11,R12 - SHLQ $13,R15:R14 - ANDQ DX,R14 - ADDQ R13,R14 - IMUL3Q $19,R15,CX - ADDQ CX,SI - MOVQ SI,CX - SHRQ $51,CX - ADDQ R8,CX - MOVQ CX,R8 - SHRQ $51,CX - ANDQ DX,SI - ADDQ R10,CX - MOVQ CX,R9 - SHRQ $51,CX - ANDQ DX,R8 - ADDQ R12,CX - MOVQ CX,AX - SHRQ $51,CX - ANDQ DX,R9 - ADDQ R14,CX - MOVQ CX,R10 - SHRQ $51,CX - ANDQ DX,AX - IMUL3Q $19,CX,CX - ADDQ CX,SI - ANDQ DX,R10 - MOVQ SI,80(DI) - MOVQ R8,88(DI) - MOVQ R9,96(DI) - MOVQ AX,104(DI) - MOVQ R10,112(DI) - RET diff --git a/vendor/golang.org/x/crypto/curve25519/mont25519_amd64.go b/vendor/golang.org/x/crypto/curve25519/mont25519_amd64.go deleted file mode 100644 index 5822bd5..0000000 --- a/vendor/golang.org/x/crypto/curve25519/mont25519_amd64.go +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build amd64,!gccgo,!appengine - -package curve25519 - -// These functions are implemented in the .s files. The names of the functions -// in the rest of the file are also taken from the SUPERCOP sources to help -// people following along. - -//go:noescape - -func cswap(inout *[5]uint64, v uint64) - -//go:noescape - -func ladderstep(inout *[5][5]uint64) - -//go:noescape - -func freeze(inout *[5]uint64) - -//go:noescape - -func mul(dest, a, b *[5]uint64) - -//go:noescape - -func square(out, in *[5]uint64) - -// mladder uses a Montgomery ladder to calculate (xr/zr) *= s. -func mladder(xr, zr *[5]uint64, s *[32]byte) { - var work [5][5]uint64 - - work[0] = *xr - setint(&work[1], 1) - setint(&work[2], 0) - work[3] = *xr - setint(&work[4], 1) - - j := uint(6) - var prevbit byte - - for i := 31; i >= 0; i-- { - for j < 8 { - bit := ((*s)[i] >> j) & 1 - swap := bit ^ prevbit - prevbit = bit - cswap(&work[1], uint64(swap)) - ladderstep(&work) - j-- - } - j = 7 - } - - *xr = work[1] - *zr = work[2] -} - -func scalarMult(out, in, base *[32]byte) { - var e [32]byte - copy(e[:], (*in)[:]) - e[0] &= 248 - e[31] &= 127 - e[31] |= 64 - - var t, z [5]uint64 - unpack(&t, base) - mladder(&t, &z, &e) - invert(&z, &z) - mul(&t, &t, &z) - pack(out, &t) -} - -func setint(r *[5]uint64, v uint64) { - r[0] = v - r[1] = 0 - r[2] = 0 - r[3] = 0 - r[4] = 0 -} - -// unpack sets r = x where r consists of 5, 51-bit limbs in little-endian -// order. -func unpack(r *[5]uint64, x *[32]byte) { - r[0] = uint64(x[0]) | - uint64(x[1])<<8 | - uint64(x[2])<<16 | - uint64(x[3])<<24 | - uint64(x[4])<<32 | - uint64(x[5])<<40 | - uint64(x[6]&7)<<48 - - r[1] = uint64(x[6])>>3 | - uint64(x[7])<<5 | - uint64(x[8])<<13 | - uint64(x[9])<<21 | - uint64(x[10])<<29 | - uint64(x[11])<<37 | - uint64(x[12]&63)<<45 - - r[2] = uint64(x[12])>>6 | - uint64(x[13])<<2 | - uint64(x[14])<<10 | - uint64(x[15])<<18 | - uint64(x[16])<<26 | - uint64(x[17])<<34 | - uint64(x[18])<<42 | - uint64(x[19]&1)<<50 - - r[3] = uint64(x[19])>>1 | - uint64(x[20])<<7 | - uint64(x[21])<<15 | - uint64(x[22])<<23 | - uint64(x[23])<<31 | - uint64(x[24])<<39 | - uint64(x[25]&15)<<47 - - r[4] = uint64(x[25])>>4 | - uint64(x[26])<<4 | - uint64(x[27])<<12 | - uint64(x[28])<<20 | - uint64(x[29])<<28 | - uint64(x[30])<<36 | - uint64(x[31]&127)<<44 -} - -// pack sets out = x where out is the usual, little-endian form of the 5, -// 51-bit limbs in x. -func pack(out *[32]byte, x *[5]uint64) { - t := *x - freeze(&t) - - out[0] = byte(t[0]) - out[1] = byte(t[0] >> 8) - out[2] = byte(t[0] >> 16) - out[3] = byte(t[0] >> 24) - out[4] = byte(t[0] >> 32) - out[5] = byte(t[0] >> 40) - out[6] = byte(t[0] >> 48) - - out[6] ^= byte(t[1]<<3) & 0xf8 - out[7] = byte(t[1] >> 5) - out[8] = byte(t[1] >> 13) - out[9] = byte(t[1] >> 21) - out[10] = byte(t[1] >> 29) - out[11] = byte(t[1] >> 37) - out[12] = byte(t[1] >> 45) - - out[12] ^= byte(t[2]<<6) & 0xc0 - out[13] = byte(t[2] >> 2) - out[14] = byte(t[2] >> 10) - out[15] = byte(t[2] >> 18) - out[16] = byte(t[2] >> 26) - out[17] = byte(t[2] >> 34) - out[18] = byte(t[2] >> 42) - out[19] = byte(t[2] >> 50) - - out[19] ^= byte(t[3]<<1) & 0xfe - out[20] = byte(t[3] >> 7) - out[21] = byte(t[3] >> 15) - out[22] = byte(t[3] >> 23) - out[23] = byte(t[3] >> 31) - out[24] = byte(t[3] >> 39) - out[25] = byte(t[3] >> 47) - - out[25] ^= byte(t[4]<<4) & 0xf0 - out[26] = byte(t[4] >> 4) - out[27] = byte(t[4] >> 12) - out[28] = byte(t[4] >> 20) - out[29] = byte(t[4] >> 28) - out[30] = byte(t[4] >> 36) - out[31] = byte(t[4] >> 44) -} - -// invert calculates r = x^-1 mod p using Fermat's little theorem. -func invert(r *[5]uint64, x *[5]uint64) { - var z2, z9, z11, z2_5_0, z2_10_0, z2_20_0, z2_50_0, z2_100_0, t [5]uint64 - - square(&z2, x) /* 2 */ - square(&t, &z2) /* 4 */ - square(&t, &t) /* 8 */ - mul(&z9, &t, x) /* 9 */ - mul(&z11, &z9, &z2) /* 11 */ - square(&t, &z11) /* 22 */ - mul(&z2_5_0, &t, &z9) /* 2^5 - 2^0 = 31 */ - - square(&t, &z2_5_0) /* 2^6 - 2^1 */ - for i := 1; i < 5; i++ { /* 2^20 - 2^10 */ - square(&t, &t) - } - mul(&z2_10_0, &t, &z2_5_0) /* 2^10 - 2^0 */ - - square(&t, &z2_10_0) /* 2^11 - 2^1 */ - for i := 1; i < 10; i++ { /* 2^20 - 2^10 */ - square(&t, &t) - } - mul(&z2_20_0, &t, &z2_10_0) /* 2^20 - 2^0 */ - - square(&t, &z2_20_0) /* 2^21 - 2^1 */ - for i := 1; i < 20; i++ { /* 2^40 - 2^20 */ - square(&t, &t) - } - mul(&t, &t, &z2_20_0) /* 2^40 - 2^0 */ - - square(&t, &t) /* 2^41 - 2^1 */ - for i := 1; i < 10; i++ { /* 2^50 - 2^10 */ - square(&t, &t) - } - mul(&z2_50_0, &t, &z2_10_0) /* 2^50 - 2^0 */ - - square(&t, &z2_50_0) /* 2^51 - 2^1 */ - for i := 1; i < 50; i++ { /* 2^100 - 2^50 */ - square(&t, &t) - } - mul(&z2_100_0, &t, &z2_50_0) /* 2^100 - 2^0 */ - - square(&t, &z2_100_0) /* 2^101 - 2^1 */ - for i := 1; i < 100; i++ { /* 2^200 - 2^100 */ - square(&t, &t) - } - mul(&t, &t, &z2_100_0) /* 2^200 - 2^0 */ - - square(&t, &t) /* 2^201 - 2^1 */ - for i := 1; i < 50; i++ { /* 2^250 - 2^50 */ - square(&t, &t) - } - mul(&t, &t, &z2_50_0) /* 2^250 - 2^0 */ - - square(&t, &t) /* 2^251 - 2^1 */ - square(&t, &t) /* 2^252 - 2^2 */ - square(&t, &t) /* 2^253 - 2^3 */ - - square(&t, &t) /* 2^254 - 2^4 */ - - square(&t, &t) /* 2^255 - 2^5 */ - mul(r, &t, &z11) /* 2^255 - 21 */ -} diff --git a/vendor/golang.org/x/crypto/curve25519/mul_amd64.s b/vendor/golang.org/x/crypto/curve25519/mul_amd64.s deleted file mode 100644 index 5ce80a2..0000000 --- a/vendor/golang.org/x/crypto/curve25519/mul_amd64.s +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code was translated into a form compatible with 6a from the public -// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html - -// +build amd64,!gccgo,!appengine - -#include "const_amd64.h" - -// func mul(dest, a, b *[5]uint64) -TEXT ·mul(SB),0,$16-24 - MOVQ dest+0(FP), DI - MOVQ a+8(FP), SI - MOVQ b+16(FP), DX - - MOVQ DX,CX - MOVQ 24(SI),DX - IMUL3Q $19,DX,AX - MOVQ AX,0(SP) - MULQ 16(CX) - MOVQ AX,R8 - MOVQ DX,R9 - MOVQ 32(SI),DX - IMUL3Q $19,DX,AX - MOVQ AX,8(SP) - MULQ 8(CX) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 0(SI),AX - MULQ 0(CX) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 0(SI),AX - MULQ 8(CX) - MOVQ AX,R10 - MOVQ DX,R11 - MOVQ 0(SI),AX - MULQ 16(CX) - MOVQ AX,R12 - MOVQ DX,R13 - MOVQ 0(SI),AX - MULQ 24(CX) - MOVQ AX,R14 - MOVQ DX,R15 - MOVQ 0(SI),AX - MULQ 32(CX) - MOVQ AX,BX - MOVQ DX,BP - MOVQ 8(SI),AX - MULQ 0(CX) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 8(SI),AX - MULQ 8(CX) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 8(SI),AX - MULQ 16(CX) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 8(SI),AX - MULQ 24(CX) - ADDQ AX,BX - ADCQ DX,BP - MOVQ 8(SI),DX - IMUL3Q $19,DX,AX - MULQ 32(CX) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 16(SI),AX - MULQ 0(CX) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 16(SI),AX - MULQ 8(CX) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 16(SI),AX - MULQ 16(CX) - ADDQ AX,BX - ADCQ DX,BP - MOVQ 16(SI),DX - IMUL3Q $19,DX,AX - MULQ 24(CX) - ADDQ AX,R8 - ADCQ DX,R9 - MOVQ 16(SI),DX - IMUL3Q $19,DX,AX - MULQ 32(CX) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 24(SI),AX - MULQ 0(CX) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ 24(SI),AX - MULQ 8(CX) - ADDQ AX,BX - ADCQ DX,BP - MOVQ 0(SP),AX - MULQ 24(CX) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 0(SP),AX - MULQ 32(CX) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 32(SI),AX - MULQ 0(CX) - ADDQ AX,BX - ADCQ DX,BP - MOVQ 8(SP),AX - MULQ 16(CX) - ADDQ AX,R10 - ADCQ DX,R11 - MOVQ 8(SP),AX - MULQ 24(CX) - ADDQ AX,R12 - ADCQ DX,R13 - MOVQ 8(SP),AX - MULQ 32(CX) - ADDQ AX,R14 - ADCQ DX,R15 - MOVQ $REDMASK51,SI - SHLQ $13,R9:R8 - ANDQ SI,R8 - SHLQ $13,R11:R10 - ANDQ SI,R10 - ADDQ R9,R10 - SHLQ $13,R13:R12 - ANDQ SI,R12 - ADDQ R11,R12 - SHLQ $13,R15:R14 - ANDQ SI,R14 - ADDQ R13,R14 - SHLQ $13,BP:BX - ANDQ SI,BX - ADDQ R15,BX - IMUL3Q $19,BP,DX - ADDQ DX,R8 - MOVQ R8,DX - SHRQ $51,DX - ADDQ R10,DX - MOVQ DX,CX - SHRQ $51,DX - ANDQ SI,R8 - ADDQ R12,DX - MOVQ DX,R9 - SHRQ $51,DX - ANDQ SI,CX - ADDQ R14,DX - MOVQ DX,AX - SHRQ $51,DX - ANDQ SI,R9 - ADDQ BX,DX - MOVQ DX,R10 - SHRQ $51,DX - ANDQ SI,AX - IMUL3Q $19,DX,DX - ADDQ DX,R8 - ANDQ SI,R10 - MOVQ R8,0(DI) - MOVQ CX,8(DI) - MOVQ R9,16(DI) - MOVQ AX,24(DI) - MOVQ R10,32(DI) - RET diff --git a/vendor/golang.org/x/crypto/curve25519/square_amd64.s b/vendor/golang.org/x/crypto/curve25519/square_amd64.s deleted file mode 100644 index 12f7373..0000000 --- a/vendor/golang.org/x/crypto/curve25519/square_amd64.s +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This code was translated into a form compatible with 6a from the public -// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html - -// +build amd64,!gccgo,!appengine - -#include "const_amd64.h" - -// func square(out, in *[5]uint64) -TEXT ·square(SB),7,$0-16 - MOVQ out+0(FP), DI - MOVQ in+8(FP), SI - - MOVQ 0(SI),AX - MULQ 0(SI) - MOVQ AX,CX - MOVQ DX,R8 - MOVQ 0(SI),AX - SHLQ $1,AX - MULQ 8(SI) - MOVQ AX,R9 - MOVQ DX,R10 - MOVQ 0(SI),AX - SHLQ $1,AX - MULQ 16(SI) - MOVQ AX,R11 - MOVQ DX,R12 - MOVQ 0(SI),AX - SHLQ $1,AX - MULQ 24(SI) - MOVQ AX,R13 - MOVQ DX,R14 - MOVQ 0(SI),AX - SHLQ $1,AX - MULQ 32(SI) - MOVQ AX,R15 - MOVQ DX,BX - MOVQ 8(SI),AX - MULQ 8(SI) - ADDQ AX,R11 - ADCQ DX,R12 - MOVQ 8(SI),AX - SHLQ $1,AX - MULQ 16(SI) - ADDQ AX,R13 - ADCQ DX,R14 - MOVQ 8(SI),AX - SHLQ $1,AX - MULQ 24(SI) - ADDQ AX,R15 - ADCQ DX,BX - MOVQ 8(SI),DX - IMUL3Q $38,DX,AX - MULQ 32(SI) - ADDQ AX,CX - ADCQ DX,R8 - MOVQ 16(SI),AX - MULQ 16(SI) - ADDQ AX,R15 - ADCQ DX,BX - MOVQ 16(SI),DX - IMUL3Q $38,DX,AX - MULQ 24(SI) - ADDQ AX,CX - ADCQ DX,R8 - MOVQ 16(SI),DX - IMUL3Q $38,DX,AX - MULQ 32(SI) - ADDQ AX,R9 - ADCQ DX,R10 - MOVQ 24(SI),DX - IMUL3Q $19,DX,AX - MULQ 24(SI) - ADDQ AX,R9 - ADCQ DX,R10 - MOVQ 24(SI),DX - IMUL3Q $38,DX,AX - MULQ 32(SI) - ADDQ AX,R11 - ADCQ DX,R12 - MOVQ 32(SI),DX - IMUL3Q $19,DX,AX - MULQ 32(SI) - ADDQ AX,R13 - ADCQ DX,R14 - MOVQ $REDMASK51,SI - SHLQ $13,R8:CX - ANDQ SI,CX - SHLQ $13,R10:R9 - ANDQ SI,R9 - ADDQ R8,R9 - SHLQ $13,R12:R11 - ANDQ SI,R11 - ADDQ R10,R11 - SHLQ $13,R14:R13 - ANDQ SI,R13 - ADDQ R12,R13 - SHLQ $13,BX:R15 - ANDQ SI,R15 - ADDQ R14,R15 - IMUL3Q $19,BX,DX - ADDQ DX,CX - MOVQ CX,DX - SHRQ $51,DX - ADDQ R9,DX - ANDQ SI,CX - MOVQ DX,R8 - SHRQ $51,DX - ADDQ R11,DX - ANDQ SI,R8 - MOVQ DX,R9 - SHRQ $51,DX - ADDQ R13,DX - ANDQ SI,R9 - MOVQ DX,AX - SHRQ $51,DX - ADDQ R15,DX - ANDQ SI,AX - MOVQ DX,R10 - SHRQ $51,DX - IMUL3Q $19,DX,DX - ADDQ DX,CX - ANDQ SI,R10 - MOVQ CX,0(DI) - MOVQ R8,8(DI) - MOVQ R9,16(DI) - MOVQ AX,24(DI) - MOVQ R10,32(DI) - RET diff --git a/vendor/golang.org/x/net/AUTHORS b/vendor/golang.org/x/net/AUTHORS deleted file mode 100644 index 15167cd..0000000 --- a/vendor/golang.org/x/net/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The Go Authors for copyright purposes. -# The master list of authors is in the main Go distribution, -# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/net/CONTRIBUTORS b/vendor/golang.org/x/net/CONTRIBUTORS deleted file mode 100644 index 1c4577e..0000000 --- a/vendor/golang.org/x/net/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the Go contributors. -# The master list of contributors is in the main Go distribution, -# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/net/LICENSE b/vendor/golang.org/x/net/LICENSE deleted file mode 100644 index 6a66aea..0000000 --- a/vendor/golang.org/x/net/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/net/PATENTS b/vendor/golang.org/x/net/PATENTS deleted file mode 100644 index 7330990..0000000 --- a/vendor/golang.org/x/net/PATENTS +++ /dev/null @@ -1,22 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Go project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Go, where such license applies only to those patent -claims, both currently owned or controlled by Google and acquired in -the future, licensable by Google that are necessarily infringed by this -implementation of Go. This grant does not include claims that would be -infringed only as a consequence of further modification of this -implementation. If you or your agent or exclusive licensee institute or -order or agree to the institution of patent litigation against any -entity (including a cross-claim or counterclaim in a lawsuit) alleging -that this implementation of Go or any code incorporated within this -implementation of Go constitutes direct or contributory patent -infringement, or inducement of patent infringement, then any patent -rights granted to you under this License for this implementation of Go -shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/net/bpf/asm.go b/vendor/golang.org/x/net/bpf/asm.go deleted file mode 100644 index 15e21b1..0000000 --- a/vendor/golang.org/x/net/bpf/asm.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package bpf - -import "fmt" - -// Assemble converts insts into raw instructions suitable for loading -// into a BPF virtual machine. -// -// Currently, no optimization is attempted, the assembled program flow -// is exactly as provided. -func Assemble(insts []Instruction) ([]RawInstruction, error) { - ret := make([]RawInstruction, len(insts)) - var err error - for i, inst := range insts { - ret[i], err = inst.Assemble() - if err != nil { - return nil, fmt.Errorf("assembling instruction %d: %s", i+1, err) - } - } - return ret, nil -} - -// Disassemble attempts to parse raw back into -// Instructions. Unrecognized RawInstructions are assumed to be an -// extension not implemented by this package, and are passed through -// unchanged to the output. The allDecoded value reports whether insts -// contains no RawInstructions. -func Disassemble(raw []RawInstruction) (insts []Instruction, allDecoded bool) { - insts = make([]Instruction, len(raw)) - allDecoded = true - for i, r := range raw { - insts[i] = r.Disassemble() - if _, ok := insts[i].(RawInstruction); ok { - allDecoded = false - } - } - return insts, allDecoded -} diff --git a/vendor/golang.org/x/net/bpf/constants.go b/vendor/golang.org/x/net/bpf/constants.go deleted file mode 100644 index 12f3ee8..0000000 --- a/vendor/golang.org/x/net/bpf/constants.go +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package bpf - -// A Register is a register of the BPF virtual machine. -type Register uint16 - -const ( - // RegA is the accumulator register. RegA is always the - // destination register of ALU operations. - RegA Register = iota - // RegX is the indirection register, used by LoadIndirect - // operations. - RegX -) - -// An ALUOp is an arithmetic or logic operation. -type ALUOp uint16 - -// ALU binary operation types. -const ( - ALUOpAdd ALUOp = iota << 4 - ALUOpSub - ALUOpMul - ALUOpDiv - ALUOpOr - ALUOpAnd - ALUOpShiftLeft - ALUOpShiftRight - aluOpNeg // Not exported because it's the only unary ALU operation, and gets its own instruction type. - ALUOpMod - ALUOpXor -) - -// A JumpTest is a comparison operator used in conditional jumps. -type JumpTest uint16 - -// Supported operators for conditional jumps. -// K can be RegX for JumpIfX -const ( - // K == A - JumpEqual JumpTest = iota - // K != A - JumpNotEqual - // K > A - JumpGreaterThan - // K < A - JumpLessThan - // K >= A - JumpGreaterOrEqual - // K <= A - JumpLessOrEqual - // K & A != 0 - JumpBitsSet - // K & A == 0 - JumpBitsNotSet -) - -// An Extension is a function call provided by the kernel that -// performs advanced operations that are expensive or impossible -// within the BPF virtual machine. -// -// Extensions are only implemented by the Linux kernel. -// -// TODO: should we prune this list? Some of these extensions seem -// either broken or near-impossible to use correctly, whereas other -// (len, random, ifindex) are quite useful. -type Extension int - -// Extension functions available in the Linux kernel. -const ( - // extOffset is the negative maximum number of instructions used - // to load instructions by overloading the K argument. - extOffset = -0x1000 - // ExtLen returns the length of the packet. - ExtLen Extension = 1 - // ExtProto returns the packet's L3 protocol type. - ExtProto Extension = 0 - // ExtType returns the packet's type (skb->pkt_type in the kernel) - // - // TODO: better documentation. How nice an API do we want to - // provide for these esoteric extensions? - ExtType Extension = 4 - // ExtPayloadOffset returns the offset of the packet payload, or - // the first protocol header that the kernel does not know how to - // parse. - ExtPayloadOffset Extension = 52 - // ExtInterfaceIndex returns the index of the interface on which - // the packet was received. - ExtInterfaceIndex Extension = 8 - // ExtNetlinkAttr returns the netlink attribute of type X at - // offset A. - ExtNetlinkAttr Extension = 12 - // ExtNetlinkAttrNested returns the nested netlink attribute of - // type X at offset A. - ExtNetlinkAttrNested Extension = 16 - // ExtMark returns the packet's mark value. - ExtMark Extension = 20 - // ExtQueue returns the packet's assigned hardware queue. - ExtQueue Extension = 24 - // ExtLinkLayerType returns the packet's hardware address type - // (e.g. Ethernet, Infiniband). - ExtLinkLayerType Extension = 28 - // ExtRXHash returns the packets receive hash. - // - // TODO: figure out what this rxhash actually is. - ExtRXHash Extension = 32 - // ExtCPUID returns the ID of the CPU processing the current - // packet. - ExtCPUID Extension = 36 - // ExtVLANTag returns the packet's VLAN tag. - ExtVLANTag Extension = 44 - // ExtVLANTagPresent returns non-zero if the packet has a VLAN - // tag. - // - // TODO: I think this might be a lie: it reads bit 0x1000 of the - // VLAN header, which changed meaning in recent revisions of the - // spec - this extension may now return meaningless information. - ExtVLANTagPresent Extension = 48 - // ExtVLANProto returns 0x8100 if the frame has a VLAN header, - // 0x88a8 if the frame has a "Q-in-Q" double VLAN header, or some - // other value if no VLAN information is present. - ExtVLANProto Extension = 60 - // ExtRand returns a uniformly random uint32. - ExtRand Extension = 56 -) - -// The following gives names to various bit patterns used in opcode construction. - -const ( - opMaskCls uint16 = 0x7 - // opClsLoad masks - opMaskLoadDest = 0x01 - opMaskLoadWidth = 0x18 - opMaskLoadMode = 0xe0 - // opClsALU & opClsJump - opMaskOperand = 0x08 - opMaskOperator = 0xf0 -) - -const ( - // +---------------+-----------------+---+---+---+ - // | AddrMode (3b) | LoadWidth (2b) | 0 | 0 | 0 | - // +---------------+-----------------+---+---+---+ - opClsLoadA uint16 = iota - // +---------------+-----------------+---+---+---+ - // | AddrMode (3b) | LoadWidth (2b) | 0 | 0 | 1 | - // +---------------+-----------------+---+---+---+ - opClsLoadX - // +---+---+---+---+---+---+---+---+ - // | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | - // +---+---+---+---+---+---+---+---+ - opClsStoreA - // +---+---+---+---+---+---+---+---+ - // | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | - // +---+---+---+---+---+---+---+---+ - opClsStoreX - // +---------------+-----------------+---+---+---+ - // | Operator (4b) | OperandSrc (1b) | 1 | 0 | 0 | - // +---------------+-----------------+---+---+---+ - opClsALU - // +-----------------------------+---+---+---+---+ - // | TestOperator (4b) | 0 | 1 | 0 | 1 | - // +-----------------------------+---+---+---+---+ - opClsJump - // +---+-------------------------+---+---+---+---+ - // | 0 | 0 | 0 | RetSrc (1b) | 0 | 1 | 1 | 0 | - // +---+-------------------------+---+---+---+---+ - opClsReturn - // +---+-------------------------+---+---+---+---+ - // | 0 | 0 | 0 | TXAorTAX (1b) | 0 | 1 | 1 | 1 | - // +---+-------------------------+---+---+---+---+ - opClsMisc -) - -const ( - opAddrModeImmediate uint16 = iota << 5 - opAddrModeAbsolute - opAddrModeIndirect - opAddrModeScratch - opAddrModePacketLen // actually an extension, not an addressing mode. - opAddrModeMemShift -) - -const ( - opLoadWidth4 uint16 = iota << 3 - opLoadWidth2 - opLoadWidth1 -) - -// Operand for ALU and Jump instructions -type opOperand uint16 - -// Supported operand sources. -const ( - opOperandConstant opOperand = iota << 3 - opOperandX -) - -// An jumpOp is a conditional jump condition. -type jumpOp uint16 - -// Supported jump conditions. -const ( - opJumpAlways jumpOp = iota << 4 - opJumpEqual - opJumpGT - opJumpGE - opJumpSet -) - -const ( - opRetSrcConstant uint16 = iota << 4 - opRetSrcA -) - -const ( - opMiscTAX = 0x00 - opMiscTXA = 0x80 -) diff --git a/vendor/golang.org/x/net/bpf/doc.go b/vendor/golang.org/x/net/bpf/doc.go deleted file mode 100644 index ae62feb..0000000 --- a/vendor/golang.org/x/net/bpf/doc.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* - -Package bpf implements marshaling and unmarshaling of programs for the -Berkeley Packet Filter virtual machine, and provides a Go implementation -of the virtual machine. - -BPF's main use is to specify a packet filter for network taps, so that -the kernel doesn't have to expensively copy every packet it sees to -userspace. However, it's been repurposed to other areas where running -user code in-kernel is needed. For example, Linux's seccomp uses BPF -to apply security policies to system calls. For simplicity, this -documentation refers only to packets, but other uses of BPF have their -own data payloads. - -BPF programs run in a restricted virtual machine. It has almost no -access to kernel functions, and while conditional branches are -allowed, they can only jump forwards, to guarantee that there are no -infinite loops. - -The virtual machine - -The BPF VM is an accumulator machine. Its main register, called -register A, is an implicit source and destination in all arithmetic -and logic operations. The machine also has 16 scratch registers for -temporary storage, and an indirection register (register X) for -indirect memory access. All registers are 32 bits wide. - -Each run of a BPF program is given one packet, which is placed in the -VM's read-only "main memory". LoadAbsolute and LoadIndirect -instructions can fetch up to 32 bits at a time into register A for -examination. - -The goal of a BPF program is to produce and return a verdict (uint32), -which tells the kernel what to do with the packet. In the context of -packet filtering, the returned value is the number of bytes of the -packet to forward to userspace, or 0 to ignore the packet. Other -contexts like seccomp define their own return values. - -In order to simplify programs, attempts to read past the end of the -packet terminate the program execution with a verdict of 0 (ignore -packet). This means that the vast majority of BPF programs don't need -to do any explicit bounds checking. - -In addition to the bytes of the packet, some BPF programs have access -to extensions, which are essentially calls to kernel utility -functions. Currently, the only extensions supported by this package -are the Linux packet filter extensions. - -Examples - -This packet filter selects all ARP packets. - - bpf.Assemble([]bpf.Instruction{ - // Load "EtherType" field from the ethernet header. - bpf.LoadAbsolute{Off: 12, Size: 2}, - // Skip over the next instruction if EtherType is not ARP. - bpf.JumpIf{Cond: bpf.JumpNotEqual, Val: 0x0806, SkipTrue: 1}, - // Verdict is "send up to 4k of the packet to userspace." - bpf.RetConstant{Val: 4096}, - // Verdict is "ignore packet." - bpf.RetConstant{Val: 0}, - }) - -This packet filter captures a random 1% sample of traffic. - - bpf.Assemble([]bpf.Instruction{ - // Get a 32-bit random number from the Linux kernel. - bpf.LoadExtension{Num: bpf.ExtRand}, - // 1% dice roll? - bpf.JumpIf{Cond: bpf.JumpLessThan, Val: 2^32/100, SkipFalse: 1}, - // Capture. - bpf.RetConstant{Val: 4096}, - // Ignore. - bpf.RetConstant{Val: 0}, - }) - -*/ -package bpf // import "golang.org/x/net/bpf" diff --git a/vendor/golang.org/x/net/bpf/instructions.go b/vendor/golang.org/x/net/bpf/instructions.go deleted file mode 100644 index 3cffcaa..0000000 --- a/vendor/golang.org/x/net/bpf/instructions.go +++ /dev/null @@ -1,726 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package bpf - -import "fmt" - -// An Instruction is one instruction executed by the BPF virtual -// machine. -type Instruction interface { - // Assemble assembles the Instruction into a RawInstruction. - Assemble() (RawInstruction, error) -} - -// A RawInstruction is a raw BPF virtual machine instruction. -type RawInstruction struct { - // Operation to execute. - Op uint16 - // For conditional jump instructions, the number of instructions - // to skip if the condition is true/false. - Jt uint8 - Jf uint8 - // Constant parameter. The meaning depends on the Op. - K uint32 -} - -// Assemble implements the Instruction Assemble method. -func (ri RawInstruction) Assemble() (RawInstruction, error) { return ri, nil } - -// Disassemble parses ri into an Instruction and returns it. If ri is -// not recognized by this package, ri itself is returned. -func (ri RawInstruction) Disassemble() Instruction { - switch ri.Op & opMaskCls { - case opClsLoadA, opClsLoadX: - reg := Register(ri.Op & opMaskLoadDest) - sz := 0 - switch ri.Op & opMaskLoadWidth { - case opLoadWidth4: - sz = 4 - case opLoadWidth2: - sz = 2 - case opLoadWidth1: - sz = 1 - default: - return ri - } - switch ri.Op & opMaskLoadMode { - case opAddrModeImmediate: - if sz != 4 { - return ri - } - return LoadConstant{Dst: reg, Val: ri.K} - case opAddrModeScratch: - if sz != 4 || ri.K > 15 { - return ri - } - return LoadScratch{Dst: reg, N: int(ri.K)} - case opAddrModeAbsolute: - if ri.K > extOffset+0xffffffff { - return LoadExtension{Num: Extension(-extOffset + ri.K)} - } - return LoadAbsolute{Size: sz, Off: ri.K} - case opAddrModeIndirect: - return LoadIndirect{Size: sz, Off: ri.K} - case opAddrModePacketLen: - if sz != 4 { - return ri - } - return LoadExtension{Num: ExtLen} - case opAddrModeMemShift: - return LoadMemShift{Off: ri.K} - default: - return ri - } - - case opClsStoreA: - if ri.Op != opClsStoreA || ri.K > 15 { - return ri - } - return StoreScratch{Src: RegA, N: int(ri.K)} - - case opClsStoreX: - if ri.Op != opClsStoreX || ri.K > 15 { - return ri - } - return StoreScratch{Src: RegX, N: int(ri.K)} - - case opClsALU: - switch op := ALUOp(ri.Op & opMaskOperator); op { - case ALUOpAdd, ALUOpSub, ALUOpMul, ALUOpDiv, ALUOpOr, ALUOpAnd, ALUOpShiftLeft, ALUOpShiftRight, ALUOpMod, ALUOpXor: - switch operand := opOperand(ri.Op & opMaskOperand); operand { - case opOperandX: - return ALUOpX{Op: op} - case opOperandConstant: - return ALUOpConstant{Op: op, Val: ri.K} - default: - return ri - } - case aluOpNeg: - return NegateA{} - default: - return ri - } - - case opClsJump: - switch op := jumpOp(ri.Op & opMaskOperator); op { - case opJumpAlways: - return Jump{Skip: ri.K} - case opJumpEqual, opJumpGT, opJumpGE, opJumpSet: - cond, skipTrue, skipFalse := jumpOpToTest(op, ri.Jt, ri.Jf) - switch operand := opOperand(ri.Op & opMaskOperand); operand { - case opOperandX: - return JumpIfX{Cond: cond, SkipTrue: skipTrue, SkipFalse: skipFalse} - case opOperandConstant: - return JumpIf{Cond: cond, Val: ri.K, SkipTrue: skipTrue, SkipFalse: skipFalse} - default: - return ri - } - default: - return ri - } - - case opClsReturn: - switch ri.Op { - case opClsReturn | opRetSrcA: - return RetA{} - case opClsReturn | opRetSrcConstant: - return RetConstant{Val: ri.K} - default: - return ri - } - - case opClsMisc: - switch ri.Op { - case opClsMisc | opMiscTAX: - return TAX{} - case opClsMisc | opMiscTXA: - return TXA{} - default: - return ri - } - - default: - panic("unreachable") // switch is exhaustive on the bit pattern - } -} - -func jumpOpToTest(op jumpOp, skipTrue uint8, skipFalse uint8) (JumpTest, uint8, uint8) { - var test JumpTest - - // Decode "fake" jump conditions that don't appear in machine code - // Ensures the Assemble -> Disassemble stage recreates the same instructions - // See https://github.com/golang/go/issues/18470 - if skipTrue == 0 { - switch op { - case opJumpEqual: - test = JumpNotEqual - case opJumpGT: - test = JumpLessOrEqual - case opJumpGE: - test = JumpLessThan - case opJumpSet: - test = JumpBitsNotSet - } - - return test, skipFalse, 0 - } - - switch op { - case opJumpEqual: - test = JumpEqual - case opJumpGT: - test = JumpGreaterThan - case opJumpGE: - test = JumpGreaterOrEqual - case opJumpSet: - test = JumpBitsSet - } - - return test, skipTrue, skipFalse -} - -// LoadConstant loads Val into register Dst. -type LoadConstant struct { - Dst Register - Val uint32 -} - -// Assemble implements the Instruction Assemble method. -func (a LoadConstant) Assemble() (RawInstruction, error) { - return assembleLoad(a.Dst, 4, opAddrModeImmediate, a.Val) -} - -// String returns the instruction in assembler notation. -func (a LoadConstant) String() string { - switch a.Dst { - case RegA: - return fmt.Sprintf("ld #%d", a.Val) - case RegX: - return fmt.Sprintf("ldx #%d", a.Val) - default: - return fmt.Sprintf("unknown instruction: %#v", a) - } -} - -// LoadScratch loads scratch[N] into register Dst. -type LoadScratch struct { - Dst Register - N int // 0-15 -} - -// Assemble implements the Instruction Assemble method. -func (a LoadScratch) Assemble() (RawInstruction, error) { - if a.N < 0 || a.N > 15 { - return RawInstruction{}, fmt.Errorf("invalid scratch slot %d", a.N) - } - return assembleLoad(a.Dst, 4, opAddrModeScratch, uint32(a.N)) -} - -// String returns the instruction in assembler notation. -func (a LoadScratch) String() string { - switch a.Dst { - case RegA: - return fmt.Sprintf("ld M[%d]", a.N) - case RegX: - return fmt.Sprintf("ldx M[%d]", a.N) - default: - return fmt.Sprintf("unknown instruction: %#v", a) - } -} - -// LoadAbsolute loads packet[Off:Off+Size] as an integer value into -// register A. -type LoadAbsolute struct { - Off uint32 - Size int // 1, 2 or 4 -} - -// Assemble implements the Instruction Assemble method. -func (a LoadAbsolute) Assemble() (RawInstruction, error) { - return assembleLoad(RegA, a.Size, opAddrModeAbsolute, a.Off) -} - -// String returns the instruction in assembler notation. -func (a LoadAbsolute) String() string { - switch a.Size { - case 1: // byte - return fmt.Sprintf("ldb [%d]", a.Off) - case 2: // half word - return fmt.Sprintf("ldh [%d]", a.Off) - case 4: // word - if a.Off > extOffset+0xffffffff { - return LoadExtension{Num: Extension(a.Off + 0x1000)}.String() - } - return fmt.Sprintf("ld [%d]", a.Off) - default: - return fmt.Sprintf("unknown instruction: %#v", a) - } -} - -// LoadIndirect loads packet[X+Off:X+Off+Size] as an integer value -// into register A. -type LoadIndirect struct { - Off uint32 - Size int // 1, 2 or 4 -} - -// Assemble implements the Instruction Assemble method. -func (a LoadIndirect) Assemble() (RawInstruction, error) { - return assembleLoad(RegA, a.Size, opAddrModeIndirect, a.Off) -} - -// String returns the instruction in assembler notation. -func (a LoadIndirect) String() string { - switch a.Size { - case 1: // byte - return fmt.Sprintf("ldb [x + %d]", a.Off) - case 2: // half word - return fmt.Sprintf("ldh [x + %d]", a.Off) - case 4: // word - return fmt.Sprintf("ld [x + %d]", a.Off) - default: - return fmt.Sprintf("unknown instruction: %#v", a) - } -} - -// LoadMemShift multiplies the first 4 bits of the byte at packet[Off] -// by 4 and stores the result in register X. -// -// This instruction is mainly useful to load into X the length of an -// IPv4 packet header in a single instruction, rather than have to do -// the arithmetic on the header's first byte by hand. -type LoadMemShift struct { - Off uint32 -} - -// Assemble implements the Instruction Assemble method. -func (a LoadMemShift) Assemble() (RawInstruction, error) { - return assembleLoad(RegX, 1, opAddrModeMemShift, a.Off) -} - -// String returns the instruction in assembler notation. -func (a LoadMemShift) String() string { - return fmt.Sprintf("ldx 4*([%d]&0xf)", a.Off) -} - -// LoadExtension invokes a linux-specific extension and stores the -// result in register A. -type LoadExtension struct { - Num Extension -} - -// Assemble implements the Instruction Assemble method. -func (a LoadExtension) Assemble() (RawInstruction, error) { - if a.Num == ExtLen { - return assembleLoad(RegA, 4, opAddrModePacketLen, 0) - } - return assembleLoad(RegA, 4, opAddrModeAbsolute, uint32(extOffset+a.Num)) -} - -// String returns the instruction in assembler notation. -func (a LoadExtension) String() string { - switch a.Num { - case ExtLen: - return "ld #len" - case ExtProto: - return "ld #proto" - case ExtType: - return "ld #type" - case ExtPayloadOffset: - return "ld #poff" - case ExtInterfaceIndex: - return "ld #ifidx" - case ExtNetlinkAttr: - return "ld #nla" - case ExtNetlinkAttrNested: - return "ld #nlan" - case ExtMark: - return "ld #mark" - case ExtQueue: - return "ld #queue" - case ExtLinkLayerType: - return "ld #hatype" - case ExtRXHash: - return "ld #rxhash" - case ExtCPUID: - return "ld #cpu" - case ExtVLANTag: - return "ld #vlan_tci" - case ExtVLANTagPresent: - return "ld #vlan_avail" - case ExtVLANProto: - return "ld #vlan_tpid" - case ExtRand: - return "ld #rand" - default: - return fmt.Sprintf("unknown instruction: %#v", a) - } -} - -// StoreScratch stores register Src into scratch[N]. -type StoreScratch struct { - Src Register - N int // 0-15 -} - -// Assemble implements the Instruction Assemble method. -func (a StoreScratch) Assemble() (RawInstruction, error) { - if a.N < 0 || a.N > 15 { - return RawInstruction{}, fmt.Errorf("invalid scratch slot %d", a.N) - } - var op uint16 - switch a.Src { - case RegA: - op = opClsStoreA - case RegX: - op = opClsStoreX - default: - return RawInstruction{}, fmt.Errorf("invalid source register %v", a.Src) - } - - return RawInstruction{ - Op: op, - K: uint32(a.N), - }, nil -} - -// String returns the instruction in assembler notation. -func (a StoreScratch) String() string { - switch a.Src { - case RegA: - return fmt.Sprintf("st M[%d]", a.N) - case RegX: - return fmt.Sprintf("stx M[%d]", a.N) - default: - return fmt.Sprintf("unknown instruction: %#v", a) - } -} - -// ALUOpConstant executes A = A Val. -type ALUOpConstant struct { - Op ALUOp - Val uint32 -} - -// Assemble implements the Instruction Assemble method. -func (a ALUOpConstant) Assemble() (RawInstruction, error) { - return RawInstruction{ - Op: opClsALU | uint16(opOperandConstant) | uint16(a.Op), - K: a.Val, - }, nil -} - -// String returns the instruction in assembler notation. -func (a ALUOpConstant) String() string { - switch a.Op { - case ALUOpAdd: - return fmt.Sprintf("add #%d", a.Val) - case ALUOpSub: - return fmt.Sprintf("sub #%d", a.Val) - case ALUOpMul: - return fmt.Sprintf("mul #%d", a.Val) - case ALUOpDiv: - return fmt.Sprintf("div #%d", a.Val) - case ALUOpMod: - return fmt.Sprintf("mod #%d", a.Val) - case ALUOpAnd: - return fmt.Sprintf("and #%d", a.Val) - case ALUOpOr: - return fmt.Sprintf("or #%d", a.Val) - case ALUOpXor: - return fmt.Sprintf("xor #%d", a.Val) - case ALUOpShiftLeft: - return fmt.Sprintf("lsh #%d", a.Val) - case ALUOpShiftRight: - return fmt.Sprintf("rsh #%d", a.Val) - default: - return fmt.Sprintf("unknown instruction: %#v", a) - } -} - -// ALUOpX executes A = A X -type ALUOpX struct { - Op ALUOp -} - -// Assemble implements the Instruction Assemble method. -func (a ALUOpX) Assemble() (RawInstruction, error) { - return RawInstruction{ - Op: opClsALU | uint16(opOperandX) | uint16(a.Op), - }, nil -} - -// String returns the instruction in assembler notation. -func (a ALUOpX) String() string { - switch a.Op { - case ALUOpAdd: - return "add x" - case ALUOpSub: - return "sub x" - case ALUOpMul: - return "mul x" - case ALUOpDiv: - return "div x" - case ALUOpMod: - return "mod x" - case ALUOpAnd: - return "and x" - case ALUOpOr: - return "or x" - case ALUOpXor: - return "xor x" - case ALUOpShiftLeft: - return "lsh x" - case ALUOpShiftRight: - return "rsh x" - default: - return fmt.Sprintf("unknown instruction: %#v", a) - } -} - -// NegateA executes A = -A. -type NegateA struct{} - -// Assemble implements the Instruction Assemble method. -func (a NegateA) Assemble() (RawInstruction, error) { - return RawInstruction{ - Op: opClsALU | uint16(aluOpNeg), - }, nil -} - -// String returns the instruction in assembler notation. -func (a NegateA) String() string { - return fmt.Sprintf("neg") -} - -// Jump skips the following Skip instructions in the program. -type Jump struct { - Skip uint32 -} - -// Assemble implements the Instruction Assemble method. -func (a Jump) Assemble() (RawInstruction, error) { - return RawInstruction{ - Op: opClsJump | uint16(opJumpAlways), - K: a.Skip, - }, nil -} - -// String returns the instruction in assembler notation. -func (a Jump) String() string { - return fmt.Sprintf("ja %d", a.Skip) -} - -// JumpIf skips the following Skip instructions in the program if A -// Val is true. -type JumpIf struct { - Cond JumpTest - Val uint32 - SkipTrue uint8 - SkipFalse uint8 -} - -// Assemble implements the Instruction Assemble method. -func (a JumpIf) Assemble() (RawInstruction, error) { - return jumpToRaw(a.Cond, opOperandConstant, a.Val, a.SkipTrue, a.SkipFalse) -} - -// String returns the instruction in assembler notation. -func (a JumpIf) String() string { - return jumpToString(a.Cond, fmt.Sprintf("#%d", a.Val), a.SkipTrue, a.SkipFalse) -} - -// JumpIfX skips the following Skip instructions in the program if A -// X is true. -type JumpIfX struct { - Cond JumpTest - SkipTrue uint8 - SkipFalse uint8 -} - -// Assemble implements the Instruction Assemble method. -func (a JumpIfX) Assemble() (RawInstruction, error) { - return jumpToRaw(a.Cond, opOperandX, 0, a.SkipTrue, a.SkipFalse) -} - -// String returns the instruction in assembler notation. -func (a JumpIfX) String() string { - return jumpToString(a.Cond, "x", a.SkipTrue, a.SkipFalse) -} - -// jumpToRaw assembles a jump instruction into a RawInstruction -func jumpToRaw(test JumpTest, operand opOperand, k uint32, skipTrue, skipFalse uint8) (RawInstruction, error) { - var ( - cond jumpOp - flip bool - ) - switch test { - case JumpEqual: - cond = opJumpEqual - case JumpNotEqual: - cond, flip = opJumpEqual, true - case JumpGreaterThan: - cond = opJumpGT - case JumpLessThan: - cond, flip = opJumpGE, true - case JumpGreaterOrEqual: - cond = opJumpGE - case JumpLessOrEqual: - cond, flip = opJumpGT, true - case JumpBitsSet: - cond = opJumpSet - case JumpBitsNotSet: - cond, flip = opJumpSet, true - default: - return RawInstruction{}, fmt.Errorf("unknown JumpTest %v", test) - } - jt, jf := skipTrue, skipFalse - if flip { - jt, jf = jf, jt - } - return RawInstruction{ - Op: opClsJump | uint16(cond) | uint16(operand), - Jt: jt, - Jf: jf, - K: k, - }, nil -} - -// jumpToString converts a jump instruction to assembler notation -func jumpToString(cond JumpTest, operand string, skipTrue, skipFalse uint8) string { - switch cond { - // K == A - case JumpEqual: - return conditionalJump(operand, skipTrue, skipFalse, "jeq", "jneq") - // K != A - case JumpNotEqual: - return fmt.Sprintf("jneq %s,%d", operand, skipTrue) - // K > A - case JumpGreaterThan: - return conditionalJump(operand, skipTrue, skipFalse, "jgt", "jle") - // K < A - case JumpLessThan: - return fmt.Sprintf("jlt %s,%d", operand, skipTrue) - // K >= A - case JumpGreaterOrEqual: - return conditionalJump(operand, skipTrue, skipFalse, "jge", "jlt") - // K <= A - case JumpLessOrEqual: - return fmt.Sprintf("jle %s,%d", operand, skipTrue) - // K & A != 0 - case JumpBitsSet: - if skipFalse > 0 { - return fmt.Sprintf("jset %s,%d,%d", operand, skipTrue, skipFalse) - } - return fmt.Sprintf("jset %s,%d", operand, skipTrue) - // K & A == 0, there is no assembler instruction for JumpBitNotSet, use JumpBitSet and invert skips - case JumpBitsNotSet: - return jumpToString(JumpBitsSet, operand, skipFalse, skipTrue) - default: - return fmt.Sprintf("unknown JumpTest %#v", cond) - } -} - -func conditionalJump(operand string, skipTrue, skipFalse uint8, positiveJump, negativeJump string) string { - if skipTrue > 0 { - if skipFalse > 0 { - return fmt.Sprintf("%s %s,%d,%d", positiveJump, operand, skipTrue, skipFalse) - } - return fmt.Sprintf("%s %s,%d", positiveJump, operand, skipTrue) - } - return fmt.Sprintf("%s %s,%d", negativeJump, operand, skipFalse) -} - -// RetA exits the BPF program, returning the value of register A. -type RetA struct{} - -// Assemble implements the Instruction Assemble method. -func (a RetA) Assemble() (RawInstruction, error) { - return RawInstruction{ - Op: opClsReturn | opRetSrcA, - }, nil -} - -// String returns the instruction in assembler notation. -func (a RetA) String() string { - return fmt.Sprintf("ret a") -} - -// RetConstant exits the BPF program, returning a constant value. -type RetConstant struct { - Val uint32 -} - -// Assemble implements the Instruction Assemble method. -func (a RetConstant) Assemble() (RawInstruction, error) { - return RawInstruction{ - Op: opClsReturn | opRetSrcConstant, - K: a.Val, - }, nil -} - -// String returns the instruction in assembler notation. -func (a RetConstant) String() string { - return fmt.Sprintf("ret #%d", a.Val) -} - -// TXA copies the value of register X to register A. -type TXA struct{} - -// Assemble implements the Instruction Assemble method. -func (a TXA) Assemble() (RawInstruction, error) { - return RawInstruction{ - Op: opClsMisc | opMiscTXA, - }, nil -} - -// String returns the instruction in assembler notation. -func (a TXA) String() string { - return fmt.Sprintf("txa") -} - -// TAX copies the value of register A to register X. -type TAX struct{} - -// Assemble implements the Instruction Assemble method. -func (a TAX) Assemble() (RawInstruction, error) { - return RawInstruction{ - Op: opClsMisc | opMiscTAX, - }, nil -} - -// String returns the instruction in assembler notation. -func (a TAX) String() string { - return fmt.Sprintf("tax") -} - -func assembleLoad(dst Register, loadSize int, mode uint16, k uint32) (RawInstruction, error) { - var ( - cls uint16 - sz uint16 - ) - switch dst { - case RegA: - cls = opClsLoadA - case RegX: - cls = opClsLoadX - default: - return RawInstruction{}, fmt.Errorf("invalid target register %v", dst) - } - switch loadSize { - case 1: - sz = opLoadWidth1 - case 2: - sz = opLoadWidth2 - case 4: - sz = opLoadWidth4 - default: - return RawInstruction{}, fmt.Errorf("invalid load byte length %d", sz) - } - return RawInstruction{ - Op: cls | sz | mode, - K: k, - }, nil -} diff --git a/vendor/golang.org/x/net/bpf/setter.go b/vendor/golang.org/x/net/bpf/setter.go deleted file mode 100644 index 43e35f0..0000000 --- a/vendor/golang.org/x/net/bpf/setter.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package bpf - -// A Setter is a type which can attach a compiled BPF filter to itself. -type Setter interface { - SetBPF(filter []RawInstruction) error -} diff --git a/vendor/golang.org/x/net/bpf/vm.go b/vendor/golang.org/x/net/bpf/vm.go deleted file mode 100644 index 73f57f1..0000000 --- a/vendor/golang.org/x/net/bpf/vm.go +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package bpf - -import ( - "errors" - "fmt" -) - -// A VM is an emulated BPF virtual machine. -type VM struct { - filter []Instruction -} - -// NewVM returns a new VM using the input BPF program. -func NewVM(filter []Instruction) (*VM, error) { - if len(filter) == 0 { - return nil, errors.New("one or more Instructions must be specified") - } - - for i, ins := range filter { - check := len(filter) - (i + 1) - switch ins := ins.(type) { - // Check for out-of-bounds jumps in instructions - case Jump: - if check <= int(ins.Skip) { - return nil, fmt.Errorf("cannot jump %d instructions; jumping past program bounds", ins.Skip) - } - case JumpIf: - if check <= int(ins.SkipTrue) { - return nil, fmt.Errorf("cannot jump %d instructions in true case; jumping past program bounds", ins.SkipTrue) - } - if check <= int(ins.SkipFalse) { - return nil, fmt.Errorf("cannot jump %d instructions in false case; jumping past program bounds", ins.SkipFalse) - } - case JumpIfX: - if check <= int(ins.SkipTrue) { - return nil, fmt.Errorf("cannot jump %d instructions in true case; jumping past program bounds", ins.SkipTrue) - } - if check <= int(ins.SkipFalse) { - return nil, fmt.Errorf("cannot jump %d instructions in false case; jumping past program bounds", ins.SkipFalse) - } - // Check for division or modulus by zero - case ALUOpConstant: - if ins.Val != 0 { - break - } - - switch ins.Op { - case ALUOpDiv, ALUOpMod: - return nil, errors.New("cannot divide by zero using ALUOpConstant") - } - // Check for unknown extensions - case LoadExtension: - switch ins.Num { - case ExtLen: - default: - return nil, fmt.Errorf("extension %d not implemented", ins.Num) - } - } - } - - // Make sure last instruction is a return instruction - switch filter[len(filter)-1].(type) { - case RetA, RetConstant: - default: - return nil, errors.New("BPF program must end with RetA or RetConstant") - } - - // Though our VM works using disassembled instructions, we - // attempt to assemble the input filter anyway to ensure it is compatible - // with an operating system VM. - _, err := Assemble(filter) - - return &VM{ - filter: filter, - }, err -} - -// Run runs the VM's BPF program against the input bytes. -// Run returns the number of bytes accepted by the BPF program, and any errors -// which occurred while processing the program. -func (v *VM) Run(in []byte) (int, error) { - var ( - // Registers of the virtual machine - regA uint32 - regX uint32 - regScratch [16]uint32 - - // OK is true if the program should continue processing the next - // instruction, or false if not, causing the loop to break - ok = true - ) - - // TODO(mdlayher): implement: - // - NegateA: - // - would require a change from uint32 registers to int32 - // registers - - // TODO(mdlayher): add interop tests that check signedness of ALU - // operations against kernel implementation, and make sure Go - // implementation matches behavior - - for i := 0; i < len(v.filter) && ok; i++ { - ins := v.filter[i] - - switch ins := ins.(type) { - case ALUOpConstant: - regA = aluOpConstant(ins, regA) - case ALUOpX: - regA, ok = aluOpX(ins, regA, regX) - case Jump: - i += int(ins.Skip) - case JumpIf: - jump := jumpIf(ins, regA) - i += jump - case JumpIfX: - jump := jumpIfX(ins, regA, regX) - i += jump - case LoadAbsolute: - regA, ok = loadAbsolute(ins, in) - case LoadConstant: - regA, regX = loadConstant(ins, regA, regX) - case LoadExtension: - regA = loadExtension(ins, in) - case LoadIndirect: - regA, ok = loadIndirect(ins, in, regX) - case LoadMemShift: - regX, ok = loadMemShift(ins, in) - case LoadScratch: - regA, regX = loadScratch(ins, regScratch, regA, regX) - case RetA: - return int(regA), nil - case RetConstant: - return int(ins.Val), nil - case StoreScratch: - regScratch = storeScratch(ins, regScratch, regA, regX) - case TAX: - regX = regA - case TXA: - regA = regX - default: - return 0, fmt.Errorf("unknown Instruction at index %d: %T", i, ins) - } - } - - return 0, nil -} diff --git a/vendor/golang.org/x/net/bpf/vm_instructions.go b/vendor/golang.org/x/net/bpf/vm_instructions.go deleted file mode 100644 index f0d2e55..0000000 --- a/vendor/golang.org/x/net/bpf/vm_instructions.go +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package bpf - -import ( - "encoding/binary" - "fmt" -) - -func aluOpConstant(ins ALUOpConstant, regA uint32) uint32 { - return aluOpCommon(ins.Op, regA, ins.Val) -} - -func aluOpX(ins ALUOpX, regA uint32, regX uint32) (uint32, bool) { - // Guard against division or modulus by zero by terminating - // the program, as the OS BPF VM does - if regX == 0 { - switch ins.Op { - case ALUOpDiv, ALUOpMod: - return 0, false - } - } - - return aluOpCommon(ins.Op, regA, regX), true -} - -func aluOpCommon(op ALUOp, regA uint32, value uint32) uint32 { - switch op { - case ALUOpAdd: - return regA + value - case ALUOpSub: - return regA - value - case ALUOpMul: - return regA * value - case ALUOpDiv: - // Division by zero not permitted by NewVM and aluOpX checks - return regA / value - case ALUOpOr: - return regA | value - case ALUOpAnd: - return regA & value - case ALUOpShiftLeft: - return regA << value - case ALUOpShiftRight: - return regA >> value - case ALUOpMod: - // Modulus by zero not permitted by NewVM and aluOpX checks - return regA % value - case ALUOpXor: - return regA ^ value - default: - return regA - } -} - -func jumpIf(ins JumpIf, regA uint32) int { - return jumpIfCommon(ins.Cond, ins.SkipTrue, ins.SkipFalse, regA, ins.Val) -} - -func jumpIfX(ins JumpIfX, regA uint32, regX uint32) int { - return jumpIfCommon(ins.Cond, ins.SkipTrue, ins.SkipFalse, regA, regX) -} - -func jumpIfCommon(cond JumpTest, skipTrue, skipFalse uint8, regA uint32, value uint32) int { - var ok bool - - switch cond { - case JumpEqual: - ok = regA == value - case JumpNotEqual: - ok = regA != value - case JumpGreaterThan: - ok = regA > value - case JumpLessThan: - ok = regA < value - case JumpGreaterOrEqual: - ok = regA >= value - case JumpLessOrEqual: - ok = regA <= value - case JumpBitsSet: - ok = (regA & value) != 0 - case JumpBitsNotSet: - ok = (regA & value) == 0 - } - - if ok { - return int(skipTrue) - } - - return int(skipFalse) -} - -func loadAbsolute(ins LoadAbsolute, in []byte) (uint32, bool) { - offset := int(ins.Off) - size := int(ins.Size) - - return loadCommon(in, offset, size) -} - -func loadConstant(ins LoadConstant, regA uint32, regX uint32) (uint32, uint32) { - switch ins.Dst { - case RegA: - regA = ins.Val - case RegX: - regX = ins.Val - } - - return regA, regX -} - -func loadExtension(ins LoadExtension, in []byte) uint32 { - switch ins.Num { - case ExtLen: - return uint32(len(in)) - default: - panic(fmt.Sprintf("unimplemented extension: %d", ins.Num)) - } -} - -func loadIndirect(ins LoadIndirect, in []byte, regX uint32) (uint32, bool) { - offset := int(ins.Off) + int(regX) - size := int(ins.Size) - - return loadCommon(in, offset, size) -} - -func loadMemShift(ins LoadMemShift, in []byte) (uint32, bool) { - offset := int(ins.Off) - - if !inBounds(len(in), offset, 0) { - return 0, false - } - - // Mask off high 4 bits and multiply low 4 bits by 4 - return uint32(in[offset]&0x0f) * 4, true -} - -func inBounds(inLen int, offset int, size int) bool { - return offset+size <= inLen -} - -func loadCommon(in []byte, offset int, size int) (uint32, bool) { - if !inBounds(len(in), offset, size) { - return 0, false - } - - switch size { - case 1: - return uint32(in[offset]), true - case 2: - return uint32(binary.BigEndian.Uint16(in[offset : offset+size])), true - case 4: - return uint32(binary.BigEndian.Uint32(in[offset : offset+size])), true - default: - panic(fmt.Sprintf("invalid load size: %d", size)) - } -} - -func loadScratch(ins LoadScratch, regScratch [16]uint32, regA uint32, regX uint32) (uint32, uint32) { - switch ins.Dst { - case RegA: - regA = regScratch[ins.N] - case RegX: - regX = regScratch[ins.N] - } - - return regA, regX -} - -func storeScratch(ins StoreScratch, regScratch [16]uint32, regA uint32, regX uint32) [16]uint32 { - switch ins.Src { - case RegA: - regScratch[ins.N] = regA - case RegX: - regScratch[ins.N] = regX - } - - return regScratch -} diff --git a/vendor/golang.org/x/net/internal/iana/const.go b/vendor/golang.org/x/net/internal/iana/const.go deleted file mode 100644 index cea712f..0000000 --- a/vendor/golang.org/x/net/internal/iana/const.go +++ /dev/null @@ -1,223 +0,0 @@ -// go generate gen.go -// Code generated by the command above; DO NOT EDIT. - -// Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA). -package iana // import "golang.org/x/net/internal/iana" - -// Differentiated Services Field Codepoints (DSCP), Updated: 2018-05-04 -const ( - DiffServCS0 = 0x00 // CS0 - DiffServCS1 = 0x20 // CS1 - DiffServCS2 = 0x40 // CS2 - DiffServCS3 = 0x60 // CS3 - DiffServCS4 = 0x80 // CS4 - DiffServCS5 = 0xa0 // CS5 - DiffServCS6 = 0xc0 // CS6 - DiffServCS7 = 0xe0 // CS7 - DiffServAF11 = 0x28 // AF11 - DiffServAF12 = 0x30 // AF12 - DiffServAF13 = 0x38 // AF13 - DiffServAF21 = 0x48 // AF21 - DiffServAF22 = 0x50 // AF22 - DiffServAF23 = 0x58 // AF23 - DiffServAF31 = 0x68 // AF31 - DiffServAF32 = 0x70 // AF32 - DiffServAF33 = 0x78 // AF33 - DiffServAF41 = 0x88 // AF41 - DiffServAF42 = 0x90 // AF42 - DiffServAF43 = 0x98 // AF43 - DiffServEF = 0xb8 // EF - DiffServVOICEADMIT = 0xb0 // VOICE-ADMIT - NotECNTransport = 0x00 // Not-ECT (Not ECN-Capable Transport) - ECNTransport1 = 0x01 // ECT(1) (ECN-Capable Transport(1)) - ECNTransport0 = 0x02 // ECT(0) (ECN-Capable Transport(0)) - CongestionExperienced = 0x03 // CE (Congestion Experienced) -) - -// Protocol Numbers, Updated: 2017-10-13 -const ( - ProtocolIP = 0 // IPv4 encapsulation, pseudo protocol number - ProtocolHOPOPT = 0 // IPv6 Hop-by-Hop Option - ProtocolICMP = 1 // Internet Control Message - ProtocolIGMP = 2 // Internet Group Management - ProtocolGGP = 3 // Gateway-to-Gateway - ProtocolIPv4 = 4 // IPv4 encapsulation - ProtocolST = 5 // Stream - ProtocolTCP = 6 // Transmission Control - ProtocolCBT = 7 // CBT - ProtocolEGP = 8 // Exterior Gateway Protocol - ProtocolIGP = 9 // any private interior gateway (used by Cisco for their IGRP) - ProtocolBBNRCCMON = 10 // BBN RCC Monitoring - ProtocolNVPII = 11 // Network Voice Protocol - ProtocolPUP = 12 // PUP - ProtocolEMCON = 14 // EMCON - ProtocolXNET = 15 // Cross Net Debugger - ProtocolCHAOS = 16 // Chaos - ProtocolUDP = 17 // User Datagram - ProtocolMUX = 18 // Multiplexing - ProtocolDCNMEAS = 19 // DCN Measurement Subsystems - ProtocolHMP = 20 // Host Monitoring - ProtocolPRM = 21 // Packet Radio Measurement - ProtocolXNSIDP = 22 // XEROX NS IDP - ProtocolTRUNK1 = 23 // Trunk-1 - ProtocolTRUNK2 = 24 // Trunk-2 - ProtocolLEAF1 = 25 // Leaf-1 - ProtocolLEAF2 = 26 // Leaf-2 - ProtocolRDP = 27 // Reliable Data Protocol - ProtocolIRTP = 28 // Internet Reliable Transaction - ProtocolISOTP4 = 29 // ISO Transport Protocol Class 4 - ProtocolNETBLT = 30 // Bulk Data Transfer Protocol - ProtocolMFENSP = 31 // MFE Network Services Protocol - ProtocolMERITINP = 32 // MERIT Internodal Protocol - ProtocolDCCP = 33 // Datagram Congestion Control Protocol - Protocol3PC = 34 // Third Party Connect Protocol - ProtocolIDPR = 35 // Inter-Domain Policy Routing Protocol - ProtocolXTP = 36 // XTP - ProtocolDDP = 37 // Datagram Delivery Protocol - ProtocolIDPRCMTP = 38 // IDPR Control Message Transport Proto - ProtocolTPPP = 39 // TP++ Transport Protocol - ProtocolIL = 40 // IL Transport Protocol - ProtocolIPv6 = 41 // IPv6 encapsulation - ProtocolSDRP = 42 // Source Demand Routing Protocol - ProtocolIPv6Route = 43 // Routing Header for IPv6 - ProtocolIPv6Frag = 44 // Fragment Header for IPv6 - ProtocolIDRP = 45 // Inter-Domain Routing Protocol - ProtocolRSVP = 46 // Reservation Protocol - ProtocolGRE = 47 // Generic Routing Encapsulation - ProtocolDSR = 48 // Dynamic Source Routing Protocol - ProtocolBNA = 49 // BNA - ProtocolESP = 50 // Encap Security Payload - ProtocolAH = 51 // Authentication Header - ProtocolINLSP = 52 // Integrated Net Layer Security TUBA - ProtocolNARP = 54 // NBMA Address Resolution Protocol - ProtocolMOBILE = 55 // IP Mobility - ProtocolTLSP = 56 // Transport Layer Security Protocol using Kryptonet key management - ProtocolSKIP = 57 // SKIP - ProtocolIPv6ICMP = 58 // ICMP for IPv6 - ProtocolIPv6NoNxt = 59 // No Next Header for IPv6 - ProtocolIPv6Opts = 60 // Destination Options for IPv6 - ProtocolCFTP = 62 // CFTP - ProtocolSATEXPAK = 64 // SATNET and Backroom EXPAK - ProtocolKRYPTOLAN = 65 // Kryptolan - ProtocolRVD = 66 // MIT Remote Virtual Disk Protocol - ProtocolIPPC = 67 // Internet Pluribus Packet Core - ProtocolSATMON = 69 // SATNET Monitoring - ProtocolVISA = 70 // VISA Protocol - ProtocolIPCV = 71 // Internet Packet Core Utility - ProtocolCPNX = 72 // Computer Protocol Network Executive - ProtocolCPHB = 73 // Computer Protocol Heart Beat - ProtocolWSN = 74 // Wang Span Network - ProtocolPVP = 75 // Packet Video Protocol - ProtocolBRSATMON = 76 // Backroom SATNET Monitoring - ProtocolSUNND = 77 // SUN ND PROTOCOL-Temporary - ProtocolWBMON = 78 // WIDEBAND Monitoring - ProtocolWBEXPAK = 79 // WIDEBAND EXPAK - ProtocolISOIP = 80 // ISO Internet Protocol - ProtocolVMTP = 81 // VMTP - ProtocolSECUREVMTP = 82 // SECURE-VMTP - ProtocolVINES = 83 // VINES - ProtocolTTP = 84 // Transaction Transport Protocol - ProtocolIPTM = 84 // Internet Protocol Traffic Manager - ProtocolNSFNETIGP = 85 // NSFNET-IGP - ProtocolDGP = 86 // Dissimilar Gateway Protocol - ProtocolTCF = 87 // TCF - ProtocolEIGRP = 88 // EIGRP - ProtocolOSPFIGP = 89 // OSPFIGP - ProtocolSpriteRPC = 90 // Sprite RPC Protocol - ProtocolLARP = 91 // Locus Address Resolution Protocol - ProtocolMTP = 92 // Multicast Transport Protocol - ProtocolAX25 = 93 // AX.25 Frames - ProtocolIPIP = 94 // IP-within-IP Encapsulation Protocol - ProtocolSCCSP = 96 // Semaphore Communications Sec. Pro. - ProtocolETHERIP = 97 // Ethernet-within-IP Encapsulation - ProtocolENCAP = 98 // Encapsulation Header - ProtocolGMTP = 100 // GMTP - ProtocolIFMP = 101 // Ipsilon Flow Management Protocol - ProtocolPNNI = 102 // PNNI over IP - ProtocolPIM = 103 // Protocol Independent Multicast - ProtocolARIS = 104 // ARIS - ProtocolSCPS = 105 // SCPS - ProtocolQNX = 106 // QNX - ProtocolAN = 107 // Active Networks - ProtocolIPComp = 108 // IP Payload Compression Protocol - ProtocolSNP = 109 // Sitara Networks Protocol - ProtocolCompaqPeer = 110 // Compaq Peer Protocol - ProtocolIPXinIP = 111 // IPX in IP - ProtocolVRRP = 112 // Virtual Router Redundancy Protocol - ProtocolPGM = 113 // PGM Reliable Transport Protocol - ProtocolL2TP = 115 // Layer Two Tunneling Protocol - ProtocolDDX = 116 // D-II Data Exchange (DDX) - ProtocolIATP = 117 // Interactive Agent Transfer Protocol - ProtocolSTP = 118 // Schedule Transfer Protocol - ProtocolSRP = 119 // SpectraLink Radio Protocol - ProtocolUTI = 120 // UTI - ProtocolSMP = 121 // Simple Message Protocol - ProtocolPTP = 123 // Performance Transparency Protocol - ProtocolISIS = 124 // ISIS over IPv4 - ProtocolFIRE = 125 // FIRE - ProtocolCRTP = 126 // Combat Radio Transport Protocol - ProtocolCRUDP = 127 // Combat Radio User Datagram - ProtocolSSCOPMCE = 128 // SSCOPMCE - ProtocolIPLT = 129 // IPLT - ProtocolSPS = 130 // Secure Packet Shield - ProtocolPIPE = 131 // Private IP Encapsulation within IP - ProtocolSCTP = 132 // Stream Control Transmission Protocol - ProtocolFC = 133 // Fibre Channel - ProtocolRSVPE2EIGNORE = 134 // RSVP-E2E-IGNORE - ProtocolMobilityHeader = 135 // Mobility Header - ProtocolUDPLite = 136 // UDPLite - ProtocolMPLSinIP = 137 // MPLS-in-IP - ProtocolMANET = 138 // MANET Protocols - ProtocolHIP = 139 // Host Identity Protocol - ProtocolShim6 = 140 // Shim6 Protocol - ProtocolWESP = 141 // Wrapped Encapsulating Security Payload - ProtocolROHC = 142 // Robust Header Compression - ProtocolReserved = 255 // Reserved -) - -// Address Family Numbers, Updated: 2018-04-02 -const ( - AddrFamilyIPv4 = 1 // IP (IP version 4) - AddrFamilyIPv6 = 2 // IP6 (IP version 6) - AddrFamilyNSAP = 3 // NSAP - AddrFamilyHDLC = 4 // HDLC (8-bit multidrop) - AddrFamilyBBN1822 = 5 // BBN 1822 - AddrFamily802 = 6 // 802 (includes all 802 media plus Ethernet "canonical format") - AddrFamilyE163 = 7 // E.163 - AddrFamilyE164 = 8 // E.164 (SMDS, Frame Relay, ATM) - AddrFamilyF69 = 9 // F.69 (Telex) - AddrFamilyX121 = 10 // X.121 (X.25, Frame Relay) - AddrFamilyIPX = 11 // IPX - AddrFamilyAppletalk = 12 // Appletalk - AddrFamilyDecnetIV = 13 // Decnet IV - AddrFamilyBanyanVines = 14 // Banyan Vines - AddrFamilyE164withSubaddress = 15 // E.164 with NSAP format subaddress - AddrFamilyDNS = 16 // DNS (Domain Name System) - AddrFamilyDistinguishedName = 17 // Distinguished Name - AddrFamilyASNumber = 18 // AS Number - AddrFamilyXTPoverIPv4 = 19 // XTP over IP version 4 - AddrFamilyXTPoverIPv6 = 20 // XTP over IP version 6 - AddrFamilyXTPnativemodeXTP = 21 // XTP native mode XTP - AddrFamilyFibreChannelWorldWidePortName = 22 // Fibre Channel World-Wide Port Name - AddrFamilyFibreChannelWorldWideNodeName = 23 // Fibre Channel World-Wide Node Name - AddrFamilyGWID = 24 // GWID - AddrFamilyL2VPN = 25 // AFI for L2VPN information - AddrFamilyMPLSTPSectionEndpointID = 26 // MPLS-TP Section Endpoint Identifier - AddrFamilyMPLSTPLSPEndpointID = 27 // MPLS-TP LSP Endpoint Identifier - AddrFamilyMPLSTPPseudowireEndpointID = 28 // MPLS-TP Pseudowire Endpoint Identifier - AddrFamilyMTIPv4 = 29 // MT IP: Multi-Topology IP version 4 - AddrFamilyMTIPv6 = 30 // MT IPv6: Multi-Topology IP version 6 - AddrFamilyEIGRPCommonServiceFamily = 16384 // EIGRP Common Service Family - AddrFamilyEIGRPIPv4ServiceFamily = 16385 // EIGRP IPv4 Service Family - AddrFamilyEIGRPIPv6ServiceFamily = 16386 // EIGRP IPv6 Service Family - AddrFamilyLISPCanonicalAddressFormat = 16387 // LISP Canonical Address Format (LCAF) - AddrFamilyBGPLS = 16388 // BGP-LS - AddrFamily48bitMAC = 16389 // 48-bit MAC - AddrFamily64bitMAC = 16390 // 64-bit MAC - AddrFamilyOUI = 16391 // OUI - AddrFamilyMACFinal24bits = 16392 // MAC/24 - AddrFamilyMACFinal40bits = 16393 // MAC/40 - AddrFamilyIPv6Initial64bits = 16394 // IPv6/64 - AddrFamilyRBridgePortID = 16395 // RBridge Port ID - AddrFamilyTRILLNickname = 16396 // TRILL Nickname -) diff --git a/vendor/golang.org/x/net/internal/iana/gen.go b/vendor/golang.org/x/net/internal/iana/gen.go deleted file mode 100644 index 2a7661c..0000000 --- a/vendor/golang.org/x/net/internal/iana/gen.go +++ /dev/null @@ -1,383 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -//go:generate go run gen.go - -// This program generates internet protocol constants and tables by -// reading IANA protocol registries. -package main - -import ( - "bytes" - "encoding/xml" - "fmt" - "go/format" - "io" - "io/ioutil" - "net/http" - "os" - "strconv" - "strings" -) - -var registries = []struct { - url string - parse func(io.Writer, io.Reader) error -}{ - { - "https://www.iana.org/assignments/dscp-registry/dscp-registry.xml", - parseDSCPRegistry, - }, - { - "https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml", - parseProtocolNumbers, - }, - { - "https://www.iana.org/assignments/address-family-numbers/address-family-numbers.xml", - parseAddrFamilyNumbers, - }, -} - -func main() { - var bb bytes.Buffer - fmt.Fprintf(&bb, "// go generate gen.go\n") - fmt.Fprintf(&bb, "// Code generated by the command above; DO NOT EDIT.\n\n") - fmt.Fprintf(&bb, "// Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).\n") - fmt.Fprintf(&bb, `package iana // import "golang.org/x/net/internal/iana"`+"\n\n") - for _, r := range registries { - resp, err := http.Get(r.url) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - fmt.Fprintf(os.Stderr, "got HTTP status code %v for %v\n", resp.StatusCode, r.url) - os.Exit(1) - } - if err := r.parse(&bb, resp.Body); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - fmt.Fprintf(&bb, "\n") - } - b, err := format.Source(bb.Bytes()) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - if err := ioutil.WriteFile("const.go", b, 0644); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func parseDSCPRegistry(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var dr dscpRegistry - if err := dec.Decode(&dr); err != nil { - return err - } - fmt.Fprintf(w, "// %s, Updated: %s\n", dr.Title, dr.Updated) - fmt.Fprintf(w, "const (\n") - for _, dr := range dr.escapeDSCP() { - fmt.Fprintf(w, "DiffServ%s = %#02x", dr.Name, dr.Value) - fmt.Fprintf(w, "// %s\n", dr.OrigName) - } - for _, er := range dr.escapeECN() { - fmt.Fprintf(w, "%s = %#02x", er.Descr, er.Value) - fmt.Fprintf(w, "// %s\n", er.OrigDescr) - } - fmt.Fprintf(w, ")\n") - return nil -} - -type dscpRegistry struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - Note string `xml:"note"` - Registries []struct { - Title string `xml:"title"` - Registries []struct { - Title string `xml:"title"` - Records []struct { - Name string `xml:"name"` - Space string `xml:"space"` - } `xml:"record"` - } `xml:"registry"` - Records []struct { - Value string `xml:"value"` - Descr string `xml:"description"` - } `xml:"record"` - } `xml:"registry"` -} - -type canonDSCPRecord struct { - OrigName string - Name string - Value int -} - -func (drr *dscpRegistry) escapeDSCP() []canonDSCPRecord { - var drs []canonDSCPRecord - for _, preg := range drr.Registries { - if !strings.Contains(preg.Title, "Differentiated Services Field Codepoints") { - continue - } - for _, reg := range preg.Registries { - if !strings.Contains(reg.Title, "Pool 1 Codepoints") { - continue - } - drs = make([]canonDSCPRecord, len(reg.Records)) - sr := strings.NewReplacer( - "+", "", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, dr := range reg.Records { - s := strings.TrimSpace(dr.Name) - drs[i].OrigName = s - drs[i].Name = sr.Replace(s) - n, err := strconv.ParseUint(dr.Space, 2, 8) - if err != nil { - continue - } - drs[i].Value = int(n) << 2 - } - } - } - return drs -} - -type canonECNRecord struct { - OrigDescr string - Descr string - Value int -} - -func (drr *dscpRegistry) escapeECN() []canonECNRecord { - var ers []canonECNRecord - for _, reg := range drr.Registries { - if !strings.Contains(reg.Title, "ECN Field") { - continue - } - ers = make([]canonECNRecord, len(reg.Records)) - sr := strings.NewReplacer( - "Capable", "", - "Not-ECT", "", - "ECT(1)", "", - "ECT(0)", "", - "CE", "", - "(", "", - ")", "", - "+", "", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, er := range reg.Records { - s := strings.TrimSpace(er.Descr) - ers[i].OrigDescr = s - ss := strings.Split(s, " ") - if len(ss) > 1 { - ers[i].Descr = strings.Join(ss[1:], " ") - } else { - ers[i].Descr = ss[0] - } - ers[i].Descr = sr.Replace(er.Descr) - n, err := strconv.ParseUint(er.Value, 2, 8) - if err != nil { - continue - } - ers[i].Value = int(n) - } - } - return ers -} - -func parseProtocolNumbers(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var pn protocolNumbers - if err := dec.Decode(&pn); err != nil { - return err - } - prs := pn.escape() - prs = append([]canonProtocolRecord{{ - Name: "IP", - Descr: "IPv4 encapsulation, pseudo protocol number", - Value: 0, - }}, prs...) - fmt.Fprintf(w, "// %s, Updated: %s\n", pn.Title, pn.Updated) - fmt.Fprintf(w, "const (\n") - for _, pr := range prs { - if pr.Name == "" { - continue - } - fmt.Fprintf(w, "Protocol%s = %d", pr.Name, pr.Value) - s := pr.Descr - if s == "" { - s = pr.OrigName - } - fmt.Fprintf(w, "// %s\n", s) - } - fmt.Fprintf(w, ")\n") - return nil -} - -type protocolNumbers struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - RegTitle string `xml:"registry>title"` - Note string `xml:"registry>note"` - Records []struct { - Value string `xml:"value"` - Name string `xml:"name"` - Descr string `xml:"description"` - } `xml:"registry>record"` -} - -type canonProtocolRecord struct { - OrigName string - Name string - Descr string - Value int -} - -func (pn *protocolNumbers) escape() []canonProtocolRecord { - prs := make([]canonProtocolRecord, len(pn.Records)) - sr := strings.NewReplacer( - "-in-", "in", - "-within-", "within", - "-over-", "over", - "+", "P", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, pr := range pn.Records { - if strings.Contains(pr.Name, "Deprecated") || - strings.Contains(pr.Name, "deprecated") { - continue - } - prs[i].OrigName = pr.Name - s := strings.TrimSpace(pr.Name) - switch pr.Name { - case "ISIS over IPv4": - prs[i].Name = "ISIS" - case "manet": - prs[i].Name = "MANET" - default: - prs[i].Name = sr.Replace(s) - } - ss := strings.Split(pr.Descr, "\n") - for i := range ss { - ss[i] = strings.TrimSpace(ss[i]) - } - if len(ss) > 1 { - prs[i].Descr = strings.Join(ss, " ") - } else { - prs[i].Descr = ss[0] - } - prs[i].Value, _ = strconv.Atoi(pr.Value) - } - return prs -} - -func parseAddrFamilyNumbers(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var afn addrFamilylNumbers - if err := dec.Decode(&afn); err != nil { - return err - } - afrs := afn.escape() - fmt.Fprintf(w, "// %s, Updated: %s\n", afn.Title, afn.Updated) - fmt.Fprintf(w, "const (\n") - for _, afr := range afrs { - if afr.Name == "" { - continue - } - fmt.Fprintf(w, "AddrFamily%s = %d", afr.Name, afr.Value) - fmt.Fprintf(w, "// %s\n", afr.Descr) - } - fmt.Fprintf(w, ")\n") - return nil -} - -type addrFamilylNumbers struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - RegTitle string `xml:"registry>title"` - Note string `xml:"registry>note"` - Records []struct { - Value string `xml:"value"` - Descr string `xml:"description"` - } `xml:"registry>record"` -} - -type canonAddrFamilyRecord struct { - Name string - Descr string - Value int -} - -func (afn *addrFamilylNumbers) escape() []canonAddrFamilyRecord { - afrs := make([]canonAddrFamilyRecord, len(afn.Records)) - sr := strings.NewReplacer( - "IP version 4", "IPv4", - "IP version 6", "IPv6", - "Identifier", "ID", - "-", "", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, afr := range afn.Records { - if strings.Contains(afr.Descr, "Unassigned") || - strings.Contains(afr.Descr, "Reserved") { - continue - } - afrs[i].Descr = afr.Descr - s := strings.TrimSpace(afr.Descr) - switch s { - case "IP (IP version 4)": - afrs[i].Name = "IPv4" - case "IP6 (IP version 6)": - afrs[i].Name = "IPv6" - case "AFI for L2VPN information": - afrs[i].Name = "L2VPN" - case "E.164 with NSAP format subaddress": - afrs[i].Name = "E164withSubaddress" - case "MT IP: Multi-Topology IP version 4": - afrs[i].Name = "MTIPv4" - case "MAC/24": - afrs[i].Name = "MACFinal24bits" - case "MAC/40": - afrs[i].Name = "MACFinal40bits" - case "IPv6/64": - afrs[i].Name = "IPv6Initial64bits" - default: - n := strings.Index(s, "(") - if n > 0 { - s = s[:n] - } - n = strings.Index(s, ":") - if n > 0 { - s = s[:n] - } - afrs[i].Name = sr.Replace(s) - } - afrs[i].Value, _ = strconv.Atoi(afr.Value) - } - return afrs -} diff --git a/vendor/golang.org/x/net/internal/socket/cmsghdr.go b/vendor/golang.org/x/net/internal/socket/cmsghdr.go deleted file mode 100644 index 1eb07d2..0000000 --- a/vendor/golang.org/x/net/internal/socket/cmsghdr.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package socket - -func (h *cmsghdr) len() int { return int(h.Len) } -func (h *cmsghdr) lvl() int { return int(h.Level) } -func (h *cmsghdr) typ() int { return int(h.Type) } diff --git a/vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go b/vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go deleted file mode 100644 index d1d0c2d..0000000 --- a/vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package socket - -func (h *cmsghdr) set(l, lvl, typ int) { - h.Len = uint32(l) - h.Level = int32(lvl) - h.Type = int32(typ) -} diff --git a/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go b/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go deleted file mode 100644 index bac6681..0000000 --- a/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build arm mips mipsle 386 -// +build linux - -package socket - -func (h *cmsghdr) set(l, lvl, typ int) { - h.Len = uint32(l) - h.Level = int32(lvl) - h.Type = int32(typ) -} diff --git a/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go b/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go deleted file mode 100644 index 63f0534..0000000 --- a/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build arm64 amd64 ppc64 ppc64le mips64 mips64le s390x -// +build linux - -package socket - -func (h *cmsghdr) set(l, lvl, typ int) { - h.Len = uint64(l) - h.Level = int32(lvl) - h.Type = int32(typ) -} diff --git a/vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go b/vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go deleted file mode 100644 index 7dedd43..0000000 --- a/vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build amd64 -// +build solaris - -package socket - -func (h *cmsghdr) set(l, lvl, typ int) { - h.Len = uint32(l) - h.Level = int32(lvl) - h.Type = int32(typ) -} diff --git a/vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go b/vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go deleted file mode 100644 index a4e7122..0000000 --- a/vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris - -package socket - -type cmsghdr struct{} - -const sizeofCmsghdr = 0 - -func (h *cmsghdr) len() int { return 0 } -func (h *cmsghdr) lvl() int { return 0 } -func (h *cmsghdr) typ() int { return 0 } - -func (h *cmsghdr) set(l, lvl, typ int) {} diff --git a/vendor/golang.org/x/net/internal/socket/defs_darwin.go b/vendor/golang.org/x/net/internal/socket/defs_darwin.go deleted file mode 100644 index 14e28c0..0000000 --- a/vendor/golang.org/x/net/internal/socket/defs_darwin.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package socket - -/* -#include - -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_INET6 = C.AF_INET6 - - sysSOCK_RAW = C.SOCK_RAW -) - -type iovec C.struct_iovec - -type msghdr C.struct_msghdr - -type cmsghdr C.struct_cmsghdr - -type sockaddrInet C.struct_sockaddr_in - -type sockaddrInet6 C.struct_sockaddr_in6 - -const ( - sizeofIovec = C.sizeof_struct_iovec - sizeofMsghdr = C.sizeof_struct_msghdr - sizeofCmsghdr = C.sizeof_struct_cmsghdr - - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 -) diff --git a/vendor/golang.org/x/net/internal/socket/defs_dragonfly.go b/vendor/golang.org/x/net/internal/socket/defs_dragonfly.go deleted file mode 100644 index 14e28c0..0000000 --- a/vendor/golang.org/x/net/internal/socket/defs_dragonfly.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package socket - -/* -#include - -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_INET6 = C.AF_INET6 - - sysSOCK_RAW = C.SOCK_RAW -) - -type iovec C.struct_iovec - -type msghdr C.struct_msghdr - -type cmsghdr C.struct_cmsghdr - -type sockaddrInet C.struct_sockaddr_in - -type sockaddrInet6 C.struct_sockaddr_in6 - -const ( - sizeofIovec = C.sizeof_struct_iovec - sizeofMsghdr = C.sizeof_struct_msghdr - sizeofCmsghdr = C.sizeof_struct_cmsghdr - - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 -) diff --git a/vendor/golang.org/x/net/internal/socket/defs_freebsd.go b/vendor/golang.org/x/net/internal/socket/defs_freebsd.go deleted file mode 100644 index 14e28c0..0000000 --- a/vendor/golang.org/x/net/internal/socket/defs_freebsd.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package socket - -/* -#include - -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_INET6 = C.AF_INET6 - - sysSOCK_RAW = C.SOCK_RAW -) - -type iovec C.struct_iovec - -type msghdr C.struct_msghdr - -type cmsghdr C.struct_cmsghdr - -type sockaddrInet C.struct_sockaddr_in - -type sockaddrInet6 C.struct_sockaddr_in6 - -const ( - sizeofIovec = C.sizeof_struct_iovec - sizeofMsghdr = C.sizeof_struct_msghdr - sizeofCmsghdr = C.sizeof_struct_cmsghdr - - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 -) diff --git a/vendor/golang.org/x/net/internal/socket/defs_linux.go b/vendor/golang.org/x/net/internal/socket/defs_linux.go deleted file mode 100644 index ce9ec2f..0000000 --- a/vendor/golang.org/x/net/internal/socket/defs_linux.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package socket - -/* -#include -#include - -#define _GNU_SOURCE -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_INET6 = C.AF_INET6 - - sysSOCK_RAW = C.SOCK_RAW -) - -type iovec C.struct_iovec - -type msghdr C.struct_msghdr - -type mmsghdr C.struct_mmsghdr - -type cmsghdr C.struct_cmsghdr - -type sockaddrInet C.struct_sockaddr_in - -type sockaddrInet6 C.struct_sockaddr_in6 - -const ( - sizeofIovec = C.sizeof_struct_iovec - sizeofMsghdr = C.sizeof_struct_msghdr - sizeofMmsghdr = C.sizeof_struct_mmsghdr - sizeofCmsghdr = C.sizeof_struct_cmsghdr - - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 -) diff --git a/vendor/golang.org/x/net/internal/socket/defs_netbsd.go b/vendor/golang.org/x/net/internal/socket/defs_netbsd.go deleted file mode 100644 index 3f84335..0000000 --- a/vendor/golang.org/x/net/internal/socket/defs_netbsd.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package socket - -/* -#include - -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_INET6 = C.AF_INET6 - - sysSOCK_RAW = C.SOCK_RAW -) - -type iovec C.struct_iovec - -type msghdr C.struct_msghdr - -type mmsghdr C.struct_mmsghdr - -type cmsghdr C.struct_cmsghdr - -type sockaddrInet C.struct_sockaddr_in - -type sockaddrInet6 C.struct_sockaddr_in6 - -const ( - sizeofIovec = C.sizeof_struct_iovec - sizeofMsghdr = C.sizeof_struct_msghdr - sizeofMmsghdr = C.sizeof_struct_mmsghdr - sizeofCmsghdr = C.sizeof_struct_cmsghdr - - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 -) diff --git a/vendor/golang.org/x/net/internal/socket/defs_openbsd.go b/vendor/golang.org/x/net/internal/socket/defs_openbsd.go deleted file mode 100644 index 14e28c0..0000000 --- a/vendor/golang.org/x/net/internal/socket/defs_openbsd.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package socket - -/* -#include - -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_INET6 = C.AF_INET6 - - sysSOCK_RAW = C.SOCK_RAW -) - -type iovec C.struct_iovec - -type msghdr C.struct_msghdr - -type cmsghdr C.struct_cmsghdr - -type sockaddrInet C.struct_sockaddr_in - -type sockaddrInet6 C.struct_sockaddr_in6 - -const ( - sizeofIovec = C.sizeof_struct_iovec - sizeofMsghdr = C.sizeof_struct_msghdr - sizeofCmsghdr = C.sizeof_struct_cmsghdr - - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 -) diff --git a/vendor/golang.org/x/net/internal/socket/defs_solaris.go b/vendor/golang.org/x/net/internal/socket/defs_solaris.go deleted file mode 100644 index 14e28c0..0000000 --- a/vendor/golang.org/x/net/internal/socket/defs_solaris.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package socket - -/* -#include - -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_INET6 = C.AF_INET6 - - sysSOCK_RAW = C.SOCK_RAW -) - -type iovec C.struct_iovec - -type msghdr C.struct_msghdr - -type cmsghdr C.struct_cmsghdr - -type sockaddrInet C.struct_sockaddr_in - -type sockaddrInet6 C.struct_sockaddr_in6 - -const ( - sizeofIovec = C.sizeof_struct_iovec - sizeofMsghdr = C.sizeof_struct_msghdr - sizeofCmsghdr = C.sizeof_struct_cmsghdr - - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 -) diff --git a/vendor/golang.org/x/net/internal/socket/empty.s b/vendor/golang.org/x/net/internal/socket/empty.s deleted file mode 100644 index bff0231..0000000 --- a/vendor/golang.org/x/net/internal/socket/empty.s +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin,go1.12 - -// This exists solely so we can linkname in symbols from syscall. diff --git a/vendor/golang.org/x/net/internal/socket/error_unix.go b/vendor/golang.org/x/net/internal/socket/error_unix.go deleted file mode 100644 index 93dff91..0000000 --- a/vendor/golang.org/x/net/internal/socket/error_unix.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package socket - -import "syscall" - -var ( - errEAGAIN error = syscall.EAGAIN - errEINVAL error = syscall.EINVAL - errENOENT error = syscall.ENOENT -) - -// errnoErr returns common boxed Errno values, to prevent allocations -// at runtime. -func errnoErr(errno syscall.Errno) error { - switch errno { - case 0: - return nil - case syscall.EAGAIN: - return errEAGAIN - case syscall.EINVAL: - return errEINVAL - case syscall.ENOENT: - return errENOENT - } - return errno -} diff --git a/vendor/golang.org/x/net/internal/socket/error_windows.go b/vendor/golang.org/x/net/internal/socket/error_windows.go deleted file mode 100644 index 6a6379a..0000000 --- a/vendor/golang.org/x/net/internal/socket/error_windows.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -import "syscall" - -var ( - errERROR_IO_PENDING error = syscall.ERROR_IO_PENDING - errEINVAL error = syscall.EINVAL -) - -// errnoErr returns common boxed Errno values, to prevent allocations -// at runtime. -func errnoErr(errno syscall.Errno) error { - switch errno { - case 0: - return nil - case syscall.ERROR_IO_PENDING: - return errERROR_IO_PENDING - case syscall.EINVAL: - return errEINVAL - } - return errno -} diff --git a/vendor/golang.org/x/net/internal/socket/iovec_32bit.go b/vendor/golang.org/x/net/internal/socket/iovec_32bit.go deleted file mode 100644 index 05d6082..0000000 --- a/vendor/golang.org/x/net/internal/socket/iovec_32bit.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build arm mips mipsle 386 -// +build darwin dragonfly freebsd linux netbsd openbsd - -package socket - -import "unsafe" - -func (v *iovec) set(b []byte) { - l := len(b) - if l == 0 { - return - } - v.Base = (*byte)(unsafe.Pointer(&b[0])) - v.Len = uint32(l) -} diff --git a/vendor/golang.org/x/net/internal/socket/iovec_64bit.go b/vendor/golang.org/x/net/internal/socket/iovec_64bit.go deleted file mode 100644 index afb34ad..0000000 --- a/vendor/golang.org/x/net/internal/socket/iovec_64bit.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build arm64 amd64 ppc64 ppc64le mips64 mips64le s390x -// +build darwin dragonfly freebsd linux netbsd openbsd - -package socket - -import "unsafe" - -func (v *iovec) set(b []byte) { - l := len(b) - if l == 0 { - return - } - v.Base = (*byte)(unsafe.Pointer(&b[0])) - v.Len = uint64(l) -} diff --git a/vendor/golang.org/x/net/internal/socket/iovec_solaris_64bit.go b/vendor/golang.org/x/net/internal/socket/iovec_solaris_64bit.go deleted file mode 100644 index 8d17a40..0000000 --- a/vendor/golang.org/x/net/internal/socket/iovec_solaris_64bit.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build amd64 -// +build solaris - -package socket - -import "unsafe" - -func (v *iovec) set(b []byte) { - l := len(b) - if l == 0 { - return - } - v.Base = (*int8)(unsafe.Pointer(&b[0])) - v.Len = uint64(l) -} diff --git a/vendor/golang.org/x/net/internal/socket/iovec_stub.go b/vendor/golang.org/x/net/internal/socket/iovec_stub.go deleted file mode 100644 index c87d2a9..0000000 --- a/vendor/golang.org/x/net/internal/socket/iovec_stub.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris - -package socket - -type iovec struct{} - -func (v *iovec) set(b []byte) {} diff --git a/vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go b/vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go deleted file mode 100644 index 2e80a9c..0000000 --- a/vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !linux,!netbsd - -package socket - -import "net" - -type mmsghdr struct{} - -type mmsghdrs []mmsghdr - -func (hs mmsghdrs) pack(ms []Message, parseFn func([]byte, string) (net.Addr, error), marshalFn func(net.Addr) []byte) error { - return nil -} - -func (hs mmsghdrs) unpack(ms []Message, parseFn func([]byte, string) (net.Addr, error), hint string) error { - return nil -} diff --git a/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go b/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go deleted file mode 100644 index 3c42ea7..0000000 --- a/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build linux netbsd - -package socket - -import "net" - -type mmsghdrs []mmsghdr - -func (hs mmsghdrs) pack(ms []Message, parseFn func([]byte, string) (net.Addr, error), marshalFn func(net.Addr) []byte) error { - for i := range hs { - vs := make([]iovec, len(ms[i].Buffers)) - var sa []byte - if parseFn != nil { - sa = make([]byte, sizeofSockaddrInet6) - } - if marshalFn != nil { - sa = marshalFn(ms[i].Addr) - } - hs[i].Hdr.pack(vs, ms[i].Buffers, ms[i].OOB, sa) - } - return nil -} - -func (hs mmsghdrs) unpack(ms []Message, parseFn func([]byte, string) (net.Addr, error), hint string) error { - for i := range hs { - ms[i].N = int(hs[i].Len) - ms[i].NN = hs[i].Hdr.controllen() - ms[i].Flags = hs[i].Hdr.flags() - if parseFn != nil { - var err error - ms[i].Addr, err = parseFn(hs[i].Hdr.name(), hint) - if err != nil { - return err - } - } - } - return nil -} diff --git a/vendor/golang.org/x/net/internal/socket/msghdr_bsd.go b/vendor/golang.org/x/net/internal/socket/msghdr_bsd.go deleted file mode 100644 index 5567afc..0000000 --- a/vendor/golang.org/x/net/internal/socket/msghdr_bsd.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package socket - -import "unsafe" - -func (h *msghdr) pack(vs []iovec, bs [][]byte, oob []byte, sa []byte) { - for i := range vs { - vs[i].set(bs[i]) - } - h.setIov(vs) - if len(oob) > 0 { - h.Control = (*byte)(unsafe.Pointer(&oob[0])) - h.Controllen = uint32(len(oob)) - } - if sa != nil { - h.Name = (*byte)(unsafe.Pointer(&sa[0])) - h.Namelen = uint32(len(sa)) - } -} - -func (h *msghdr) name() []byte { - if h.Name != nil && h.Namelen > 0 { - return (*[sizeofSockaddrInet6]byte)(unsafe.Pointer(h.Name))[:h.Namelen] - } - return nil -} - -func (h *msghdr) controllen() int { - return int(h.Controllen) -} - -func (h *msghdr) flags() int { - return int(h.Flags) -} diff --git a/vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go b/vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go deleted file mode 100644 index b8c87b7..0000000 --- a/vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd - -package socket - -func (h *msghdr) setIov(vs []iovec) { - l := len(vs) - if l == 0 { - return - } - h.Iov = &vs[0] - h.Iovlen = int32(l) -} diff --git a/vendor/golang.org/x/net/internal/socket/msghdr_linux.go b/vendor/golang.org/x/net/internal/socket/msghdr_linux.go deleted file mode 100644 index 5a38798..0000000 --- a/vendor/golang.org/x/net/internal/socket/msghdr_linux.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -import "unsafe" - -func (h *msghdr) pack(vs []iovec, bs [][]byte, oob []byte, sa []byte) { - for i := range vs { - vs[i].set(bs[i]) - } - h.setIov(vs) - if len(oob) > 0 { - h.setControl(oob) - } - if sa != nil { - h.Name = (*byte)(unsafe.Pointer(&sa[0])) - h.Namelen = uint32(len(sa)) - } -} - -func (h *msghdr) name() []byte { - if h.Name != nil && h.Namelen > 0 { - return (*[sizeofSockaddrInet6]byte)(unsafe.Pointer(h.Name))[:h.Namelen] - } - return nil -} - -func (h *msghdr) controllen() int { - return int(h.Controllen) -} - -func (h *msghdr) flags() int { - return int(h.Flags) -} diff --git a/vendor/golang.org/x/net/internal/socket/msghdr_linux_32bit.go b/vendor/golang.org/x/net/internal/socket/msghdr_linux_32bit.go deleted file mode 100644 index a7a5987..0000000 --- a/vendor/golang.org/x/net/internal/socket/msghdr_linux_32bit.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build arm mips mipsle 386 -// +build linux - -package socket - -import "unsafe" - -func (h *msghdr) setIov(vs []iovec) { - l := len(vs) - if l == 0 { - return - } - h.Iov = &vs[0] - h.Iovlen = uint32(l) -} - -func (h *msghdr) setControl(b []byte) { - h.Control = (*byte)(unsafe.Pointer(&b[0])) - h.Controllen = uint32(len(b)) -} diff --git a/vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go b/vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go deleted file mode 100644 index 610fc4f..0000000 --- a/vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build arm64 amd64 ppc64 ppc64le mips64 mips64le s390x -// +build linux - -package socket - -import "unsafe" - -func (h *msghdr) setIov(vs []iovec) { - l := len(vs) - if l == 0 { - return - } - h.Iov = &vs[0] - h.Iovlen = uint64(l) -} - -func (h *msghdr) setControl(b []byte) { - h.Control = (*byte)(unsafe.Pointer(&b[0])) - h.Controllen = uint64(len(b)) -} diff --git a/vendor/golang.org/x/net/internal/socket/msghdr_openbsd.go b/vendor/golang.org/x/net/internal/socket/msghdr_openbsd.go deleted file mode 100644 index 71a69e2..0000000 --- a/vendor/golang.org/x/net/internal/socket/msghdr_openbsd.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -func (h *msghdr) setIov(vs []iovec) { - l := len(vs) - if l == 0 { - return - } - h.Iov = &vs[0] - h.Iovlen = uint32(l) -} diff --git a/vendor/golang.org/x/net/internal/socket/msghdr_solaris_64bit.go b/vendor/golang.org/x/net/internal/socket/msghdr_solaris_64bit.go deleted file mode 100644 index 6465b20..0000000 --- a/vendor/golang.org/x/net/internal/socket/msghdr_solaris_64bit.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build amd64 -// +build solaris - -package socket - -import "unsafe" - -func (h *msghdr) pack(vs []iovec, bs [][]byte, oob []byte, sa []byte) { - for i := range vs { - vs[i].set(bs[i]) - } - if len(vs) > 0 { - h.Iov = &vs[0] - h.Iovlen = int32(len(vs)) - } - if len(oob) > 0 { - h.Accrights = (*int8)(unsafe.Pointer(&oob[0])) - h.Accrightslen = int32(len(oob)) - } - if sa != nil { - h.Name = (*byte)(unsafe.Pointer(&sa[0])) - h.Namelen = uint32(len(sa)) - } -} - -func (h *msghdr) controllen() int { - return int(h.Accrightslen) -} - -func (h *msghdr) flags() int { - return int(NativeEndian.Uint32(h.Pad_cgo_2[:])) -} diff --git a/vendor/golang.org/x/net/internal/socket/msghdr_stub.go b/vendor/golang.org/x/net/internal/socket/msghdr_stub.go deleted file mode 100644 index 64e8173..0000000 --- a/vendor/golang.org/x/net/internal/socket/msghdr_stub.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris - -package socket - -type msghdr struct{} - -func (h *msghdr) pack(vs []iovec, bs [][]byte, oob []byte, sa []byte) {} -func (h *msghdr) name() []byte { return nil } -func (h *msghdr) controllen() int { return 0 } -func (h *msghdr) flags() int { return 0 } diff --git a/vendor/golang.org/x/net/internal/socket/rawconn.go b/vendor/golang.org/x/net/internal/socket/rawconn.go deleted file mode 100644 index d6871d5..0000000 --- a/vendor/golang.org/x/net/internal/socket/rawconn.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 - -package socket - -import ( - "errors" - "net" - "os" - "syscall" -) - -// A Conn represents a raw connection. -type Conn struct { - network string - c syscall.RawConn -} - -// NewConn returns a new raw connection. -func NewConn(c net.Conn) (*Conn, error) { - var err error - var cc Conn - switch c := c.(type) { - case *net.TCPConn: - cc.network = "tcp" - cc.c, err = c.SyscallConn() - case *net.UDPConn: - cc.network = "udp" - cc.c, err = c.SyscallConn() - case *net.IPConn: - cc.network = "ip" - cc.c, err = c.SyscallConn() - default: - return nil, errors.New("unknown connection type") - } - if err != nil { - return nil, err - } - return &cc, nil -} - -func (o *Option) get(c *Conn, b []byte) (int, error) { - var operr error - var n int - fn := func(s uintptr) { - n, operr = getsockopt(s, o.Level, o.Name, b) - } - if err := c.c.Control(fn); err != nil { - return 0, err - } - return n, os.NewSyscallError("getsockopt", operr) -} - -func (o *Option) set(c *Conn, b []byte) error { - var operr error - fn := func(s uintptr) { - operr = setsockopt(s, o.Level, o.Name, b) - } - if err := c.c.Control(fn); err != nil { - return err - } - return os.NewSyscallError("setsockopt", operr) -} diff --git a/vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go b/vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go deleted file mode 100644 index 499164a..0000000 --- a/vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 -// +build linux - -package socket - -import ( - "net" - "os" - "syscall" -) - -func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) { - hs := make(mmsghdrs, len(ms)) - var parseFn func([]byte, string) (net.Addr, error) - if c.network != "tcp" { - parseFn = parseInetAddr - } - if err := hs.pack(ms, parseFn, nil); err != nil { - return 0, err - } - var operr error - var n int - fn := func(s uintptr) bool { - n, operr = recvmmsg(s, hs, flags) - if operr == syscall.EAGAIN { - return false - } - return true - } - if err := c.c.Read(fn); err != nil { - return n, err - } - if operr != nil { - return n, os.NewSyscallError("recvmmsg", operr) - } - if err := hs[:n].unpack(ms[:n], parseFn, c.network); err != nil { - return n, err - } - return n, nil -} - -func (c *Conn) sendMsgs(ms []Message, flags int) (int, error) { - hs := make(mmsghdrs, len(ms)) - var marshalFn func(net.Addr) []byte - if c.network != "tcp" { - marshalFn = marshalInetAddr - } - if err := hs.pack(ms, nil, marshalFn); err != nil { - return 0, err - } - var operr error - var n int - fn := func(s uintptr) bool { - n, operr = sendmmsg(s, hs, flags) - if operr == syscall.EAGAIN { - return false - } - return true - } - if err := c.c.Write(fn); err != nil { - return n, err - } - if operr != nil { - return n, os.NewSyscallError("sendmmsg", operr) - } - if err := hs[:n].unpack(ms[:n], nil, ""); err != nil { - return n, err - } - return n, nil -} diff --git a/vendor/golang.org/x/net/internal/socket/rawconn_msg.go b/vendor/golang.org/x/net/internal/socket/rawconn_msg.go deleted file mode 100644 index b21d2e6..0000000 --- a/vendor/golang.org/x/net/internal/socket/rawconn_msg.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package socket - -import ( - "os" - "syscall" -) - -func (c *Conn) recvMsg(m *Message, flags int) error { - var h msghdr - vs := make([]iovec, len(m.Buffers)) - var sa []byte - if c.network != "tcp" { - sa = make([]byte, sizeofSockaddrInet6) - } - h.pack(vs, m.Buffers, m.OOB, sa) - var operr error - var n int - fn := func(s uintptr) bool { - n, operr = recvmsg(s, &h, flags) - if operr == syscall.EAGAIN { - return false - } - return true - } - if err := c.c.Read(fn); err != nil { - return err - } - if operr != nil { - return os.NewSyscallError("recvmsg", operr) - } - if c.network != "tcp" { - var err error - m.Addr, err = parseInetAddr(sa[:], c.network) - if err != nil { - return err - } - } - m.N = n - m.NN = h.controllen() - m.Flags = h.flags() - return nil -} - -func (c *Conn) sendMsg(m *Message, flags int) error { - var h msghdr - vs := make([]iovec, len(m.Buffers)) - var sa []byte - if m.Addr != nil { - sa = marshalInetAddr(m.Addr) - } - h.pack(vs, m.Buffers, m.OOB, sa) - var operr error - var n int - fn := func(s uintptr) bool { - n, operr = sendmsg(s, &h, flags) - if operr == syscall.EAGAIN { - return false - } - return true - } - if err := c.c.Write(fn); err != nil { - return err - } - if operr != nil { - return os.NewSyscallError("sendmsg", operr) - } - m.N = n - m.NN = len(m.OOB) - return nil -} diff --git a/vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go b/vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go deleted file mode 100644 index f78832a..0000000 --- a/vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 -// +build !linux - -package socket - -import "errors" - -func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) { - return 0, errors.New("not implemented") -} - -func (c *Conn) sendMsgs(ms []Message, flags int) (int, error) { - return 0, errors.New("not implemented") -} diff --git a/vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go b/vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go deleted file mode 100644 index 96733cb..0000000 --- a/vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 -// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows - -package socket - -import "errors" - -func (c *Conn) recvMsg(m *Message, flags int) error { - return errors.New("not implemented") -} - -func (c *Conn) sendMsg(m *Message, flags int) error { - return errors.New("not implemented") -} diff --git a/vendor/golang.org/x/net/internal/socket/rawconn_stub.go b/vendor/golang.org/x/net/internal/socket/rawconn_stub.go deleted file mode 100644 index d2add1a..0000000 --- a/vendor/golang.org/x/net/internal/socket/rawconn_stub.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.9 - -package socket - -import "errors" - -func (c *Conn) recvMsg(m *Message, flags int) error { - return errors.New("not implemented") -} - -func (c *Conn) sendMsg(m *Message, flags int) error { - return errors.New("not implemented") -} - -func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) { - return 0, errors.New("not implemented") -} - -func (c *Conn) sendMsgs(ms []Message, flags int) (int, error) { - return 0, errors.New("not implemented") -} diff --git a/vendor/golang.org/x/net/internal/socket/reflect.go b/vendor/golang.org/x/net/internal/socket/reflect.go deleted file mode 100644 index bb179f1..0000000 --- a/vendor/golang.org/x/net/internal/socket/reflect.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.9 - -package socket - -import ( - "errors" - "net" - "os" - "reflect" - "runtime" -) - -// A Conn represents a raw connection. -type Conn struct { - c net.Conn -} - -// NewConn returns a new raw connection. -func NewConn(c net.Conn) (*Conn, error) { - return &Conn{c: c}, nil -} - -func (o *Option) get(c *Conn, b []byte) (int, error) { - s, err := socketOf(c.c) - if err != nil { - return 0, err - } - n, err := getsockopt(s, o.Level, o.Name, b) - return n, os.NewSyscallError("getsockopt", err) -} - -func (o *Option) set(c *Conn, b []byte) error { - s, err := socketOf(c.c) - if err != nil { - return err - } - return os.NewSyscallError("setsockopt", setsockopt(s, o.Level, o.Name, b)) -} - -func socketOf(c net.Conn) (uintptr, error) { - switch c.(type) { - case *net.TCPConn, *net.UDPConn, *net.IPConn: - v := reflect.ValueOf(c) - switch e := v.Elem(); e.Kind() { - case reflect.Struct: - fd := e.FieldByName("conn").FieldByName("fd") - switch e := fd.Elem(); e.Kind() { - case reflect.Struct: - sysfd := e.FieldByName("sysfd") - if runtime.GOOS == "windows" { - return uintptr(sysfd.Uint()), nil - } - return uintptr(sysfd.Int()), nil - } - } - } - return 0, errors.New("invalid type") -} diff --git a/vendor/golang.org/x/net/internal/socket/socket.go b/vendor/golang.org/x/net/internal/socket/socket.go deleted file mode 100644 index 5f9730e..0000000 --- a/vendor/golang.org/x/net/internal/socket/socket.go +++ /dev/null @@ -1,285 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package socket provides a portable interface for socket system -// calls. -package socket // import "golang.org/x/net/internal/socket" - -import ( - "errors" - "net" - "unsafe" -) - -// An Option represents a sticky socket option. -type Option struct { - Level int // level - Name int // name; must be equal or greater than 1 - Len int // length of value in bytes; must be equal or greater than 1 -} - -// Get reads a value for the option from the kernel. -// It returns the number of bytes written into b. -func (o *Option) Get(c *Conn, b []byte) (int, error) { - if o.Name < 1 || o.Len < 1 { - return 0, errors.New("invalid option") - } - if len(b) < o.Len { - return 0, errors.New("short buffer") - } - return o.get(c, b) -} - -// GetInt returns an integer value for the option. -// -// The Len field of Option must be either 1 or 4. -func (o *Option) GetInt(c *Conn) (int, error) { - if o.Len != 1 && o.Len != 4 { - return 0, errors.New("invalid option") - } - var b []byte - var bb [4]byte - if o.Len == 1 { - b = bb[:1] - } else { - b = bb[:4] - } - n, err := o.get(c, b) - if err != nil { - return 0, err - } - if n != o.Len { - return 0, errors.New("invalid option length") - } - if o.Len == 1 { - return int(b[0]), nil - } - return int(NativeEndian.Uint32(b[:4])), nil -} - -// Set writes the option and value to the kernel. -func (o *Option) Set(c *Conn, b []byte) error { - if o.Name < 1 || o.Len < 1 { - return errors.New("invalid option") - } - if len(b) < o.Len { - return errors.New("short buffer") - } - return o.set(c, b) -} - -// SetInt writes the option and value to the kernel. -// -// The Len field of Option must be either 1 or 4. -func (o *Option) SetInt(c *Conn, v int) error { - if o.Len != 1 && o.Len != 4 { - return errors.New("invalid option") - } - var b []byte - if o.Len == 1 { - b = []byte{byte(v)} - } else { - var bb [4]byte - NativeEndian.PutUint32(bb[:o.Len], uint32(v)) - b = bb[:4] - } - return o.set(c, b) -} - -func controlHeaderLen() int { - return roundup(sizeofCmsghdr) -} - -func controlMessageLen(dataLen int) int { - return roundup(sizeofCmsghdr) + dataLen -} - -// ControlMessageSpace returns the whole length of control message. -func ControlMessageSpace(dataLen int) int { - return roundup(sizeofCmsghdr) + roundup(dataLen) -} - -// A ControlMessage represents the head message in a stream of control -// messages. -// -// A control message comprises of a header, data and a few padding -// fields to conform to the interface to the kernel. -// -// See RFC 3542 for further information. -type ControlMessage []byte - -// Data returns the data field of the control message at the head on -// m. -func (m ControlMessage) Data(dataLen int) []byte { - l := controlHeaderLen() - if len(m) < l || len(m) < l+dataLen { - return nil - } - return m[l : l+dataLen] -} - -// Next returns the control message at the next on m. -// -// Next works only for standard control messages. -func (m ControlMessage) Next(dataLen int) ControlMessage { - l := ControlMessageSpace(dataLen) - if len(m) < l { - return nil - } - return m[l:] -} - -// MarshalHeader marshals the header fields of the control message at -// the head on m. -func (m ControlMessage) MarshalHeader(lvl, typ, dataLen int) error { - if len(m) < controlHeaderLen() { - return errors.New("short message") - } - h := (*cmsghdr)(unsafe.Pointer(&m[0])) - h.set(controlMessageLen(dataLen), lvl, typ) - return nil -} - -// ParseHeader parses and returns the header fields of the control -// message at the head on m. -func (m ControlMessage) ParseHeader() (lvl, typ, dataLen int, err error) { - l := controlHeaderLen() - if len(m) < l { - return 0, 0, 0, errors.New("short message") - } - h := (*cmsghdr)(unsafe.Pointer(&m[0])) - return h.lvl(), h.typ(), int(uint64(h.len()) - uint64(l)), nil -} - -// Marshal marshals the control message at the head on m, and returns -// the next control message. -func (m ControlMessage) Marshal(lvl, typ int, data []byte) (ControlMessage, error) { - l := len(data) - if len(m) < ControlMessageSpace(l) { - return nil, errors.New("short message") - } - h := (*cmsghdr)(unsafe.Pointer(&m[0])) - h.set(controlMessageLen(l), lvl, typ) - if l > 0 { - copy(m.Data(l), data) - } - return m.Next(l), nil -} - -// Parse parses m as a single or multiple control messages. -// -// Parse works for both standard and compatible messages. -func (m ControlMessage) Parse() ([]ControlMessage, error) { - var ms []ControlMessage - for len(m) >= controlHeaderLen() { - h := (*cmsghdr)(unsafe.Pointer(&m[0])) - l := h.len() - if l <= 0 { - return nil, errors.New("invalid header length") - } - if uint64(l) < uint64(controlHeaderLen()) { - return nil, errors.New("invalid message length") - } - if uint64(l) > uint64(len(m)) { - return nil, errors.New("short buffer") - } - // On message reception: - // - // |<- ControlMessageSpace --------------->| - // |<- controlMessageLen ---------->| | - // |<- controlHeaderLen ->| | | - // +---------------+------+---------+------+ - // | Header | PadH | Data | PadD | - // +---------------+------+---------+------+ - // - // On compatible message reception: - // - // | ... |<- controlMessageLen ----------->| - // | ... |<- controlHeaderLen ->| | - // +-----+---------------+------+----------+ - // | ... | Header | PadH | Data | - // +-----+---------------+------+----------+ - ms = append(ms, ControlMessage(m[:l])) - ll := l - controlHeaderLen() - if len(m) >= ControlMessageSpace(ll) { - m = m[ControlMessageSpace(ll):] - } else { - m = m[controlMessageLen(ll):] - } - } - return ms, nil -} - -// NewControlMessage returns a new stream of control messages. -func NewControlMessage(dataLen []int) ControlMessage { - var l int - for i := range dataLen { - l += ControlMessageSpace(dataLen[i]) - } - return make([]byte, l) -} - -// A Message represents an IO message. -type Message struct { - // When writing, the Buffers field must contain at least one - // byte to write. - // When reading, the Buffers field will always contain a byte - // to read. - Buffers [][]byte - - // OOB contains protocol-specific control or miscellaneous - // ancillary data known as out-of-band data. - OOB []byte - - // Addr specifies a destination address when writing. - // It can be nil when the underlying protocol of the raw - // connection uses connection-oriented communication. - // After a successful read, it may contain the source address - // on the received packet. - Addr net.Addr - - N int // # of bytes read or written from/to Buffers - NN int // # of bytes read or written from/to OOB - Flags int // protocol-specific information on the received message -} - -// RecvMsg wraps recvmsg system call. -// -// The provided flags is a set of platform-dependent flags, such as -// syscall.MSG_PEEK. -func (c *Conn) RecvMsg(m *Message, flags int) error { - return c.recvMsg(m, flags) -} - -// SendMsg wraps sendmsg system call. -// -// The provided flags is a set of platform-dependent flags, such as -// syscall.MSG_DONTROUTE. -func (c *Conn) SendMsg(m *Message, flags int) error { - return c.sendMsg(m, flags) -} - -// RecvMsgs wraps recvmmsg system call. -// -// It returns the number of processed messages. -// -// The provided flags is a set of platform-dependent flags, such as -// syscall.MSG_PEEK. -// -// Only Linux supports this. -func (c *Conn) RecvMsgs(ms []Message, flags int) (int, error) { - return c.recvMsgs(ms, flags) -} - -// SendMsgs wraps sendmmsg system call. -// -// It returns the number of processed messages. -// -// The provided flags is a set of platform-dependent flags, such as -// syscall.MSG_DONTROUTE. -// -// Only Linux supports this. -func (c *Conn) SendMsgs(ms []Message, flags int) (int, error) { - return c.sendMsgs(ms, flags) -} diff --git a/vendor/golang.org/x/net/internal/socket/sys.go b/vendor/golang.org/x/net/internal/socket/sys.go deleted file mode 100644 index 4f0eead..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -import ( - "encoding/binary" - "unsafe" -) - -var ( - // NativeEndian is the machine native endian implementation of - // ByteOrder. - NativeEndian binary.ByteOrder - - kernelAlign int -) - -func init() { - i := uint32(1) - b := (*[4]byte)(unsafe.Pointer(&i)) - if b[0] == 1 { - NativeEndian = binary.LittleEndian - } else { - NativeEndian = binary.BigEndian - } - kernelAlign = probeProtocolStack() -} - -func roundup(l int) int { - return (l + kernelAlign - 1) & ^(kernelAlign - 1) -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_bsd.go b/vendor/golang.org/x/net/internal/socket/sys_bsd.go deleted file mode 100644 index f13e14f..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_bsd.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd openbsd - -package socket - -import "errors" - -func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - return 0, errors.New("not implemented") -} - -func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - return 0, errors.New("not implemented") -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_bsdvar.go b/vendor/golang.org/x/net/internal/socket/sys_bsdvar.go deleted file mode 100644 index 164ddfc..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_bsdvar.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build freebsd netbsd openbsd - -package socket - -import ( - "runtime" - "unsafe" -) - -func probeProtocolStack() int { - if runtime.GOOS == "openbsd" && runtime.GOARCH == "arm" { - return 8 - } - var p uintptr - return int(unsafe.Sizeof(p)) -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_darwin.go b/vendor/golang.org/x/net/internal/socket/sys_darwin.go deleted file mode 100644 index b17d223..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_darwin.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -func probeProtocolStack() int { return 4 } diff --git a/vendor/golang.org/x/net/internal/socket/sys_dragonfly.go b/vendor/golang.org/x/net/internal/socket/sys_dragonfly.go deleted file mode 100644 index b17d223..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_dragonfly.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -func probeProtocolStack() int { return 4 } diff --git a/vendor/golang.org/x/net/internal/socket/sys_go1_11_darwin.go b/vendor/golang.org/x/net/internal/socket/sys_go1_11_darwin.go deleted file mode 100644 index 02d2b3c..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_go1_11_darwin.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.12 - -package socket - -import ( - "syscall" - "unsafe" -) - -func getsockopt(s uintptr, level, name int, b []byte) (int, error) { - l := uint32(len(b)) - _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0) - return int(l), errnoErr(errno) -} - -func setsockopt(s uintptr, level, name int, b []byte) error { - _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0) - return errnoErr(errno) -} - -func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { - n, _, errno := syscall.Syscall(syscall.SYS_RECVMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags)) - return int(n), errnoErr(errno) -} - -func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { - n, _, errno := syscall.Syscall(syscall.SYS_SENDMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags)) - return int(n), errnoErr(errno) -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_go1_12_darwin.go b/vendor/golang.org/x/net/internal/socket/sys_go1_12_darwin.go deleted file mode 100644 index 0999a19..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_go1_12_darwin.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.12 - -package socket - -import ( - "syscall" - "unsafe" -) - -//go:linkname syscall_getsockopt syscall.getsockopt -func syscall_getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *uint32) error - -func getsockopt(s uintptr, level, name int, b []byte) (int, error) { - l := uint32(len(b)) - err := syscall_getsockopt(int(s), level, name, unsafe.Pointer(&b[0]), &l) - return int(l), err -} - -//go:linkname syscall_setsockopt syscall.setsockopt -func syscall_setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) error - -func setsockopt(s uintptr, level, name int, b []byte) error { - return syscall_setsockopt(int(s), level, name, unsafe.Pointer(&b[0]), uintptr(len(b))) -} - -//go:linkname syscall_recvmsg syscall.recvmsg -func syscall_recvmsg(s int, msg *syscall.Msghdr, flags int) (n int, err error) - -func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { - return syscall_recvmsg(int(s), (*syscall.Msghdr)(unsafe.Pointer(h)), flags) -} - -//go:linkname syscall_sendmsg syscall.sendmsg -func syscall_sendmsg(s int, msg *syscall.Msghdr, flags int) (n int, err error) - -func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { - return syscall_sendmsg(int(s), (*syscall.Msghdr)(unsafe.Pointer(h)), flags) -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux.go b/vendor/golang.org/x/net/internal/socket/sys_linux.go deleted file mode 100644 index 1559521..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build linux,!s390x,!386 - -package socket - -import ( - "syscall" - "unsafe" -) - -func probeProtocolStack() int { - var p uintptr - return int(unsafe.Sizeof(p)) -} - -func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - n, _, errno := syscall.Syscall6(sysRECVMMSG, s, uintptr(unsafe.Pointer(&hs[0])), uintptr(len(hs)), uintptr(flags), 0, 0) - return int(n), errnoErr(errno) -} - -func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - n, _, errno := syscall.Syscall6(sysSENDMMSG, s, uintptr(unsafe.Pointer(&hs[0])), uintptr(len(hs)), uintptr(flags), 0, 0) - return int(n), errnoErr(errno) -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_386.go b/vendor/golang.org/x/net/internal/socket/sys_linux_386.go deleted file mode 100644 index 235b2cc..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_386.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -import ( - "syscall" - "unsafe" -) - -func probeProtocolStack() int { return 4 } - -const ( - sysSETSOCKOPT = 0xe - sysGETSOCKOPT = 0xf - sysSENDMSG = 0x10 - sysRECVMSG = 0x11 - sysRECVMMSG = 0x13 - sysSENDMMSG = 0x14 -) - -func socketcall(call, a0, a1, a2, a3, a4, a5 uintptr) (uintptr, syscall.Errno) -func rawsocketcall(call, a0, a1, a2, a3, a4, a5 uintptr) (uintptr, syscall.Errno) - -func getsockopt(s uintptr, level, name int, b []byte) (int, error) { - l := uint32(len(b)) - _, errno := socketcall(sysGETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0) - return int(l), errnoErr(errno) -} - -func setsockopt(s uintptr, level, name int, b []byte) error { - _, errno := socketcall(sysSETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0) - return errnoErr(errno) -} - -func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { - n, errno := socketcall(sysRECVMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags), 0, 0, 0) - return int(n), errnoErr(errno) -} - -func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { - n, errno := socketcall(sysSENDMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags), 0, 0, 0) - return int(n), errnoErr(errno) -} - -func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - n, errno := socketcall(sysRECVMMSG, s, uintptr(unsafe.Pointer(&hs[0])), uintptr(len(hs)), uintptr(flags), 0, 0) - return int(n), errnoErr(errno) -} - -func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - n, errno := socketcall(sysSENDMMSG, s, uintptr(unsafe.Pointer(&hs[0])), uintptr(len(hs)), uintptr(flags), 0, 0) - return int(n), errnoErr(errno) -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_386.s b/vendor/golang.org/x/net/internal/socket/sys_linux_386.s deleted file mode 100644 index 93e7d75..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_386.s +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" - -TEXT ·socketcall(SB),NOSPLIT,$0-36 - JMP syscall·socketcall(SB) - -TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 - JMP syscall·rawsocketcall(SB) diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_amd64.go b/vendor/golang.org/x/net/internal/socket/sys_linux_amd64.go deleted file mode 100644 index 9decee2..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_amd64.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -const ( - sysRECVMMSG = 0x12b - sysSENDMMSG = 0x133 -) diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_arm.go b/vendor/golang.org/x/net/internal/socket/sys_linux_arm.go deleted file mode 100644 index d753b43..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_arm.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -const ( - sysRECVMMSG = 0x16d - sysSENDMMSG = 0x176 -) diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_arm64.go b/vendor/golang.org/x/net/internal/socket/sys_linux_arm64.go deleted file mode 100644 index b670894..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_arm64.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -const ( - sysRECVMMSG = 0xf3 - sysSENDMMSG = 0x10d -) diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_mips.go b/vendor/golang.org/x/net/internal/socket/sys_linux_mips.go deleted file mode 100644 index 9c0d740..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_mips.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -const ( - sysRECVMMSG = 0x10ef - sysSENDMMSG = 0x10f7 -) diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_mips64.go b/vendor/golang.org/x/net/internal/socket/sys_linux_mips64.go deleted file mode 100644 index 071a4ab..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_mips64.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -const ( - sysRECVMMSG = 0x14ae - sysSENDMMSG = 0x14b6 -) diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_mips64le.go b/vendor/golang.org/x/net/internal/socket/sys_linux_mips64le.go deleted file mode 100644 index 071a4ab..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_mips64le.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -const ( - sysRECVMMSG = 0x14ae - sysSENDMMSG = 0x14b6 -) diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_mipsle.go b/vendor/golang.org/x/net/internal/socket/sys_linux_mipsle.go deleted file mode 100644 index 9c0d740..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_mipsle.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -const ( - sysRECVMMSG = 0x10ef - sysSENDMMSG = 0x10f7 -) diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64.go b/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64.go deleted file mode 100644 index 21c1e3f..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -const ( - sysRECVMMSG = 0x157 - sysSENDMMSG = 0x15d -) diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64le.go b/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64le.go deleted file mode 100644 index 21c1e3f..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64le.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -const ( - sysRECVMMSG = 0x157 - sysSENDMMSG = 0x15d -) diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.go b/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.go deleted file mode 100644 index 327979e..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -import ( - "syscall" - "unsafe" -) - -func probeProtocolStack() int { return 8 } - -const ( - sysSETSOCKOPT = 0xe - sysGETSOCKOPT = 0xf - sysSENDMSG = 0x10 - sysRECVMSG = 0x11 - sysRECVMMSG = 0x13 - sysSENDMMSG = 0x14 -) - -func socketcall(call, a0, a1, a2, a3, a4, a5 uintptr) (uintptr, syscall.Errno) -func rawsocketcall(call, a0, a1, a2, a3, a4, a5 uintptr) (uintptr, syscall.Errno) - -func getsockopt(s uintptr, level, name int, b []byte) (int, error) { - l := uint32(len(b)) - _, errno := socketcall(sysGETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0) - return int(l), errnoErr(errno) -} - -func setsockopt(s uintptr, level, name int, b []byte) error { - _, errno := socketcall(sysSETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0) - return errnoErr(errno) -} - -func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { - n, errno := socketcall(sysRECVMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags), 0, 0, 0) - return int(n), errnoErr(errno) -} - -func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { - n, errno := socketcall(sysSENDMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags), 0, 0, 0) - return int(n), errnoErr(errno) -} - -func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - n, errno := socketcall(sysRECVMMSG, s, uintptr(unsafe.Pointer(&hs[0])), uintptr(len(hs)), uintptr(flags), 0, 0) - return int(n), errnoErr(errno) -} - -func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - n, errno := socketcall(sysSENDMMSG, s, uintptr(unsafe.Pointer(&hs[0])), uintptr(len(hs)), uintptr(flags), 0, 0) - return int(n), errnoErr(errno) -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.s b/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.s deleted file mode 100644 index 06d7562..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.s +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" - -TEXT ·socketcall(SB),NOSPLIT,$0-72 - JMP syscall·socketcall(SB) - -TEXT ·rawsocketcall(SB),NOSPLIT,$0-72 - JMP syscall·rawsocketcall(SB) diff --git a/vendor/golang.org/x/net/internal/socket/sys_netbsd.go b/vendor/golang.org/x/net/internal/socket/sys_netbsd.go deleted file mode 100644 index 431851c..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_netbsd.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -import ( - "syscall" - "unsafe" -) - -const ( - sysRECVMMSG = 0x1db - sysSENDMMSG = 0x1dc -) - -func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - n, _, errno := syscall.Syscall6(sysRECVMMSG, s, uintptr(unsafe.Pointer(&hs[0])), uintptr(len(hs)), uintptr(flags), 0, 0) - return int(n), errnoErr(errno) -} - -func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - n, _, errno := syscall.Syscall6(sysSENDMMSG, s, uintptr(unsafe.Pointer(&hs[0])), uintptr(len(hs)), uintptr(flags), 0, 0) - return int(n), errnoErr(errno) -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_posix.go b/vendor/golang.org/x/net/internal/socket/sys_posix.go deleted file mode 100644 index 9a9bc47..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_posix.go +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package socket - -import ( - "encoding/binary" - "errors" - "net" - "runtime" - "strconv" - "sync" - "time" -) - -func marshalInetAddr(a net.Addr) []byte { - switch a := a.(type) { - case *net.TCPAddr: - return marshalSockaddr(a.IP, a.Port, a.Zone) - case *net.UDPAddr: - return marshalSockaddr(a.IP, a.Port, a.Zone) - case *net.IPAddr: - return marshalSockaddr(a.IP, 0, a.Zone) - default: - return nil - } -} - -func marshalSockaddr(ip net.IP, port int, zone string) []byte { - if ip4 := ip.To4(); ip4 != nil { - b := make([]byte, sizeofSockaddrInet) - switch runtime.GOOS { - case "android", "linux", "solaris", "windows": - NativeEndian.PutUint16(b[:2], uint16(sysAF_INET)) - default: - b[0] = sizeofSockaddrInet - b[1] = sysAF_INET - } - binary.BigEndian.PutUint16(b[2:4], uint16(port)) - copy(b[4:8], ip4) - return b - } - if ip6 := ip.To16(); ip6 != nil && ip.To4() == nil { - b := make([]byte, sizeofSockaddrInet6) - switch runtime.GOOS { - case "android", "linux", "solaris", "windows": - NativeEndian.PutUint16(b[:2], uint16(sysAF_INET6)) - default: - b[0] = sizeofSockaddrInet6 - b[1] = sysAF_INET6 - } - binary.BigEndian.PutUint16(b[2:4], uint16(port)) - copy(b[8:24], ip6) - if zone != "" { - NativeEndian.PutUint32(b[24:28], uint32(zoneCache.index(zone))) - } - return b - } - return nil -} - -func parseInetAddr(b []byte, network string) (net.Addr, error) { - if len(b) < 2 { - return nil, errors.New("invalid address") - } - var af int - switch runtime.GOOS { - case "android", "linux", "solaris", "windows": - af = int(NativeEndian.Uint16(b[:2])) - default: - af = int(b[1]) - } - var ip net.IP - var zone string - if af == sysAF_INET { - if len(b) < sizeofSockaddrInet { - return nil, errors.New("short address") - } - ip = make(net.IP, net.IPv4len) - copy(ip, b[4:8]) - } - if af == sysAF_INET6 { - if len(b) < sizeofSockaddrInet6 { - return nil, errors.New("short address") - } - ip = make(net.IP, net.IPv6len) - copy(ip, b[8:24]) - if id := int(NativeEndian.Uint32(b[24:28])); id > 0 { - zone = zoneCache.name(id) - } - } - switch network { - case "tcp", "tcp4", "tcp6": - return &net.TCPAddr{IP: ip, Port: int(binary.BigEndian.Uint16(b[2:4])), Zone: zone}, nil - case "udp", "udp4", "udp6": - return &net.UDPAddr{IP: ip, Port: int(binary.BigEndian.Uint16(b[2:4])), Zone: zone}, nil - default: - return &net.IPAddr{IP: ip, Zone: zone}, nil - } -} - -// An ipv6ZoneCache represents a cache holding partial network -// interface information. It is used for reducing the cost of IPv6 -// addressing scope zone resolution. -// -// Multiple names sharing the index are managed by first-come -// first-served basis for consistency. -type ipv6ZoneCache struct { - sync.RWMutex // guard the following - lastFetched time.Time // last time routing information was fetched - toIndex map[string]int // interface name to its index - toName map[int]string // interface index to its name -} - -var zoneCache = ipv6ZoneCache{ - toIndex: make(map[string]int), - toName: make(map[int]string), -} - -// update refreshes the network interface information if the cache was last -// updated more than 1 minute ago, or if force is set. It returns whether the -// cache was updated. -func (zc *ipv6ZoneCache) update(ift []net.Interface, force bool) (updated bool) { - zc.Lock() - defer zc.Unlock() - now := time.Now() - if !force && zc.lastFetched.After(now.Add(-60*time.Second)) { - return false - } - zc.lastFetched = now - if len(ift) == 0 { - var err error - if ift, err = net.Interfaces(); err != nil { - return false - } - } - zc.toIndex = make(map[string]int, len(ift)) - zc.toName = make(map[int]string, len(ift)) - for _, ifi := range ift { - zc.toIndex[ifi.Name] = ifi.Index - if _, ok := zc.toName[ifi.Index]; !ok { - zc.toName[ifi.Index] = ifi.Name - } - } - return true -} - -func (zc *ipv6ZoneCache) name(zone int) string { - updated := zoneCache.update(nil, false) - zoneCache.RLock() - name, ok := zoneCache.toName[zone] - zoneCache.RUnlock() - if !ok && !updated { - zoneCache.update(nil, true) - zoneCache.RLock() - name, ok = zoneCache.toName[zone] - zoneCache.RUnlock() - } - if !ok { // last resort - name = strconv.Itoa(zone) - } - return name -} - -func (zc *ipv6ZoneCache) index(zone string) int { - updated := zoneCache.update(nil, false) - zoneCache.RLock() - index, ok := zoneCache.toIndex[zone] - zoneCache.RUnlock() - if !ok && !updated { - zoneCache.update(nil, true) - zoneCache.RLock() - index, ok = zoneCache.toIndex[zone] - zoneCache.RUnlock() - } - if !ok { // last resort - index, _ = strconv.Atoi(zone) - } - return index -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_solaris.go b/vendor/golang.org/x/net/internal/socket/sys_solaris.go deleted file mode 100644 index cced74e..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_solaris.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -import ( - "errors" - "runtime" - "syscall" - "unsafe" -) - -func probeProtocolStack() int { - switch runtime.GOARCH { - case "amd64": - return 4 - default: - var p uintptr - return int(unsafe.Sizeof(p)) - } -} - -//go:cgo_import_dynamic libc___xnet_getsockopt __xnet_getsockopt "libsocket.so" -//go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so" -//go:cgo_import_dynamic libc___xnet_recvmsg __xnet_recvmsg "libsocket.so" -//go:cgo_import_dynamic libc___xnet_sendmsg __xnet_sendmsg "libsocket.so" - -//go:linkname procGetsockopt libc___xnet_getsockopt -//go:linkname procSetsockopt libc_setsockopt -//go:linkname procRecvmsg libc___xnet_recvmsg -//go:linkname procSendmsg libc___xnet_sendmsg - -var ( - procGetsockopt uintptr - procSetsockopt uintptr - procRecvmsg uintptr - procSendmsg uintptr -) - -func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, uintptr, syscall.Errno) -func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, uintptr, syscall.Errno) - -func getsockopt(s uintptr, level, name int, b []byte) (int, error) { - l := uint32(len(b)) - _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procGetsockopt)), 5, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0) - return int(l), errnoErr(errno) -} - -func setsockopt(s uintptr, level, name int, b []byte) error { - _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procSetsockopt)), 5, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0) - return errnoErr(errno) -} - -func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { - n, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procRecvmsg)), 3, s, uintptr(unsafe.Pointer(h)), uintptr(flags), 0, 0, 0) - return int(n), errnoErr(errno) -} - -func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { - n, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procSendmsg)), 3, s, uintptr(unsafe.Pointer(h)), uintptr(flags), 0, 0, 0) - return int(n), errnoErr(errno) -} - -func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - return 0, errors.New("not implemented") -} - -func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - return 0, errors.New("not implemented") -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_solaris_amd64.s b/vendor/golang.org/x/net/internal/socket/sys_solaris_amd64.s deleted file mode 100644 index a18ac5e..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_solaris_amd64.s +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" - -TEXT ·sysvicall6(SB),NOSPLIT,$0-88 - JMP syscall·sysvicall6(SB) - -TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 - JMP syscall·rawSysvicall6(SB) diff --git a/vendor/golang.org/x/net/internal/socket/sys_stub.go b/vendor/golang.org/x/net/internal/socket/sys_stub.go deleted file mode 100644 index d9f06d0..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_stub.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows - -package socket - -import ( - "errors" - "net" - "runtime" - "unsafe" -) - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0xa - - sysSOCK_RAW = 0x3 -) - -func probeProtocolStack() int { - switch runtime.GOARCH { - case "amd64p32", "mips64p32": - return 4 - default: - var p uintptr - return int(unsafe.Sizeof(p)) - } -} - -func marshalInetAddr(ip net.IP, port int, zone string) []byte { - return nil -} - -func parseInetAddr(b []byte, network string) (net.Addr, error) { - return nil, errors.New("not implemented") -} - -func getsockopt(s uintptr, level, name int, b []byte) (int, error) { - return 0, errors.New("not implemented") -} - -func setsockopt(s uintptr, level, name int, b []byte) error { - return errors.New("not implemented") -} - -func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { - return 0, errors.New("not implemented") -} - -func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { - return 0, errors.New("not implemented") -} - -func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - return 0, errors.New("not implemented") -} - -func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - return 0, errors.New("not implemented") -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_unix.go b/vendor/golang.org/x/net/internal/socket/sys_unix.go deleted file mode 100644 index 0eb7128..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_unix.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build dragonfly freebsd linux,!s390x,!386 netbsd openbsd - -package socket - -import ( - "syscall" - "unsafe" -) - -func getsockopt(s uintptr, level, name int, b []byte) (int, error) { - l := uint32(len(b)) - _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0) - return int(l), errnoErr(errno) -} - -func setsockopt(s uintptr, level, name int, b []byte) error { - _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0) - return errnoErr(errno) -} - -func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { - n, _, errno := syscall.Syscall(syscall.SYS_RECVMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags)) - return int(n), errnoErr(errno) -} - -func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { - n, _, errno := syscall.Syscall(syscall.SYS_SENDMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags)) - return int(n), errnoErr(errno) -} diff --git a/vendor/golang.org/x/net/internal/socket/sys_windows.go b/vendor/golang.org/x/net/internal/socket/sys_windows.go deleted file mode 100644 index 54a470e..0000000 --- a/vendor/golang.org/x/net/internal/socket/sys_windows.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package socket - -import ( - "errors" - "syscall" - "unsafe" -) - -func probeProtocolStack() int { - var p uintptr - return int(unsafe.Sizeof(p)) -} - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x17 - - sysSOCK_RAW = 0x3 -) - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) - -func getsockopt(s uintptr, level, name int, b []byte) (int, error) { - l := uint32(len(b)) - err := syscall.Getsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(unsafe.Pointer(&b[0])), (*int32)(unsafe.Pointer(&l))) - return int(l), err -} - -func setsockopt(s uintptr, level, name int, b []byte) error { - return syscall.Setsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(unsafe.Pointer(&b[0])), int32(len(b))) -} - -func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { - return 0, errors.New("not implemented") -} - -func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { - return 0, errors.New("not implemented") -} - -func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - return 0, errors.New("not implemented") -} - -func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) { - return 0, errors.New("not implemented") -} diff --git a/vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go b/vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go deleted file mode 100644 index 26f8fef..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go +++ /dev/null @@ -1,59 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_darwin.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x1e - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen int32 - Control *byte - Controllen uint32 - Flags int32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_darwin_amd64.go b/vendor/golang.org/x/net/internal/socket/zsys_darwin_amd64.go deleted file mode 100644 index e2987f7..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_darwin_amd64.go +++ /dev/null @@ -1,61 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_darwin.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x1e - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen int32 - Pad_cgo_1 [4]byte - Control *byte - Controllen uint32 - Flags int32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x30 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm.go b/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm.go deleted file mode 100644 index 26f8fef..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm.go +++ /dev/null @@ -1,59 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_darwin.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x1e - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen int32 - Control *byte - Controllen uint32 - Flags int32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm64.go b/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm64.go deleted file mode 100644 index e2987f7..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm64.go +++ /dev/null @@ -1,61 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_darwin.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x1e - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen int32 - Pad_cgo_1 [4]byte - Control *byte - Controllen uint32 - Flags int32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x30 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_dragonfly_amd64.go b/vendor/golang.org/x/net/internal/socket/zsys_dragonfly_amd64.go deleted file mode 100644 index c582abd..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_dragonfly_amd64.go +++ /dev/null @@ -1,61 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_dragonfly.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x1c - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen int32 - Pad_cgo_1 [4]byte - Control *byte - Controllen uint32 - Flags int32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x30 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_freebsd_386.go b/vendor/golang.org/x/net/internal/socket/zsys_freebsd_386.go deleted file mode 100644 index 04a2488..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_freebsd_386.go +++ /dev/null @@ -1,59 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x1c - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen int32 - Control *byte - Controllen uint32 - Flags int32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_freebsd_amd64.go b/vendor/golang.org/x/net/internal/socket/zsys_freebsd_amd64.go deleted file mode 100644 index 35c7cb9..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_freebsd_amd64.go +++ /dev/null @@ -1,61 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x1c - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen int32 - Pad_cgo_1 [4]byte - Control *byte - Controllen uint32 - Flags int32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x30 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm.go b/vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm.go deleted file mode 100644 index 04a2488..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm.go +++ /dev/null @@ -1,59 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x1c - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen int32 - Control *byte - Controllen uint32 - Flags int32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_linux_386.go b/vendor/golang.org/x/net/internal/socket/zsys_linux_386.go deleted file mode 100644 index 4302069..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_linux_386.go +++ /dev/null @@ -1,63 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0xa - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen uint32 - Control *byte - Controllen uint32 - Flags int32 -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c - sizeofMmsghdr = 0x20 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_linux_amd64.go b/vendor/golang.org/x/net/internal/socket/zsys_linux_amd64.go deleted file mode 100644 index 1502f6c..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_linux_amd64.go +++ /dev/null @@ -1,66 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0xa - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen uint64 - Control *byte - Controllen uint64 - Flags int32 - Pad_cgo_1 [4]byte -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 - Pad_cgo_0 [4]byte -} - -type cmsghdr struct { - Len uint64 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x38 - sizeofMmsghdr = 0x40 - sizeofCmsghdr = 0x10 - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_linux_arm.go b/vendor/golang.org/x/net/internal/socket/zsys_linux_arm.go deleted file mode 100644 index 4302069..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_linux_arm.go +++ /dev/null @@ -1,63 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0xa - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen uint32 - Control *byte - Controllen uint32 - Flags int32 -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c - sizeofMmsghdr = 0x20 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_linux_arm64.go b/vendor/golang.org/x/net/internal/socket/zsys_linux_arm64.go deleted file mode 100644 index 1502f6c..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_linux_arm64.go +++ /dev/null @@ -1,66 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0xa - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen uint64 - Control *byte - Controllen uint64 - Flags int32 - Pad_cgo_1 [4]byte -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 - Pad_cgo_0 [4]byte -} - -type cmsghdr struct { - Len uint64 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x38 - sizeofMmsghdr = 0x40 - sizeofCmsghdr = 0x10 - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_linux_mips.go b/vendor/golang.org/x/net/internal/socket/zsys_linux_mips.go deleted file mode 100644 index 4302069..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_linux_mips.go +++ /dev/null @@ -1,63 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0xa - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen uint32 - Control *byte - Controllen uint32 - Flags int32 -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c - sizeofMmsghdr = 0x20 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64.go b/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64.go deleted file mode 100644 index 1502f6c..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64.go +++ /dev/null @@ -1,66 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0xa - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen uint64 - Control *byte - Controllen uint64 - Flags int32 - Pad_cgo_1 [4]byte -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 - Pad_cgo_0 [4]byte -} - -type cmsghdr struct { - Len uint64 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x38 - sizeofMmsghdr = 0x40 - sizeofCmsghdr = 0x10 - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64le.go b/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64le.go deleted file mode 100644 index 1502f6c..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64le.go +++ /dev/null @@ -1,66 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0xa - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen uint64 - Control *byte - Controllen uint64 - Flags int32 - Pad_cgo_1 [4]byte -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 - Pad_cgo_0 [4]byte -} - -type cmsghdr struct { - Len uint64 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x38 - sizeofMmsghdr = 0x40 - sizeofCmsghdr = 0x10 - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_linux_mipsle.go b/vendor/golang.org/x/net/internal/socket/zsys_linux_mipsle.go deleted file mode 100644 index 4302069..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_linux_mipsle.go +++ /dev/null @@ -1,63 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0xa - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen uint32 - Control *byte - Controllen uint32 - Flags int32 -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c - sizeofMmsghdr = 0x20 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64.go b/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64.go deleted file mode 100644 index 1502f6c..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64.go +++ /dev/null @@ -1,66 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0xa - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen uint64 - Control *byte - Controllen uint64 - Flags int32 - Pad_cgo_1 [4]byte -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 - Pad_cgo_0 [4]byte -} - -type cmsghdr struct { - Len uint64 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x38 - sizeofMmsghdr = 0x40 - sizeofCmsghdr = 0x10 - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64le.go b/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64le.go deleted file mode 100644 index 1502f6c..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64le.go +++ /dev/null @@ -1,66 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0xa - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen uint64 - Control *byte - Controllen uint64 - Flags int32 - Pad_cgo_1 [4]byte -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 - Pad_cgo_0 [4]byte -} - -type cmsghdr struct { - Len uint64 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x38 - sizeofMmsghdr = 0x40 - sizeofCmsghdr = 0x10 - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_linux_s390x.go b/vendor/golang.org/x/net/internal/socket/zsys_linux_s390x.go deleted file mode 100644 index 1502f6c..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_linux_s390x.go +++ /dev/null @@ -1,66 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0xa - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen uint64 - Control *byte - Controllen uint64 - Flags int32 - Pad_cgo_1 [4]byte -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 - Pad_cgo_0 [4]byte -} - -type cmsghdr struct { - Len uint64 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x38 - sizeofMmsghdr = 0x40 - sizeofCmsghdr = 0x10 - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_netbsd_386.go b/vendor/golang.org/x/net/internal/socket/zsys_netbsd_386.go deleted file mode 100644 index db60491..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_netbsd_386.go +++ /dev/null @@ -1,65 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_netbsd.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x18 - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen int32 - Control *byte - Controllen uint32 - Flags int32 -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c - sizeofMmsghdr = 0x20 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_netbsd_amd64.go b/vendor/golang.org/x/net/internal/socket/zsys_netbsd_amd64.go deleted file mode 100644 index 2a1a799..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_netbsd_amd64.go +++ /dev/null @@ -1,68 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_netbsd.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x18 - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen int32 - Pad_cgo_1 [4]byte - Control *byte - Controllen uint32 - Flags int32 -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 - Pad_cgo_0 [4]byte -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x30 - sizeofMmsghdr = 0x40 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm.go b/vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm.go deleted file mode 100644 index db60491..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm.go +++ /dev/null @@ -1,65 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_netbsd.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x18 - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen int32 - Control *byte - Controllen uint32 - Flags int32 -} - -type mmsghdr struct { - Hdr msghdr - Len uint32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c - sizeofMmsghdr = 0x20 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_openbsd_386.go b/vendor/golang.org/x/net/internal/socket/zsys_openbsd_386.go deleted file mode 100644 index 1c83636..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_openbsd_386.go +++ /dev/null @@ -1,59 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_openbsd.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x18 - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen uint32 - Control *byte - Controllen uint32 - Flags int32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_openbsd_amd64.go b/vendor/golang.org/x/net/internal/socket/zsys_openbsd_amd64.go deleted file mode 100644 index a6c0bf4..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_openbsd_amd64.go +++ /dev/null @@ -1,61 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_openbsd.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x18 - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen uint32 - Pad_cgo_1 [4]byte - Control *byte - Controllen uint32 - Flags int32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x30 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_openbsd_arm.go b/vendor/golang.org/x/net/internal/socket/zsys_openbsd_arm.go deleted file mode 100644 index 1c83636..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_openbsd_arm.go +++ /dev/null @@ -1,59 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_openbsd.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x18 - - sysSOCK_RAW = 0x3 -) - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen uint32 - Control *byte - Controllen uint32 - Flags int32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_solaris_amd64.go b/vendor/golang.org/x/net/internal/socket/zsys_solaris_amd64.go deleted file mode 100644 index 327c632..0000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_solaris_amd64.go +++ /dev/null @@ -1,60 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_solaris.go - -package socket - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_INET6 = 0x1a - - sysSOCK_RAW = 0x4 -) - -type iovec struct { - Base *int8 - Len uint64 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Pad_cgo_0 [4]byte - Iov *iovec - Iovlen int32 - Pad_cgo_1 [4]byte - Accrights *int8 - Accrightslen int32 - Pad_cgo_2 [4]byte -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 - X__sin6_src_id uint32 -} - -const ( - sizeofIovec = 0x10 - sizeofMsghdr = 0x30 - sizeofCmsghdr = 0xc - - sizeofSockaddrInet = 0x10 - sizeofSockaddrInet6 = 0x20 -) diff --git a/vendor/golang.org/x/net/ipv4/batch.go b/vendor/golang.org/x/net/ipv4/batch.go deleted file mode 100644 index 5ce9b35..0000000 --- a/vendor/golang.org/x/net/ipv4/batch.go +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 - -package ipv4 - -import ( - "net" - "runtime" - - "golang.org/x/net/internal/socket" -) - -// BUG(mikio): On Windows, the ReadBatch and WriteBatch methods of -// PacketConn are not implemented. - -// BUG(mikio): On Windows, the ReadBatch and WriteBatch methods of -// RawConn are not implemented. - -// A Message represents an IO message. -// -// type Message struct { -// Buffers [][]byte -// OOB []byte -// Addr net.Addr -// N int -// NN int -// Flags int -// } -// -// The Buffers fields represents a list of contiguous buffers, which -// can be used for vectored IO, for example, putting a header and a -// payload in each slice. -// When writing, the Buffers field must contain at least one byte to -// write. -// When reading, the Buffers field will always contain a byte to read. -// -// The OOB field contains protocol-specific control or miscellaneous -// ancillary data known as out-of-band data. -// It can be nil when not required. -// -// The Addr field specifies a destination address when writing. -// It can be nil when the underlying protocol of the endpoint uses -// connection-oriented communication. -// After a successful read, it may contain the source address on the -// received packet. -// -// The N field indicates the number of bytes read or written from/to -// Buffers. -// -// The NN field indicates the number of bytes read or written from/to -// OOB. -// -// The Flags field contains protocol-specific information on the -// received message. -type Message = socket.Message - -// ReadBatch reads a batch of messages. -// -// The provided flags is a set of platform-dependent flags, such as -// syscall.MSG_PEEK. -// -// On a successful read it returns the number of messages received, up -// to len(ms). -// -// On Linux, a batch read will be optimized. -// On other platforms, this method will read only a single message. -// -// Unlike the ReadFrom method, it doesn't strip the IPv4 header -// followed by option headers from the received IPv4 datagram when the -// underlying transport is net.IPConn. Each Buffers field of Message -// must be large enough to accommodate an IPv4 header and option -// headers. -func (c *payloadHandler) ReadBatch(ms []Message, flags int) (int, error) { - if !c.ok() { - return 0, errInvalidConn - } - switch runtime.GOOS { - case "linux": - n, err := c.RecvMsgs([]socket.Message(ms), flags) - if err != nil { - err = &net.OpError{Op: "read", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err} - } - return n, err - default: - n := 1 - err := c.RecvMsg(&ms[0], flags) - if err != nil { - n = 0 - err = &net.OpError{Op: "read", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err} - } - return n, err - } -} - -// WriteBatch writes a batch of messages. -// -// The provided flags is a set of platform-dependent flags, such as -// syscall.MSG_DONTROUTE. -// -// It returns the number of messages written on a successful write. -// -// On Linux, a batch write will be optimized. -// On other platforms, this method will write only a single message. -func (c *payloadHandler) WriteBatch(ms []Message, flags int) (int, error) { - if !c.ok() { - return 0, errInvalidConn - } - switch runtime.GOOS { - case "linux": - n, err := c.SendMsgs([]socket.Message(ms), flags) - if err != nil { - err = &net.OpError{Op: "write", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err} - } - return n, err - default: - n := 1 - err := c.SendMsg(&ms[0], flags) - if err != nil { - n = 0 - err = &net.OpError{Op: "write", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err} - } - return n, err - } -} - -// ReadBatch reads a batch of messages. -// -// The provided flags is a set of platform-dependent flags, such as -// syscall.MSG_PEEK. -// -// On a successful read it returns the number of messages received, up -// to len(ms). -// -// On Linux, a batch read will be optimized. -// On other platforms, this method will read only a single message. -func (c *packetHandler) ReadBatch(ms []Message, flags int) (int, error) { - if !c.ok() { - return 0, errInvalidConn - } - switch runtime.GOOS { - case "linux": - n, err := c.RecvMsgs([]socket.Message(ms), flags) - if err != nil { - err = &net.OpError{Op: "read", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err} - } - return n, err - default: - n := 1 - err := c.RecvMsg(&ms[0], flags) - if err != nil { - n = 0 - err = &net.OpError{Op: "read", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err} - } - return n, err - } -} - -// WriteBatch writes a batch of messages. -// -// The provided flags is a set of platform-dependent flags, such as -// syscall.MSG_DONTROUTE. -// -// It returns the number of messages written on a successful write. -// -// On Linux, a batch write will be optimized. -// On other platforms, this method will write only a single message. -func (c *packetHandler) WriteBatch(ms []Message, flags int) (int, error) { - if !c.ok() { - return 0, errInvalidConn - } - switch runtime.GOOS { - case "linux": - n, err := c.SendMsgs([]socket.Message(ms), flags) - if err != nil { - err = &net.OpError{Op: "write", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err} - } - return n, err - default: - n := 1 - err := c.SendMsg(&ms[0], flags) - if err != nil { - n = 0 - err = &net.OpError{Op: "write", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err} - } - return n, err - } -} diff --git a/vendor/golang.org/x/net/ipv4/control.go b/vendor/golang.org/x/net/ipv4/control.go deleted file mode 100644 index a2b02ca..0000000 --- a/vendor/golang.org/x/net/ipv4/control.go +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "fmt" - "net" - "sync" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/socket" -) - -type rawOpt struct { - sync.RWMutex - cflags ControlFlags -} - -func (c *rawOpt) set(f ControlFlags) { c.cflags |= f } -func (c *rawOpt) clear(f ControlFlags) { c.cflags &^= f } -func (c *rawOpt) isset(f ControlFlags) bool { return c.cflags&f != 0 } - -type ControlFlags uint - -const ( - FlagTTL ControlFlags = 1 << iota // pass the TTL on the received packet - FlagSrc // pass the source address on the received packet - FlagDst // pass the destination address on the received packet - FlagInterface // pass the interface index on the received packet -) - -// A ControlMessage represents per packet basis IP-level socket options. -type ControlMessage struct { - // Receiving socket options: SetControlMessage allows to - // receive the options from the protocol stack using ReadFrom - // method of PacketConn or RawConn. - // - // Specifying socket options: ControlMessage for WriteTo - // method of PacketConn or RawConn allows to send the options - // to the protocol stack. - // - TTL int // time-to-live, receiving only - Src net.IP // source address, specifying only - Dst net.IP // destination address, receiving only - IfIndex int // interface index, must be 1 <= value when specifying -} - -func (cm *ControlMessage) String() string { - if cm == nil { - return "" - } - return fmt.Sprintf("ttl=%d src=%v dst=%v ifindex=%d", cm.TTL, cm.Src, cm.Dst, cm.IfIndex) -} - -// Marshal returns the binary encoding of cm. -func (cm *ControlMessage) Marshal() []byte { - if cm == nil { - return nil - } - var m socket.ControlMessage - if ctlOpts[ctlPacketInfo].name > 0 && (cm.Src.To4() != nil || cm.IfIndex > 0) { - m = socket.NewControlMessage([]int{ctlOpts[ctlPacketInfo].length}) - } - if len(m) > 0 { - ctlOpts[ctlPacketInfo].marshal(m, cm) - } - return m -} - -// Parse parses b as a control message and stores the result in cm. -func (cm *ControlMessage) Parse(b []byte) error { - ms, err := socket.ControlMessage(b).Parse() - if err != nil { - return err - } - for _, m := range ms { - lvl, typ, l, err := m.ParseHeader() - if err != nil { - return err - } - if lvl != iana.ProtocolIP { - continue - } - switch { - case typ == ctlOpts[ctlTTL].name && l >= ctlOpts[ctlTTL].length: - ctlOpts[ctlTTL].parse(cm, m.Data(l)) - case typ == ctlOpts[ctlDst].name && l >= ctlOpts[ctlDst].length: - ctlOpts[ctlDst].parse(cm, m.Data(l)) - case typ == ctlOpts[ctlInterface].name && l >= ctlOpts[ctlInterface].length: - ctlOpts[ctlInterface].parse(cm, m.Data(l)) - case typ == ctlOpts[ctlPacketInfo].name && l >= ctlOpts[ctlPacketInfo].length: - ctlOpts[ctlPacketInfo].parse(cm, m.Data(l)) - } - } - return nil -} - -// NewControlMessage returns a new control message. -// -// The returned message is large enough for options specified by cf. -func NewControlMessage(cf ControlFlags) []byte { - opt := rawOpt{cflags: cf} - var l int - if opt.isset(FlagTTL) && ctlOpts[ctlTTL].name > 0 { - l += socket.ControlMessageSpace(ctlOpts[ctlTTL].length) - } - if ctlOpts[ctlPacketInfo].name > 0 { - if opt.isset(FlagSrc | FlagDst | FlagInterface) { - l += socket.ControlMessageSpace(ctlOpts[ctlPacketInfo].length) - } - } else { - if opt.isset(FlagDst) && ctlOpts[ctlDst].name > 0 { - l += socket.ControlMessageSpace(ctlOpts[ctlDst].length) - } - if opt.isset(FlagInterface) && ctlOpts[ctlInterface].name > 0 { - l += socket.ControlMessageSpace(ctlOpts[ctlInterface].length) - } - } - var b []byte - if l > 0 { - b = make([]byte, l) - } - return b -} - -// Ancillary data socket options -const ( - ctlTTL = iota // header field - ctlSrc // header field - ctlDst // header field - ctlInterface // inbound or outbound interface - ctlPacketInfo // inbound or outbound packet path - ctlMax -) - -// A ctlOpt represents a binding for ancillary data socket option. -type ctlOpt struct { - name int // option name, must be equal or greater than 1 - length int // option length - marshal func([]byte, *ControlMessage) []byte - parse func(*ControlMessage, []byte) -} diff --git a/vendor/golang.org/x/net/ipv4/control_bsd.go b/vendor/golang.org/x/net/ipv4/control_bsd.go deleted file mode 100644 index 77e7ad5..0000000 --- a/vendor/golang.org/x/net/ipv4/control_bsd.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package ipv4 - -import ( - "net" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/socket" -) - -func marshalDst(b []byte, cm *ControlMessage) []byte { - m := socket.ControlMessage(b) - m.MarshalHeader(iana.ProtocolIP, sysIP_RECVDSTADDR, net.IPv4len) - return m.Next(net.IPv4len) -} - -func parseDst(cm *ControlMessage, b []byte) { - if len(cm.Dst) < net.IPv4len { - cm.Dst = make(net.IP, net.IPv4len) - } - copy(cm.Dst, b[:net.IPv4len]) -} - -func marshalInterface(b []byte, cm *ControlMessage) []byte { - m := socket.ControlMessage(b) - m.MarshalHeader(iana.ProtocolIP, sysIP_RECVIF, syscall.SizeofSockaddrDatalink) - return m.Next(syscall.SizeofSockaddrDatalink) -} - -func parseInterface(cm *ControlMessage, b []byte) { - sadl := (*syscall.SockaddrDatalink)(unsafe.Pointer(&b[0])) - cm.IfIndex = int(sadl.Index) -} diff --git a/vendor/golang.org/x/net/ipv4/control_pktinfo.go b/vendor/golang.org/x/net/ipv4/control_pktinfo.go deleted file mode 100644 index 425338f..0000000 --- a/vendor/golang.org/x/net/ipv4/control_pktinfo.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin linux solaris - -package ipv4 - -import ( - "net" - "unsafe" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/socket" -) - -func marshalPacketInfo(b []byte, cm *ControlMessage) []byte { - m := socket.ControlMessage(b) - m.MarshalHeader(iana.ProtocolIP, sysIP_PKTINFO, sizeofInetPktinfo) - if cm != nil { - pi := (*inetPktinfo)(unsafe.Pointer(&m.Data(sizeofInetPktinfo)[0])) - if ip := cm.Src.To4(); ip != nil { - copy(pi.Spec_dst[:], ip) - } - if cm.IfIndex > 0 { - pi.setIfindex(cm.IfIndex) - } - } - return m.Next(sizeofInetPktinfo) -} - -func parsePacketInfo(cm *ControlMessage, b []byte) { - pi := (*inetPktinfo)(unsafe.Pointer(&b[0])) - cm.IfIndex = int(pi.Ifindex) - if len(cm.Dst) < net.IPv4len { - cm.Dst = make(net.IP, net.IPv4len) - } - copy(cm.Dst, pi.Addr[:]) -} diff --git a/vendor/golang.org/x/net/ipv4/control_stub.go b/vendor/golang.org/x/net/ipv4/control_stub.go deleted file mode 100644 index 5a2f7d8..0000000 --- a/vendor/golang.org/x/net/ipv4/control_stub.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows - -package ipv4 - -import "golang.org/x/net/internal/socket" - -func setControlMessage(c *socket.Conn, opt *rawOpt, cf ControlFlags, on bool) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/control_unix.go b/vendor/golang.org/x/net/ipv4/control_unix.go deleted file mode 100644 index e1ae816..0000000 --- a/vendor/golang.org/x/net/ipv4/control_unix.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package ipv4 - -import ( - "unsafe" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/socket" -) - -func setControlMessage(c *socket.Conn, opt *rawOpt, cf ControlFlags, on bool) error { - opt.Lock() - defer opt.Unlock() - if so, ok := sockOpts[ssoReceiveTTL]; ok && cf&FlagTTL != 0 { - if err := so.SetInt(c, boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagTTL) - } else { - opt.clear(FlagTTL) - } - } - if so, ok := sockOpts[ssoPacketInfo]; ok { - if cf&(FlagSrc|FlagDst|FlagInterface) != 0 { - if err := so.SetInt(c, boolint(on)); err != nil { - return err - } - if on { - opt.set(cf & (FlagSrc | FlagDst | FlagInterface)) - } else { - opt.clear(cf & (FlagSrc | FlagDst | FlagInterface)) - } - } - } else { - if so, ok := sockOpts[ssoReceiveDst]; ok && cf&FlagDst != 0 { - if err := so.SetInt(c, boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagDst) - } else { - opt.clear(FlagDst) - } - } - if so, ok := sockOpts[ssoReceiveInterface]; ok && cf&FlagInterface != 0 { - if err := so.SetInt(c, boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagInterface) - } else { - opt.clear(FlagInterface) - } - } - } - return nil -} - -func marshalTTL(b []byte, cm *ControlMessage) []byte { - m := socket.ControlMessage(b) - m.MarshalHeader(iana.ProtocolIP, sysIP_RECVTTL, 1) - return m.Next(1) -} - -func parseTTL(cm *ControlMessage, b []byte) { - cm.TTL = int(*(*byte)(unsafe.Pointer(&b[:1][0]))) -} diff --git a/vendor/golang.org/x/net/ipv4/control_windows.go b/vendor/golang.org/x/net/ipv4/control_windows.go deleted file mode 100644 index ce55c66..0000000 --- a/vendor/golang.org/x/net/ipv4/control_windows.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "syscall" - - "golang.org/x/net/internal/socket" -) - -func setControlMessage(c *socket.Conn, opt *rawOpt, cf ControlFlags, on bool) error { - // TODO(mikio): implement this - return syscall.EWINDOWS -} diff --git a/vendor/golang.org/x/net/ipv4/defs_darwin.go b/vendor/golang.org/x/net/ipv4/defs_darwin.go deleted file mode 100644 index c8f2e05..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_darwin.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include - -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_STRIPHDR = C.IP_STRIPHDR - sysIP_RECVTTL = C.IP_RECVTTL - sysIP_BOUND_IF = C.IP_BOUND_IF - sysIP_PKTINFO = C.IP_PKTINFO - sysIP_RECVPKTINFO = C.IP_RECVPKTINFO - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF - sysIP_MULTICAST_IFINDEX = C.IP_MULTICAST_IFINDEX - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofInetPktinfo = C.sizeof_struct_in_pktinfo - - sizeofIPMreq = C.sizeof_struct_ip_mreq - sizeofIPMreqn = C.sizeof_struct_ip_mreqn - sizeofIPMreqSource = C.sizeof_struct_ip_mreq_source - sizeofGroupReq = C.sizeof_struct_group_req - sizeofGroupSourceReq = C.sizeof_struct_group_source_req -) - -type sockaddrStorage C.struct_sockaddr_storage - -type sockaddrInet C.struct_sockaddr_in - -type inetPktinfo C.struct_in_pktinfo - -type ipMreq C.struct_ip_mreq - -type ipMreqn C.struct_ip_mreqn - -type ipMreqSource C.struct_ip_mreq_source - -type groupReq C.struct_group_req - -type groupSourceReq C.struct_group_source_req diff --git a/vendor/golang.org/x/net/ipv4/defs_dragonfly.go b/vendor/golang.org/x/net/ipv4/defs_dragonfly.go deleted file mode 100644 index f30544e..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_dragonfly.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_RECVTTL = C.IP_RECVTTL - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - - sizeofIPMreq = C.sizeof_struct_ip_mreq -) - -type ipMreq C.struct_ip_mreq diff --git a/vendor/golang.org/x/net/ipv4/defs_freebsd.go b/vendor/golang.org/x/net/ipv4/defs_freebsd.go deleted file mode 100644 index 4dd57d8..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_freebsd.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include - -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_SENDSRCADDR = C.IP_SENDSRCADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_ONESBCAST = C.IP_ONESBCAST - sysIP_BINDANY = C.IP_BINDANY - sysIP_RECVTTL = C.IP_RECVTTL - sysIP_MINTTL = C.IP_MINTTL - sysIP_DONTFRAG = C.IP_DONTFRAG - sysIP_RECVTOS = C.IP_RECVTOS - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - - sizeofIPMreq = C.sizeof_struct_ip_mreq - sizeofIPMreqn = C.sizeof_struct_ip_mreqn - sizeofIPMreqSource = C.sizeof_struct_ip_mreq_source - sizeofGroupReq = C.sizeof_struct_group_req - sizeofGroupSourceReq = C.sizeof_struct_group_source_req -) - -type sockaddrStorage C.struct_sockaddr_storage - -type sockaddrInet C.struct_sockaddr_in - -type ipMreq C.struct_ip_mreq - -type ipMreqn C.struct_ip_mreqn - -type ipMreqSource C.struct_ip_mreq_source - -type groupReq C.struct_group_req - -type groupSourceReq C.struct_group_source_req diff --git a/vendor/golang.org/x/net/ipv4/defs_linux.go b/vendor/golang.org/x/net/ipv4/defs_linux.go deleted file mode 100644 index beb1107..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_linux.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include - -#include -#include -#include -#include -#include -*/ -import "C" - -const ( - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_ROUTER_ALERT = C.IP_ROUTER_ALERT - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_PKTINFO = C.IP_PKTINFO - sysIP_PKTOPTIONS = C.IP_PKTOPTIONS - sysIP_MTU_DISCOVER = C.IP_MTU_DISCOVER - sysIP_RECVERR = C.IP_RECVERR - sysIP_RECVTTL = C.IP_RECVTTL - sysIP_RECVTOS = C.IP_RECVTOS - sysIP_MTU = C.IP_MTU - sysIP_FREEBIND = C.IP_FREEBIND - sysIP_TRANSPARENT = C.IP_TRANSPARENT - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_ORIGDSTADDR = C.IP_ORIGDSTADDR - sysIP_RECVORIGDSTADDR = C.IP_RECVORIGDSTADDR - sysIP_MINTTL = C.IP_MINTTL - sysIP_NODEFRAG = C.IP_NODEFRAG - sysIP_UNICAST_IF = C.IP_UNICAST_IF - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP - sysIP_MSFILTER = C.IP_MSFILTER - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - sysMCAST_MSFILTER = C.MCAST_MSFILTER - sysIP_MULTICAST_ALL = C.IP_MULTICAST_ALL - - //sysIP_PMTUDISC_DONT = C.IP_PMTUDISC_DONT - //sysIP_PMTUDISC_WANT = C.IP_PMTUDISC_WANT - //sysIP_PMTUDISC_DO = C.IP_PMTUDISC_DO - //sysIP_PMTUDISC_PROBE = C.IP_PMTUDISC_PROBE - //sysIP_PMTUDISC_INTERFACE = C.IP_PMTUDISC_INTERFACE - //sysIP_PMTUDISC_OMIT = C.IP_PMTUDISC_OMIT - - sysICMP_FILTER = C.ICMP_FILTER - - sysSO_EE_ORIGIN_NONE = C.SO_EE_ORIGIN_NONE - sysSO_EE_ORIGIN_LOCAL = C.SO_EE_ORIGIN_LOCAL - sysSO_EE_ORIGIN_ICMP = C.SO_EE_ORIGIN_ICMP - sysSO_EE_ORIGIN_ICMP6 = C.SO_EE_ORIGIN_ICMP6 - sysSO_EE_ORIGIN_TXSTATUS = C.SO_EE_ORIGIN_TXSTATUS - sysSO_EE_ORIGIN_TIMESTAMPING = C.SO_EE_ORIGIN_TIMESTAMPING - - sysSOL_SOCKET = C.SOL_SOCKET - sysSO_ATTACH_FILTER = C.SO_ATTACH_FILTER - - sizeofKernelSockaddrStorage = C.sizeof_struct___kernel_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofInetPktinfo = C.sizeof_struct_in_pktinfo - sizeofSockExtendedErr = C.sizeof_struct_sock_extended_err - - sizeofIPMreq = C.sizeof_struct_ip_mreq - sizeofIPMreqn = C.sizeof_struct_ip_mreqn - sizeofIPMreqSource = C.sizeof_struct_ip_mreq_source - sizeofGroupReq = C.sizeof_struct_group_req - sizeofGroupSourceReq = C.sizeof_struct_group_source_req - - sizeofICMPFilter = C.sizeof_struct_icmp_filter - - sizeofSockFprog = C.sizeof_struct_sock_fprog -) - -type kernelSockaddrStorage C.struct___kernel_sockaddr_storage - -type sockaddrInet C.struct_sockaddr_in - -type inetPktinfo C.struct_in_pktinfo - -type sockExtendedErr C.struct_sock_extended_err - -type ipMreq C.struct_ip_mreq - -type ipMreqn C.struct_ip_mreqn - -type ipMreqSource C.struct_ip_mreq_source - -type groupReq C.struct_group_req - -type groupSourceReq C.struct_group_source_req - -type icmpFilter C.struct_icmp_filter - -type sockFProg C.struct_sock_fprog - -type sockFilter C.struct_sock_filter diff --git a/vendor/golang.org/x/net/ipv4/defs_netbsd.go b/vendor/golang.org/x/net/ipv4/defs_netbsd.go deleted file mode 100644 index 8f8af1b..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_netbsd.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_RECVTTL = C.IP_RECVTTL - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - - sizeofIPMreq = C.sizeof_struct_ip_mreq -) - -type ipMreq C.struct_ip_mreq diff --git a/vendor/golang.org/x/net/ipv4/defs_openbsd.go b/vendor/golang.org/x/net/ipv4/defs_openbsd.go deleted file mode 100644 index 8f8af1b..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_openbsd.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_RECVTTL = C.IP_RECVTTL - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - - sizeofIPMreq = C.sizeof_struct_ip_mreq -) - -type ipMreq C.struct_ip_mreq diff --git a/vendor/golang.org/x/net/ipv4/defs_solaris.go b/vendor/golang.org/x/net/ipv4/defs_solaris.go deleted file mode 100644 index aeb33e9..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_solaris.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include - -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_RECVSLLA = C.IP_RECVSLLA - sysIP_RECVTTL = C.IP_RECVTTL - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP - sysIP_NEXTHOP = C.IP_NEXTHOP - - sysIP_PKTINFO = C.IP_PKTINFO - sysIP_RECVPKTINFO = C.IP_RECVPKTINFO - sysIP_DONTFRAG = C.IP_DONTFRAG - - sysIP_BOUND_IF = C.IP_BOUND_IF - sysIP_UNSPEC_SRC = C.IP_UNSPEC_SRC - sysIP_BROADCAST_TTL = C.IP_BROADCAST_TTL - sysIP_DHCPINIT_IF = C.IP_DHCPINIT_IF - - sysIP_REUSEADDR = C.IP_REUSEADDR - sysIP_DONTROUTE = C.IP_DONTROUTE - sysIP_BROADCAST = C.IP_BROADCAST - - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - - sizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sizeofInetPktinfo = C.sizeof_struct_in_pktinfo - - sizeofIPMreq = C.sizeof_struct_ip_mreq - sizeofIPMreqSource = C.sizeof_struct_ip_mreq_source - sizeofGroupReq = C.sizeof_struct_group_req - sizeofGroupSourceReq = C.sizeof_struct_group_source_req -) - -type sockaddrStorage C.struct_sockaddr_storage - -type sockaddrInet C.struct_sockaddr_in - -type inetPktinfo C.struct_in_pktinfo - -type ipMreq C.struct_ip_mreq - -type ipMreqSource C.struct_ip_mreq_source - -type groupReq C.struct_group_req - -type groupSourceReq C.struct_group_source_req diff --git a/vendor/golang.org/x/net/ipv4/dgramopt.go b/vendor/golang.org/x/net/ipv4/dgramopt.go deleted file mode 100644 index 3676449..0000000 --- a/vendor/golang.org/x/net/ipv4/dgramopt.go +++ /dev/null @@ -1,264 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - - "golang.org/x/net/bpf" -) - -// MulticastTTL returns the time-to-live field value for outgoing -// multicast packets. -func (c *dgramOpt) MulticastTTL() (int, error) { - if !c.ok() { - return 0, errInvalidConn - } - so, ok := sockOpts[ssoMulticastTTL] - if !ok { - return 0, errOpNoSupport - } - return so.GetInt(c.Conn) -} - -// SetMulticastTTL sets the time-to-live field value for future -// outgoing multicast packets. -func (c *dgramOpt) SetMulticastTTL(ttl int) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoMulticastTTL] - if !ok { - return errOpNoSupport - } - return so.SetInt(c.Conn, ttl) -} - -// MulticastInterface returns the default interface for multicast -// packet transmissions. -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) { - if !c.ok() { - return nil, errInvalidConn - } - so, ok := sockOpts[ssoMulticastInterface] - if !ok { - return nil, errOpNoSupport - } - return so.getMulticastInterface(c.Conn) -} - -// SetMulticastInterface sets the default interface for future -// multicast packet transmissions. -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoMulticastInterface] - if !ok { - return errOpNoSupport - } - return so.setMulticastInterface(c.Conn, ifi) -} - -// MulticastLoopback reports whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) MulticastLoopback() (bool, error) { - if !c.ok() { - return false, errInvalidConn - } - so, ok := sockOpts[ssoMulticastLoopback] - if !ok { - return false, errOpNoSupport - } - on, err := so.GetInt(c.Conn) - if err != nil { - return false, err - } - return on == 1, nil -} - -// SetMulticastLoopback sets whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) SetMulticastLoopback(on bool) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoMulticastLoopback] - if !ok { - return errOpNoSupport - } - return so.SetInt(c.Conn, boolint(on)) -} - -// JoinGroup joins the group address group on the interface ifi. -// By default all sources that can cast data to group are accepted. -// It's possible to mute and unmute data transmission from a specific -// source by using ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup. -// JoinGroup uses the system assigned multicast interface when ifi is -// nil, although this is not recommended because the assignment -// depends on platforms and sometimes it might require routing -// configuration. -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoJoinGroup] - if !ok { - return errOpNoSupport - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - return so.setGroup(c.Conn, ifi, grp) -} - -// LeaveGroup leaves the group address group on the interface ifi -// regardless of whether the group is any-source group or -// source-specific group. -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoLeaveGroup] - if !ok { - return errOpNoSupport - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - return so.setGroup(c.Conn, ifi, grp) -} - -// JoinSourceSpecificGroup joins the source-specific group comprising -// group and source on the interface ifi. -// JoinSourceSpecificGroup uses the system assigned multicast -// interface when ifi is nil, although this is not recommended because -// the assignment depends on platforms and sometimes it might require -// routing configuration. -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoJoinSourceGroup] - if !ok { - return errOpNoSupport - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP4(source) - if src == nil { - return errMissingAddress - } - return so.setSourceGroup(c.Conn, ifi, grp, src) -} - -// LeaveSourceSpecificGroup leaves the source-specific group on the -// interface ifi. -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoLeaveSourceGroup] - if !ok { - return errOpNoSupport - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP4(source) - if src == nil { - return errMissingAddress - } - return so.setSourceGroup(c.Conn, ifi, grp, src) -} - -// ExcludeSourceSpecificGroup excludes the source-specific group from -// the already joined any-source groups by JoinGroup on the interface -// ifi. -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoBlockSourceGroup] - if !ok { - return errOpNoSupport - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP4(source) - if src == nil { - return errMissingAddress - } - return so.setSourceGroup(c.Conn, ifi, grp, src) -} - -// IncludeSourceSpecificGroup includes the excluded source-specific -// group by ExcludeSourceSpecificGroup again on the interface ifi. -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoUnblockSourceGroup] - if !ok { - return errOpNoSupport - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP4(source) - if src == nil { - return errMissingAddress - } - return so.setSourceGroup(c.Conn, ifi, grp, src) -} - -// ICMPFilter returns an ICMP filter. -// Currently only Linux supports this. -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) { - if !c.ok() { - return nil, errInvalidConn - } - so, ok := sockOpts[ssoICMPFilter] - if !ok { - return nil, errOpNoSupport - } - return so.getICMPFilter(c.Conn) -} - -// SetICMPFilter deploys the ICMP filter. -// Currently only Linux supports this. -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoICMPFilter] - if !ok { - return errOpNoSupport - } - return so.setICMPFilter(c.Conn, f) -} - -// SetBPF attaches a BPF program to the connection. -// -// Only supported on Linux. -func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoAttachFilter] - if !ok { - return errOpNoSupport - } - return so.setBPF(c.Conn, filter) -} diff --git a/vendor/golang.org/x/net/ipv4/doc.go b/vendor/golang.org/x/net/ipv4/doc.go deleted file mode 100644 index 863d55b..0000000 --- a/vendor/golang.org/x/net/ipv4/doc.go +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package ipv4 implements IP-level socket options for the Internet -// Protocol version 4. -// -// The package provides IP-level socket options that allow -// manipulation of IPv4 facilities. -// -// The IPv4 protocol and basic host requirements for IPv4 are defined -// in RFC 791 and RFC 1122. -// Host extensions for multicasting and socket interface extensions -// for multicast source filters are defined in RFC 1112 and RFC 3678. -// IGMPv1, IGMPv2 and IGMPv3 are defined in RFC 1112, RFC 2236 and RFC -// 3376. -// Source-specific multicast is defined in RFC 4607. -// -// -// Unicasting -// -// The options for unicasting are available for net.TCPConn, -// net.UDPConn and net.IPConn which are created as network connections -// that use the IPv4 transport. When a single TCP connection carrying -// a data flow of multiple packets needs to indicate the flow is -// important, Conn is used to set the type-of-service field on the -// IPv4 header for each packet. -// -// ln, err := net.Listen("tcp4", "0.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer ln.Close() -// for { -// c, err := ln.Accept() -// if err != nil { -// // error handling -// } -// go func(c net.Conn) { -// defer c.Close() -// -// The outgoing packets will be labeled DiffServ assured forwarding -// class 1 low drop precedence, known as AF11 packets. -// -// if err := ipv4.NewConn(c).SetTOS(0x28); err != nil { -// // error handling -// } -// if _, err := c.Write(data); err != nil { -// // error handling -// } -// }(c) -// } -// -// -// Multicasting -// -// The options for multicasting are available for net.UDPConn and -// net.IPConn which are created as network connections that use the -// IPv4 transport. A few network facilities must be prepared before -// you begin multicasting, at a minimum joining network interfaces and -// multicast groups. -// -// en0, err := net.InterfaceByName("en0") -// if err != nil { -// // error handling -// } -// en1, err := net.InterfaceByIndex(911) -// if err != nil { -// // error handling -// } -// group := net.IPv4(224, 0, 0, 250) -// -// First, an application listens to an appropriate address with an -// appropriate service port. -// -// c, err := net.ListenPacket("udp4", "0.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer c.Close() -// -// Second, the application joins multicast groups, starts listening to -// the groups on the specified network interfaces. Note that the -// service port for transport layer protocol does not matter with this -// operation as joining groups affects only network and link layer -// protocols, such as IPv4 and Ethernet. -// -// p := ipv4.NewPacketConn(c) -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: group}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: group}); err != nil { -// // error handling -// } -// -// The application might set per packet control message transmissions -// between the protocol stack within the kernel. When the application -// needs a destination address on an incoming packet, -// SetControlMessage of PacketConn is used to enable control message -// transmissions. -// -// if err := p.SetControlMessage(ipv4.FlagDst, true); err != nil { -// // error handling -// } -// -// The application could identify whether the received packets are -// of interest by using the control message that contains the -// destination address of the received packet. -// -// b := make([]byte, 1500) -// for { -// n, cm, src, err := p.ReadFrom(b) -// if err != nil { -// // error handling -// } -// if cm.Dst.IsMulticast() { -// if cm.Dst.Equal(group) { -// // joined group, do something -// } else { -// // unknown group, discard -// continue -// } -// } -// -// The application can also send both unicast and multicast packets. -// -// p.SetTOS(0x0) -// p.SetTTL(16) -// if _, err := p.WriteTo(data, nil, src); err != nil { -// // error handling -// } -// dst := &net.UDPAddr{IP: group, Port: 1024} -// for _, ifi := range []*net.Interface{en0, en1} { -// if err := p.SetMulticastInterface(ifi); err != nil { -// // error handling -// } -// p.SetMulticastTTL(2) -// if _, err := p.WriteTo(data, nil, dst); err != nil { -// // error handling -// } -// } -// } -// -// -// More multicasting -// -// An application that uses PacketConn or RawConn may join multiple -// multicast groups. For example, a UDP listener with port 1024 might -// join two different groups across over two different network -// interfaces by using: -// -// c, err := net.ListenPacket("udp4", "0.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer c.Close() -// p := ipv4.NewPacketConn(c) -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}); err != nil { -// // error handling -// } -// -// It is possible for multiple UDP listeners that listen on the same -// UDP port to join the same multicast group. The net package will -// provide a socket that listens to a wildcard address with reusable -// UDP port when an appropriate multicast address prefix is passed to -// the net.ListenPacket or net.ListenUDP. -// -// c1, err := net.ListenPacket("udp4", "224.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer c1.Close() -// c2, err := net.ListenPacket("udp4", "224.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer c2.Close() -// p1 := ipv4.NewPacketConn(c1) -// if err := p1.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil { -// // error handling -// } -// p2 := ipv4.NewPacketConn(c2) -// if err := p2.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil { -// // error handling -// } -// -// Also it is possible for the application to leave or rejoin a -// multicast group on the network interface. -// -// if err := p.LeaveGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 250)}); err != nil { -// // error handling -// } -// -// -// Source-specific multicasting -// -// An application that uses PacketConn or RawConn on IGMPv3 supported -// platform is able to join source-specific multicast groups. -// The application may use JoinSourceSpecificGroup and -// LeaveSourceSpecificGroup for the operation known as "include" mode, -// -// ssmgroup := net.UDPAddr{IP: net.IPv4(232, 7, 8, 9)} -// ssmsource := net.UDPAddr{IP: net.IPv4(192, 168, 0, 1)}) -// if err := p.JoinSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil { -// // error handling -// } -// if err := p.LeaveSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil { -// // error handling -// } -// -// or JoinGroup, ExcludeSourceSpecificGroup, -// IncludeSourceSpecificGroup and LeaveGroup for the operation known -// as "exclude" mode. -// -// exclsource := net.UDPAddr{IP: net.IPv4(192, 168, 0, 254)} -// if err := p.JoinGroup(en0, &ssmgroup); err != nil { -// // error handling -// } -// if err := p.ExcludeSourceSpecificGroup(en0, &ssmgroup, &exclsource); err != nil { -// // error handling -// } -// if err := p.LeaveGroup(en0, &ssmgroup); err != nil { -// // error handling -// } -// -// Note that it depends on each platform implementation what happens -// when an application which runs on IGMPv3 unsupported platform uses -// JoinSourceSpecificGroup and LeaveSourceSpecificGroup. -// In general the platform tries to fall back to conversations using -// IGMPv1 or IGMPv2 and starts to listen to multicast traffic. -// In the fallback case, ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup may return an error. -package ipv4 // import "golang.org/x/net/ipv4" - -// BUG(mikio): This package is not implemented on AIX, JS, NaCl and -// Plan 9. diff --git a/vendor/golang.org/x/net/ipv4/endpoint.go b/vendor/golang.org/x/net/ipv4/endpoint.go deleted file mode 100644 index 5009463..0000000 --- a/vendor/golang.org/x/net/ipv4/endpoint.go +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "time" - - "golang.org/x/net/internal/socket" -) - -// BUG(mikio): On Windows, the JoinSourceSpecificGroup, -// LeaveSourceSpecificGroup, ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup methods of PacketConn and RawConn are -// not implemented. - -// A Conn represents a network endpoint that uses the IPv4 transport. -// It is used to control basic IP-level socket options such as TOS and -// TTL. -type Conn struct { - genericOpt -} - -type genericOpt struct { - *socket.Conn -} - -func (c *genericOpt) ok() bool { return c != nil && c.Conn != nil } - -// NewConn returns a new Conn. -func NewConn(c net.Conn) *Conn { - cc, _ := socket.NewConn(c) - return &Conn{ - genericOpt: genericOpt{Conn: cc}, - } -} - -// A PacketConn represents a packet network endpoint that uses the -// IPv4 transport. It is used to control several IP-level socket -// options including multicasting. It also provides datagram based -// network I/O methods specific to the IPv4 and higher layer protocols -// such as UDP. -type PacketConn struct { - genericOpt - dgramOpt - payloadHandler -} - -type dgramOpt struct { - *socket.Conn -} - -func (c *dgramOpt) ok() bool { return c != nil && c.Conn != nil } - -// SetControlMessage sets the per packet IP-level socket options. -func (c *PacketConn) SetControlMessage(cf ControlFlags, on bool) error { - if !c.payloadHandler.ok() { - return errInvalidConn - } - return setControlMessage(c.dgramOpt.Conn, &c.payloadHandler.rawOpt, cf, on) -} - -// SetDeadline sets the read and write deadlines associated with the -// endpoint. -func (c *PacketConn) SetDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return errInvalidConn - } - return c.payloadHandler.PacketConn.SetDeadline(t) -} - -// SetReadDeadline sets the read deadline associated with the -// endpoint. -func (c *PacketConn) SetReadDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return errInvalidConn - } - return c.payloadHandler.PacketConn.SetReadDeadline(t) -} - -// SetWriteDeadline sets the write deadline associated with the -// endpoint. -func (c *PacketConn) SetWriteDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return errInvalidConn - } - return c.payloadHandler.PacketConn.SetWriteDeadline(t) -} - -// Close closes the endpoint. -func (c *PacketConn) Close() error { - if !c.payloadHandler.ok() { - return errInvalidConn - } - return c.payloadHandler.PacketConn.Close() -} - -// NewPacketConn returns a new PacketConn using c as its underlying -// transport. -func NewPacketConn(c net.PacketConn) *PacketConn { - cc, _ := socket.NewConn(c.(net.Conn)) - p := &PacketConn{ - genericOpt: genericOpt{Conn: cc}, - dgramOpt: dgramOpt{Conn: cc}, - payloadHandler: payloadHandler{PacketConn: c, Conn: cc}, - } - return p -} - -// A RawConn represents a packet network endpoint that uses the IPv4 -// transport. It is used to control several IP-level socket options -// including IPv4 header manipulation. It also provides datagram -// based network I/O methods specific to the IPv4 and higher layer -// protocols that handle IPv4 datagram directly such as OSPF, GRE. -type RawConn struct { - genericOpt - dgramOpt - packetHandler -} - -// SetControlMessage sets the per packet IP-level socket options. -func (c *RawConn) SetControlMessage(cf ControlFlags, on bool) error { - if !c.packetHandler.ok() { - return errInvalidConn - } - return setControlMessage(c.dgramOpt.Conn, &c.packetHandler.rawOpt, cf, on) -} - -// SetDeadline sets the read and write deadlines associated with the -// endpoint. -func (c *RawConn) SetDeadline(t time.Time) error { - if !c.packetHandler.ok() { - return errInvalidConn - } - return c.packetHandler.IPConn.SetDeadline(t) -} - -// SetReadDeadline sets the read deadline associated with the -// endpoint. -func (c *RawConn) SetReadDeadline(t time.Time) error { - if !c.packetHandler.ok() { - return errInvalidConn - } - return c.packetHandler.IPConn.SetReadDeadline(t) -} - -// SetWriteDeadline sets the write deadline associated with the -// endpoint. -func (c *RawConn) SetWriteDeadline(t time.Time) error { - if !c.packetHandler.ok() { - return errInvalidConn - } - return c.packetHandler.IPConn.SetWriteDeadline(t) -} - -// Close closes the endpoint. -func (c *RawConn) Close() error { - if !c.packetHandler.ok() { - return errInvalidConn - } - return c.packetHandler.IPConn.Close() -} - -// NewRawConn returns a new RawConn using c as its underlying -// transport. -func NewRawConn(c net.PacketConn) (*RawConn, error) { - cc, err := socket.NewConn(c.(net.Conn)) - if err != nil { - return nil, err - } - r := &RawConn{ - genericOpt: genericOpt{Conn: cc}, - dgramOpt: dgramOpt{Conn: cc}, - packetHandler: packetHandler{IPConn: c.(*net.IPConn), Conn: cc}, - } - so, ok := sockOpts[ssoHeaderPrepend] - if !ok { - return nil, errOpNoSupport - } - if err := so.SetInt(r.dgramOpt.Conn, boolint(true)); err != nil { - return nil, err - } - return r, nil -} diff --git a/vendor/golang.org/x/net/ipv4/gen.go b/vendor/golang.org/x/net/ipv4/gen.go deleted file mode 100644 index 1bb1737..0000000 --- a/vendor/golang.org/x/net/ipv4/gen.go +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -//go:generate go run gen.go - -// This program generates system adaptation constants and types, -// internet protocol constants and tables by reading template files -// and IANA protocol registries. -package main - -import ( - "bytes" - "encoding/xml" - "fmt" - "go/format" - "io" - "io/ioutil" - "net/http" - "os" - "os/exec" - "runtime" - "strconv" - "strings" -) - -func main() { - if err := genzsys(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - if err := geniana(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func genzsys() error { - defs := "defs_" + runtime.GOOS + ".go" - f, err := os.Open(defs) - if err != nil { - if os.IsNotExist(err) { - return nil - } - return err - } - f.Close() - cmd := exec.Command("go", "tool", "cgo", "-godefs", defs) - b, err := cmd.Output() - if err != nil { - return err - } - b, err = format.Source(b) - if err != nil { - return err - } - zsys := "zsys_" + runtime.GOOS + ".go" - switch runtime.GOOS { - case "freebsd", "linux": - zsys = "zsys_" + runtime.GOOS + "_" + runtime.GOARCH + ".go" - } - if err := ioutil.WriteFile(zsys, b, 0644); err != nil { - return err - } - return nil -} - -var registries = []struct { - url string - parse func(io.Writer, io.Reader) error -}{ - { - "https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xml", - parseICMPv4Parameters, - }, -} - -func geniana() error { - var bb bytes.Buffer - fmt.Fprintf(&bb, "// go generate gen.go\n") - fmt.Fprintf(&bb, "// Code generated by the command above; DO NOT EDIT.\n\n") - fmt.Fprintf(&bb, "package ipv4\n\n") - for _, r := range registries { - resp, err := http.Get(r.url) - if err != nil { - return err - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("got HTTP status code %v for %v\n", resp.StatusCode, r.url) - } - if err := r.parse(&bb, resp.Body); err != nil { - return err - } - fmt.Fprintf(&bb, "\n") - } - b, err := format.Source(bb.Bytes()) - if err != nil { - return err - } - if err := ioutil.WriteFile("iana.go", b, 0644); err != nil { - return err - } - return nil -} - -func parseICMPv4Parameters(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var icp icmpv4Parameters - if err := dec.Decode(&icp); err != nil { - return err - } - prs := icp.escape() - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated) - fmt.Fprintf(w, "const (\n") - for _, pr := range prs { - if pr.Descr == "" { - continue - } - fmt.Fprintf(w, "ICMPType%s ICMPType = %d", pr.Descr, pr.Value) - fmt.Fprintf(w, "// %s\n", pr.OrigDescr) - } - fmt.Fprintf(w, ")\n\n") - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated) - fmt.Fprintf(w, "var icmpTypes = map[ICMPType]string{\n") - for _, pr := range prs { - if pr.Descr == "" { - continue - } - fmt.Fprintf(w, "%d: %q,\n", pr.Value, strings.ToLower(pr.OrigDescr)) - } - fmt.Fprintf(w, "}\n") - return nil -} - -type icmpv4Parameters struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - Registries []struct { - Title string `xml:"title"` - Records []struct { - Value string `xml:"value"` - Descr string `xml:"description"` - } `xml:"record"` - } `xml:"registry"` -} - -type canonICMPv4ParamRecord struct { - OrigDescr string - Descr string - Value int -} - -func (icp *icmpv4Parameters) escape() []canonICMPv4ParamRecord { - id := -1 - for i, r := range icp.Registries { - if strings.Contains(r.Title, "Type") || strings.Contains(r.Title, "type") { - id = i - break - } - } - if id < 0 { - return nil - } - prs := make([]canonICMPv4ParamRecord, len(icp.Registries[id].Records)) - sr := strings.NewReplacer( - "Messages", "", - "Message", "", - "ICMP", "", - "+", "P", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, pr := range icp.Registries[id].Records { - if strings.Contains(pr.Descr, "Reserved") || - strings.Contains(pr.Descr, "Unassigned") || - strings.Contains(pr.Descr, "Deprecated") || - strings.Contains(pr.Descr, "Experiment") || - strings.Contains(pr.Descr, "experiment") { - continue - } - ss := strings.Split(pr.Descr, "\n") - if len(ss) > 1 { - prs[i].Descr = strings.Join(ss, " ") - } else { - prs[i].Descr = ss[0] - } - s := strings.TrimSpace(prs[i].Descr) - prs[i].OrigDescr = s - prs[i].Descr = sr.Replace(s) - prs[i].Value, _ = strconv.Atoi(pr.Value) - } - return prs -} diff --git a/vendor/golang.org/x/net/ipv4/genericopt.go b/vendor/golang.org/x/net/ipv4/genericopt.go deleted file mode 100644 index 587ae4a..0000000 --- a/vendor/golang.org/x/net/ipv4/genericopt.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -// TOS returns the type-of-service field value for outgoing packets. -func (c *genericOpt) TOS() (int, error) { - if !c.ok() { - return 0, errInvalidConn - } - so, ok := sockOpts[ssoTOS] - if !ok { - return 0, errOpNoSupport - } - return so.GetInt(c.Conn) -} - -// SetTOS sets the type-of-service field value for future outgoing -// packets. -func (c *genericOpt) SetTOS(tos int) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoTOS] - if !ok { - return errOpNoSupport - } - return so.SetInt(c.Conn, tos) -} - -// TTL returns the time-to-live field value for outgoing packets. -func (c *genericOpt) TTL() (int, error) { - if !c.ok() { - return 0, errInvalidConn - } - so, ok := sockOpts[ssoTTL] - if !ok { - return 0, errOpNoSupport - } - return so.GetInt(c.Conn) -} - -// SetTTL sets the time-to-live field value for future outgoing -// packets. -func (c *genericOpt) SetTTL(ttl int) error { - if !c.ok() { - return errInvalidConn - } - so, ok := sockOpts[ssoTTL] - if !ok { - return errOpNoSupport - } - return so.SetInt(c.Conn, ttl) -} diff --git a/vendor/golang.org/x/net/ipv4/header.go b/vendor/golang.org/x/net/ipv4/header.go deleted file mode 100644 index a8c8f7a..0000000 --- a/vendor/golang.org/x/net/ipv4/header.go +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "encoding/binary" - "fmt" - "net" - "runtime" - - "golang.org/x/net/internal/socket" -) - -const ( - Version = 4 // protocol version - HeaderLen = 20 // header length without extension headers - maxHeaderLen = 60 // sensible default, revisit if later RFCs define new usage of version and header length fields -) - -type HeaderFlags int - -const ( - MoreFragments HeaderFlags = 1 << iota // more fragments flag - DontFragment // don't fragment flag -) - -// A Header represents an IPv4 header. -type Header struct { - Version int // protocol version - Len int // header length - TOS int // type-of-service - TotalLen int // packet total length - ID int // identification - Flags HeaderFlags // flags - FragOff int // fragment offset - TTL int // time-to-live - Protocol int // next protocol - Checksum int // checksum - Src net.IP // source address - Dst net.IP // destination address - Options []byte // options, extension headers -} - -func (h *Header) String() string { - if h == nil { - return "" - } - return fmt.Sprintf("ver=%d hdrlen=%d tos=%#x totallen=%d id=%#x flags=%#x fragoff=%#x ttl=%d proto=%d cksum=%#x src=%v dst=%v", h.Version, h.Len, h.TOS, h.TotalLen, h.ID, h.Flags, h.FragOff, h.TTL, h.Protocol, h.Checksum, h.Src, h.Dst) -} - -// Marshal returns the binary encoding of h. -// -// The returned slice is in the format used by a raw IP socket on the -// local system. -// This may differ from the wire format, depending on the system. -func (h *Header) Marshal() ([]byte, error) { - if h == nil { - return nil, errInvalidConn - } - if h.Len < HeaderLen { - return nil, errHeaderTooShort - } - hdrlen := HeaderLen + len(h.Options) - b := make([]byte, hdrlen) - b[0] = byte(Version<<4 | (hdrlen >> 2 & 0x0f)) - b[1] = byte(h.TOS) - flagsAndFragOff := (h.FragOff & 0x1fff) | int(h.Flags<<13) - switch runtime.GOOS { - case "darwin", "dragonfly", "netbsd": - socket.NativeEndian.PutUint16(b[2:4], uint16(h.TotalLen)) - socket.NativeEndian.PutUint16(b[6:8], uint16(flagsAndFragOff)) - case "freebsd": - if freebsdVersion < 1100000 { - socket.NativeEndian.PutUint16(b[2:4], uint16(h.TotalLen)) - socket.NativeEndian.PutUint16(b[6:8], uint16(flagsAndFragOff)) - } else { - binary.BigEndian.PutUint16(b[2:4], uint16(h.TotalLen)) - binary.BigEndian.PutUint16(b[6:8], uint16(flagsAndFragOff)) - } - default: - binary.BigEndian.PutUint16(b[2:4], uint16(h.TotalLen)) - binary.BigEndian.PutUint16(b[6:8], uint16(flagsAndFragOff)) - } - binary.BigEndian.PutUint16(b[4:6], uint16(h.ID)) - b[8] = byte(h.TTL) - b[9] = byte(h.Protocol) - binary.BigEndian.PutUint16(b[10:12], uint16(h.Checksum)) - if ip := h.Src.To4(); ip != nil { - copy(b[12:16], ip[:net.IPv4len]) - } - if ip := h.Dst.To4(); ip != nil { - copy(b[16:20], ip[:net.IPv4len]) - } else { - return nil, errMissingAddress - } - if len(h.Options) > 0 { - copy(b[HeaderLen:], h.Options) - } - return b, nil -} - -// Parse parses b as an IPv4 header and stores the result in h. -// -// The provided b must be in the format used by a raw IP socket on the -// local system. -// This may differ from the wire format, depending on the system. -func (h *Header) Parse(b []byte) error { - if h == nil || len(b) < HeaderLen { - return errHeaderTooShort - } - hdrlen := int(b[0]&0x0f) << 2 - if hdrlen > len(b) { - return errBufferTooShort - } - h.Version = int(b[0] >> 4) - h.Len = hdrlen - h.TOS = int(b[1]) - h.ID = int(binary.BigEndian.Uint16(b[4:6])) - h.TTL = int(b[8]) - h.Protocol = int(b[9]) - h.Checksum = int(binary.BigEndian.Uint16(b[10:12])) - h.Src = net.IPv4(b[12], b[13], b[14], b[15]) - h.Dst = net.IPv4(b[16], b[17], b[18], b[19]) - switch runtime.GOOS { - case "darwin", "dragonfly", "netbsd": - h.TotalLen = int(socket.NativeEndian.Uint16(b[2:4])) + hdrlen - h.FragOff = int(socket.NativeEndian.Uint16(b[6:8])) - case "freebsd": - if freebsdVersion < 1100000 { - h.TotalLen = int(socket.NativeEndian.Uint16(b[2:4])) - if freebsdVersion < 1000000 { - h.TotalLen += hdrlen - } - h.FragOff = int(socket.NativeEndian.Uint16(b[6:8])) - } else { - h.TotalLen = int(binary.BigEndian.Uint16(b[2:4])) - h.FragOff = int(binary.BigEndian.Uint16(b[6:8])) - } - default: - h.TotalLen = int(binary.BigEndian.Uint16(b[2:4])) - h.FragOff = int(binary.BigEndian.Uint16(b[6:8])) - } - h.Flags = HeaderFlags(h.FragOff&0xe000) >> 13 - h.FragOff = h.FragOff & 0x1fff - optlen := hdrlen - HeaderLen - if optlen > 0 && len(b) >= hdrlen { - if cap(h.Options) < optlen { - h.Options = make([]byte, optlen) - } else { - h.Options = h.Options[:optlen] - } - copy(h.Options, b[HeaderLen:hdrlen]) - } - return nil -} - -// ParseHeader parses b as an IPv4 header. -// -// The provided b must be in the format used by a raw IP socket on the -// local system. -// This may differ from the wire format, depending on the system. -func ParseHeader(b []byte) (*Header, error) { - h := new(Header) - if err := h.Parse(b); err != nil { - return nil, err - } - return h, nil -} diff --git a/vendor/golang.org/x/net/ipv4/helper.go b/vendor/golang.org/x/net/ipv4/helper.go deleted file mode 100644 index 8d8ff98..0000000 --- a/vendor/golang.org/x/net/ipv4/helper.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "errors" - "net" -) - -var ( - errInvalidConn = errors.New("invalid connection") - errMissingAddress = errors.New("missing address") - errMissingHeader = errors.New("missing header") - errHeaderTooShort = errors.New("header too short") - errBufferTooShort = errors.New("buffer too short") - errInvalidConnType = errors.New("invalid conn type") - errOpNoSupport = errors.New("operation not supported") - errNoSuchInterface = errors.New("no such interface") - errNoSuchMulticastInterface = errors.New("no such multicast interface") - - // See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html. - freebsdVersion uint32 -) - -func boolint(b bool) int { - if b { - return 1 - } - return 0 -} - -func netAddrToIP4(a net.Addr) net.IP { - switch v := a.(type) { - case *net.UDPAddr: - if ip := v.IP.To4(); ip != nil { - return ip - } - case *net.IPAddr: - if ip := v.IP.To4(); ip != nil { - return ip - } - } - return nil -} - -func opAddr(a net.Addr) net.Addr { - switch a.(type) { - case *net.TCPAddr: - if a == nil { - return nil - } - case *net.UDPAddr: - if a == nil { - return nil - } - case *net.IPAddr: - if a == nil { - return nil - } - } - return a -} diff --git a/vendor/golang.org/x/net/ipv4/iana.go b/vendor/golang.org/x/net/ipv4/iana.go deleted file mode 100644 index 4375b40..0000000 --- a/vendor/golang.org/x/net/ipv4/iana.go +++ /dev/null @@ -1,38 +0,0 @@ -// go generate gen.go -// Code generated by the command above; DO NOT EDIT. - -package ipv4 - -// Internet Control Message Protocol (ICMP) Parameters, Updated: 2018-02-26 -const ( - ICMPTypeEchoReply ICMPType = 0 // Echo Reply - ICMPTypeDestinationUnreachable ICMPType = 3 // Destination Unreachable - ICMPTypeRedirect ICMPType = 5 // Redirect - ICMPTypeEcho ICMPType = 8 // Echo - ICMPTypeRouterAdvertisement ICMPType = 9 // Router Advertisement - ICMPTypeRouterSolicitation ICMPType = 10 // Router Solicitation - ICMPTypeTimeExceeded ICMPType = 11 // Time Exceeded - ICMPTypeParameterProblem ICMPType = 12 // Parameter Problem - ICMPTypeTimestamp ICMPType = 13 // Timestamp - ICMPTypeTimestampReply ICMPType = 14 // Timestamp Reply - ICMPTypePhoturis ICMPType = 40 // Photuris - ICMPTypeExtendedEchoRequest ICMPType = 42 // Extended Echo Request - ICMPTypeExtendedEchoReply ICMPType = 43 // Extended Echo Reply -) - -// Internet Control Message Protocol (ICMP) Parameters, Updated: 2018-02-26 -var icmpTypes = map[ICMPType]string{ - 0: "echo reply", - 3: "destination unreachable", - 5: "redirect", - 8: "echo", - 9: "router advertisement", - 10: "router solicitation", - 11: "time exceeded", - 12: "parameter problem", - 13: "timestamp", - 14: "timestamp reply", - 40: "photuris", - 42: "extended echo request", - 43: "extended echo reply", -} diff --git a/vendor/golang.org/x/net/ipv4/icmp.go b/vendor/golang.org/x/net/ipv4/icmp.go deleted file mode 100644 index 9902bb3..0000000 --- a/vendor/golang.org/x/net/ipv4/icmp.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import "golang.org/x/net/internal/iana" - -// An ICMPType represents a type of ICMP message. -type ICMPType int - -func (typ ICMPType) String() string { - s, ok := icmpTypes[typ] - if !ok { - return "" - } - return s -} - -// Protocol returns the ICMPv4 protocol number. -func (typ ICMPType) Protocol() int { - return iana.ProtocolICMP -} - -// An ICMPFilter represents an ICMP message filter for incoming -// packets. The filter belongs to a packet delivery path on a host and -// it cannot interact with forwarding packets or tunnel-outer packets. -// -// Note: RFC 8200 defines a reasonable role model and it works not -// only for IPv6 but IPv4. A node means a device that implements IP. -// A router means a node that forwards IP packets not explicitly -// addressed to itself, and a host means a node that is not a router. -type ICMPFilter struct { - icmpFilter -} - -// Accept accepts incoming ICMP packets including the type field value -// typ. -func (f *ICMPFilter) Accept(typ ICMPType) { - f.accept(typ) -} - -// Block blocks incoming ICMP packets including the type field value -// typ. -func (f *ICMPFilter) Block(typ ICMPType) { - f.block(typ) -} - -// SetAll sets the filter action to the filter. -func (f *ICMPFilter) SetAll(block bool) { - f.setAll(block) -} - -// WillBlock reports whether the ICMP type will be blocked. -func (f *ICMPFilter) WillBlock(typ ICMPType) bool { - return f.willBlock(typ) -} diff --git a/vendor/golang.org/x/net/ipv4/icmp_linux.go b/vendor/golang.org/x/net/ipv4/icmp_linux.go deleted file mode 100644 index 6e1c5c8..0000000 --- a/vendor/golang.org/x/net/ipv4/icmp_linux.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -func (f *icmpFilter) accept(typ ICMPType) { - f.Data &^= 1 << (uint32(typ) & 31) -} - -func (f *icmpFilter) block(typ ICMPType) { - f.Data |= 1 << (uint32(typ) & 31) -} - -func (f *icmpFilter) setAll(block bool) { - if block { - f.Data = 1<<32 - 1 - } else { - f.Data = 0 - } -} - -func (f *icmpFilter) willBlock(typ ICMPType) bool { - return f.Data&(1<<(uint32(typ)&31)) != 0 -} diff --git a/vendor/golang.org/x/net/ipv4/icmp_stub.go b/vendor/golang.org/x/net/ipv4/icmp_stub.go deleted file mode 100644 index 21bb29a..0000000 --- a/vendor/golang.org/x/net/ipv4/icmp_stub.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !linux - -package ipv4 - -const sizeofICMPFilter = 0x0 - -type icmpFilter struct { -} - -func (f *icmpFilter) accept(typ ICMPType) { -} - -func (f *icmpFilter) block(typ ICMPType) { -} - -func (f *icmpFilter) setAll(block bool) { -} - -func (f *icmpFilter) willBlock(typ ICMPType) bool { - return false -} diff --git a/vendor/golang.org/x/net/ipv4/packet.go b/vendor/golang.org/x/net/ipv4/packet.go deleted file mode 100644 index 966bb77..0000000 --- a/vendor/golang.org/x/net/ipv4/packet.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - - "golang.org/x/net/internal/socket" -) - -// BUG(mikio): On Windows, the ReadFrom and WriteTo methods of RawConn -// are not implemented. - -// A packetHandler represents the IPv4 datagram handler. -type packetHandler struct { - *net.IPConn - *socket.Conn - rawOpt -} - -func (c *packetHandler) ok() bool { return c != nil && c.IPConn != nil && c.Conn != nil } - -// ReadFrom reads an IPv4 datagram from the endpoint c, copying the -// datagram into b. It returns the received datagram as the IPv4 -// header h, the payload p and the control message cm. -func (c *packetHandler) ReadFrom(b []byte) (h *Header, p []byte, cm *ControlMessage, err error) { - if !c.ok() { - return nil, nil, nil, errInvalidConn - } - return c.readFrom(b) -} - -func slicePacket(b []byte) (h, p []byte, err error) { - if len(b) < HeaderLen { - return nil, nil, errHeaderTooShort - } - hdrlen := int(b[0]&0x0f) << 2 - return b[:hdrlen], b[hdrlen:], nil -} - -// WriteTo writes an IPv4 datagram through the endpoint c, copying the -// datagram from the IPv4 header h and the payload p. The control -// message cm allows the datagram path and the outgoing interface to be -// specified. Currently only Darwin and Linux support this. The cm -// may be nil if control of the outgoing datagram is not required. -// -// The IPv4 header h must contain appropriate fields that include: -// -// Version = -// Len = -// TOS = -// TotalLen = -// ID = platform sets an appropriate value if ID is zero -// FragOff = -// TTL = -// Protocol = -// Checksum = platform sets an appropriate value if Checksum is zero -// Src = platform sets an appropriate value if Src is nil -// Dst = -// Options = optional -func (c *packetHandler) WriteTo(h *Header, p []byte, cm *ControlMessage) error { - if !c.ok() { - return errInvalidConn - } - return c.writeTo(h, p, cm) -} diff --git a/vendor/golang.org/x/net/ipv4/packet_go1_8.go b/vendor/golang.org/x/net/ipv4/packet_go1_8.go deleted file mode 100644 index b47d186..0000000 --- a/vendor/golang.org/x/net/ipv4/packet_go1_8.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.9 - -package ipv4 - -import "net" - -func (c *packetHandler) readFrom(b []byte) (h *Header, p []byte, cm *ControlMessage, err error) { - c.rawOpt.RLock() - oob := NewControlMessage(c.rawOpt.cflags) - c.rawOpt.RUnlock() - n, nn, _, src, err := c.ReadMsgIP(b, oob) - if err != nil { - return nil, nil, nil, err - } - var hs []byte - if hs, p, err = slicePacket(b[:n]); err != nil { - return nil, nil, nil, err - } - if h, err = ParseHeader(hs); err != nil { - return nil, nil, nil, err - } - if nn > 0 { - cm = new(ControlMessage) - if err := cm.Parse(oob[:nn]); err != nil { - return nil, nil, nil, err - } - } - if src != nil && cm != nil { - cm.Src = src.IP - } - return -} - -func (c *packetHandler) writeTo(h *Header, p []byte, cm *ControlMessage) error { - oob := cm.Marshal() - wh, err := h.Marshal() - if err != nil { - return err - } - dst := new(net.IPAddr) - if cm != nil { - if ip := cm.Dst.To4(); ip != nil { - dst.IP = ip - } - } - if dst.IP == nil { - dst.IP = h.Dst - } - wh = append(wh, p...) - _, _, err = c.WriteMsgIP(wh, oob, dst) - return err -} diff --git a/vendor/golang.org/x/net/ipv4/packet_go1_9.go b/vendor/golang.org/x/net/ipv4/packet_go1_9.go deleted file mode 100644 index 082c36d..0000000 --- a/vendor/golang.org/x/net/ipv4/packet_go1_9.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 - -package ipv4 - -import ( - "net" - - "golang.org/x/net/internal/socket" -) - -func (c *packetHandler) readFrom(b []byte) (h *Header, p []byte, cm *ControlMessage, err error) { - c.rawOpt.RLock() - m := socket.Message{ - Buffers: [][]byte{b}, - OOB: NewControlMessage(c.rawOpt.cflags), - } - c.rawOpt.RUnlock() - if err := c.RecvMsg(&m, 0); err != nil { - return nil, nil, nil, &net.OpError{Op: "read", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err} - } - var hs []byte - if hs, p, err = slicePacket(b[:m.N]); err != nil { - return nil, nil, nil, &net.OpError{Op: "read", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err} - } - if h, err = ParseHeader(hs); err != nil { - return nil, nil, nil, &net.OpError{Op: "read", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err} - } - if m.NN > 0 { - cm = new(ControlMessage) - if err := cm.Parse(m.OOB[:m.NN]); err != nil { - return nil, nil, nil, &net.OpError{Op: "read", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err} - } - } - if src, ok := m.Addr.(*net.IPAddr); ok && cm != nil { - cm.Src = src.IP - } - return -} - -func (c *packetHandler) writeTo(h *Header, p []byte, cm *ControlMessage) error { - m := socket.Message{ - OOB: cm.Marshal(), - } - wh, err := h.Marshal() - if err != nil { - return err - } - m.Buffers = [][]byte{wh, p} - dst := new(net.IPAddr) - if cm != nil { - if ip := cm.Dst.To4(); ip != nil { - dst.IP = ip - } - } - if dst.IP == nil { - dst.IP = h.Dst - } - m.Addr = dst - if err := c.SendMsg(&m, 0); err != nil { - return &net.OpError{Op: "write", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Addr: opAddr(dst), Err: err} - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv4/payload.go b/vendor/golang.org/x/net/ipv4/payload.go deleted file mode 100644 index f95f811..0000000 --- a/vendor/golang.org/x/net/ipv4/payload.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - - "golang.org/x/net/internal/socket" -) - -// BUG(mikio): On Windows, the ControlMessage for ReadFrom and WriteTo -// methods of PacketConn is not implemented. - -// A payloadHandler represents the IPv4 datagram payload handler. -type payloadHandler struct { - net.PacketConn - *socket.Conn - rawOpt -} - -func (c *payloadHandler) ok() bool { return c != nil && c.PacketConn != nil && c.Conn != nil } diff --git a/vendor/golang.org/x/net/ipv4/payload_cmsg.go b/vendor/golang.org/x/net/ipv4/payload_cmsg.go deleted file mode 100644 index a7c892d..0000000 --- a/vendor/golang.org/x/net/ipv4/payload_cmsg.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package ipv4 - -import "net" - -// ReadFrom reads a payload of the received IPv4 datagram, from the -// endpoint c, copying the payload into b. It returns the number of -// bytes copied into b, the control message cm and the source address -// src of the received datagram. -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { - if !c.ok() { - return 0, nil, nil, errInvalidConn - } - return c.readFrom(b) -} - -// WriteTo writes a payload of the IPv4 datagram, to the destination -// address dst through the endpoint c, copying the payload from b. It -// returns the number of bytes written. The control message cm allows -// the datagram path and the outgoing interface to be specified. -// Currently only Darwin and Linux support this. The cm may be nil if -// control of the outgoing datagram is not required. -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { - if !c.ok() { - return 0, errInvalidConn - } - return c.writeTo(b, cm, dst) -} diff --git a/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_8.go b/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_8.go deleted file mode 100644 index 15a27b7..0000000 --- a/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_8.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.9 -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package ipv4 - -import "net" - -func (c *payloadHandler) readFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { - c.rawOpt.RLock() - oob := NewControlMessage(c.rawOpt.cflags) - c.rawOpt.RUnlock() - var nn int - switch c := c.PacketConn.(type) { - case *net.UDPConn: - if n, nn, _, src, err = c.ReadMsgUDP(b, oob); err != nil { - return 0, nil, nil, err - } - case *net.IPConn: - nb := make([]byte, maxHeaderLen+len(b)) - if n, nn, _, src, err = c.ReadMsgIP(nb, oob); err != nil { - return 0, nil, nil, err - } - hdrlen := int(nb[0]&0x0f) << 2 - copy(b, nb[hdrlen:]) - n -= hdrlen - default: - return 0, nil, nil, &net.OpError{Op: "read", Net: c.LocalAddr().Network(), Source: c.LocalAddr(), Err: errInvalidConnType} - } - if nn > 0 { - cm = new(ControlMessage) - if err = cm.Parse(oob[:nn]); err != nil { - return 0, nil, nil, &net.OpError{Op: "read", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err} - } - } - if cm != nil { - cm.Src = netAddrToIP4(src) - } - return -} - -func (c *payloadHandler) writeTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { - oob := cm.Marshal() - if dst == nil { - return 0, &net.OpError{Op: "write", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: errMissingAddress} - } - switch c := c.PacketConn.(type) { - case *net.UDPConn: - n, _, err = c.WriteMsgUDP(b, oob, dst.(*net.UDPAddr)) - case *net.IPConn: - n, _, err = c.WriteMsgIP(b, oob, dst.(*net.IPAddr)) - default: - return 0, &net.OpError{Op: "write", Net: c.LocalAddr().Network(), Source: c.LocalAddr(), Addr: opAddr(dst), Err: errInvalidConnType} - } - return -} diff --git a/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_9.go b/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_9.go deleted file mode 100644 index aab3b22..0000000 --- a/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_9.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.9 -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package ipv4 - -import ( - "net" - - "golang.org/x/net/internal/socket" -) - -func (c *payloadHandler) readFrom(b []byte) (int, *ControlMessage, net.Addr, error) { - c.rawOpt.RLock() - m := socket.Message{ - OOB: NewControlMessage(c.rawOpt.cflags), - } - c.rawOpt.RUnlock() - switch c.PacketConn.(type) { - case *net.UDPConn: - m.Buffers = [][]byte{b} - if err := c.RecvMsg(&m, 0); err != nil { - return 0, nil, nil, &net.OpError{Op: "read", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err} - } - case *net.IPConn: - h := make([]byte, HeaderLen) - m.Buffers = [][]byte{h, b} - if err := c.RecvMsg(&m, 0); err != nil { - return 0, nil, nil, &net.OpError{Op: "read", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err} - } - hdrlen := int(h[0]&0x0f) << 2 - if hdrlen > len(h) { - d := hdrlen - len(h) - copy(b, b[d:]) - m.N -= d - } else { - m.N -= hdrlen - } - default: - return 0, nil, nil, &net.OpError{Op: "read", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: errInvalidConnType} - } - var cm *ControlMessage - if m.NN > 0 { - cm = new(ControlMessage) - if err := cm.Parse(m.OOB[:m.NN]); err != nil { - return 0, nil, nil, &net.OpError{Op: "read", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err} - } - cm.Src = netAddrToIP4(m.Addr) - } - return m.N, cm, m.Addr, nil -} - -func (c *payloadHandler) writeTo(b []byte, cm *ControlMessage, dst net.Addr) (int, error) { - m := socket.Message{ - Buffers: [][]byte{b}, - OOB: cm.Marshal(), - Addr: dst, - } - err := c.SendMsg(&m, 0) - if err != nil { - err = &net.OpError{Op: "write", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Addr: opAddr(dst), Err: err} - } - return m.N, err -} diff --git a/vendor/golang.org/x/net/ipv4/payload_nocmsg.go b/vendor/golang.org/x/net/ipv4/payload_nocmsg.go deleted file mode 100644 index d57f05c..0000000 --- a/vendor/golang.org/x/net/ipv4/payload_nocmsg.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris - -package ipv4 - -import "net" - -// ReadFrom reads a payload of the received IPv4 datagram, from the -// endpoint c, copying the payload into b. It returns the number of -// bytes copied into b, the control message cm and the source address -// src of the received datagram. -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { - if !c.ok() { - return 0, nil, nil, errInvalidConn - } - if n, src, err = c.PacketConn.ReadFrom(b); err != nil { - return 0, nil, nil, err - } - return -} - -// WriteTo writes a payload of the IPv4 datagram, to the destination -// address dst through the endpoint c, copying the payload from b. It -// returns the number of bytes written. The control message cm allows -// the datagram path and the outgoing interface to be specified. -// Currently only Darwin and Linux support this. The cm may be nil if -// control of the outgoing datagram is not required. -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { - if !c.ok() { - return 0, errInvalidConn - } - if dst == nil { - return 0, errMissingAddress - } - return c.PacketConn.WriteTo(b, dst) -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt.go b/vendor/golang.org/x/net/ipv4/sockopt.go deleted file mode 100644 index 22e90c0..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import "golang.org/x/net/internal/socket" - -// Sticky socket options -const ( - ssoTOS = iota // header field for unicast packet - ssoTTL // header field for unicast packet - ssoMulticastTTL // header field for multicast packet - ssoMulticastInterface // outbound interface for multicast packet - ssoMulticastLoopback // loopback for multicast packet - ssoReceiveTTL // header field on received packet - ssoReceiveDst // header field on received packet - ssoReceiveInterface // inbound interface on received packet - ssoPacketInfo // incbound or outbound packet path - ssoHeaderPrepend // ipv4 header prepend - ssoStripHeader // strip ipv4 header - ssoICMPFilter // icmp filter - ssoJoinGroup // any-source multicast - ssoLeaveGroup // any-source multicast - ssoJoinSourceGroup // source-specific multicast - ssoLeaveSourceGroup // source-specific multicast - ssoBlockSourceGroup // any-source or source-specific multicast - ssoUnblockSourceGroup // any-source or source-specific multicast - ssoAttachFilter // attach BPF for filtering inbound traffic -) - -// Sticky socket option value types -const ( - ssoTypeIPMreq = iota + 1 - ssoTypeIPMreqn - ssoTypeGroupReq - ssoTypeGroupSourceReq -) - -// A sockOpt represents a binding for sticky socket option. -type sockOpt struct { - socket.Option - typ int // hint for option value type; optional -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_posix.go b/vendor/golang.org/x/net/ipv4/sockopt_posix.go deleted file mode 100644 index e96955b..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_posix.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package ipv4 - -import ( - "net" - "unsafe" - - "golang.org/x/net/bpf" - "golang.org/x/net/internal/socket" -) - -func (so *sockOpt) getMulticastInterface(c *socket.Conn) (*net.Interface, error) { - switch so.typ { - case ssoTypeIPMreqn: - return so.getIPMreqn(c) - default: - return so.getMulticastIf(c) - } -} - -func (so *sockOpt) setMulticastInterface(c *socket.Conn, ifi *net.Interface) error { - switch so.typ { - case ssoTypeIPMreqn: - return so.setIPMreqn(c, ifi, nil) - default: - return so.setMulticastIf(c, ifi) - } -} - -func (so *sockOpt) getICMPFilter(c *socket.Conn) (*ICMPFilter, error) { - b := make([]byte, so.Len) - n, err := so.Get(c, b) - if err != nil { - return nil, err - } - if n != sizeofICMPFilter { - return nil, errOpNoSupport - } - return (*ICMPFilter)(unsafe.Pointer(&b[0])), nil -} - -func (so *sockOpt) setICMPFilter(c *socket.Conn, f *ICMPFilter) error { - b := (*[sizeofICMPFilter]byte)(unsafe.Pointer(f))[:sizeofICMPFilter] - return so.Set(c, b) -} - -func (so *sockOpt) setGroup(c *socket.Conn, ifi *net.Interface, grp net.IP) error { - switch so.typ { - case ssoTypeIPMreq: - return so.setIPMreq(c, ifi, grp) - case ssoTypeIPMreqn: - return so.setIPMreqn(c, ifi, grp) - case ssoTypeGroupReq: - return so.setGroupReq(c, ifi, grp) - default: - return errOpNoSupport - } -} - -func (so *sockOpt) setSourceGroup(c *socket.Conn, ifi *net.Interface, grp, src net.IP) error { - return so.setGroupSourceReq(c, ifi, grp, src) -} - -func (so *sockOpt) setBPF(c *socket.Conn, f []bpf.RawInstruction) error { - return so.setAttachFilter(c, f) -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_stub.go b/vendor/golang.org/x/net/ipv4/sockopt_stub.go deleted file mode 100644 index 23249b7..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_stub.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows - -package ipv4 - -import ( - "net" - - "golang.org/x/net/bpf" - "golang.org/x/net/internal/socket" -) - -func (so *sockOpt) getMulticastInterface(c *socket.Conn) (*net.Interface, error) { - return nil, errOpNoSupport -} - -func (so *sockOpt) setMulticastInterface(c *socket.Conn, ifi *net.Interface) error { - return errOpNoSupport -} - -func (so *sockOpt) getICMPFilter(c *socket.Conn) (*ICMPFilter, error) { - return nil, errOpNoSupport -} - -func (so *sockOpt) setICMPFilter(c *socket.Conn, f *ICMPFilter) error { - return errOpNoSupport -} - -func (so *sockOpt) setGroup(c *socket.Conn, ifi *net.Interface, grp net.IP) error { - return errOpNoSupport -} - -func (so *sockOpt) setSourceGroup(c *socket.Conn, ifi *net.Interface, grp, src net.IP) error { - return errOpNoSupport -} - -func (so *sockOpt) setBPF(c *socket.Conn, f []bpf.RawInstruction) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sys_asmreq.go b/vendor/golang.org/x/net/ipv4/sys_asmreq.go deleted file mode 100644 index 0388cba..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_asmreq.go +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd solaris windows - -package ipv4 - -import ( - "net" - "unsafe" - - "golang.org/x/net/internal/socket" -) - -func (so *sockOpt) setIPMreq(c *socket.Conn, ifi *net.Interface, grp net.IP) error { - mreq := ipMreq{Multiaddr: [4]byte{grp[0], grp[1], grp[2], grp[3]}} - if err := setIPMreqInterface(&mreq, ifi); err != nil { - return err - } - b := (*[sizeofIPMreq]byte)(unsafe.Pointer(&mreq))[:sizeofIPMreq] - return so.Set(c, b) -} - -func (so *sockOpt) getMulticastIf(c *socket.Conn) (*net.Interface, error) { - var b [4]byte - if _, err := so.Get(c, b[:]); err != nil { - return nil, err - } - ifi, err := netIP4ToInterface(net.IPv4(b[0], b[1], b[2], b[3])) - if err != nil { - return nil, err - } - return ifi, nil -} - -func (so *sockOpt) setMulticastIf(c *socket.Conn, ifi *net.Interface) error { - ip, err := netInterfaceToIP4(ifi) - if err != nil { - return err - } - var b [4]byte - copy(b[:], ip) - return so.Set(c, b[:]) -} - -func setIPMreqInterface(mreq *ipMreq, ifi *net.Interface) error { - if ifi == nil { - return nil - } - ifat, err := ifi.Addrs() - if err != nil { - return err - } - for _, ifa := range ifat { - switch ifa := ifa.(type) { - case *net.IPAddr: - if ip := ifa.IP.To4(); ip != nil { - copy(mreq.Interface[:], ip) - return nil - } - case *net.IPNet: - if ip := ifa.IP.To4(); ip != nil { - copy(mreq.Interface[:], ip) - return nil - } - } - } - return errNoSuchInterface -} - -func netIP4ToInterface(ip net.IP) (*net.Interface, error) { - ift, err := net.Interfaces() - if err != nil { - return nil, err - } - for _, ifi := range ift { - ifat, err := ifi.Addrs() - if err != nil { - return nil, err - } - for _, ifa := range ifat { - switch ifa := ifa.(type) { - case *net.IPAddr: - if ip.Equal(ifa.IP) { - return &ifi, nil - } - case *net.IPNet: - if ip.Equal(ifa.IP) { - return &ifi, nil - } - } - } - } - return nil, errNoSuchInterface -} - -func netInterfaceToIP4(ifi *net.Interface) (net.IP, error) { - if ifi == nil { - return net.IPv4zero.To4(), nil - } - ifat, err := ifi.Addrs() - if err != nil { - return nil, err - } - for _, ifa := range ifat { - switch ifa := ifa.(type) { - case *net.IPAddr: - if ip := ifa.IP.To4(); ip != nil { - return ip, nil - } - case *net.IPNet: - if ip := ifa.IP.To4(); ip != nil { - return ip, nil - } - } - } - return nil, errNoSuchInterface -} diff --git a/vendor/golang.org/x/net/ipv4/sys_asmreq_stub.go b/vendor/golang.org/x/net/ipv4/sys_asmreq_stub.go deleted file mode 100644 index f391920..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_asmreq_stub.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!windows - -package ipv4 - -import ( - "net" - - "golang.org/x/net/internal/socket" -) - -func (so *sockOpt) setIPMreq(c *socket.Conn, ifi *net.Interface, grp net.IP) error { - return errOpNoSupport -} - -func (so *sockOpt) getMulticastIf(c *socket.Conn) (*net.Interface, error) { - return nil, errOpNoSupport -} - -func (so *sockOpt) setMulticastIf(c *socket.Conn, ifi *net.Interface) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sys_asmreqn.go b/vendor/golang.org/x/net/ipv4/sys_asmreqn.go deleted file mode 100644 index 1f24f69..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_asmreqn.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin freebsd linux - -package ipv4 - -import ( - "net" - "unsafe" - - "golang.org/x/net/internal/socket" -) - -func (so *sockOpt) getIPMreqn(c *socket.Conn) (*net.Interface, error) { - b := make([]byte, so.Len) - if _, err := so.Get(c, b); err != nil { - return nil, err - } - mreqn := (*ipMreqn)(unsafe.Pointer(&b[0])) - if mreqn.Ifindex == 0 { - return nil, nil - } - ifi, err := net.InterfaceByIndex(int(mreqn.Ifindex)) - if err != nil { - return nil, err - } - return ifi, nil -} - -func (so *sockOpt) setIPMreqn(c *socket.Conn, ifi *net.Interface, grp net.IP) error { - var mreqn ipMreqn - if ifi != nil { - mreqn.Ifindex = int32(ifi.Index) - } - if grp != nil { - mreqn.Multiaddr = [4]byte{grp[0], grp[1], grp[2], grp[3]} - } - b := (*[sizeofIPMreqn]byte)(unsafe.Pointer(&mreqn))[:sizeofIPMreqn] - return so.Set(c, b) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_asmreqn_stub.go b/vendor/golang.org/x/net/ipv4/sys_asmreqn_stub.go deleted file mode 100644 index 0711d3d..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_asmreqn_stub.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!freebsd,!linux - -package ipv4 - -import ( - "net" - - "golang.org/x/net/internal/socket" -) - -func (so *sockOpt) getIPMreqn(c *socket.Conn) (*net.Interface, error) { - return nil, errOpNoSupport -} - -func (so *sockOpt) setIPMreqn(c *socket.Conn, ifi *net.Interface, grp net.IP) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sys_bpf.go b/vendor/golang.org/x/net/ipv4/sys_bpf.go deleted file mode 100644 index 9f30b73..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_bpf.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build linux - -package ipv4 - -import ( - "unsafe" - - "golang.org/x/net/bpf" - "golang.org/x/net/internal/socket" -) - -func (so *sockOpt) setAttachFilter(c *socket.Conn, f []bpf.RawInstruction) error { - prog := sockFProg{ - Len: uint16(len(f)), - Filter: (*sockFilter)(unsafe.Pointer(&f[0])), - } - b := (*[sizeofSockFprog]byte)(unsafe.Pointer(&prog))[:sizeofSockFprog] - return so.Set(c, b) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_bpf_stub.go b/vendor/golang.org/x/net/ipv4/sys_bpf_stub.go deleted file mode 100644 index 9a21320..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_bpf_stub.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !linux - -package ipv4 - -import ( - "golang.org/x/net/bpf" - "golang.org/x/net/internal/socket" -) - -func (so *sockOpt) setAttachFilter(c *socket.Conn, f []bpf.RawInstruction) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sys_bsd.go b/vendor/golang.org/x/net/ipv4/sys_bsd.go deleted file mode 100644 index 58256dd..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_bsd.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build netbsd openbsd - -package ipv4 - -import ( - "net" - "syscall" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/socket" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - } - - sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 1}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 1}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVDSTADDR, Len: 4}}, - ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVIF, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, - } -) diff --git a/vendor/golang.org/x/net/ipv4/sys_darwin.go b/vendor/golang.org/x/net/ipv4/sys_darwin.go deleted file mode 100644 index e8fb191..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_darwin.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "strconv" - "strings" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/socket" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - } - - sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 1}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 4}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVDSTADDR, Len: 4}}, - ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVIF, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoStripHeader: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_STRIPHDR, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, - } -) - -func init() { - // Seems like kern.osreldate is veiled on latest OS X. We use - // kern.osrelease instead. - s, err := syscall.Sysctl("kern.osrelease") - if err != nil { - return - } - ss := strings.Split(s, ".") - if len(ss) == 0 { - return - } - // The IP_PKTINFO and protocol-independent multicast API were - // introduced in OS X 10.7 (Darwin 11). But it looks like - // those features require OS X 10.8 (Darwin 12) or above. - // See http://support.apple.com/kb/HT1633. - if mjver, err := strconv.Atoi(ss[0]); err != nil || mjver < 12 { - return - } - ctlOpts[ctlPacketInfo].name = sysIP_PKTINFO - ctlOpts[ctlPacketInfo].length = sizeofInetPktinfo - ctlOpts[ctlPacketInfo].marshal = marshalPacketInfo - ctlOpts[ctlPacketInfo].parse = parsePacketInfo - sockOpts[ssoPacketInfo] = &sockOpt{Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVPKTINFO, Len: 4}} - sockOpts[ssoMulticastInterface] = &sockOpt{Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: sizeofIPMreqn}, typ: ssoTypeIPMreqn} - sockOpts[ssoJoinGroup] = &sockOpt{Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq} - sockOpts[ssoLeaveGroup] = &sockOpt{Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq} - sockOpts[ssoJoinSourceGroup] = &sockOpt{Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq} - sockOpts[ssoLeaveSourceGroup] = &sockOpt{Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq} - sockOpts[ssoBlockSourceGroup] = &sockOpt{Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq} - sockOpts[ssoUnblockSourceGroup] = &sockOpt{Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq} -} - -func (pi *inetPktinfo) setIfindex(i int) { - pi.Ifindex = uint32(i) -} - -func (gr *groupReq) setGroup(grp net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gr)) + 4)) - sa.Len = sizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) -} - -func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 4)) - sa.Len = sizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) - sa = (*sockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 132)) - sa.Len = sizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_dragonfly.go b/vendor/golang.org/x/net/ipv4/sys_dragonfly.go deleted file mode 100644 index 859764f..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_dragonfly.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/socket" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - } - - sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 1}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 4}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVDSTADDR, Len: 4}}, - ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVIF, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, - } -) diff --git a/vendor/golang.org/x/net/ipv4/sys_freebsd.go b/vendor/golang.org/x/net/ipv4/sys_freebsd.go deleted file mode 100644 index b800324..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_freebsd.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "runtime" - "strings" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/socket" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - } - - sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 1}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 4}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVDSTADDR, Len: 4}}, - ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVIF, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - } -) - -func init() { - freebsdVersion, _ = syscall.SysctlUint32("kern.osreldate") - if freebsdVersion >= 1000000 { - sockOpts[ssoMulticastInterface] = &sockOpt{Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: sizeofIPMreqn}, typ: ssoTypeIPMreqn} - } - if runtime.GOOS == "freebsd" && runtime.GOARCH == "386" { - archs, _ := syscall.Sysctl("kern.supported_archs") - for _, s := range strings.Fields(archs) { - if s == "amd64" { - freebsd32o64 = true - break - } - } - } -} - -func (gr *groupReq) setGroup(grp net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(&gr.Group)) - sa.Len = sizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) -} - -func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(&gsr.Group)) - sa.Len = sizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) - sa = (*sockaddrInet)(unsafe.Pointer(&gsr.Source)) - sa.Len = sizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_linux.go b/vendor/golang.org/x/net/ipv4/sys_linux.go deleted file mode 100644 index 60defe1..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_linux.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/socket" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_TTL, 1, marshalTTL, parseTTL}, - ctlPacketInfo: {sysIP_PKTINFO, sizeofInetPktinfo, marshalPacketInfo, parsePacketInfo}, - } - - sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 4}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: sizeofIPMreqn}, typ: ssoTypeIPMreqn}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 4}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoPacketInfo: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_PKTINFO, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolReserved, Name: sysICMP_FILTER, Len: sizeofICMPFilter}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoAttachFilter: {Option: socket.Option{Level: sysSOL_SOCKET, Name: sysSO_ATTACH_FILTER, Len: sizeofSockFprog}}, - } -) - -func (pi *inetPktinfo) setIfindex(i int) { - pi.Ifindex = int32(i) -} - -func (gr *groupReq) setGroup(grp net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(&gr.Group)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) -} - -func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(&gsr.Group)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) - sa = (*sockaddrInet)(unsafe.Pointer(&gsr.Source)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_solaris.go b/vendor/golang.org/x/net/ipv4/sys_solaris.go deleted file mode 100644 index 832fef1..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_solaris.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/socket" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 4, marshalTTL, parseTTL}, - ctlPacketInfo: {sysIP_PKTINFO, sizeofInetPktinfo, marshalPacketInfo, parsePacketInfo}, - } - - sockOpts = map[int]sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 1}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 1}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoPacketInfo: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVPKTINFO, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - } -) - -func (pi *inetPktinfo) setIfindex(i int) { - pi.Ifindex = uint32(i) -} - -func (gr *groupReq) setGroup(grp net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gr)) + 4)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) -} - -func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 4)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) - sa = (*sockaddrInet)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 260)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_ssmreq.go b/vendor/golang.org/x/net/ipv4/sys_ssmreq.go deleted file mode 100644 index ae5704e..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_ssmreq.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin freebsd linux solaris - -package ipv4 - -import ( - "net" - "unsafe" - - "golang.org/x/net/internal/socket" -) - -var freebsd32o64 bool - -func (so *sockOpt) setGroupReq(c *socket.Conn, ifi *net.Interface, grp net.IP) error { - var gr groupReq - if ifi != nil { - gr.Interface = uint32(ifi.Index) - } - gr.setGroup(grp) - var b []byte - if freebsd32o64 { - var d [sizeofGroupReq + 4]byte - s := (*[sizeofGroupReq]byte)(unsafe.Pointer(&gr)) - copy(d[:4], s[:4]) - copy(d[8:], s[4:]) - b = d[:] - } else { - b = (*[sizeofGroupReq]byte)(unsafe.Pointer(&gr))[:sizeofGroupReq] - } - return so.Set(c, b) -} - -func (so *sockOpt) setGroupSourceReq(c *socket.Conn, ifi *net.Interface, grp, src net.IP) error { - var gsr groupSourceReq - if ifi != nil { - gsr.Interface = uint32(ifi.Index) - } - gsr.setSourceGroup(grp, src) - var b []byte - if freebsd32o64 { - var d [sizeofGroupSourceReq + 4]byte - s := (*[sizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr)) - copy(d[:4], s[:4]) - copy(d[8:], s[4:]) - b = d[:] - } else { - b = (*[sizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr))[:sizeofGroupSourceReq] - } - return so.Set(c, b) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_ssmreq_stub.go b/vendor/golang.org/x/net/ipv4/sys_ssmreq_stub.go deleted file mode 100644 index e6b7623..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_ssmreq_stub.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!freebsd,!linux,!solaris - -package ipv4 - -import ( - "net" - - "golang.org/x/net/internal/socket" -) - -func (so *sockOpt) setGroupReq(c *socket.Conn, ifi *net.Interface, grp net.IP) error { - return errOpNoSupport -} - -func (so *sockOpt) setGroupSourceReq(c *socket.Conn, ifi *net.Interface, grp, src net.IP) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sys_stub.go b/vendor/golang.org/x/net/ipv4/sys_stub.go deleted file mode 100644 index 4f07647..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_stub.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows - -package ipv4 - -var ( - ctlOpts = [ctlMax]ctlOpt{} - - sockOpts = map[int]*sockOpt{} -) diff --git a/vendor/golang.org/x/net/ipv4/sys_windows.go b/vendor/golang.org/x/net/ipv4/sys_windows.go deleted file mode 100644 index b0913d5..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_windows.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/socket" -) - -const ( - // See ws2tcpip.h. - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_DONTFRAGMENT = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0xf - sysIP_DROP_SOURCE_MEMBERSHIP = 0x10 - sysIP_PKTINFO = 0x13 - - sizeofInetPktinfo = 0x8 - sizeofIPMreq = 0x8 - sizeofIPMreqSource = 0xc -) - -type inetPktinfo struct { - Addr [4]byte - Ifindex int32 -} - -type ipMreq struct { - Multiaddr [4]byte - Interface [4]byte -} - -type ipMreqSource struct { - Multiaddr [4]byte - Sourceaddr [4]byte - Interface [4]byte -} - -// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms738586(v=vs.85).aspx -var ( - ctlOpts = [ctlMax]ctlOpt{} - - sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 4}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, - } -) - -func (pi *inetPktinfo) setIfindex(i int) { - pi.Ifindex = int32(i) -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_darwin.go b/vendor/golang.org/x/net/ipv4/zsys_darwin.go deleted file mode 100644 index c07cc88..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_darwin.go +++ /dev/null @@ -1,99 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_darwin.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_STRIPHDR = 0x17 - sysIP_RECVTTL = 0x18 - sysIP_BOUND_IF = 0x19 - sysIP_PKTINFO = 0x1a - sysIP_RECVPKTINFO = 0x1a - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_MULTICAST_IFINDEX = 0x42 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 -) - -type sockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type inetPktinfo struct { - Ifindex uint32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [128]byte -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [128]byte - Pad_cgo_1 [128]byte -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go b/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go deleted file mode 100644 index c4365e9..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go +++ /dev/null @@ -1,31 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_dragonfly.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_RECVTTL = 0x41 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - - sizeofIPMreq = 0x8 -) - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go b/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go deleted file mode 100644 index 8c4aec9..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go +++ /dev/null @@ -1,93 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 - sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 -) - -type sockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type groupReq struct { - Interface uint32 - Group sockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group sockaddrStorage - Source sockaddrStorage -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go b/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go deleted file mode 100644 index 4b10b7c..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go +++ /dev/null @@ -1,95 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 - sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 -) - -type sockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sockaddrStorage - Source sockaddrStorage -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go b/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go deleted file mode 100644 index 4b10b7c..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go +++ /dev/null @@ -1,95 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 - sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sizeofSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 -) - -type sockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sockaddrStorage - Source sockaddrStorage -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_386.go b/vendor/golang.org/x/net/ipv4/zsys_linux_386.go deleted file mode 100644 index c0260f0..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_386.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPFilter = 0x4 - - sizeofSockFprog = 0x8 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go b/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go deleted file mode 100644 index 9c967ea..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 - - sizeofSockFprog = 0x10 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go b/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go deleted file mode 100644 index c0260f0..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPFilter = 0x4 - - sizeofSockFprog = 0x8 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go b/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go deleted file mode 100644 index 9c967ea..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 - - sizeofSockFprog = 0x10 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go b/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go deleted file mode 100644 index c0260f0..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPFilter = 0x4 - - sizeofSockFprog = 0x8 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go b/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go deleted file mode 100644 index 9c967ea..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 - - sizeofSockFprog = 0x10 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go b/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go deleted file mode 100644 index 9c967ea..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 - - sizeofSockFprog = 0x10 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go b/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go deleted file mode 100644 index c0260f0..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPFilter = 0x4 - - sizeofSockFprog = 0x8 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go b/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go deleted file mode 100644 index f65bd9a..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x84 - sizeofGroupSourceReq = 0x104 - - sizeofICMPFilter = 0x4 - - sizeofSockFprog = 0x8 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]uint8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go b/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go deleted file mode 100644 index 9c967ea..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 - - sizeofSockFprog = 0x10 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go b/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go deleted file mode 100644 index 9c967ea..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 - - sizeofSockFprog = 0x10 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go b/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go deleted file mode 100644 index 9c967ea..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sizeofKernelSockaddrStorage = 0x80 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - sizeofSockExtendedErr = 0x10 - - sizeofIPMreq = 0x8 - sizeofIPMreqn = 0xc - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x88 - sizeofGroupSourceReq = 0x108 - - sizeofICMPFilter = 0x4 - - sizeofSockFprog = 0x10 -) - -type kernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type inetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type ipMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group kernelSockaddrStorage - Source kernelSockaddrStorage -} - -type icmpFilter struct { - Data uint32 -} - -type sockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sockFilter -} - -type sockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_netbsd.go b/vendor/golang.org/x/net/ipv4/zsys_netbsd.go deleted file mode 100644 index fd3624d..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_netbsd.go +++ /dev/null @@ -1,30 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_netbsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_RECVTTL = 0x17 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - - sizeofIPMreq = 0x8 -) - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_openbsd.go b/vendor/golang.org/x/net/ipv4/zsys_openbsd.go deleted file mode 100644 index 12f36be..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_openbsd.go +++ /dev/null @@ -1,30 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_openbsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x1e - sysIP_RECVTTL = 0x1f - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - - sizeofIPMreq = 0x8 -) - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_solaris.go b/vendor/golang.org/x/net/ipv4/zsys_solaris.go deleted file mode 100644 index 0a3875c..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_solaris.go +++ /dev/null @@ -1,100 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_solaris.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x9 - sysIP_RECVSLLA = 0xa - sysIP_RECVTTL = 0xb - - sysIP_MULTICAST_IF = 0x10 - sysIP_MULTICAST_TTL = 0x11 - sysIP_MULTICAST_LOOP = 0x12 - sysIP_ADD_MEMBERSHIP = 0x13 - sysIP_DROP_MEMBERSHIP = 0x14 - sysIP_BLOCK_SOURCE = 0x15 - sysIP_UNBLOCK_SOURCE = 0x16 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x17 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x18 - sysIP_NEXTHOP = 0x19 - - sysIP_PKTINFO = 0x1a - sysIP_RECVPKTINFO = 0x1a - sysIP_DONTFRAG = 0x1b - - sysIP_BOUND_IF = 0x41 - sysIP_UNSPEC_SRC = 0x42 - sysIP_BROADCAST_TTL = 0x43 - sysIP_DHCPINIT_IF = 0x45 - - sysIP_REUSEADDR = 0x104 - sysIP_DONTROUTE = 0x105 - sysIP_BROADCAST = 0x106 - - sysMCAST_JOIN_GROUP = 0x29 - sysMCAST_LEAVE_GROUP = 0x2a - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_JOIN_SOURCE_GROUP = 0x2d - sysMCAST_LEAVE_SOURCE_GROUP = 0x2e - - sizeofSockaddrStorage = 0x100 - sizeofSockaddrInet = 0x10 - sizeofInetPktinfo = 0xc - - sizeofIPMreq = 0x8 - sizeofIPMreqSource = 0xc - sizeofGroupReq = 0x104 - sizeofGroupSourceReq = 0x204 -) - -type sockaddrStorage struct { - Family uint16 - X_ss_pad1 [6]int8 - X_ss_align float64 - X_ss_pad2 [240]int8 -} - -type sockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type inetPktinfo struct { - Ifindex uint32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type ipMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type ipMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type groupReq struct { - Interface uint32 - Pad_cgo_0 [256]byte -} - -type groupSourceReq struct { - Interface uint32 - Pad_cgo_0 [256]byte - Pad_cgo_1 [256]byte -} diff --git a/vendor/modules.txt b/vendor/modules.txt deleted file mode 100644 index 108a26f..0000000 --- a/vendor/modules.txt +++ /dev/null @@ -1,32 +0,0 @@ -# github.com/google/uuid v1.0.0 -github.com/google/uuid -# github.com/pions/dtls v1.0.2 -github.com/pions/dtls/pkg/dtls -github.com/pions/dtls/pkg/dtls/internal/udp -# github.com/pions/pkg v0.0.0-20181115215726-b60cd756f712 -github.com/pions/pkg/stun -# github.com/pions/webrtc v1.2.0 -github.com/pions/webrtc -github.com/pions/webrtc/pkg/datachannel -github.com/pions/webrtc/pkg/ice -github.com/pions/webrtc/internal/datachannel -github.com/pions/webrtc/internal/network -github.com/pions/webrtc/internal/sdp -github.com/pions/webrtc/pkg/media -github.com/pions/webrtc/pkg/rtcerr -github.com/pions/webrtc/pkg/rtcp -github.com/pions/webrtc/pkg/rtp -github.com/pions/webrtc/pkg/rtp/codecs -github.com/pions/webrtc/internal/util -github.com/pions/webrtc/internal/sctp -github.com/pions/webrtc/internal/mux -github.com/pions/webrtc/internal/srtp -# github.com/pkg/errors v0.8.0 -github.com/pkg/errors -# golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 -golang.org/x/crypto/curve25519 -# golang.org/x/net v0.0.0-20181220203305-927f97764cc3 -golang.org/x/net/ipv4 -golang.org/x/net/bpf -golang.org/x/net/internal/iana -golang.org/x/net/internal/socket