From f65aee0759633966e0e1052d0c18079da551d24e Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Wed, 6 Sep 2017 14:57:25 -0700 Subject: [PATCH 1/5] *: replace 'golang.org/x/net/context' with 'context' Signed-off-by: Gyu-Ho Lee --- auth/jwt.go | 2 +- auth/simple_token.go | 3 +-- auth/store.go | 3 ++- auth/store_test.go | 2 +- client/README.md | 2 +- client/auth_role.go | 3 +-- client/auth_user.go | 3 +-- client/client.go | 3 +-- client/client_test.go | 2 +- client/doc.go | 2 +- client/example_keys_test.go | 2 +- client/integration/client_test.go | 3 +-- client/keys.go | 2 +- client/keys_test.go | 3 +-- client/members.go | 3 +-- client/members_test.go | 3 +-- clientv3/auth.go | 3 ++- clientv3/balancer.go | 2 +- clientv3/balancer_test.go | 2 +- clientv3/client.go | 2 +- clientv3/client_test.go | 2 +- clientv3/cluster.go | 3 ++- clientv3/concurrency/election.go | 2 +- clientv3/concurrency/key.go | 2 +- clientv3/concurrency/mutex.go | 2 +- clientv3/concurrency/session.go | 2 +- clientv3/concurrency/stm.go | 2 +- clientv3/config.go | 2 +- clientv3/example_auth_test.go | 2 +- clientv3/example_cluster_test.go | 2 +- clientv3/example_kv_test.go | 2 +- clientv3/example_lease_test.go | 2 +- clientv3/example_maintenence_test.go | 3 +-- clientv3/example_metrics_test.go | 2 +- clientv3/example_test.go | 2 +- clientv3/example_watch_test.go | 2 +- clientv3/integration/cluster_test.go | 2 +- clientv3/integration/dial_test.go | 3 +-- clientv3/integration/kv_test.go | 3 ++- clientv3/integration/lease_test.go | 3 ++- clientv3/integration/metrics_test.go | 2 +- clientv3/integration/mirror_test.go | 2 +- clientv3/integration/role_test.go | 2 +- clientv3/integration/txn_test.go | 2 +- clientv3/integration/user_test.go | 2 +- clientv3/integration/watch_test.go | 3 ++- clientv3/kv.go | 4 +++- clientv3/lease.go | 3 ++- clientv3/leasing/cache.go | 2 +- clientv3/leasing/kv.go | 2 +- clientv3/maintenance.go | 2 +- clientv3/mirror/syncer.go | 3 ++- clientv3/namespace/kv.go | 2 +- clientv3/namespace/lease.go | 3 +-- clientv3/namespace/watch.go | 3 +-- clientv3/naming/grpc.go | 2 +- clientv3/naming/grpc_test.go | 6 +++--- clientv3/ordering/kv.go | 2 +- clientv3/ordering/kv_test.go | 2 +- clientv3/retry.go | 4 +++- clientv3/txn.go | 3 ++- clientv3/watch.go | 3 ++- compactor/compactor.go | 6 +++--- compactor/compactor_test.go | 2 +- compactor/periodic.go | 6 +++--- compactor/revision.go | 6 +++--- contrib/raftexample/raft.go | 7 +++---- contrib/recipes/barrier.go | 3 ++- contrib/recipes/client.go | 2 +- contrib/recipes/double_barrier.go | 3 ++- contrib/recipes/key.go | 2 +- contrib/recipes/priority_queue.go | 2 +- contrib/recipes/queue.go | 3 ++- contrib/recipes/rwmutex.go | 3 ++- contrib/recipes/watch.go | 3 ++- discovery/discovery.go | 3 ++- discovery/discovery_test.go | 6 +++--- e2e/ctl_v3_alarm_test.go | 2 +- e2e/ctl_v3_migrate_test.go | 3 +-- embed/serve.go | 2 +- etcdctl/ctlv2/command/cluster_health.go | 3 ++- etcdctl/ctlv2/command/exec_watch_command.go | 3 ++- etcdctl/ctlv2/command/util.go | 5 +++-- etcdctl/ctlv2/command/watch_command.go | 3 ++- etcdctl/ctlv3/command/elect_command.go | 3 ++- etcdctl/ctlv3/command/lease_command.go | 3 ++- etcdctl/ctlv3/command/lock_command.go | 3 ++- etcdctl/ctlv3/command/make_mirror_command.go | 3 ++- etcdctl/ctlv3/command/role_command.go | 2 +- etcdctl/ctlv3/command/snapshot_command.go | 5 +++-- etcdctl/ctlv3/command/txn_command.go | 3 ++- etcdctl/ctlv3/command/user_command.go | 2 +- etcdctl/ctlv3/command/util.go | 3 ++- etcdctl/ctlv3/command/watch_command.go | 3 ++- etcdserver/api/v2http/client.go | 3 ++- etcdserver/api/v2http/client_test.go | 3 ++- etcdserver/api/v2http/http_test.go | 3 ++- etcdserver/api/v2v3/server.go | 2 +- etcdserver/api/v3client/v3client.go | 3 +-- etcdserver/api/v3election/election.go | 2 +- etcdserver/api/v3lock/lock.go | 2 +- etcdserver/api/v3rpc/auth.go | 3 ++- etcdserver/api/v3rpc/interceptor.go | 2 +- etcdserver/api/v3rpc/key.go | 4 +++- etcdserver/api/v3rpc/lease.go | 2 +- etcdserver/api/v3rpc/maintenance.go | 2 +- etcdserver/api/v3rpc/member.go | 2 +- etcdserver/api/v3rpc/quota.go | 3 ++- etcdserver/api/v3rpc/watch.go | 3 +-- etcdserver/apply.go | 3 ++- etcdserver/auth/auth.go | 3 ++- etcdserver/auth/auth_requests.go | 2 +- etcdserver/auth/auth_test.go | 2 +- etcdserver/config.go | 3 +-- etcdserver/corrupt.go | 3 +-- etcdserver/membership/cluster.go | 4 ++-- etcdserver/server.go | 3 ++- etcdserver/server_test.go | 2 +- etcdserver/v2_server.go | 2 +- etcdserver/v3_server.go | 5 ++--- integration/cluster.go | 8 ++++---- integration/cluster_test.go | 4 ++-- integration/member_test.go | 2 +- integration/v3_alarm_test.go | 2 +- integration/v3_auth_test.go | 3 +-- integration/v3_election_test.go | 2 +- integration/v3_grpc_inflight_test.go | 2 +- integration/v3_grpc_test.go | 2 +- integration/v3_lease_test.go | 8 ++++---- integration/v3_lock_test.go | 2 +- integration/v3_watch_test.go | 2 +- integration/v3election_grpc_test.go | 2 +- integration/v3lock_grpc_test.go | 2 +- lease/leasehttp/http_test.go | 3 +-- mvcc/kvstore.go | 2 +- pkg/schedule/schedule.go | 3 +-- pkg/schedule/schedule_test.go | 3 +-- proxy/grpcproxy/adapter/auth_client_adapter.go | 4 +++- proxy/grpcproxy/adapter/chan_stream.go | 2 +- proxy/grpcproxy/adapter/cluster_client_adapter.go | 3 ++- proxy/grpcproxy/adapter/election_client_adapter.go | 3 ++- proxy/grpcproxy/adapter/kv_client_adapter.go | 4 +++- proxy/grpcproxy/adapter/lease_client_adapter.go | 3 ++- proxy/grpcproxy/adapter/lock_client_adapter.go | 3 ++- proxy/grpcproxy/adapter/maintenance_client_adapter.go | 3 ++- proxy/grpcproxy/adapter/watch_client_adapter.go | 2 +- proxy/grpcproxy/auth.go | 2 +- proxy/grpcproxy/cluster.go | 2 +- proxy/grpcproxy/cluster_test.go | 2 +- proxy/grpcproxy/election.go | 2 +- proxy/grpcproxy/health.go | 3 +-- proxy/grpcproxy/kv.go | 4 ++-- proxy/grpcproxy/kv_test.go | 2 +- proxy/grpcproxy/leader.go | 6 +++--- proxy/grpcproxy/lease.go | 9 ++++----- proxy/grpcproxy/lock.go | 2 +- proxy/grpcproxy/maintenance.go | 3 +-- proxy/grpcproxy/watch.go | 8 ++++---- proxy/grpcproxy/watch_broadcast.go | 3 +-- raft/node.go | 2 +- raft/node_bench_test.go | 3 +-- raft/node_test.go | 2 +- raft/rafttest/node.go | 2 +- raft/rafttest/node_bench_test.go | 2 +- raft/rafttest/node_test.go | 2 +- rafthttp/functional_test.go | 2 +- rafthttp/http.go | 2 +- rafthttp/peer.go | 3 ++- rafthttp/transport.go | 3 ++- rafthttp/transport_bench_test.go | 2 +- tools/functional-tester/etcd-tester/checks.go | 6 +++--- tools/functional-tester/etcd-tester/cluster.go | 4 ++-- tools/functional-tester/etcd-tester/key_stresser.go | 10 +++++----- tools/functional-tester/etcd-tester/lease_stresser.go | 4 ++-- tools/functional-tester/etcd-tester/member.go | 6 +++--- 175 files changed, 270 insertions(+), 245 deletions(-) diff --git a/auth/jwt.go b/auth/jwt.go index 12ccc62c699..99b2d6b5c71 100644 --- a/auth/jwt.go +++ b/auth/jwt.go @@ -15,11 +15,11 @@ package auth import ( + "context" "crypto/rsa" "io/ioutil" jwt "github.com/dgrijalva/jwt-go" - "golang.org/x/net/context" ) type tokenJWT struct { diff --git a/auth/simple_token.go b/auth/simple_token.go index e39678d6cf3..aa30b045bd0 100644 --- a/auth/simple_token.go +++ b/auth/simple_token.go @@ -18,6 +18,7 @@ package auth // JWT based mechanism will be added in the near future. import ( + "context" "crypto/rand" "fmt" "math/big" @@ -25,8 +26,6 @@ import ( "strings" "sync" "time" - - "golang.org/x/net/context" ) const ( diff --git a/auth/store.go b/auth/store.go index fa1d5b8e76b..0b549abc5a1 100644 --- a/auth/store.go +++ b/auth/store.go @@ -16,6 +16,7 @@ package auth import ( "bytes" + "context" "encoding/binary" "errors" "sort" @@ -26,9 +27,9 @@ import ( "github.com/coreos/etcd/auth/authpb" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/mvcc/backend" + "github.com/coreos/pkg/capnslog" "golang.org/x/crypto/bcrypt" - "golang.org/x/net/context" "google.golang.org/grpc/credentials" "google.golang.org/grpc/metadata" "google.golang.org/grpc/peer" diff --git a/auth/store_test.go b/auth/store_test.go index f2a25aac6bf..951bd7b4502 100644 --- a/auth/store_test.go +++ b/auth/store_test.go @@ -15,6 +15,7 @@ package auth import ( + "context" "fmt" "os" "reflect" @@ -27,7 +28,6 @@ import ( "github.com/coreos/etcd/mvcc/backend" "golang.org/x/crypto/bcrypt" - "golang.org/x/net/context" "google.golang.org/grpc/metadata" ) diff --git a/client/README.md b/client/README.md index c0ec8190163..2be731ede0b 100644 --- a/client/README.md +++ b/client/README.md @@ -25,8 +25,8 @@ package main import ( "log" "time" + "context" - "golang.org/x/net/context" "github.com/coreos/etcd/client" ) diff --git a/client/auth_role.go b/client/auth_role.go index d15e00dd716..b6ba7e150dc 100644 --- a/client/auth_role.go +++ b/client/auth_role.go @@ -16,11 +16,10 @@ package client import ( "bytes" + "context" "encoding/json" "net/http" "net/url" - - "golang.org/x/net/context" ) type Role struct { diff --git a/client/auth_user.go b/client/auth_user.go index 97c3f31813b..8e7e2efe833 100644 --- a/client/auth_user.go +++ b/client/auth_user.go @@ -16,12 +16,11 @@ package client import ( "bytes" + "context" "encoding/json" "net/http" "net/url" "path" - - "golang.org/x/net/context" ) var ( diff --git a/client/client.go b/client/client.go index 498dfbcc8fc..03054150ccd 100644 --- a/client/client.go +++ b/client/client.go @@ -15,6 +15,7 @@ package client import ( + "context" "encoding/json" "errors" "fmt" @@ -29,8 +30,6 @@ import ( "time" "github.com/coreos/etcd/version" - - "golang.org/x/net/context" ) var ( diff --git a/client/client_test.go b/client/client_test.go index 4ab54d88359..0a355c5e445 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -15,6 +15,7 @@ package client import ( + "context" "errors" "io" "io/ioutil" @@ -29,7 +30,6 @@ import ( "github.com/coreos/etcd/pkg/testutil" "github.com/coreos/etcd/version" - "golang.org/x/net/context" ) type actionAssertingHTTPClient struct { diff --git a/client/doc.go b/client/doc.go index dd336d18878..ad4eca4e163 100644 --- a/client/doc.go +++ b/client/doc.go @@ -19,9 +19,9 @@ Create a Config and exchange it for a Client: import ( "net/http" + "context" "github.com/coreos/etcd/client" - "golang.org/x/net/context" ) cfg := client.Config{ diff --git a/client/example_keys_test.go b/client/example_keys_test.go index 105a74791bc..66063571dd4 100644 --- a/client/example_keys_test.go +++ b/client/example_keys_test.go @@ -15,12 +15,12 @@ package client_test import ( + "context" "fmt" "log" "sort" "github.com/coreos/etcd/client" - "golang.org/x/net/context" ) func ExampleKeysAPI_directory() { diff --git a/client/integration/client_test.go b/client/integration/client_test.go index 490990b6583..5d4d0a05e30 100644 --- a/client/integration/client_test.go +++ b/client/integration/client_test.go @@ -15,6 +15,7 @@ package integration import ( + "context" "fmt" "net/http" "net/http/httptest" @@ -23,8 +24,6 @@ import ( "sync/atomic" "testing" - "golang.org/x/net/context" - "github.com/coreos/etcd/client" "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" diff --git a/client/keys.go b/client/keys.go index 4a6c41a78bc..e8373b94507 100644 --- a/client/keys.go +++ b/client/keys.go @@ -17,6 +17,7 @@ package client //go:generate codecgen -d 1819 -r "Node|Response|Nodes" -o keys.generated.go keys.go import ( + "context" "encoding/json" "errors" "fmt" @@ -28,7 +29,6 @@ import ( "github.com/coreos/etcd/pkg/pathutil" "github.com/ugorji/go/codec" - "golang.org/x/net/context" ) const ( diff --git a/client/keys_test.go b/client/keys_test.go index 253fa9b8f09..0e190cf5981 100644 --- a/client/keys_test.go +++ b/client/keys_test.go @@ -15,6 +15,7 @@ package client import ( + "context" "errors" "fmt" "io/ioutil" @@ -23,8 +24,6 @@ import ( "reflect" "testing" "time" - - "golang.org/x/net/context" ) func TestV2KeysURLHelper(t *testing.T) { diff --git a/client/members.go b/client/members.go index 20548956063..aafa3d1b870 100644 --- a/client/members.go +++ b/client/members.go @@ -16,14 +16,13 @@ package client import ( "bytes" + "context" "encoding/json" "fmt" "net/http" "net/url" "path" - "golang.org/x/net/context" - "github.com/coreos/etcd/pkg/types" ) diff --git a/client/members_test.go b/client/members_test.go index f199db2cb70..706b6aeb8cd 100644 --- a/client/members_test.go +++ b/client/members_test.go @@ -15,6 +15,7 @@ package client import ( + "context" "encoding/json" "errors" "net/http" @@ -22,8 +23,6 @@ import ( "reflect" "testing" - "golang.org/x/net/context" - "github.com/coreos/etcd/pkg/types" ) diff --git a/clientv3/auth.go b/clientv3/auth.go index 18f1f5b0919..a6ab4684140 100644 --- a/clientv3/auth.go +++ b/clientv3/auth.go @@ -15,12 +15,13 @@ package clientv3 import ( + "context" "fmt" "strings" "github.com/coreos/etcd/auth/authpb" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" + "google.golang.org/grpc" ) diff --git a/clientv3/balancer.go b/clientv3/balancer.go index e27958cf3c7..83b4d1aaa20 100644 --- a/clientv3/balancer.go +++ b/clientv3/balancer.go @@ -15,11 +15,11 @@ package clientv3 import ( + "context" "net/url" "strings" "sync" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" ) diff --git a/clientv3/balancer_test.go b/clientv3/balancer_test.go index 5245b69a2aa..cffa5d4178f 100644 --- a/clientv3/balancer_test.go +++ b/clientv3/balancer_test.go @@ -15,6 +15,7 @@ package clientv3 import ( + "context" "errors" "net" "sync" @@ -24,7 +25,6 @@ import ( pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/clientv3/client.go b/clientv3/client.go index fb2e0ce9a35..2f56d511ea8 100644 --- a/clientv3/client.go +++ b/clientv3/client.go @@ -15,6 +15,7 @@ package clientv3 import ( + "context" "crypto/tls" "errors" "fmt" @@ -27,7 +28,6 @@ import ( "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" diff --git a/clientv3/client_test.go b/clientv3/client_test.go index 400fc627a28..d09e6433017 100644 --- a/clientv3/client_test.go +++ b/clientv3/client_test.go @@ -15,6 +15,7 @@ package clientv3 import ( + "context" "fmt" "net" "testing" @@ -22,7 +23,6 @@ import ( "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) func TestDialCancel(t *testing.T) { diff --git a/clientv3/cluster.go b/clientv3/cluster.go index 922d900e3c3..bbecaaca74e 100644 --- a/clientv3/cluster.go +++ b/clientv3/cluster.go @@ -15,8 +15,9 @@ package clientv3 import ( + "context" + pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/clientv3/concurrency/election.go b/clientv3/concurrency/election.go index 05628db0758..1a6bbfc90fb 100644 --- a/clientv3/concurrency/election.go +++ b/clientv3/concurrency/election.go @@ -15,13 +15,13 @@ package concurrency import ( + "context" "errors" "fmt" v3 "github.com/coreos/etcd/clientv3" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/mvcc/mvccpb" - "golang.org/x/net/context" ) var ( diff --git a/clientv3/concurrency/key.go b/clientv3/concurrency/key.go index cf006d70e67..4b6e399bd4e 100644 --- a/clientv3/concurrency/key.go +++ b/clientv3/concurrency/key.go @@ -15,12 +15,12 @@ package concurrency import ( + "context" "fmt" v3 "github.com/coreos/etcd/clientv3" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/mvcc/mvccpb" - "golang.org/x/net/context" ) func waitDelete(ctx context.Context, client *v3.Client, key string, rev int64) error { diff --git a/clientv3/concurrency/mutex.go b/clientv3/concurrency/mutex.go index 83df27c799b..dac9ba5a2a3 100644 --- a/clientv3/concurrency/mutex.go +++ b/clientv3/concurrency/mutex.go @@ -15,12 +15,12 @@ package concurrency import ( + "context" "fmt" "sync" v3 "github.com/coreos/etcd/clientv3" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" ) // Mutex implements the sync Locker interface with etcd diff --git a/clientv3/concurrency/session.go b/clientv3/concurrency/session.go index 0cb5ea7cf1e..7e2ff89b4e4 100644 --- a/clientv3/concurrency/session.go +++ b/clientv3/concurrency/session.go @@ -15,10 +15,10 @@ package concurrency import ( + "context" "time" v3 "github.com/coreos/etcd/clientv3" - "golang.org/x/net/context" ) const defaultSessionTTL = 60 diff --git a/clientv3/concurrency/stm.go b/clientv3/concurrency/stm.go index 9b6576f6839..d11023ebe36 100644 --- a/clientv3/concurrency/stm.go +++ b/clientv3/concurrency/stm.go @@ -15,10 +15,10 @@ package concurrency import ( + "context" "math" v3 "github.com/coreos/etcd/clientv3" - "golang.org/x/net/context" ) // STM is an interface for software transactional memory. diff --git a/clientv3/config.go b/clientv3/config.go index ccf7445c7ba..87d61cf577d 100644 --- a/clientv3/config.go +++ b/clientv3/config.go @@ -15,10 +15,10 @@ package clientv3 import ( + "context" "crypto/tls" "time" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/clientv3/example_auth_test.go b/clientv3/example_auth_test.go index f07e5095c0c..8200df99836 100644 --- a/clientv3/example_auth_test.go +++ b/clientv3/example_auth_test.go @@ -15,11 +15,11 @@ package clientv3_test import ( + "context" "fmt" "log" "github.com/coreos/etcd/clientv3" - "golang.org/x/net/context" ) func ExampleAuth() { diff --git a/clientv3/example_cluster_test.go b/clientv3/example_cluster_test.go index e9e516ba997..5aa03fd65ee 100644 --- a/clientv3/example_cluster_test.go +++ b/clientv3/example_cluster_test.go @@ -15,11 +15,11 @@ package clientv3_test import ( + "context" "fmt" "log" "github.com/coreos/etcd/clientv3" - "golang.org/x/net/context" ) func ExampleCluster_memberList() { diff --git a/clientv3/example_kv_test.go b/clientv3/example_kv_test.go index bd153797ae3..e2476e3e781 100644 --- a/clientv3/example_kv_test.go +++ b/clientv3/example_kv_test.go @@ -15,12 +15,12 @@ package clientv3_test import ( + "context" "fmt" "log" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" - "golang.org/x/net/context" ) func ExampleKV_put() { diff --git a/clientv3/example_lease_test.go b/clientv3/example_lease_test.go index e1bd57a15d7..98db148b96e 100644 --- a/clientv3/example_lease_test.go +++ b/clientv3/example_lease_test.go @@ -15,11 +15,11 @@ package clientv3_test import ( + "context" "fmt" "log" "github.com/coreos/etcd/clientv3" - "golang.org/x/net/context" ) func ExampleLease_grant() { diff --git a/clientv3/example_maintenence_test.go b/clientv3/example_maintenence_test.go index 6e128276f1c..a66a23abc61 100644 --- a/clientv3/example_maintenence_test.go +++ b/clientv3/example_maintenence_test.go @@ -15,11 +15,10 @@ package clientv3_test import ( + "context" "fmt" "log" - "golang.org/x/net/context" - "github.com/coreos/etcd/clientv3" ) diff --git a/clientv3/example_metrics_test.go b/clientv3/example_metrics_test.go index a7453083dc0..8406bfefd96 100644 --- a/clientv3/example_metrics_test.go +++ b/clientv3/example_metrics_test.go @@ -15,6 +15,7 @@ package clientv3_test import ( + "context" "fmt" "io/ioutil" "log" @@ -26,7 +27,6 @@ import ( grpcprom "github.com/grpc-ecosystem/go-grpc-prometheus" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/clientv3/example_test.go b/clientv3/example_test.go index 4e9b5042d99..e9987b33914 100644 --- a/clientv3/example_test.go +++ b/clientv3/example_test.go @@ -15,13 +15,13 @@ package clientv3_test import ( + "context" "log" "time" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/pkg/transport" "github.com/coreos/pkg/capnslog" - "golang.org/x/net/context" ) var ( diff --git a/clientv3/example_watch_test.go b/clientv3/example_watch_test.go index b3a0f1dd2df..08c199b38e3 100644 --- a/clientv3/example_watch_test.go +++ b/clientv3/example_watch_test.go @@ -15,11 +15,11 @@ package clientv3_test import ( + "context" "fmt" "log" "github.com/coreos/etcd/clientv3" - "golang.org/x/net/context" ) func ExampleWatcher_watch() { diff --git a/clientv3/integration/cluster_test.go b/clientv3/integration/cluster_test.go index 6397f8a8a26..6abe0c51362 100644 --- a/clientv3/integration/cluster_test.go +++ b/clientv3/integration/cluster_test.go @@ -15,13 +15,13 @@ package integration import ( + "context" "reflect" "testing" "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" "github.com/coreos/etcd/pkg/types" - "golang.org/x/net/context" ) func TestMemberList(t *testing.T) { diff --git a/clientv3/integration/dial_test.go b/clientv3/integration/dial_test.go index abe5ebe61f6..ec69900b635 100644 --- a/clientv3/integration/dial_test.go +++ b/clientv3/integration/dial_test.go @@ -15,6 +15,7 @@ package integration import ( + "context" "math/rand" "strings" "testing" @@ -25,8 +26,6 @@ import ( "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" "github.com/coreos/etcd/pkg/transport" - - "golang.org/x/net/context" ) var ( diff --git a/clientv3/integration/kv_test.go b/clientv3/integration/kv_test.go index 90dde1aa362..f5feb0aaea0 100644 --- a/clientv3/integration/kv_test.go +++ b/clientv3/integration/kv_test.go @@ -16,6 +16,7 @@ package integration import ( "bytes" + "context" "math/rand" "os" "reflect" @@ -28,7 +29,7 @@ import ( "github.com/coreos/etcd/integration" "github.com/coreos/etcd/mvcc/mvccpb" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" + "google.golang.org/grpc" ) diff --git a/clientv3/integration/lease_test.go b/clientv3/integration/lease_test.go index 3207852051b..360806ef8bc 100644 --- a/clientv3/integration/lease_test.go +++ b/clientv3/integration/lease_test.go @@ -15,6 +15,7 @@ package integration import ( + "context" "reflect" "sort" "sync" @@ -26,7 +27,7 @@ import ( "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" + "google.golang.org/grpc" ) diff --git a/clientv3/integration/metrics_test.go b/clientv3/integration/metrics_test.go index 6311fe0d77f..54ca206da73 100644 --- a/clientv3/integration/metrics_test.go +++ b/clientv3/integration/metrics_test.go @@ -16,6 +16,7 @@ package integration import ( "bufio" + "context" "io" "net" "net/http" @@ -31,7 +32,6 @@ import ( grpcprom "github.com/grpc-ecosystem/go-grpc-prometheus" "github.com/prometheus/client_golang/prometheus" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/clientv3/integration/mirror_test.go b/clientv3/integration/mirror_test.go index df9911efb7e..01bfef10a2c 100644 --- a/clientv3/integration/mirror_test.go +++ b/clientv3/integration/mirror_test.go @@ -15,6 +15,7 @@ package integration import ( + "context" "fmt" "reflect" "sync" @@ -25,7 +26,6 @@ import ( "github.com/coreos/etcd/integration" "github.com/coreos/etcd/mvcc/mvccpb" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) func TestMirrorSync(t *testing.T) { diff --git a/clientv3/integration/role_test.go b/clientv3/integration/role_test.go index 7814db5ebd6..5b4fad43c73 100644 --- a/clientv3/integration/role_test.go +++ b/clientv3/integration/role_test.go @@ -15,12 +15,12 @@ package integration import ( + "context" "testing" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) func TestRoleError(t *testing.T) { diff --git a/clientv3/integration/txn_test.go b/clientv3/integration/txn_test.go index e895b5b625d..313f0033b9c 100644 --- a/clientv3/integration/txn_test.go +++ b/clientv3/integration/txn_test.go @@ -15,6 +15,7 @@ package integration import ( + "context" "fmt" "testing" "time" @@ -24,7 +25,6 @@ import ( "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) func TestTxnError(t *testing.T) { diff --git a/clientv3/integration/user_test.go b/clientv3/integration/user_test.go index 5d8f7263b47..11548123ddb 100644 --- a/clientv3/integration/user_test.go +++ b/clientv3/integration/user_test.go @@ -15,13 +15,13 @@ package integration import ( + "context" "testing" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) func TestUserError(t *testing.T) { diff --git a/clientv3/integration/watch_test.go b/clientv3/integration/watch_test.go index 0de3faef3b9..30d166efff9 100644 --- a/clientv3/integration/watch_test.go +++ b/clientv3/integration/watch_test.go @@ -15,6 +15,7 @@ package integration import ( + "context" "fmt" "math/rand" "reflect" @@ -28,7 +29,7 @@ import ( "github.com/coreos/etcd/integration" mvccpb "github.com/coreos/etcd/mvcc/mvccpb" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" + "google.golang.org/grpc" "google.golang.org/grpc/metadata" ) diff --git a/clientv3/kv.go b/clientv3/kv.go index b0557aa29de..ead08a0827f 100644 --- a/clientv3/kv.go +++ b/clientv3/kv.go @@ -15,8 +15,10 @@ package clientv3 import ( + "context" + pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" + "google.golang.org/grpc" ) diff --git a/clientv3/lease.go b/clientv3/lease.go index 3e687794291..e476db5be2e 100644 --- a/clientv3/lease.go +++ b/clientv3/lease.go @@ -15,12 +15,13 @@ package clientv3 import ( + "context" "sync" "time" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" + "google.golang.org/grpc" "google.golang.org/grpc/metadata" ) diff --git a/clientv3/leasing/cache.go b/clientv3/leasing/cache.go index 7d47c94a380..6903a785c78 100644 --- a/clientv3/leasing/cache.go +++ b/clientv3/leasing/cache.go @@ -15,6 +15,7 @@ package leasing import ( + "context" "strings" "sync" "time" @@ -22,7 +23,6 @@ import ( v3 "github.com/coreos/etcd/clientv3" v3pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/mvcc/mvccpb" - "golang.org/x/net/context" ) const revokeBackoff = 2 * time.Second diff --git a/clientv3/leasing/kv.go b/clientv3/leasing/kv.go index 91a7d85c7d1..39b38bd404f 100644 --- a/clientv3/leasing/kv.go +++ b/clientv3/leasing/kv.go @@ -15,6 +15,7 @@ package leasing import ( + "context" "strings" "sync" "time" @@ -25,7 +26,6 @@ import ( pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/mvcc/mvccpb" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" ) diff --git a/clientv3/maintenance.go b/clientv3/maintenance.go index 4752dc6070b..988a5f7c288 100644 --- a/clientv3/maintenance.go +++ b/clientv3/maintenance.go @@ -15,11 +15,11 @@ package clientv3 import ( + "context" "io" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/clientv3/mirror/syncer.go b/clientv3/mirror/syncer.go index f2a8f107f67..b820933227c 100644 --- a/clientv3/mirror/syncer.go +++ b/clientv3/mirror/syncer.go @@ -16,8 +16,9 @@ package mirror import ( + "context" + "github.com/coreos/etcd/clientv3" - "golang.org/x/net/context" ) const ( diff --git a/clientv3/namespace/kv.go b/clientv3/namespace/kv.go index b5ec5e964e9..f8c90089136 100644 --- a/clientv3/namespace/kv.go +++ b/clientv3/namespace/kv.go @@ -15,7 +15,7 @@ package namespace import ( - "golang.org/x/net/context" + "context" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" diff --git a/clientv3/namespace/lease.go b/clientv3/namespace/lease.go index fc7c228699d..f092106cbf2 100644 --- a/clientv3/namespace/lease.go +++ b/clientv3/namespace/lease.go @@ -16,8 +16,7 @@ package namespace import ( "bytes" - - "golang.org/x/net/context" + "context" "github.com/coreos/etcd/clientv3" ) diff --git a/clientv3/namespace/watch.go b/clientv3/namespace/watch.go index 6257e296829..5a9596df5d8 100644 --- a/clientv3/namespace/watch.go +++ b/clientv3/namespace/watch.go @@ -15,10 +15,9 @@ package namespace import ( + "context" "sync" - "golang.org/x/net/context" - "github.com/coreos/etcd/clientv3" ) diff --git a/clientv3/naming/grpc.go b/clientv3/naming/grpc.go index 9bb92ea6163..327d9f6440d 100644 --- a/clientv3/naming/grpc.go +++ b/clientv3/naming/grpc.go @@ -15,11 +15,11 @@ package naming import ( + "context" "encoding/json" "fmt" etcd "github.com/coreos/etcd/clientv3" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" diff --git a/clientv3/naming/grpc_test.go b/clientv3/naming/grpc_test.go index 5a463f64884..ba53666a9e1 100644 --- a/clientv3/naming/grpc_test.go +++ b/clientv3/naming/grpc_test.go @@ -15,16 +15,16 @@ package naming import ( + "context" "encoding/json" "reflect" "testing" - "golang.org/x/net/context" - "google.golang.org/grpc/naming" - etcd "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" + + "google.golang.org/grpc/naming" ) func TestGRPCResolver(t *testing.T) { diff --git a/clientv3/ordering/kv.go b/clientv3/ordering/kv.go index 0001ce0131c..e8bf07b8c74 100644 --- a/clientv3/ordering/kv.go +++ b/clientv3/ordering/kv.go @@ -15,10 +15,10 @@ package ordering import ( + "context" "sync" "github.com/coreos/etcd/clientv3" - "golang.org/x/net/context" ) // kvOrdering ensures that serialized requests do not return diff --git a/clientv3/ordering/kv_test.go b/clientv3/ordering/kv_test.go index d6ec597b65b..5c68cc7877c 100644 --- a/clientv3/ordering/kv_test.go +++ b/clientv3/ordering/kv_test.go @@ -16,6 +16,7 @@ package ordering import ( "context" + gContext "context" "errors" "sync" "testing" @@ -25,7 +26,6 @@ import ( pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" - gContext "golang.org/x/net/context" ) func TestDetectKvOrderViolation(t *testing.T) { diff --git a/clientv3/retry.go b/clientv3/retry.go index b4b8b3d38da..a5d748c24bd 100644 --- a/clientv3/retry.go +++ b/clientv3/retry.go @@ -15,9 +15,11 @@ package clientv3 import ( + "context" + "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" + "google.golang.org/grpc" "google.golang.org/grpc/codes" ) diff --git a/clientv3/txn.go b/clientv3/txn.go index 0d9e04fccb8..ea4ec6160b5 100644 --- a/clientv3/txn.go +++ b/clientv3/txn.go @@ -15,10 +15,11 @@ package clientv3 import ( + "context" "sync" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" + "google.golang.org/grpc" ) diff --git a/clientv3/watch.go b/clientv3/watch.go index d000c9951ae..cfa47812691 100644 --- a/clientv3/watch.go +++ b/clientv3/watch.go @@ -15,6 +15,7 @@ package clientv3 import ( + "context" "fmt" "sync" "time" @@ -22,7 +23,7 @@ import ( v3rpc "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" mvccpb "github.com/coreos/etcd/mvcc/mvccpb" - "golang.org/x/net/context" + "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" diff --git a/compactor/compactor.go b/compactor/compactor.go index e25fd7e4174..5a83d13f833 100644 --- a/compactor/compactor.go +++ b/compactor/compactor.go @@ -15,13 +15,13 @@ package compactor import ( + "context" "fmt" "time" - "github.com/coreos/pkg/capnslog" - "golang.org/x/net/context" - pb "github.com/coreos/etcd/etcdserver/etcdserverpb" + + "github.com/coreos/pkg/capnslog" ) var ( diff --git a/compactor/compactor_test.go b/compactor/compactor_test.go index c38ef4b2e54..c3db1c1f8e1 100644 --- a/compactor/compactor_test.go +++ b/compactor/compactor_test.go @@ -15,11 +15,11 @@ package compactor import ( + "context" "sync/atomic" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) type fakeCompactable struct { diff --git a/compactor/periodic.go b/compactor/periodic.go index 7eb7cf7a8c4..784cef7c166 100644 --- a/compactor/periodic.go +++ b/compactor/periodic.go @@ -15,14 +15,14 @@ package compactor import ( + "context" "sync" "time" - "github.com/jonboulle/clockwork" - "golang.org/x/net/context" - pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/mvcc" + + "github.com/jonboulle/clockwork" ) // Periodic compacts the log by purging revisions older than diff --git a/compactor/revision.go b/compactor/revision.go index fd80c278dd1..14baec9706f 100644 --- a/compactor/revision.go +++ b/compactor/revision.go @@ -15,13 +15,13 @@ package compactor import ( + "context" "sync" - "github.com/jonboulle/clockwork" - "golang.org/x/net/context" - pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/mvcc" + + "github.com/jonboulle/clockwork" ) // Revision compacts the log by purging revisions older than diff --git a/contrib/raftexample/raft.go b/contrib/raftexample/raft.go index b212dcb7c00..b50c5d0082a 100644 --- a/contrib/raftexample/raft.go +++ b/contrib/raftexample/raft.go @@ -15,15 +15,15 @@ package main import ( + "context" "fmt" "log" + "net/http" + "net/url" "os" "strconv" "time" - "net/http" - "net/url" - "github.com/coreos/etcd/etcdserver/stats" "github.com/coreos/etcd/pkg/fileutil" "github.com/coreos/etcd/pkg/types" @@ -33,7 +33,6 @@ import ( "github.com/coreos/etcd/snap" "github.com/coreos/etcd/wal" "github.com/coreos/etcd/wal/walpb" - "golang.org/x/net/context" ) // A key-value stream backed by raft diff --git a/contrib/recipes/barrier.go b/contrib/recipes/barrier.go index 33aedf6c528..6e92817219d 100644 --- a/contrib/recipes/barrier.go +++ b/contrib/recipes/barrier.go @@ -15,9 +15,10 @@ package recipe import ( + "context" + v3 "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/mvcc/mvccpb" - "golang.org/x/net/context" ) // Barrier creates a key in etcd to block processes, then deletes the key to diff --git a/contrib/recipes/client.go b/contrib/recipes/client.go index 30d7389c958..111b0b40c5c 100644 --- a/contrib/recipes/client.go +++ b/contrib/recipes/client.go @@ -15,11 +15,11 @@ package recipe import ( + "context" "errors" v3 "github.com/coreos/etcd/clientv3" spb "github.com/coreos/etcd/mvcc/mvccpb" - "golang.org/x/net/context" ) var ( diff --git a/contrib/recipes/double_barrier.go b/contrib/recipes/double_barrier.go index 7690ba1d412..93cc61b4f8a 100644 --- a/contrib/recipes/double_barrier.go +++ b/contrib/recipes/double_barrier.go @@ -15,10 +15,11 @@ package recipe import ( + "context" + "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" "github.com/coreos/etcd/mvcc/mvccpb" - "golang.org/x/net/context" ) // DoubleBarrier blocks processes on Enter until an expected count enters, then diff --git a/contrib/recipes/key.go b/contrib/recipes/key.go index b6df5323560..aea00059aa8 100644 --- a/contrib/recipes/key.go +++ b/contrib/recipes/key.go @@ -15,13 +15,13 @@ package recipe import ( + "context" "fmt" "strings" "time" v3 "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" - "golang.org/x/net/context" ) // RemoteKV is a key/revision pair created by the client and stored on etcd diff --git a/contrib/recipes/priority_queue.go b/contrib/recipes/priority_queue.go index a62fb02aff7..2378ce2f89f 100644 --- a/contrib/recipes/priority_queue.go +++ b/contrib/recipes/priority_queue.go @@ -15,11 +15,11 @@ package recipe import ( + "context" "fmt" v3 "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/mvcc/mvccpb" - "golang.org/x/net/context" ) // PriorityQueue implements a multi-reader, multi-writer distributed queue. diff --git a/contrib/recipes/queue.go b/contrib/recipes/queue.go index 714c40604ee..5d0423a427e 100644 --- a/contrib/recipes/queue.go +++ b/contrib/recipes/queue.go @@ -15,9 +15,10 @@ package recipe import ( + "context" + v3 "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/mvcc/mvccpb" - "golang.org/x/net/context" ) // Queue implements a multi-reader, multi-writer distributed queue. diff --git a/contrib/recipes/rwmutex.go b/contrib/recipes/rwmutex.go index 2714305dfae..1213b7e4202 100644 --- a/contrib/recipes/rwmutex.go +++ b/contrib/recipes/rwmutex.go @@ -15,10 +15,11 @@ package recipe import ( + "context" + v3 "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" "github.com/coreos/etcd/mvcc/mvccpb" - "golang.org/x/net/context" ) type RWMutex struct { diff --git a/contrib/recipes/watch.go b/contrib/recipes/watch.go index 1c4619d3388..5367872273f 100644 --- a/contrib/recipes/watch.go +++ b/contrib/recipes/watch.go @@ -15,9 +15,10 @@ package recipe import ( + "context" + "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/mvcc/mvccpb" - "golang.org/x/net/context" ) // WaitEvents waits on a key until it observes the given events and returns the final one. diff --git a/discovery/discovery.go b/discovery/discovery.go index edc842ffb97..7d1fa0d058d 100644 --- a/discovery/discovery.go +++ b/discovery/discovery.go @@ -17,6 +17,7 @@ package discovery import ( + "context" "errors" "fmt" "math" @@ -31,9 +32,9 @@ import ( "github.com/coreos/etcd/client" "github.com/coreos/etcd/pkg/transport" "github.com/coreos/etcd/pkg/types" + "github.com/coreos/pkg/capnslog" "github.com/jonboulle/clockwork" - "golang.org/x/net/context" ) var ( diff --git a/discovery/discovery_test.go b/discovery/discovery_test.go index bf0636af8bf..89897266ffd 100644 --- a/discovery/discovery_test.go +++ b/discovery/discovery_test.go @@ -15,6 +15,7 @@ package discovery import ( + "context" "errors" "math" "math/rand" @@ -25,10 +26,9 @@ import ( "testing" "time" - "github.com/jonboulle/clockwork" - "golang.org/x/net/context" - "github.com/coreos/etcd/client" + + "github.com/jonboulle/clockwork" ) const ( diff --git a/e2e/ctl_v3_alarm_test.go b/e2e/ctl_v3_alarm_test.go index 912620e810d..395ac297a23 100644 --- a/e2e/ctl_v3_alarm_test.go +++ b/e2e/ctl_v3_alarm_test.go @@ -15,13 +15,13 @@ package e2e import ( + "context" "os" "strings" "testing" "time" "github.com/coreos/etcd/clientv3" - "golang.org/x/net/context" ) func TestCtlV3Alarm(t *testing.T) { diff --git a/e2e/ctl_v3_migrate_test.go b/e2e/ctl_v3_migrate_test.go index 7252fe0a3a0..1bad8c43920 100644 --- a/e2e/ctl_v3_migrate_test.go +++ b/e2e/ctl_v3_migrate_test.go @@ -15,13 +15,12 @@ package e2e import ( + "context" "fmt" "os" "testing" "time" - "golang.org/x/net/context" - "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/pkg/testutil" ) diff --git a/embed/serve.go b/embed/serve.go index 6af2374327c..501d5f25363 100644 --- a/embed/serve.go +++ b/embed/serve.go @@ -15,6 +15,7 @@ package embed import ( + "context" "io/ioutil" defaultLog "log" "net" @@ -36,7 +37,6 @@ import ( gw "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/soheilhy/cmux" - "golang.org/x/net/context" "golang.org/x/net/trace" "google.golang.org/grpc" "google.golang.org/grpc/credentials" diff --git a/etcdctl/ctlv2/command/cluster_health.go b/etcdctl/ctlv2/command/cluster_health.go index d1429649aed..ec0bb241de4 100644 --- a/etcdctl/ctlv2/command/cluster_health.go +++ b/etcdctl/ctlv2/command/cluster_health.go @@ -15,6 +15,7 @@ package command import ( + "context" "encoding/json" "fmt" "io/ioutil" @@ -24,8 +25,8 @@ import ( "time" "github.com/coreos/etcd/client" + "github.com/urfave/cli" - "golang.org/x/net/context" ) func NewClusterHealthCommand() cli.Command { diff --git a/etcdctl/ctlv2/command/exec_watch_command.go b/etcdctl/ctlv2/command/exec_watch_command.go index 5ae24524564..cc3478cc32f 100644 --- a/etcdctl/ctlv2/command/exec_watch_command.go +++ b/etcdctl/ctlv2/command/exec_watch_command.go @@ -15,6 +15,7 @@ package command import ( + "context" "errors" "fmt" "os" @@ -22,8 +23,8 @@ import ( "os/signal" "github.com/coreos/etcd/client" + "github.com/urfave/cli" - "golang.org/x/net/context" ) // NewExecWatchCommand returns the CLI command for "exec-watch". diff --git a/etcdctl/ctlv2/command/util.go b/etcdctl/ctlv2/command/util.go index d6a58145c82..e4719d77a1b 100644 --- a/etcdctl/ctlv2/command/util.go +++ b/etcdctl/ctlv2/command/util.go @@ -15,6 +15,7 @@ package command import ( + "context" "errors" "fmt" "io" @@ -27,11 +28,11 @@ import ( "syscall" "time" - "github.com/bgentry/speakeasy" "github.com/coreos/etcd/client" "github.com/coreos/etcd/pkg/transport" + + "github.com/bgentry/speakeasy" "github.com/urfave/cli" - "golang.org/x/net/context" ) var ( diff --git a/etcdctl/ctlv2/command/watch_command.go b/etcdctl/ctlv2/command/watch_command.go index 71f4c014c9e..eac63b04078 100644 --- a/etcdctl/ctlv2/command/watch_command.go +++ b/etcdctl/ctlv2/command/watch_command.go @@ -15,14 +15,15 @@ package command import ( + "context" "errors" "fmt" "os" "os/signal" "github.com/coreos/etcd/client" + "github.com/urfave/cli" - "golang.org/x/net/context" ) // NewWatchCommand returns the CLI command for "watch". diff --git a/etcdctl/ctlv3/command/elect_command.go b/etcdctl/ctlv3/command/elect_command.go index 74216f3e6a4..ace4f1197b8 100644 --- a/etcdctl/ctlv3/command/elect_command.go +++ b/etcdctl/ctlv3/command/elect_command.go @@ -15,6 +15,7 @@ package command import ( + "context" "errors" "os" "os/signal" @@ -22,8 +23,8 @@ import ( "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" + "github.com/spf13/cobra" - "golang.org/x/net/context" ) var ( diff --git a/etcdctl/ctlv3/command/lease_command.go b/etcdctl/ctlv3/command/lease_command.go index fe6fa3634a0..28c9a0adaaa 100644 --- a/etcdctl/ctlv3/command/lease_command.go +++ b/etcdctl/ctlv3/command/lease_command.go @@ -15,12 +15,13 @@ package command import ( + "context" "fmt" "strconv" v3 "github.com/coreos/etcd/clientv3" + "github.com/spf13/cobra" - "golang.org/x/net/context" ) // NewLeaseCommand returns the cobra command for "lease". diff --git a/etcdctl/ctlv3/command/lock_command.go b/etcdctl/ctlv3/command/lock_command.go index 13d3a7c7828..74ebac81e34 100644 --- a/etcdctl/ctlv3/command/lock_command.go +++ b/etcdctl/ctlv3/command/lock_command.go @@ -15,6 +15,7 @@ package command import ( + "context" "errors" "fmt" "os" @@ -24,8 +25,8 @@ import ( "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" + "github.com/spf13/cobra" - "golang.org/x/net/context" ) var lockTTL = 10 diff --git a/etcdctl/ctlv3/command/make_mirror_command.go b/etcdctl/ctlv3/command/make_mirror_command.go index e333c9994b7..502406441f4 100644 --- a/etcdctl/ctlv3/command/make_mirror_command.go +++ b/etcdctl/ctlv3/command/make_mirror_command.go @@ -15,6 +15,7 @@ package command import ( + "context" "errors" "fmt" "strings" @@ -25,8 +26,8 @@ import ( "github.com/coreos/etcd/clientv3/mirror" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" "github.com/coreos/etcd/mvcc/mvccpb" + "github.com/spf13/cobra" - "golang.org/x/net/context" ) var ( diff --git a/etcdctl/ctlv3/command/role_command.go b/etcdctl/ctlv3/command/role_command.go index b467a56322b..4f062b2a542 100644 --- a/etcdctl/ctlv3/command/role_command.go +++ b/etcdctl/ctlv3/command/role_command.go @@ -15,11 +15,11 @@ package command import ( + "context" "fmt" "github.com/coreos/etcd/clientv3" "github.com/spf13/cobra" - "golang.org/x/net/context" ) var ( diff --git a/etcdctl/ctlv3/command/snapshot_command.go b/etcdctl/ctlv3/command/snapshot_command.go index db12df50afb..3c59ec70cd1 100644 --- a/etcdctl/ctlv3/command/snapshot_command.go +++ b/etcdctl/ctlv3/command/snapshot_command.go @@ -15,6 +15,7 @@ package command import ( + "context" "crypto/sha256" "encoding/binary" "encoding/json" @@ -27,7 +28,6 @@ import ( "reflect" "strings" - bolt "github.com/coreos/bbolt" "github.com/coreos/etcd/etcdserver" "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/etcdserver/membership" @@ -42,8 +42,9 @@ import ( "github.com/coreos/etcd/store" "github.com/coreos/etcd/wal" "github.com/coreos/etcd/wal/walpb" + + bolt "github.com/coreos/bbolt" "github.com/spf13/cobra" - "golang.org/x/net/context" ) const ( diff --git a/etcdctl/ctlv3/command/txn_command.go b/etcdctl/ctlv3/command/txn_command.go index f809ec88cf0..eec1e0916c3 100644 --- a/etcdctl/ctlv3/command/txn_command.go +++ b/etcdctl/ctlv3/command/txn_command.go @@ -16,6 +16,7 @@ package command import ( "bufio" + "context" "fmt" "os" "strconv" @@ -23,8 +24,8 @@ import ( "github.com/coreos/etcd/clientv3" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" + "github.com/spf13/cobra" - "golang.org/x/net/context" ) var ( diff --git a/etcdctl/ctlv3/command/user_command.go b/etcdctl/ctlv3/command/user_command.go index 8a157e2a60e..4df56f720a1 100644 --- a/etcdctl/ctlv3/command/user_command.go +++ b/etcdctl/ctlv3/command/user_command.go @@ -15,12 +15,12 @@ package command import ( + "context" "fmt" "strings" "github.com/bgentry/speakeasy" "github.com/spf13/cobra" - "golang.org/x/net/context" ) var ( diff --git a/etcdctl/ctlv3/command/util.go b/etcdctl/ctlv3/command/util.go index c9201c7bee9..addd023db08 100644 --- a/etcdctl/ctlv3/command/util.go +++ b/etcdctl/ctlv3/command/util.go @@ -15,13 +15,14 @@ package command import ( + "context" "encoding/hex" "fmt" "regexp" pb "github.com/coreos/etcd/mvcc/mvccpb" + "github.com/spf13/cobra" - "golang.org/x/net/context" ) func printKV(isHex bool, valueOnly bool, kv *pb.KeyValue) { diff --git a/etcdctl/ctlv3/command/watch_command.go b/etcdctl/ctlv3/command/watch_command.go index 17b670e9d35..4adf547e9cd 100644 --- a/etcdctl/ctlv3/command/watch_command.go +++ b/etcdctl/ctlv3/command/watch_command.go @@ -16,13 +16,14 @@ package command import ( "bufio" + "context" "fmt" "os" "strings" "github.com/coreos/etcd/clientv3" + "github.com/spf13/cobra" - "golang.org/x/net/context" ) var ( diff --git a/etcdserver/api/v2http/client.go b/etcdserver/api/v2http/client.go index c9d86508e01..d233752974b 100644 --- a/etcdserver/api/v2http/client.go +++ b/etcdserver/api/v2http/client.go @@ -15,6 +15,7 @@ package v2http import ( + "context" "encoding/json" "errors" "fmt" @@ -37,8 +38,8 @@ import ( "github.com/coreos/etcd/etcdserver/stats" "github.com/coreos/etcd/pkg/types" "github.com/coreos/etcd/store" + "github.com/jonboulle/clockwork" - "golang.org/x/net/context" ) const ( diff --git a/etcdserver/api/v2http/client_test.go b/etcdserver/api/v2http/client_test.go index 0a58082a41b..44448d0bf77 100644 --- a/etcdserver/api/v2http/client_test.go +++ b/etcdserver/api/v2http/client_test.go @@ -16,6 +16,7 @@ package v2http import ( "bytes" + "context" "encoding/json" "errors" "io/ioutil" @@ -38,9 +39,9 @@ import ( "github.com/coreos/etcd/pkg/types" "github.com/coreos/etcd/raft/raftpb" "github.com/coreos/etcd/store" + "github.com/coreos/go-semver/semver" "github.com/jonboulle/clockwork" - "golang.org/x/net/context" ) func mustMarshalEvent(t *testing.T, ev *store.Event) string { diff --git a/etcdserver/api/v2http/http_test.go b/etcdserver/api/v2http/http_test.go index 5b68a49a540..e9d8dc00dd1 100644 --- a/etcdserver/api/v2http/http_test.go +++ b/etcdserver/api/v2http/http_test.go @@ -15,6 +15,7 @@ package v2http import ( + "context" "errors" "net/http" "net/http/httptest" @@ -27,8 +28,8 @@ import ( "github.com/coreos/etcd/etcdserver/membership" "github.com/coreos/etcd/pkg/types" "github.com/coreos/etcd/raft/raftpb" + "github.com/coreos/go-semver/semver" - "golang.org/x/net/context" ) type fakeCluster struct { diff --git a/etcdserver/api/v2v3/server.go b/etcdserver/api/v2v3/server.go index dae457ccf9d..2ef63ce6844 100644 --- a/etcdserver/api/v2v3/server.go +++ b/etcdserver/api/v2v3/server.go @@ -15,6 +15,7 @@ package v2v3 import ( + "context" "net/http" "time" @@ -26,7 +27,6 @@ import ( "github.com/coreos/etcd/pkg/types" "github.com/coreos/go-semver/semver" - "golang.org/x/net/context" // TODO: replace with context in go1.9 ) type fakeStats struct{} diff --git a/etcdserver/api/v3client/v3client.go b/etcdserver/api/v3client/v3client.go index cc4147d2f0c..6f943184f0b 100644 --- a/etcdserver/api/v3client/v3client.go +++ b/etcdserver/api/v3client/v3client.go @@ -15,14 +15,13 @@ package v3client import ( + "context" "time" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/etcdserver" "github.com/coreos/etcd/etcdserver/api/v3rpc" "github.com/coreos/etcd/proxy/grpcproxy/adapter" - - "golang.org/x/net/context" ) // New creates a clientv3 client that wraps an in-process EtcdServer. Instead diff --git a/etcdserver/api/v3election/election.go b/etcdserver/api/v3election/election.go index f9061c07926..51e181446c6 100644 --- a/etcdserver/api/v3election/election.go +++ b/etcdserver/api/v3election/election.go @@ -15,7 +15,7 @@ package v3election import ( - "golang.org/x/net/context" + "context" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" diff --git a/etcdserver/api/v3lock/lock.go b/etcdserver/api/v3lock/lock.go index 66465bf13f6..a5efcbab5b5 100644 --- a/etcdserver/api/v3lock/lock.go +++ b/etcdserver/api/v3lock/lock.go @@ -15,7 +15,7 @@ package v3lock import ( - "golang.org/x/net/context" + "context" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" diff --git a/etcdserver/api/v3rpc/auth.go b/etcdserver/api/v3rpc/auth.go index e66c5261d0a..ca8e53ad049 100644 --- a/etcdserver/api/v3rpc/auth.go +++ b/etcdserver/api/v3rpc/auth.go @@ -15,9 +15,10 @@ package v3rpc import ( + "context" + "github.com/coreos/etcd/etcdserver" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" ) type AuthServer struct { diff --git a/etcdserver/api/v3rpc/interceptor.go b/etcdserver/api/v3rpc/interceptor.go index de9470a8905..f38dc4a99cf 100644 --- a/etcdserver/api/v3rpc/interceptor.go +++ b/etcdserver/api/v3rpc/interceptor.go @@ -15,6 +15,7 @@ package v3rpc import ( + "context" "sync" "time" @@ -25,7 +26,6 @@ import ( "github.com/coreos/etcd/raft" prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/metadata" ) diff --git a/etcdserver/api/v3rpc/key.go b/etcdserver/api/v3rpc/key.go index 973346592de..9781bddda9c 100644 --- a/etcdserver/api/v3rpc/key.go +++ b/etcdserver/api/v3rpc/key.go @@ -16,12 +16,14 @@ package v3rpc import ( + "context" + "github.com/coreos/etcd/etcdserver" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/pkg/adt" + "github.com/coreos/pkg/capnslog" - "golang.org/x/net/context" ) var ( diff --git a/etcdserver/api/v3rpc/lease.go b/etcdserver/api/v3rpc/lease.go index 6c267da7575..7b5e17ca268 100644 --- a/etcdserver/api/v3rpc/lease.go +++ b/etcdserver/api/v3rpc/lease.go @@ -15,13 +15,13 @@ package v3rpc import ( + "context" "io" "github.com/coreos/etcd/etcdserver" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/lease" - "golang.org/x/net/context" ) type LeaseServer struct { diff --git a/etcdserver/api/v3rpc/maintenance.go b/etcdserver/api/v3rpc/maintenance.go index a88aec9952d..c9df1800db2 100644 --- a/etcdserver/api/v3rpc/maintenance.go +++ b/etcdserver/api/v3rpc/maintenance.go @@ -15,6 +15,7 @@ package v3rpc import ( + "context" "crypto/sha256" "io" @@ -26,7 +27,6 @@ import ( "github.com/coreos/etcd/mvcc/backend" "github.com/coreos/etcd/pkg/types" "github.com/coreos/etcd/version" - "golang.org/x/net/context" ) type KVGetter interface { diff --git a/etcdserver/api/v3rpc/member.go b/etcdserver/api/v3rpc/member.go index ff271e8ddba..cbe7b470ab9 100644 --- a/etcdserver/api/v3rpc/member.go +++ b/etcdserver/api/v3rpc/member.go @@ -15,6 +15,7 @@ package v3rpc import ( + "context" "time" "github.com/coreos/etcd/etcdserver" @@ -23,7 +24,6 @@ import ( pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/etcdserver/membership" "github.com/coreos/etcd/pkg/types" - "golang.org/x/net/context" ) type ClusterServer struct { diff --git a/etcdserver/api/v3rpc/quota.go b/etcdserver/api/v3rpc/quota.go index 836f2fd3f43..02d99609d88 100644 --- a/etcdserver/api/v3rpc/quota.go +++ b/etcdserver/api/v3rpc/quota.go @@ -15,11 +15,12 @@ package v3rpc import ( + "context" + "github.com/coreos/etcd/etcdserver" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/pkg/types" - "golang.org/x/net/context" ) type quotaKVServer struct { diff --git a/etcdserver/api/v3rpc/watch.go b/etcdserver/api/v3rpc/watch.go index a456307fea5..c796c338673 100644 --- a/etcdserver/api/v3rpc/watch.go +++ b/etcdserver/api/v3rpc/watch.go @@ -15,12 +15,11 @@ package v3rpc import ( + "context" "io" "sync" "time" - "golang.org/x/net/context" - "github.com/coreos/etcd/auth" "github.com/coreos/etcd/etcdserver" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" diff --git a/etcdserver/apply.go b/etcdserver/apply.go index 26b17f14194..295d93714ec 100644 --- a/etcdserver/apply.go +++ b/etcdserver/apply.go @@ -16,6 +16,7 @@ package etcdserver import ( "bytes" + "context" "sort" "time" @@ -24,8 +25,8 @@ import ( "github.com/coreos/etcd/mvcc" "github.com/coreos/etcd/mvcc/mvccpb" "github.com/coreos/etcd/pkg/types" + "github.com/gogo/protobuf/proto" - "golang.org/x/net/context" ) const ( diff --git a/etcdserver/auth/auth.go b/etcdserver/auth/auth.go index 19e96d57c6d..8991675cc71 100644 --- a/etcdserver/auth/auth.go +++ b/etcdserver/auth/auth.go @@ -16,6 +16,7 @@ package auth import ( + "context" "encoding/json" "fmt" "net/http" @@ -30,8 +31,8 @@ import ( "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/pkg/types" "github.com/coreos/pkg/capnslog" + "golang.org/x/crypto/bcrypt" - "golang.org/x/net/context" ) const ( diff --git a/etcdserver/auth/auth_requests.go b/etcdserver/auth/auth_requests.go index eec700accd7..2464828e654 100644 --- a/etcdserver/auth/auth_requests.go +++ b/etcdserver/auth/auth_requests.go @@ -15,13 +15,13 @@ package auth import ( + "context" "encoding/json" "path" etcderr "github.com/coreos/etcd/error" "github.com/coreos/etcd/etcdserver" "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" ) func (s *store) ensureAuthDirectories() error { diff --git a/etcdserver/auth/auth_test.go b/etcdserver/auth/auth_test.go index 2d81d92463a..ad32260de09 100644 --- a/etcdserver/auth/auth_test.go +++ b/etcdserver/auth/auth_test.go @@ -15,6 +15,7 @@ package auth import ( + "context" "reflect" "testing" "time" @@ -23,7 +24,6 @@ import ( "github.com/coreos/etcd/etcdserver" "github.com/coreos/etcd/etcdserver/etcdserverpb" etcdstore "github.com/coreos/etcd/store" - "golang.org/x/net/context" ) type fakeDoer struct{} diff --git a/etcdserver/config.go b/etcdserver/config.go index 1e39369026c..cac4fb01060 100644 --- a/etcdserver/config.go +++ b/etcdserver/config.go @@ -15,14 +15,13 @@ package etcdserver import ( + "context" "fmt" "path/filepath" "sort" "strings" "time" - "golang.org/x/net/context" - "github.com/coreos/etcd/pkg/netutil" "github.com/coreos/etcd/pkg/transport" "github.com/coreos/etcd/pkg/types" diff --git a/etcdserver/corrupt.go b/etcdserver/corrupt.go index b1602de1ebd..ea614954336 100644 --- a/etcdserver/corrupt.go +++ b/etcdserver/corrupt.go @@ -15,14 +15,13 @@ package etcdserver import ( + "context" "time" "github.com/coreos/etcd/clientv3" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/mvcc" "github.com/coreos/etcd/pkg/types" - - "golang.org/x/net/context" ) func (s *EtcdServer) monitorKVHash() { diff --git a/etcdserver/membership/cluster.go b/etcdserver/membership/cluster.go index 2330219f18a..565354402e2 100644 --- a/etcdserver/membership/cluster.go +++ b/etcdserver/membership/cluster.go @@ -16,6 +16,7 @@ package membership import ( "bytes" + "context" "crypto/sha1" "encoding/binary" "encoding/json" @@ -26,8 +27,6 @@ import ( "sync" "time" - "golang.org/x/net/context" - "github.com/coreos/etcd/mvcc/backend" "github.com/coreos/etcd/pkg/netutil" "github.com/coreos/etcd/pkg/types" @@ -35,6 +34,7 @@ import ( "github.com/coreos/etcd/raft/raftpb" "github.com/coreos/etcd/store" "github.com/coreos/etcd/version" + "github.com/coreos/go-semver/semver" ) diff --git a/etcdserver/server.go b/etcdserver/server.go index ffeaf88cc42..20f8a7166b2 100644 --- a/etcdserver/server.go +++ b/etcdserver/server.go @@ -15,6 +15,7 @@ package etcdserver import ( + "context" "encoding/json" "expvar" "fmt" @@ -55,9 +56,9 @@ import ( "github.com/coreos/etcd/store" "github.com/coreos/etcd/version" "github.com/coreos/etcd/wal" + "github.com/coreos/go-semver/semver" "github.com/coreos/pkg/capnslog" - "golang.org/x/net/context" ) const ( diff --git a/etcdserver/server_test.go b/etcdserver/server_test.go index c2bd0045f3e..bafacad6cd3 100644 --- a/etcdserver/server_test.go +++ b/etcdserver/server_test.go @@ -15,6 +15,7 @@ package etcdserver import ( + "context" "encoding/json" "fmt" "io/ioutil" @@ -44,7 +45,6 @@ import ( "github.com/coreos/etcd/rafthttp" "github.com/coreos/etcd/snap" "github.com/coreos/etcd/store" - "golang.org/x/net/context" ) // TestDoLocalAction tests requests which do not need to go through raft to be applied, diff --git a/etcdserver/v2_server.go b/etcdserver/v2_server.go index 6c4aa8baf19..4b027f18d3b 100644 --- a/etcdserver/v2_server.go +++ b/etcdserver/v2_server.go @@ -15,11 +15,11 @@ package etcdserver import ( + "context" "time" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/store" - "golang.org/x/net/context" ) type RequestV2 pb.Request diff --git a/etcdserver/v3_server.go b/etcdserver/v3_server.go index 6b80468f45b..451d3de4132 100644 --- a/etcdserver/v3_server.go +++ b/etcdserver/v3_server.go @@ -16,11 +16,10 @@ package etcdserver import ( "bytes" + "context" "encoding/binary" "time" - "github.com/gogo/protobuf/proto" - "github.com/coreos/etcd/auth" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/etcdserver/membership" @@ -29,7 +28,7 @@ import ( "github.com/coreos/etcd/mvcc" "github.com/coreos/etcd/raft" - "golang.org/x/net/context" + "github.com/gogo/protobuf/proto" ) const ( diff --git a/integration/cluster.go b/integration/cluster.go index 01a2aa6adfd..c85eccccd05 100644 --- a/integration/cluster.go +++ b/integration/cluster.go @@ -15,6 +15,7 @@ package integration import ( + "context" "crypto/tls" "fmt" "io/ioutil" @@ -31,10 +32,6 @@ import ( "testing" "time" - "github.com/soheilhy/cmux" - "golang.org/x/net/context" - "google.golang.org/grpc" - "github.com/coreos/etcd/client" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/embed" @@ -52,7 +49,10 @@ import ( "github.com/coreos/etcd/pkg/transport" "github.com/coreos/etcd/pkg/types" "github.com/coreos/etcd/rafthttp" + "github.com/coreos/pkg/capnslog" + "github.com/soheilhy/cmux" + "google.golang.org/grpc" ) const ( diff --git a/integration/cluster_test.go b/integration/cluster_test.go index 14549dac0ba..e7475abaa47 100644 --- a/integration/cluster_test.go +++ b/integration/cluster_test.go @@ -15,6 +15,7 @@ package integration import ( + "context" "fmt" "log" "math/rand" @@ -27,9 +28,8 @@ import ( "github.com/coreos/etcd/client" "github.com/coreos/etcd/etcdserver" "github.com/coreos/etcd/pkg/testutil" - "github.com/coreos/pkg/capnslog" - "golang.org/x/net/context" + "github.com/coreos/pkg/capnslog" ) func init() { diff --git a/integration/member_test.go b/integration/member_test.go index 501d918380e..539adfec9b0 100644 --- a/integration/member_test.go +++ b/integration/member_test.go @@ -15,6 +15,7 @@ package integration import ( + "context" "fmt" "io/ioutil" "os" @@ -23,7 +24,6 @@ import ( "github.com/coreos/etcd/client" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) func TestPauseMember(t *testing.T) { diff --git a/integration/v3_alarm_test.go b/integration/v3_alarm_test.go index 9c735231d1c..0dbaf6b7f3c 100644 --- a/integration/v3_alarm_test.go +++ b/integration/v3_alarm_test.go @@ -15,6 +15,7 @@ package integration import ( + "context" "os" "path/filepath" "sync" @@ -26,7 +27,6 @@ import ( "github.com/coreos/etcd/mvcc" "github.com/coreos/etcd/mvcc/backend" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) // TestV3StorageQuotaApply tests the V3 server respects quotas during apply diff --git a/integration/v3_auth_test.go b/integration/v3_auth_test.go index 03ea88cd944..5d883d0c6bd 100644 --- a/integration/v3_auth_test.go +++ b/integration/v3_auth_test.go @@ -15,13 +15,12 @@ package integration import ( + "context" "fmt" "sync" "testing" "time" - "golang.org/x/net/context" - "github.com/coreos/etcd/auth/authpb" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" diff --git a/integration/v3_election_test.go b/integration/v3_election_test.go index 95f5b4949b9..341430df529 100644 --- a/integration/v3_election_test.go +++ b/integration/v3_election_test.go @@ -15,13 +15,13 @@ package integration import ( + "context" "fmt" "testing" "time" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" - "golang.org/x/net/context" ) // TestElectionWait tests if followers can correctly wait for elections. diff --git a/integration/v3_grpc_inflight_test.go b/integration/v3_grpc_inflight_test.go index 1994af06dd9..0c9f892a3e1 100644 --- a/integration/v3_grpc_inflight_test.go +++ b/integration/v3_grpc_inflight_test.go @@ -15,6 +15,7 @@ package integration import ( + "context" "sync" "testing" "time" @@ -22,7 +23,6 @@ import ( pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/integration/v3_grpc_test.go b/integration/v3_grpc_test.go index 47d4591e075..345ce762ef7 100644 --- a/integration/v3_grpc_test.go +++ b/integration/v3_grpc_test.go @@ -16,6 +16,7 @@ package integration import ( "bytes" + "context" "fmt" "io/ioutil" "math/rand" @@ -30,7 +31,6 @@ import ( "github.com/coreos/etcd/pkg/testutil" "github.com/coreos/etcd/pkg/transport" - "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/metadata" ) diff --git a/integration/v3_lease_test.go b/integration/v3_lease_test.go index 7ea873f86bf..39df1cabe61 100644 --- a/integration/v3_lease_test.go +++ b/integration/v3_lease_test.go @@ -15,18 +15,18 @@ package integration import ( + "context" "fmt" "testing" "time" - "golang.org/x/net/context" - "google.golang.org/grpc" - "google.golang.org/grpc/metadata" - "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/mvcc/mvccpb" "github.com/coreos/etcd/pkg/testutil" + + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" ) // TestV3LeasePrmote ensures the newly elected leader can promote itself diff --git a/integration/v3_lock_test.go b/integration/v3_lock_test.go index e2f37afe2a3..889a6ef1f62 100644 --- a/integration/v3_lock_test.go +++ b/integration/v3_lock_test.go @@ -15,6 +15,7 @@ package integration import ( + "context" "math/rand" "sync" "testing" @@ -25,7 +26,6 @@ import ( "github.com/coreos/etcd/contrib/recipes" "github.com/coreos/etcd/mvcc/mvccpb" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) func TestMutexSingleNode(t *testing.T) { diff --git a/integration/v3_watch_test.go b/integration/v3_watch_test.go index 92fc98ef3cb..c91f4df6503 100644 --- a/integration/v3_watch_test.go +++ b/integration/v3_watch_test.go @@ -16,6 +16,7 @@ package integration import ( "bytes" + "context" "fmt" "reflect" "sort" @@ -27,7 +28,6 @@ import ( pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/mvcc/mvccpb" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) // TestV3WatchFromCurrentRevision tests Watch APIs from current revision. diff --git a/integration/v3election_grpc_test.go b/integration/v3election_grpc_test.go index be320286e81..12a0908b722 100644 --- a/integration/v3election_grpc_test.go +++ b/integration/v3election_grpc_test.go @@ -15,6 +15,7 @@ package integration import ( + "context" "fmt" "testing" "time" @@ -22,7 +23,6 @@ import ( epb "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) // TestV3ElectionCampaign checks that Campaign will not give diff --git a/integration/v3lock_grpc_test.go b/integration/v3lock_grpc_test.go index a66a8cf460c..ccaf0a9ccbb 100644 --- a/integration/v3lock_grpc_test.go +++ b/integration/v3lock_grpc_test.go @@ -15,13 +15,13 @@ package integration import ( + "context" "testing" "time" lockpb "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" ) // TestV3LockLockWaiter tests that a client will wait for a lock, then acquire it diff --git a/lease/leasehttp/http_test.go b/lease/leasehttp/http_test.go index 41320810426..367cd8e64a4 100644 --- a/lease/leasehttp/http_test.go +++ b/lease/leasehttp/http_test.go @@ -15,6 +15,7 @@ package leasehttp import ( + "context" "net/http" "net/http/httptest" "os" @@ -24,8 +25,6 @@ import ( "github.com/coreos/etcd/lease" "github.com/coreos/etcd/mvcc/backend" - - "golang.org/x/net/context" ) func TestRenewHTTP(t *testing.T) { diff --git a/mvcc/kvstore.go b/mvcc/kvstore.go index 9d972311ade..1a695e3ab80 100644 --- a/mvcc/kvstore.go +++ b/mvcc/kvstore.go @@ -15,6 +15,7 @@ package mvcc import ( + "context" "encoding/binary" "errors" "hash/crc32" @@ -28,7 +29,6 @@ import ( "github.com/coreos/etcd/mvcc/mvccpb" "github.com/coreos/etcd/pkg/schedule" "github.com/coreos/pkg/capnslog" - "golang.org/x/net/context" ) var ( diff --git a/pkg/schedule/schedule.go b/pkg/schedule/schedule.go index bf8528b753a..234d01989df 100644 --- a/pkg/schedule/schedule.go +++ b/pkg/schedule/schedule.go @@ -15,9 +15,8 @@ package schedule import ( + "context" "sync" - - "golang.org/x/net/context" ) type Job func(context.Context) diff --git a/pkg/schedule/schedule_test.go b/pkg/schedule/schedule_test.go index 88c5bf3c972..aa9c709f819 100644 --- a/pkg/schedule/schedule_test.go +++ b/pkg/schedule/schedule_test.go @@ -15,9 +15,8 @@ package schedule import ( + "context" "testing" - - "golang.org/x/net/context" ) func TestFIFOSchedule(t *testing.T) { diff --git a/proxy/grpcproxy/adapter/auth_client_adapter.go b/proxy/grpcproxy/adapter/auth_client_adapter.go index 7f38a9ac76e..33dc91f013f 100644 --- a/proxy/grpcproxy/adapter/auth_client_adapter.go +++ b/proxy/grpcproxy/adapter/auth_client_adapter.go @@ -15,8 +15,10 @@ package adapter import ( + "context" + pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" + grpc "google.golang.org/grpc" ) diff --git a/proxy/grpcproxy/adapter/chan_stream.go b/proxy/grpcproxy/adapter/chan_stream.go index 3aa01f2052b..82e34119311 100644 --- a/proxy/grpcproxy/adapter/chan_stream.go +++ b/proxy/grpcproxy/adapter/chan_stream.go @@ -15,7 +15,7 @@ package adapter import ( - "golang.org/x/net/context" + "context" "google.golang.org/grpc" "google.golang.org/grpc/metadata" diff --git a/proxy/grpcproxy/adapter/cluster_client_adapter.go b/proxy/grpcproxy/adapter/cluster_client_adapter.go index 4ddf78e15ec..6c0340998b9 100644 --- a/proxy/grpcproxy/adapter/cluster_client_adapter.go +++ b/proxy/grpcproxy/adapter/cluster_client_adapter.go @@ -15,9 +15,10 @@ package adapter import ( + "context" + pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/proxy/grpcproxy/adapter/election_client_adapter.go b/proxy/grpcproxy/adapter/election_client_adapter.go index 383c1b9d8fb..a2ebf138f3b 100644 --- a/proxy/grpcproxy/adapter/election_client_adapter.go +++ b/proxy/grpcproxy/adapter/election_client_adapter.go @@ -15,9 +15,10 @@ package adapter import ( + "context" + "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/proxy/grpcproxy/adapter/kv_client_adapter.go b/proxy/grpcproxy/adapter/kv_client_adapter.go index fec401d9dd0..acd5673d005 100644 --- a/proxy/grpcproxy/adapter/kv_client_adapter.go +++ b/proxy/grpcproxy/adapter/kv_client_adapter.go @@ -15,8 +15,10 @@ package adapter import ( + "context" + pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" + grpc "google.golang.org/grpc" ) diff --git a/proxy/grpcproxy/adapter/lease_client_adapter.go b/proxy/grpcproxy/adapter/lease_client_adapter.go index c8c67ce6e13..84c48b591b0 100644 --- a/proxy/grpcproxy/adapter/lease_client_adapter.go +++ b/proxy/grpcproxy/adapter/lease_client_adapter.go @@ -15,9 +15,10 @@ package adapter import ( - "golang.org/x/net/context" + "context" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" + "google.golang.org/grpc" ) diff --git a/proxy/grpcproxy/adapter/lock_client_adapter.go b/proxy/grpcproxy/adapter/lock_client_adapter.go index 05e5cb020a1..9ce7913a3ba 100644 --- a/proxy/grpcproxy/adapter/lock_client_adapter.go +++ b/proxy/grpcproxy/adapter/lock_client_adapter.go @@ -15,9 +15,10 @@ package adapter import ( + "context" + "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/proxy/grpcproxy/adapter/maintenance_client_adapter.go b/proxy/grpcproxy/adapter/maintenance_client_adapter.go index 66aaabba10a..92d9dfd204e 100644 --- a/proxy/grpcproxy/adapter/maintenance_client_adapter.go +++ b/proxy/grpcproxy/adapter/maintenance_client_adapter.go @@ -15,9 +15,10 @@ package adapter import ( + "context" + pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/proxy/grpcproxy/adapter/watch_client_adapter.go b/proxy/grpcproxy/adapter/watch_client_adapter.go index af4a13c4152..afe61e837b5 100644 --- a/proxy/grpcproxy/adapter/watch_client_adapter.go +++ b/proxy/grpcproxy/adapter/watch_client_adapter.go @@ -15,10 +15,10 @@ package adapter import ( + "context" "errors" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/proxy/grpcproxy/auth.go b/proxy/grpcproxy/auth.go index c1b75e36dbd..0ed8d246d2b 100644 --- a/proxy/grpcproxy/auth.go +++ b/proxy/grpcproxy/auth.go @@ -15,7 +15,7 @@ package grpcproxy import ( - "golang.org/x/net/context" + "context" "github.com/coreos/etcd/clientv3" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" diff --git a/proxy/grpcproxy/cluster.go b/proxy/grpcproxy/cluster.go index 899fb9be65f..2ee91ae10bf 100644 --- a/proxy/grpcproxy/cluster.go +++ b/proxy/grpcproxy/cluster.go @@ -15,6 +15,7 @@ package grpcproxy import ( + "context" "fmt" "os" "sync" @@ -23,7 +24,6 @@ import ( "github.com/coreos/etcd/clientv3/naming" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" "golang.org/x/time/rate" "google.golang.org/grpc" gnaming "google.golang.org/grpc/naming" diff --git a/proxy/grpcproxy/cluster_test.go b/proxy/grpcproxy/cluster_test.go index e36234c195c..f2c0af3f0a1 100644 --- a/proxy/grpcproxy/cluster_test.go +++ b/proxy/grpcproxy/cluster_test.go @@ -15,6 +15,7 @@ package grpcproxy import ( + "context" "net" "testing" "time" @@ -24,7 +25,6 @@ import ( "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/proxy/grpcproxy/election.go b/proxy/grpcproxy/election.go index 27115a81d7d..4b4a4cc4210 100644 --- a/proxy/grpcproxy/election.go +++ b/proxy/grpcproxy/election.go @@ -15,7 +15,7 @@ package grpcproxy import ( - "golang.org/x/net/context" + "context" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb" diff --git a/proxy/grpcproxy/health.go b/proxy/grpcproxy/health.go index e660800e907..9e2c93ca8a9 100644 --- a/proxy/grpcproxy/health.go +++ b/proxy/grpcproxy/health.go @@ -15,14 +15,13 @@ package grpcproxy import ( + "context" "net/http" "time" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/etcdserver/api/etcdhttp" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" - - "golang.org/x/net/context" ) // HandleHealth registers health handler on '/health'. diff --git a/proxy/grpcproxy/kv.go b/proxy/grpcproxy/kv.go index 4e6b0366173..ff445393df6 100644 --- a/proxy/grpcproxy/kv.go +++ b/proxy/grpcproxy/kv.go @@ -15,11 +15,11 @@ package grpcproxy import ( + "context" + "github.com/coreos/etcd/clientv3" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/proxy/grpcproxy/cache" - - "golang.org/x/net/context" ) type kvProxy struct { diff --git a/proxy/grpcproxy/kv_test.go b/proxy/grpcproxy/kv_test.go index b0fecc37ac9..33fb597c08b 100644 --- a/proxy/grpcproxy/kv_test.go +++ b/proxy/grpcproxy/kv_test.go @@ -15,6 +15,7 @@ package grpcproxy import ( + "context" "net" "testing" "time" @@ -24,7 +25,6 @@ import ( "github.com/coreos/etcd/integration" "github.com/coreos/etcd/pkg/testutil" - "golang.org/x/net/context" "google.golang.org/grpc" ) diff --git a/proxy/grpcproxy/leader.go b/proxy/grpcproxy/leader.go index 86afdb7072b..7dde221c4dc 100644 --- a/proxy/grpcproxy/leader.go +++ b/proxy/grpcproxy/leader.go @@ -15,14 +15,14 @@ package grpcproxy import ( + "context" "math" "sync" - "golang.org/x/net/context" + "github.com/coreos/etcd/clientv3" + "golang.org/x/time/rate" "google.golang.org/grpc" - - "github.com/coreos/etcd/clientv3" ) const ( diff --git a/proxy/grpcproxy/lease.go b/proxy/grpcproxy/lease.go index cad013f6f4a..65f68b0ea0c 100644 --- a/proxy/grpcproxy/lease.go +++ b/proxy/grpcproxy/lease.go @@ -15,19 +15,18 @@ package grpcproxy import ( + "context" "io" "sync" "sync/atomic" "time" - "google.golang.org/grpc" - "google.golang.org/grpc/metadata" - - "golang.org/x/net/context" - "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" + + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" ) type leaseProxy struct { diff --git a/proxy/grpcproxy/lock.go b/proxy/grpcproxy/lock.go index 804aff64a96..ceef26f0a0f 100644 --- a/proxy/grpcproxy/lock.go +++ b/proxy/grpcproxy/lock.go @@ -15,7 +15,7 @@ package grpcproxy import ( - "golang.org/x/net/context" + "context" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb" diff --git a/proxy/grpcproxy/maintenance.go b/proxy/grpcproxy/maintenance.go index b32a573b4bc..21fe79fa5c0 100644 --- a/proxy/grpcproxy/maintenance.go +++ b/proxy/grpcproxy/maintenance.go @@ -15,10 +15,9 @@ package grpcproxy import ( + "context" "io" - "golang.org/x/net/context" - "github.com/coreos/etcd/clientv3" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" ) diff --git a/proxy/grpcproxy/watch.go b/proxy/grpcproxy/watch.go index b960c94769a..c93cfc38d62 100644 --- a/proxy/grpcproxy/watch.go +++ b/proxy/grpcproxy/watch.go @@ -15,16 +15,16 @@ package grpcproxy import ( + "context" "sync" - "golang.org/x/net/context" - "google.golang.org/grpc" - "google.golang.org/grpc/metadata" - "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/etcdserver/api/v3rpc" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" + + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" ) type watchProxy struct { diff --git a/proxy/grpcproxy/watch_broadcast.go b/proxy/grpcproxy/watch_broadcast.go index 5e750bdb0d4..ce45f87703c 100644 --- a/proxy/grpcproxy/watch_broadcast.go +++ b/proxy/grpcproxy/watch_broadcast.go @@ -15,10 +15,9 @@ package grpcproxy import ( + "context" "sync" - "golang.org/x/net/context" - "github.com/coreos/etcd/clientv3" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" ) diff --git a/raft/node.go b/raft/node.go index 5da1c1193b2..ba25b7ddd48 100644 --- a/raft/node.go +++ b/raft/node.go @@ -15,10 +15,10 @@ package raft import ( + "context" "errors" pb "github.com/coreos/etcd/raft/raftpb" - "golang.org/x/net/context" ) type SnapshotStatus int diff --git a/raft/node_bench_test.go b/raft/node_bench_test.go index 4e60634a223..c3fc89f3f83 100644 --- a/raft/node_bench_test.go +++ b/raft/node_bench_test.go @@ -15,10 +15,9 @@ package raft import ( + "context" "testing" "time" - - "golang.org/x/net/context" ) func BenchmarkOneNode(b *testing.B) { diff --git a/raft/node_test.go b/raft/node_test.go index f4c726ea869..4401412e774 100644 --- a/raft/node_test.go +++ b/raft/node_test.go @@ -16,13 +16,13 @@ package raft import ( "bytes" + "context" "reflect" "testing" "time" "github.com/coreos/etcd/pkg/testutil" "github.com/coreos/etcd/raft/raftpb" - "golang.org/x/net/context" ) // TestNodeStep ensures that node.Step sends msgProp to propc chan diff --git a/raft/rafttest/node.go b/raft/rafttest/node.go index a37a16839ce..0c47bb2f9be 100644 --- a/raft/rafttest/node.go +++ b/raft/rafttest/node.go @@ -15,13 +15,13 @@ package rafttest import ( + "context" "log" "sync" "time" "github.com/coreos/etcd/raft" "github.com/coreos/etcd/raft/raftpb" - "golang.org/x/net/context" ) type node struct { diff --git a/raft/rafttest/node_bench_test.go b/raft/rafttest/node_bench_test.go index 1aa13c7b637..17cce676721 100644 --- a/raft/rafttest/node_bench_test.go +++ b/raft/rafttest/node_bench_test.go @@ -15,11 +15,11 @@ package rafttest import ( + "context" "testing" "time" "github.com/coreos/etcd/raft" - "golang.org/x/net/context" ) func BenchmarkProposal3Nodes(b *testing.B) { diff --git a/raft/rafttest/node_test.go b/raft/rafttest/node_test.go index c4f98de22b3..6a81c8b4f3e 100644 --- a/raft/rafttest/node_test.go +++ b/raft/rafttest/node_test.go @@ -15,11 +15,11 @@ package rafttest import ( + "context" "testing" "time" "github.com/coreos/etcd/raft" - "golang.org/x/net/context" ) func TestBasicProgress(t *testing.T) { diff --git a/rafthttp/functional_test.go b/rafthttp/functional_test.go index b4f04d3ebba..2a04a91cdce 100644 --- a/rafthttp/functional_test.go +++ b/rafthttp/functional_test.go @@ -15,6 +15,7 @@ package rafthttp import ( + "context" "net/http/httptest" "reflect" "testing" @@ -24,7 +25,6 @@ import ( "github.com/coreos/etcd/pkg/types" "github.com/coreos/etcd/raft" "github.com/coreos/etcd/raft/raftpb" - "golang.org/x/net/context" ) func TestSendMessage(t *testing.T) { diff --git a/rafthttp/http.go b/rafthttp/http.go index 55df26e9b75..d99832d89e9 100644 --- a/rafthttp/http.go +++ b/rafthttp/http.go @@ -15,6 +15,7 @@ package rafthttp import ( + "context" "errors" "fmt" "io/ioutil" @@ -27,7 +28,6 @@ import ( "github.com/coreos/etcd/raft/raftpb" "github.com/coreos/etcd/snap" "github.com/coreos/etcd/version" - "golang.org/x/net/context" ) const ( diff --git a/rafthttp/peer.go b/rafthttp/peer.go index b8de635aa83..9aee4dbc919 100644 --- a/rafthttp/peer.go +++ b/rafthttp/peer.go @@ -15,6 +15,7 @@ package rafthttp import ( + "context" "sync" "time" @@ -23,7 +24,7 @@ import ( "github.com/coreos/etcd/raft" "github.com/coreos/etcd/raft/raftpb" "github.com/coreos/etcd/snap" - "golang.org/x/net/context" + "golang.org/x/time/rate" ) diff --git a/rafthttp/transport.go b/rafthttp/transport.go index 50219db71b9..78f92dd2172 100644 --- a/rafthttp/transport.go +++ b/rafthttp/transport.go @@ -15,6 +15,7 @@ package rafthttp import ( + "context" "net/http" "sync" "time" @@ -26,9 +27,9 @@ import ( "github.com/coreos/etcd/raft" "github.com/coreos/etcd/raft/raftpb" "github.com/coreos/etcd/snap" + "github.com/coreos/pkg/capnslog" "github.com/xiang90/probing" - "golang.org/x/net/context" "golang.org/x/time/rate" ) diff --git a/rafthttp/transport_bench_test.go b/rafthttp/transport_bench_test.go index 620e0dbf711..cd586461fb4 100644 --- a/rafthttp/transport_bench_test.go +++ b/rafthttp/transport_bench_test.go @@ -15,6 +15,7 @@ package rafthttp import ( + "context" "net/http/httptest" "sync" "testing" @@ -24,7 +25,6 @@ import ( "github.com/coreos/etcd/pkg/types" "github.com/coreos/etcd/raft" "github.com/coreos/etcd/raft/raftpb" - "golang.org/x/net/context" ) func BenchmarkSendingMsgApp(b *testing.B) { diff --git a/tools/functional-tester/etcd-tester/checks.go b/tools/functional-tester/etcd-tester/checks.go index f3c5de9b460..81a659ac24c 100644 --- a/tools/functional-tester/etcd-tester/checks.go +++ b/tools/functional-tester/etcd-tester/checks.go @@ -15,15 +15,15 @@ package main import ( + "context" "fmt" "time" - "google.golang.org/grpc" - "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" + + "google.golang.org/grpc" ) const ( diff --git a/tools/functional-tester/etcd-tester/cluster.go b/tools/functional-tester/etcd-tester/cluster.go index 61f36f0c99b..5f6e001a6c8 100644 --- a/tools/functional-tester/etcd-tester/cluster.go +++ b/tools/functional-tester/etcd-tester/cluster.go @@ -15,16 +15,16 @@ package main import ( + "context" "fmt" "math/rand" "net" "strings" "time" - "golang.org/x/net/context" - pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/tools/functional-tester/etcd-agent/client" + "google.golang.org/grpc" ) diff --git a/tools/functional-tester/etcd-tester/key_stresser.go b/tools/functional-tester/etcd-tester/key_stresser.go index 1e351b7e10e..d94a7c7bfdc 100644 --- a/tools/functional-tester/etcd-tester/key_stresser.go +++ b/tools/functional-tester/etcd-tester/key_stresser.go @@ -15,20 +15,20 @@ package main import ( + "context" "fmt" "math/rand" "sync" "sync/atomic" "time" - "golang.org/x/net/context" // grpc does a comparison on context.Cancel; can't use "context" package - "golang.org/x/time/rate" - "google.golang.org/grpc" - "google.golang.org/grpc/transport" - "github.com/coreos/etcd/etcdserver" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" + + "golang.org/x/time/rate" + "google.golang.org/grpc" + "google.golang.org/grpc/transport" ) type keyStresser struct { diff --git a/tools/functional-tester/etcd-tester/lease_stresser.go b/tools/functional-tester/etcd-tester/lease_stresser.go index 0767ccc2b5c..1ca788410c4 100644 --- a/tools/functional-tester/etcd-tester/lease_stresser.go +++ b/tools/functional-tester/etcd-tester/lease_stresser.go @@ -15,16 +15,16 @@ package main import ( + "context" "fmt" "math/rand" "sync" "sync/atomic" - "time" "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" - "golang.org/x/net/context" + "golang.org/x/time/rate" "google.golang.org/grpc" ) diff --git a/tools/functional-tester/etcd-tester/member.go b/tools/functional-tester/etcd-tester/member.go index 7954e534ce9..64aa5ca1278 100644 --- a/tools/functional-tester/etcd-tester/member.go +++ b/tools/functional-tester/etcd-tester/member.go @@ -15,17 +15,17 @@ package main import ( + "context" "fmt" "net" "net/url" "time" - "golang.org/x/net/context" - "google.golang.org/grpc" - "github.com/coreos/etcd/clientv3" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/tools/functional-tester/etcd-agent/client" + + "google.golang.org/grpc" ) type member struct { From 887a0585e6e7478b5925964c5dafd3833ff22e83 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Wed, 6 Sep 2017 15:01:51 -0700 Subject: [PATCH 2/5] vendor: upgrade 'golang.org/x/net' with type alias Use Go 1.9 type alias. Signed-off-by: Gyu-Ho Lee --- .../golang.org/x/net/context/context.go | 102 --- cmd/vendor/golang.org/x/net/context/go19.go | 20 + .../golang.org/x/net/context/pre_go19.go | 109 +++ cmd/vendor/golang.org/x/net/http2/ciphers.go | 641 ++++++++++++++++++ .../x/net/http2/configure_transport.go | 2 +- cmd/vendor/golang.org/x/net/http2/errors.go | 13 +- cmd/vendor/golang.org/x/net/http2/go16.go | 27 - cmd/vendor/golang.org/x/net/http2/go18.go | 2 + cmd/vendor/golang.org/x/net/http2/go19.go | 16 + .../golang.org/x/net/http2/hpack/tables.go | 131 ++-- cmd/vendor/golang.org/x/net/http2/http2.go | 8 +- cmd/vendor/golang.org/x/net/http2/not_go16.go | 25 - cmd/vendor/golang.org/x/net/http2/not_go18.go | 2 + cmd/vendor/golang.org/x/net/http2/not_go19.go | 16 + cmd/vendor/golang.org/x/net/http2/pipe.go | 16 +- cmd/vendor/golang.org/x/net/http2/server.go | 221 ++++-- .../golang.org/x/net/http2/transport.go | 437 ++++++++---- .../x/net/http2/writesched_priority.go | 2 +- cmd/vendor/golang.org/x/net/idna/idna.go | 64 +- cmd/vendor/golang.org/x/net/trace/events.go | 6 +- cmd/vendor/golang.org/x/net/trace/trace.go | 71 +- .../golang.org/x/net/trace/trace_go16.go | 21 + .../golang.org/x/net/trace/trace_go17.go | 21 + glide.lock | 8 +- glide.yaml | 2 +- 25 files changed, 1468 insertions(+), 515 deletions(-) create mode 100644 cmd/vendor/golang.org/x/net/context/go19.go create mode 100644 cmd/vendor/golang.org/x/net/context/pre_go19.go create mode 100644 cmd/vendor/golang.org/x/net/http2/ciphers.go create mode 100644 cmd/vendor/golang.org/x/net/http2/go19.go create mode 100644 cmd/vendor/golang.org/x/net/http2/not_go19.go create mode 100644 cmd/vendor/golang.org/x/net/trace/trace_go16.go create mode 100644 cmd/vendor/golang.org/x/net/trace/trace_go17.go diff --git a/cmd/vendor/golang.org/x/net/context/context.go b/cmd/vendor/golang.org/x/net/context/context.go index f143ed6a1eb..d3681ab428c 100644 --- a/cmd/vendor/golang.org/x/net/context/context.go +++ b/cmd/vendor/golang.org/x/net/context/context.go @@ -36,103 +36,6 @@ // Contexts. package context // import "golang.org/x/net/context" -import "time" - -// A Context carries a deadline, a cancelation signal, and other values across -// API boundaries. -// -// Context's methods may be called by multiple goroutines simultaneously. -type Context interface { - // Deadline returns the time when work done on behalf of this context - // should be canceled. Deadline returns ok==false when no deadline is - // set. Successive calls to Deadline return the same results. - Deadline() (deadline time.Time, ok bool) - - // Done returns a channel that's closed when work done on behalf of this - // context should be canceled. Done may return nil if this context can - // never be canceled. Successive calls to Done return the same value. - // - // WithCancel arranges for Done to be closed when cancel is called; - // WithDeadline arranges for Done to be closed when the deadline - // expires; WithTimeout arranges for Done to be closed when the timeout - // elapses. - // - // Done is provided for use in select statements: - // - // // Stream generates values with DoSomething and sends them to out - // // until DoSomething returns an error or ctx.Done is closed. - // func Stream(ctx context.Context, out chan<- Value) error { - // for { - // v, err := DoSomething(ctx) - // if err != nil { - // return err - // } - // select { - // case <-ctx.Done(): - // return ctx.Err() - // case out <- v: - // } - // } - // } - // - // See http://blog.golang.org/pipelines for more examples of how to use - // a Done channel for cancelation. - Done() <-chan struct{} - - // Err returns a non-nil error value after Done is closed. Err returns - // Canceled if the context was canceled or DeadlineExceeded if the - // context's deadline passed. No other values for Err are defined. - // After Done is closed, successive calls to Err return the same value. - Err() error - - // Value returns the value associated with this context for key, or nil - // if no value is associated with key. Successive calls to Value with - // the same key returns the same result. - // - // Use context values only for request-scoped data that transits - // processes and API boundaries, not for passing optional parameters to - // functions. - // - // A key identifies a specific value in a Context. Functions that wish - // to store values in Context typically allocate a key in a global - // variable then use that key as the argument to context.WithValue and - // Context.Value. A key can be any type that supports equality; - // packages should define keys as an unexported type to avoid - // collisions. - // - // Packages that define a Context key should provide type-safe accessors - // for the values stores using that key: - // - // // Package user defines a User type that's stored in Contexts. - // package user - // - // import "golang.org/x/net/context" - // - // // User is the type of value stored in the Contexts. - // type User struct {...} - // - // // key is an unexported type for keys defined in this package. - // // This prevents collisions with keys defined in other packages. - // type key int - // - // // userKey is the key for user.User values in Contexts. It is - // // unexported; clients use user.NewContext and user.FromContext - // // instead of using this key directly. - // var userKey key = 0 - // - // // NewContext returns a new Context that carries value u. - // func NewContext(ctx context.Context, u *User) context.Context { - // return context.WithValue(ctx, userKey, u) - // } - // - // // FromContext returns the User value stored in ctx, if any. - // func FromContext(ctx context.Context) (*User, bool) { - // u, ok := ctx.Value(userKey).(*User) - // return u, ok - // } - Value(key interface{}) interface{} -} - // Background returns a non-nil, empty Context. It is never canceled, has no // values, and has no deadline. It is typically used by the main function, // initialization, and tests, and as the top-level Context for incoming @@ -149,8 +52,3 @@ func Background() Context { func TODO() Context { return todo } - -// A CancelFunc tells an operation to abandon its work. -// A CancelFunc does not wait for the work to stop. -// After the first call, subsequent calls to a CancelFunc do nothing. -type CancelFunc func() diff --git a/cmd/vendor/golang.org/x/net/context/go19.go b/cmd/vendor/golang.org/x/net/context/go19.go new file mode 100644 index 00000000000..d88bd1db127 --- /dev/null +++ b/cmd/vendor/golang.org/x/net/context/go19.go @@ -0,0 +1,20 @@ +// 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 context + +import "context" // standard library's context, as of Go 1.7 + +// A Context carries a deadline, a cancelation signal, and other values across +// API boundaries. +// +// Context's methods may be called by multiple goroutines simultaneously. +type Context = context.Context + +// A CancelFunc tells an operation to abandon its work. +// A CancelFunc does not wait for the work to stop. +// After the first call, subsequent calls to a CancelFunc do nothing. +type CancelFunc = context.CancelFunc diff --git a/cmd/vendor/golang.org/x/net/context/pre_go19.go b/cmd/vendor/golang.org/x/net/context/pre_go19.go new file mode 100644 index 00000000000..b105f80be4f --- /dev/null +++ b/cmd/vendor/golang.org/x/net/context/pre_go19.go @@ -0,0 +1,109 @@ +// 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 !go1.9 + +package context + +import "time" + +// A Context carries a deadline, a cancelation signal, and other values across +// API boundaries. +// +// Context's methods may be called by multiple goroutines simultaneously. +type Context interface { + // Deadline returns the time when work done on behalf of this context + // should be canceled. Deadline returns ok==false when no deadline is + // set. Successive calls to Deadline return the same results. + Deadline() (deadline time.Time, ok bool) + + // Done returns a channel that's closed when work done on behalf of this + // context should be canceled. Done may return nil if this context can + // never be canceled. Successive calls to Done return the same value. + // + // WithCancel arranges for Done to be closed when cancel is called; + // WithDeadline arranges for Done to be closed when the deadline + // expires; WithTimeout arranges for Done to be closed when the timeout + // elapses. + // + // Done is provided for use in select statements: + // + // // Stream generates values with DoSomething and sends them to out + // // until DoSomething returns an error or ctx.Done is closed. + // func Stream(ctx context.Context, out chan<- Value) error { + // for { + // v, err := DoSomething(ctx) + // if err != nil { + // return err + // } + // select { + // case <-ctx.Done(): + // return ctx.Err() + // case out <- v: + // } + // } + // } + // + // See http://blog.golang.org/pipelines for more examples of how to use + // a Done channel for cancelation. + Done() <-chan struct{} + + // Err returns a non-nil error value after Done is closed. Err returns + // Canceled if the context was canceled or DeadlineExceeded if the + // context's deadline passed. No other values for Err are defined. + // After Done is closed, successive calls to Err return the same value. + Err() error + + // Value returns the value associated with this context for key, or nil + // if no value is associated with key. Successive calls to Value with + // the same key returns the same result. + // + // Use context values only for request-scoped data that transits + // processes and API boundaries, not for passing optional parameters to + // functions. + // + // A key identifies a specific value in a Context. Functions that wish + // to store values in Context typically allocate a key in a global + // variable then use that key as the argument to context.WithValue and + // Context.Value. A key can be any type that supports equality; + // packages should define keys as an unexported type to avoid + // collisions. + // + // Packages that define a Context key should provide type-safe accessors + // for the values stores using that key: + // + // // Package user defines a User type that's stored in Contexts. + // package user + // + // import "golang.org/x/net/context" + // + // // User is the type of value stored in the Contexts. + // type User struct {...} + // + // // key is an unexported type for keys defined in this package. + // // This prevents collisions with keys defined in other packages. + // type key int + // + // // userKey is the key for user.User values in Contexts. It is + // // unexported; clients use user.NewContext and user.FromContext + // // instead of using this key directly. + // var userKey key = 0 + // + // // NewContext returns a new Context that carries value u. + // func NewContext(ctx context.Context, u *User) context.Context { + // return context.WithValue(ctx, userKey, u) + // } + // + // // FromContext returns the User value stored in ctx, if any. + // func FromContext(ctx context.Context) (*User, bool) { + // u, ok := ctx.Value(userKey).(*User) + // return u, ok + // } + Value(key interface{}) interface{} +} + +// A CancelFunc tells an operation to abandon its work. +// A CancelFunc does not wait for the work to stop. +// After the first call, subsequent calls to a CancelFunc do nothing. +type CancelFunc func() diff --git a/cmd/vendor/golang.org/x/net/http2/ciphers.go b/cmd/vendor/golang.org/x/net/http2/ciphers.go new file mode 100644 index 00000000000..698860b7775 --- /dev/null +++ b/cmd/vendor/golang.org/x/net/http2/ciphers.go @@ -0,0 +1,641 @@ +// 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 http2 + +// A list of the possible cipher suite ids. Taken from +// http://www.iana.org/assignments/tls-parameters/tls-parameters.txt + +const ( + cipher_TLS_NULL_WITH_NULL_NULL uint16 = 0x0000 + cipher_TLS_RSA_WITH_NULL_MD5 uint16 = 0x0001 + cipher_TLS_RSA_WITH_NULL_SHA uint16 = 0x0002 + cipher_TLS_RSA_EXPORT_WITH_RC4_40_MD5 uint16 = 0x0003 + cipher_TLS_RSA_WITH_RC4_128_MD5 uint16 = 0x0004 + cipher_TLS_RSA_WITH_RC4_128_SHA uint16 = 0x0005 + cipher_TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 uint16 = 0x0006 + cipher_TLS_RSA_WITH_IDEA_CBC_SHA uint16 = 0x0007 + cipher_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA uint16 = 0x0008 + cipher_TLS_RSA_WITH_DES_CBC_SHA uint16 = 0x0009 + cipher_TLS_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x000A + cipher_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA uint16 = 0x000B + cipher_TLS_DH_DSS_WITH_DES_CBC_SHA uint16 = 0x000C + cipher_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA uint16 = 0x000D + cipher_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA uint16 = 0x000E + cipher_TLS_DH_RSA_WITH_DES_CBC_SHA uint16 = 0x000F + cipher_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x0010 + cipher_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA uint16 = 0x0011 + cipher_TLS_DHE_DSS_WITH_DES_CBC_SHA uint16 = 0x0012 + cipher_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA uint16 = 0x0013 + cipher_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA uint16 = 0x0014 + cipher_TLS_DHE_RSA_WITH_DES_CBC_SHA uint16 = 0x0015 + cipher_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x0016 + cipher_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 uint16 = 0x0017 + cipher_TLS_DH_anon_WITH_RC4_128_MD5 uint16 = 0x0018 + cipher_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA uint16 = 0x0019 + cipher_TLS_DH_anon_WITH_DES_CBC_SHA uint16 = 0x001A + cipher_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA uint16 = 0x001B + // Reserved uint16 = 0x001C-1D + cipher_TLS_KRB5_WITH_DES_CBC_SHA uint16 = 0x001E + cipher_TLS_KRB5_WITH_3DES_EDE_CBC_SHA uint16 = 0x001F + cipher_TLS_KRB5_WITH_RC4_128_SHA uint16 = 0x0020 + cipher_TLS_KRB5_WITH_IDEA_CBC_SHA uint16 = 0x0021 + cipher_TLS_KRB5_WITH_DES_CBC_MD5 uint16 = 0x0022 + cipher_TLS_KRB5_WITH_3DES_EDE_CBC_MD5 uint16 = 0x0023 + cipher_TLS_KRB5_WITH_RC4_128_MD5 uint16 = 0x0024 + cipher_TLS_KRB5_WITH_IDEA_CBC_MD5 uint16 = 0x0025 + cipher_TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA uint16 = 0x0026 + cipher_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA uint16 = 0x0027 + cipher_TLS_KRB5_EXPORT_WITH_RC4_40_SHA uint16 = 0x0028 + cipher_TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 uint16 = 0x0029 + cipher_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5 uint16 = 0x002A + cipher_TLS_KRB5_EXPORT_WITH_RC4_40_MD5 uint16 = 0x002B + cipher_TLS_PSK_WITH_NULL_SHA uint16 = 0x002C + cipher_TLS_DHE_PSK_WITH_NULL_SHA uint16 = 0x002D + cipher_TLS_RSA_PSK_WITH_NULL_SHA uint16 = 0x002E + cipher_TLS_RSA_WITH_AES_128_CBC_SHA uint16 = 0x002F + cipher_TLS_DH_DSS_WITH_AES_128_CBC_SHA uint16 = 0x0030 + cipher_TLS_DH_RSA_WITH_AES_128_CBC_SHA uint16 = 0x0031 + cipher_TLS_DHE_DSS_WITH_AES_128_CBC_SHA uint16 = 0x0032 + cipher_TLS_DHE_RSA_WITH_AES_128_CBC_SHA uint16 = 0x0033 + cipher_TLS_DH_anon_WITH_AES_128_CBC_SHA uint16 = 0x0034 + cipher_TLS_RSA_WITH_AES_256_CBC_SHA uint16 = 0x0035 + cipher_TLS_DH_DSS_WITH_AES_256_CBC_SHA uint16 = 0x0036 + cipher_TLS_DH_RSA_WITH_AES_256_CBC_SHA uint16 = 0x0037 + cipher_TLS_DHE_DSS_WITH_AES_256_CBC_SHA uint16 = 0x0038 + cipher_TLS_DHE_RSA_WITH_AES_256_CBC_SHA uint16 = 0x0039 + cipher_TLS_DH_anon_WITH_AES_256_CBC_SHA uint16 = 0x003A + cipher_TLS_RSA_WITH_NULL_SHA256 uint16 = 0x003B + cipher_TLS_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0x003C + cipher_TLS_RSA_WITH_AES_256_CBC_SHA256 uint16 = 0x003D + cipher_TLS_DH_DSS_WITH_AES_128_CBC_SHA256 uint16 = 0x003E + cipher_TLS_DH_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0x003F + cipher_TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 uint16 = 0x0040 + cipher_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA uint16 = 0x0041 + cipher_TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA uint16 = 0x0042 + cipher_TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA uint16 = 0x0043 + cipher_TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA uint16 = 0x0044 + cipher_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA uint16 = 0x0045 + cipher_TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA uint16 = 0x0046 + // Reserved uint16 = 0x0047-4F + // Reserved uint16 = 0x0050-58 + // Reserved uint16 = 0x0059-5C + // Unassigned uint16 = 0x005D-5F + // Reserved uint16 = 0x0060-66 + cipher_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0x0067 + cipher_TLS_DH_DSS_WITH_AES_256_CBC_SHA256 uint16 = 0x0068 + cipher_TLS_DH_RSA_WITH_AES_256_CBC_SHA256 uint16 = 0x0069 + cipher_TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 uint16 = 0x006A + cipher_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 uint16 = 0x006B + cipher_TLS_DH_anon_WITH_AES_128_CBC_SHA256 uint16 = 0x006C + cipher_TLS_DH_anon_WITH_AES_256_CBC_SHA256 uint16 = 0x006D + // Unassigned uint16 = 0x006E-83 + cipher_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA uint16 = 0x0084 + cipher_TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA uint16 = 0x0085 + cipher_TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA uint16 = 0x0086 + cipher_TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA uint16 = 0x0087 + cipher_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA uint16 = 0x0088 + cipher_TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA uint16 = 0x0089 + cipher_TLS_PSK_WITH_RC4_128_SHA uint16 = 0x008A + cipher_TLS_PSK_WITH_3DES_EDE_CBC_SHA uint16 = 0x008B + cipher_TLS_PSK_WITH_AES_128_CBC_SHA uint16 = 0x008C + cipher_TLS_PSK_WITH_AES_256_CBC_SHA uint16 = 0x008D + cipher_TLS_DHE_PSK_WITH_RC4_128_SHA uint16 = 0x008E + cipher_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA uint16 = 0x008F + cipher_TLS_DHE_PSK_WITH_AES_128_CBC_SHA uint16 = 0x0090 + cipher_TLS_DHE_PSK_WITH_AES_256_CBC_SHA uint16 = 0x0091 + cipher_TLS_RSA_PSK_WITH_RC4_128_SHA uint16 = 0x0092 + cipher_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA uint16 = 0x0093 + cipher_TLS_RSA_PSK_WITH_AES_128_CBC_SHA uint16 = 0x0094 + cipher_TLS_RSA_PSK_WITH_AES_256_CBC_SHA uint16 = 0x0095 + cipher_TLS_RSA_WITH_SEED_CBC_SHA uint16 = 0x0096 + cipher_TLS_DH_DSS_WITH_SEED_CBC_SHA uint16 = 0x0097 + cipher_TLS_DH_RSA_WITH_SEED_CBC_SHA uint16 = 0x0098 + cipher_TLS_DHE_DSS_WITH_SEED_CBC_SHA uint16 = 0x0099 + cipher_TLS_DHE_RSA_WITH_SEED_CBC_SHA uint16 = 0x009A + cipher_TLS_DH_anon_WITH_SEED_CBC_SHA uint16 = 0x009B + cipher_TLS_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0x009C + cipher_TLS_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0x009D + cipher_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0x009E + cipher_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0x009F + cipher_TLS_DH_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0x00A0 + cipher_TLS_DH_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0x00A1 + cipher_TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 uint16 = 0x00A2 + cipher_TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 uint16 = 0x00A3 + cipher_TLS_DH_DSS_WITH_AES_128_GCM_SHA256 uint16 = 0x00A4 + cipher_TLS_DH_DSS_WITH_AES_256_GCM_SHA384 uint16 = 0x00A5 + cipher_TLS_DH_anon_WITH_AES_128_GCM_SHA256 uint16 = 0x00A6 + cipher_TLS_DH_anon_WITH_AES_256_GCM_SHA384 uint16 = 0x00A7 + cipher_TLS_PSK_WITH_AES_128_GCM_SHA256 uint16 = 0x00A8 + cipher_TLS_PSK_WITH_AES_256_GCM_SHA384 uint16 = 0x00A9 + cipher_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 uint16 = 0x00AA + cipher_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 uint16 = 0x00AB + cipher_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 uint16 = 0x00AC + cipher_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 uint16 = 0x00AD + cipher_TLS_PSK_WITH_AES_128_CBC_SHA256 uint16 = 0x00AE + cipher_TLS_PSK_WITH_AES_256_CBC_SHA384 uint16 = 0x00AF + cipher_TLS_PSK_WITH_NULL_SHA256 uint16 = 0x00B0 + cipher_TLS_PSK_WITH_NULL_SHA384 uint16 = 0x00B1 + cipher_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 uint16 = 0x00B2 + cipher_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 uint16 = 0x00B3 + cipher_TLS_DHE_PSK_WITH_NULL_SHA256 uint16 = 0x00B4 + cipher_TLS_DHE_PSK_WITH_NULL_SHA384 uint16 = 0x00B5 + cipher_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 uint16 = 0x00B6 + cipher_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 uint16 = 0x00B7 + cipher_TLS_RSA_PSK_WITH_NULL_SHA256 uint16 = 0x00B8 + cipher_TLS_RSA_PSK_WITH_NULL_SHA384 uint16 = 0x00B9 + cipher_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0x00BA + cipher_TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0x00BB + cipher_TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0x00BC + cipher_TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0x00BD + cipher_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0x00BE + cipher_TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0x00BF + cipher_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 uint16 = 0x00C0 + cipher_TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 uint16 = 0x00C1 + cipher_TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 uint16 = 0x00C2 + cipher_TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 uint16 = 0x00C3 + cipher_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 uint16 = 0x00C4 + cipher_TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256 uint16 = 0x00C5 + // Unassigned uint16 = 0x00C6-FE + cipher_TLS_EMPTY_RENEGOTIATION_INFO_SCSV uint16 = 0x00FF + // Unassigned uint16 = 0x01-55,* + cipher_TLS_FALLBACK_SCSV uint16 = 0x5600 + // Unassigned uint16 = 0x5601 - 0xC000 + cipher_TLS_ECDH_ECDSA_WITH_NULL_SHA uint16 = 0xC001 + cipher_TLS_ECDH_ECDSA_WITH_RC4_128_SHA uint16 = 0xC002 + cipher_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xC003 + cipher_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA uint16 = 0xC004 + cipher_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA uint16 = 0xC005 + cipher_TLS_ECDHE_ECDSA_WITH_NULL_SHA uint16 = 0xC006 + cipher_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA uint16 = 0xC007 + cipher_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xC008 + cipher_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA uint16 = 0xC009 + cipher_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA uint16 = 0xC00A + cipher_TLS_ECDH_RSA_WITH_NULL_SHA uint16 = 0xC00B + cipher_TLS_ECDH_RSA_WITH_RC4_128_SHA uint16 = 0xC00C + cipher_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xC00D + cipher_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA uint16 = 0xC00E + cipher_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA uint16 = 0xC00F + cipher_TLS_ECDHE_RSA_WITH_NULL_SHA uint16 = 0xC010 + cipher_TLS_ECDHE_RSA_WITH_RC4_128_SHA uint16 = 0xC011 + cipher_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xC012 + cipher_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA uint16 = 0xC013 + cipher_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA uint16 = 0xC014 + cipher_TLS_ECDH_anon_WITH_NULL_SHA uint16 = 0xC015 + cipher_TLS_ECDH_anon_WITH_RC4_128_SHA uint16 = 0xC016 + cipher_TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA uint16 = 0xC017 + cipher_TLS_ECDH_anon_WITH_AES_128_CBC_SHA uint16 = 0xC018 + cipher_TLS_ECDH_anon_WITH_AES_256_CBC_SHA uint16 = 0xC019 + cipher_TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA uint16 = 0xC01A + cipher_TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xC01B + cipher_TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA uint16 = 0xC01C + cipher_TLS_SRP_SHA_WITH_AES_128_CBC_SHA uint16 = 0xC01D + cipher_TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA uint16 = 0xC01E + cipher_TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA uint16 = 0xC01F + cipher_TLS_SRP_SHA_WITH_AES_256_CBC_SHA uint16 = 0xC020 + cipher_TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA uint16 = 0xC021 + cipher_TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA uint16 = 0xC022 + cipher_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 uint16 = 0xC023 + cipher_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 uint16 = 0xC024 + cipher_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 uint16 = 0xC025 + cipher_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 uint16 = 0xC026 + cipher_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0xC027 + cipher_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 uint16 = 0xC028 + cipher_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0xC029 + cipher_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 uint16 = 0xC02A + cipher_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 uint16 = 0xC02B + cipher_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 uint16 = 0xC02C + cipher_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 uint16 = 0xC02D + cipher_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 uint16 = 0xC02E + cipher_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0xC02F + cipher_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0xC030 + cipher_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0xC031 + cipher_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0xC032 + cipher_TLS_ECDHE_PSK_WITH_RC4_128_SHA uint16 = 0xC033 + cipher_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA uint16 = 0xC034 + cipher_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA uint16 = 0xC035 + cipher_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA uint16 = 0xC036 + cipher_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 uint16 = 0xC037 + cipher_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 uint16 = 0xC038 + cipher_TLS_ECDHE_PSK_WITH_NULL_SHA uint16 = 0xC039 + cipher_TLS_ECDHE_PSK_WITH_NULL_SHA256 uint16 = 0xC03A + cipher_TLS_ECDHE_PSK_WITH_NULL_SHA384 uint16 = 0xC03B + cipher_TLS_RSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC03C + cipher_TLS_RSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC03D + cipher_TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC03E + cipher_TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC03F + cipher_TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC040 + cipher_TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC041 + cipher_TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC042 + cipher_TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC043 + cipher_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC044 + cipher_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC045 + cipher_TLS_DH_anon_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC046 + cipher_TLS_DH_anon_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC047 + cipher_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC048 + cipher_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC049 + cipher_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC04A + cipher_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC04B + cipher_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC04C + cipher_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC04D + cipher_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC04E + cipher_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC04F + cipher_TLS_RSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC050 + cipher_TLS_RSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC051 + cipher_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC052 + cipher_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC053 + cipher_TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC054 + cipher_TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC055 + cipher_TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC056 + cipher_TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC057 + cipher_TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC058 + cipher_TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC059 + cipher_TLS_DH_anon_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC05A + cipher_TLS_DH_anon_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC05B + cipher_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC05C + cipher_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC05D + cipher_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC05E + cipher_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC05F + cipher_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC060 + cipher_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC061 + cipher_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC062 + cipher_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC063 + cipher_TLS_PSK_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC064 + cipher_TLS_PSK_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC065 + cipher_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC066 + cipher_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC067 + cipher_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC068 + cipher_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC069 + cipher_TLS_PSK_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC06A + cipher_TLS_PSK_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC06B + cipher_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC06C + cipher_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC06D + cipher_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 uint16 = 0xC06E + cipher_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 uint16 = 0xC06F + cipher_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 uint16 = 0xC070 + cipher_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 uint16 = 0xC071 + cipher_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC072 + cipher_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC073 + cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC074 + cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC075 + cipher_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC076 + cipher_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC077 + cipher_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC078 + cipher_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC079 + cipher_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC07A + cipher_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC07B + cipher_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC07C + cipher_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC07D + cipher_TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC07E + cipher_TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC07F + cipher_TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC080 + cipher_TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC081 + cipher_TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC082 + cipher_TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC083 + cipher_TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC084 + cipher_TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC085 + cipher_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC086 + cipher_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC087 + cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC088 + cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC089 + cipher_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC08A + cipher_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC08B + cipher_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC08C + cipher_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC08D + cipher_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC08E + cipher_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC08F + cipher_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC090 + cipher_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC091 + cipher_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 uint16 = 0xC092 + cipher_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 uint16 = 0xC093 + cipher_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC094 + cipher_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC095 + cipher_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC096 + cipher_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC097 + cipher_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC098 + cipher_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC099 + cipher_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 uint16 = 0xC09A + cipher_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 uint16 = 0xC09B + cipher_TLS_RSA_WITH_AES_128_CCM uint16 = 0xC09C + cipher_TLS_RSA_WITH_AES_256_CCM uint16 = 0xC09D + cipher_TLS_DHE_RSA_WITH_AES_128_CCM uint16 = 0xC09E + cipher_TLS_DHE_RSA_WITH_AES_256_CCM uint16 = 0xC09F + cipher_TLS_RSA_WITH_AES_128_CCM_8 uint16 = 0xC0A0 + cipher_TLS_RSA_WITH_AES_256_CCM_8 uint16 = 0xC0A1 + cipher_TLS_DHE_RSA_WITH_AES_128_CCM_8 uint16 = 0xC0A2 + cipher_TLS_DHE_RSA_WITH_AES_256_CCM_8 uint16 = 0xC0A3 + cipher_TLS_PSK_WITH_AES_128_CCM uint16 = 0xC0A4 + cipher_TLS_PSK_WITH_AES_256_CCM uint16 = 0xC0A5 + cipher_TLS_DHE_PSK_WITH_AES_128_CCM uint16 = 0xC0A6 + cipher_TLS_DHE_PSK_WITH_AES_256_CCM uint16 = 0xC0A7 + cipher_TLS_PSK_WITH_AES_128_CCM_8 uint16 = 0xC0A8 + cipher_TLS_PSK_WITH_AES_256_CCM_8 uint16 = 0xC0A9 + cipher_TLS_PSK_DHE_WITH_AES_128_CCM_8 uint16 = 0xC0AA + cipher_TLS_PSK_DHE_WITH_AES_256_CCM_8 uint16 = 0xC0AB + cipher_TLS_ECDHE_ECDSA_WITH_AES_128_CCM uint16 = 0xC0AC + cipher_TLS_ECDHE_ECDSA_WITH_AES_256_CCM uint16 = 0xC0AD + cipher_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 uint16 = 0xC0AE + cipher_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 uint16 = 0xC0AF + // Unassigned uint16 = 0xC0B0-FF + // Unassigned uint16 = 0xC1-CB,* + // Unassigned uint16 = 0xCC00-A7 + cipher_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCA8 + cipher_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCA9 + cipher_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCAA + cipher_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCAB + cipher_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCAC + cipher_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCAD + cipher_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256 uint16 = 0xCCAE +) + +// isBadCipher reports whether the cipher is blacklisted by the HTTP/2 spec. +// References: +// https://tools.ietf.org/html/rfc7540#appendix-A +// Reject cipher suites from Appendix A. +// "This list includes those cipher suites that do not +// offer an ephemeral key exchange and those that are +// based on the TLS null, stream or block cipher type" +func isBadCipher(cipher uint16) bool { + switch cipher { + case cipher_TLS_NULL_WITH_NULL_NULL, + cipher_TLS_RSA_WITH_NULL_MD5, + cipher_TLS_RSA_WITH_NULL_SHA, + cipher_TLS_RSA_EXPORT_WITH_RC4_40_MD5, + cipher_TLS_RSA_WITH_RC4_128_MD5, + cipher_TLS_RSA_WITH_RC4_128_SHA, + cipher_TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5, + cipher_TLS_RSA_WITH_IDEA_CBC_SHA, + cipher_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA, + cipher_TLS_RSA_WITH_DES_CBC_SHA, + cipher_TLS_RSA_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA, + cipher_TLS_DH_DSS_WITH_DES_CBC_SHA, + cipher_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA, + cipher_TLS_DH_RSA_WITH_DES_CBC_SHA, + cipher_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, + cipher_TLS_DHE_DSS_WITH_DES_CBC_SHA, + cipher_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, + cipher_TLS_DHE_RSA_WITH_DES_CBC_SHA, + cipher_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5, + cipher_TLS_DH_anon_WITH_RC4_128_MD5, + cipher_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA, + cipher_TLS_DH_anon_WITH_DES_CBC_SHA, + cipher_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_KRB5_WITH_DES_CBC_SHA, + cipher_TLS_KRB5_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_KRB5_WITH_RC4_128_SHA, + cipher_TLS_KRB5_WITH_IDEA_CBC_SHA, + cipher_TLS_KRB5_WITH_DES_CBC_MD5, + cipher_TLS_KRB5_WITH_3DES_EDE_CBC_MD5, + cipher_TLS_KRB5_WITH_RC4_128_MD5, + cipher_TLS_KRB5_WITH_IDEA_CBC_MD5, + cipher_TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA, + cipher_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA, + cipher_TLS_KRB5_EXPORT_WITH_RC4_40_SHA, + cipher_TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5, + cipher_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5, + cipher_TLS_KRB5_EXPORT_WITH_RC4_40_MD5, + cipher_TLS_PSK_WITH_NULL_SHA, + cipher_TLS_DHE_PSK_WITH_NULL_SHA, + cipher_TLS_RSA_PSK_WITH_NULL_SHA, + cipher_TLS_RSA_WITH_AES_128_CBC_SHA, + cipher_TLS_DH_DSS_WITH_AES_128_CBC_SHA, + cipher_TLS_DH_RSA_WITH_AES_128_CBC_SHA, + cipher_TLS_DHE_DSS_WITH_AES_128_CBC_SHA, + cipher_TLS_DHE_RSA_WITH_AES_128_CBC_SHA, + cipher_TLS_DH_anon_WITH_AES_128_CBC_SHA, + cipher_TLS_RSA_WITH_AES_256_CBC_SHA, + cipher_TLS_DH_DSS_WITH_AES_256_CBC_SHA, + cipher_TLS_DH_RSA_WITH_AES_256_CBC_SHA, + cipher_TLS_DHE_DSS_WITH_AES_256_CBC_SHA, + cipher_TLS_DHE_RSA_WITH_AES_256_CBC_SHA, + cipher_TLS_DH_anon_WITH_AES_256_CBC_SHA, + cipher_TLS_RSA_WITH_NULL_SHA256, + cipher_TLS_RSA_WITH_AES_128_CBC_SHA256, + cipher_TLS_RSA_WITH_AES_256_CBC_SHA256, + cipher_TLS_DH_DSS_WITH_AES_128_CBC_SHA256, + cipher_TLS_DH_RSA_WITH_AES_128_CBC_SHA256, + cipher_TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, + cipher_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA, + cipher_TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA, + cipher_TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA, + cipher_TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA, + cipher_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA, + cipher_TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA, + cipher_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, + cipher_TLS_DH_DSS_WITH_AES_256_CBC_SHA256, + cipher_TLS_DH_RSA_WITH_AES_256_CBC_SHA256, + cipher_TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, + cipher_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, + cipher_TLS_DH_anon_WITH_AES_128_CBC_SHA256, + cipher_TLS_DH_anon_WITH_AES_256_CBC_SHA256, + cipher_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA, + cipher_TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA, + cipher_TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA, + cipher_TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA, + cipher_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA, + cipher_TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA, + cipher_TLS_PSK_WITH_RC4_128_SHA, + cipher_TLS_PSK_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_PSK_WITH_AES_128_CBC_SHA, + cipher_TLS_PSK_WITH_AES_256_CBC_SHA, + cipher_TLS_DHE_PSK_WITH_RC4_128_SHA, + cipher_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_DHE_PSK_WITH_AES_128_CBC_SHA, + cipher_TLS_DHE_PSK_WITH_AES_256_CBC_SHA, + cipher_TLS_RSA_PSK_WITH_RC4_128_SHA, + cipher_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_RSA_PSK_WITH_AES_128_CBC_SHA, + cipher_TLS_RSA_PSK_WITH_AES_256_CBC_SHA, + cipher_TLS_RSA_WITH_SEED_CBC_SHA, + cipher_TLS_DH_DSS_WITH_SEED_CBC_SHA, + cipher_TLS_DH_RSA_WITH_SEED_CBC_SHA, + cipher_TLS_DHE_DSS_WITH_SEED_CBC_SHA, + cipher_TLS_DHE_RSA_WITH_SEED_CBC_SHA, + cipher_TLS_DH_anon_WITH_SEED_CBC_SHA, + cipher_TLS_RSA_WITH_AES_128_GCM_SHA256, + cipher_TLS_RSA_WITH_AES_256_GCM_SHA384, + cipher_TLS_DH_RSA_WITH_AES_128_GCM_SHA256, + cipher_TLS_DH_RSA_WITH_AES_256_GCM_SHA384, + cipher_TLS_DH_DSS_WITH_AES_128_GCM_SHA256, + cipher_TLS_DH_DSS_WITH_AES_256_GCM_SHA384, + cipher_TLS_DH_anon_WITH_AES_128_GCM_SHA256, + cipher_TLS_DH_anon_WITH_AES_256_GCM_SHA384, + cipher_TLS_PSK_WITH_AES_128_GCM_SHA256, + cipher_TLS_PSK_WITH_AES_256_GCM_SHA384, + cipher_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256, + cipher_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384, + cipher_TLS_PSK_WITH_AES_128_CBC_SHA256, + cipher_TLS_PSK_WITH_AES_256_CBC_SHA384, + cipher_TLS_PSK_WITH_NULL_SHA256, + cipher_TLS_PSK_WITH_NULL_SHA384, + cipher_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256, + cipher_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384, + cipher_TLS_DHE_PSK_WITH_NULL_SHA256, + cipher_TLS_DHE_PSK_WITH_NULL_SHA384, + cipher_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256, + cipher_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384, + cipher_TLS_RSA_PSK_WITH_NULL_SHA256, + cipher_TLS_RSA_PSK_WITH_NULL_SHA384, + cipher_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256, + cipher_TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256, + cipher_TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256, + cipher_TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256, + cipher_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256, + cipher_TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256, + cipher_TLS_EMPTY_RENEGOTIATION_INFO_SCSV, + cipher_TLS_ECDH_ECDSA_WITH_NULL_SHA, + cipher_TLS_ECDH_ECDSA_WITH_RC4_128_SHA, + cipher_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, + cipher_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, + cipher_TLS_ECDHE_ECDSA_WITH_NULL_SHA, + cipher_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, + cipher_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + cipher_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, + cipher_TLS_ECDH_RSA_WITH_NULL_SHA, + cipher_TLS_ECDH_RSA_WITH_RC4_128_SHA, + cipher_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, + cipher_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, + cipher_TLS_ECDHE_RSA_WITH_NULL_SHA, + cipher_TLS_ECDHE_RSA_WITH_RC4_128_SHA, + cipher_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + cipher_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, + cipher_TLS_ECDH_anon_WITH_NULL_SHA, + cipher_TLS_ECDH_anon_WITH_RC4_128_SHA, + cipher_TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_ECDH_anon_WITH_AES_128_CBC_SHA, + cipher_TLS_ECDH_anon_WITH_AES_256_CBC_SHA, + cipher_TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_SRP_SHA_WITH_AES_128_CBC_SHA, + cipher_TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA, + cipher_TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA, + cipher_TLS_SRP_SHA_WITH_AES_256_CBC_SHA, + cipher_TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA, + cipher_TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA, + cipher_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, + cipher_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, + cipher_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, + cipher_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, + cipher_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, + cipher_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, + cipher_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, + cipher_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, + cipher_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, + cipher_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, + cipher_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, + cipher_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, + cipher_TLS_ECDHE_PSK_WITH_RC4_128_SHA, + cipher_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA, + cipher_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA, + cipher_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA, + cipher_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256, + cipher_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384, + cipher_TLS_ECDHE_PSK_WITH_NULL_SHA, + cipher_TLS_ECDHE_PSK_WITH_NULL_SHA256, + cipher_TLS_ECDHE_PSK_WITH_NULL_SHA384, + cipher_TLS_RSA_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_RSA_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_DH_anon_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_DH_anon_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_RSA_WITH_ARIA_128_GCM_SHA256, + cipher_TLS_RSA_WITH_ARIA_256_GCM_SHA384, + cipher_TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256, + cipher_TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384, + cipher_TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256, + cipher_TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384, + cipher_TLS_DH_anon_WITH_ARIA_128_GCM_SHA256, + cipher_TLS_DH_anon_WITH_ARIA_256_GCM_SHA384, + cipher_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256, + cipher_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384, + cipher_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256, + cipher_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384, + cipher_TLS_PSK_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_PSK_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_PSK_WITH_ARIA_128_GCM_SHA256, + cipher_TLS_PSK_WITH_ARIA_256_GCM_SHA384, + cipher_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256, + cipher_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384, + cipher_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256, + cipher_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384, + cipher_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, + cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, + cipher_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384, + cipher_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384, + cipher_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256, + cipher_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384, + cipher_TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256, + cipher_TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384, + cipher_TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256, + cipher_TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384, + cipher_TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256, + cipher_TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384, + cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256, + cipher_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384, + cipher_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256, + cipher_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384, + cipher_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256, + cipher_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384, + cipher_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256, + cipher_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384, + cipher_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384, + cipher_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, + cipher_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384, + cipher_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, + cipher_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, + cipher_TLS_RSA_WITH_AES_128_CCM, + cipher_TLS_RSA_WITH_AES_256_CCM, + cipher_TLS_RSA_WITH_AES_128_CCM_8, + cipher_TLS_RSA_WITH_AES_256_CCM_8, + cipher_TLS_PSK_WITH_AES_128_CCM, + cipher_TLS_PSK_WITH_AES_256_CCM, + cipher_TLS_PSK_WITH_AES_128_CCM_8, + cipher_TLS_PSK_WITH_AES_256_CCM_8: + return true + default: + return false + } +} diff --git a/cmd/vendor/golang.org/x/net/http2/configure_transport.go b/cmd/vendor/golang.org/x/net/http2/configure_transport.go index 4f720f530b0..b65fc6d423d 100644 --- a/cmd/vendor/golang.org/x/net/http2/configure_transport.go +++ b/cmd/vendor/golang.org/x/net/http2/configure_transport.go @@ -56,7 +56,7 @@ func configureTransport(t1 *http.Transport) (*Transport, error) { } // registerHTTPSProtocol calls Transport.RegisterProtocol but -// convering panics into errors. +// converting panics into errors. func registerHTTPSProtocol(t *http.Transport, rt http.RoundTripper) (err error) { defer func() { if e := recover(); e != nil { diff --git a/cmd/vendor/golang.org/x/net/http2/errors.go b/cmd/vendor/golang.org/x/net/http2/errors.go index 20fd7626a56..71f2c463178 100644 --- a/cmd/vendor/golang.org/x/net/http2/errors.go +++ b/cmd/vendor/golang.org/x/net/http2/errors.go @@ -87,13 +87,16 @@ type goAwayFlowError struct{} func (goAwayFlowError) Error() string { return "connection exceeded flow control window size" } -// connErrorReason wraps a ConnectionError with an informative error about why it occurs. - +// connError represents an HTTP/2 ConnectionError error code, along +// with a string (for debugging) explaining why. +// // Errors of this type are only returned by the frame parser functions -// and converted into ConnectionError(ErrCodeProtocol). +// and converted into ConnectionError(Code), after stashing away +// the Reason into the Framer's errDetail field, accessible via +// the (*Framer).ErrorDetail method. type connError struct { - Code ErrCode - Reason string + Code ErrCode // the ConnectionError error code + Reason string // additional reason } func (e connError) Error() string { diff --git a/cmd/vendor/golang.org/x/net/http2/go16.go b/cmd/vendor/golang.org/x/net/http2/go16.go index 2b72855f552..00b2e9e3cf3 100644 --- a/cmd/vendor/golang.org/x/net/http2/go16.go +++ b/cmd/vendor/golang.org/x/net/http2/go16.go @@ -7,7 +7,6 @@ package http2 import ( - "crypto/tls" "net/http" "time" ) @@ -15,29 +14,3 @@ import ( func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { return t1.ExpectContinueTimeout } - -// isBadCipher reports whether the cipher is blacklisted by the HTTP/2 spec. -func isBadCipher(cipher uint16) bool { - switch cipher { - case tls.TLS_RSA_WITH_RC4_128_SHA, - tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_RSA_WITH_AES_128_GCM_SHA256, - tls.TLS_RSA_WITH_AES_256_GCM_SHA384, - tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, - tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: - // Reject cipher suites from Appendix A. - // "This list includes those cipher suites that do not - // offer an ephemeral key exchange and those that are - // based on the TLS null, stream or block cipher type" - return true - default: - return false - } -} diff --git a/cmd/vendor/golang.org/x/net/http2/go18.go b/cmd/vendor/golang.org/x/net/http2/go18.go index 73cc2381f32..4f30d228a88 100644 --- a/cmd/vendor/golang.org/x/net/http2/go18.go +++ b/cmd/vendor/golang.org/x/net/http2/go18.go @@ -52,3 +52,5 @@ func reqGetBody(req *http.Request) func() (io.ReadCloser, error) { func reqBodyIsNoBody(body io.ReadCloser) bool { return body == http.NoBody } + +func go18httpNoBody() io.ReadCloser { return http.NoBody } // for tests only diff --git a/cmd/vendor/golang.org/x/net/http2/go19.go b/cmd/vendor/golang.org/x/net/http2/go19.go new file mode 100644 index 00000000000..38124ba56e2 --- /dev/null +++ b/cmd/vendor/golang.org/x/net/http2/go19.go @@ -0,0 +1,16 @@ +// Copyright 2015 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 http2 + +import ( + "net/http" +) + +func configureServer19(s *http.Server, conf *Server) error { + s.RegisterOnShutdown(conf.state.startGracefulShutdown) + return nil +} diff --git a/cmd/vendor/golang.org/x/net/http2/hpack/tables.go b/cmd/vendor/golang.org/x/net/http2/hpack/tables.go index 31bd5a553f2..a66cfbea69d 100644 --- a/cmd/vendor/golang.org/x/net/http2/hpack/tables.go +++ b/cmd/vendor/golang.org/x/net/http2/hpack/tables.go @@ -125,77 +125,78 @@ func (t *headerFieldTable) idToIndex(id uint64) uint64 { return k + 1 } -func pair(name, value string) HeaderField { - return HeaderField{Name: name, Value: value} -} - // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#appendix-B var staticTable = newStaticTable() +var staticTableEntries = [...]HeaderField{ + {Name: ":authority"}, + {Name: ":method", Value: "GET"}, + {Name: ":method", Value: "POST"}, + {Name: ":path", Value: "/"}, + {Name: ":path", Value: "/index.html"}, + {Name: ":scheme", Value: "http"}, + {Name: ":scheme", Value: "https"}, + {Name: ":status", Value: "200"}, + {Name: ":status", Value: "204"}, + {Name: ":status", Value: "206"}, + {Name: ":status", Value: "304"}, + {Name: ":status", Value: "400"}, + {Name: ":status", Value: "404"}, + {Name: ":status", Value: "500"}, + {Name: "accept-charset"}, + {Name: "accept-encoding", Value: "gzip, deflate"}, + {Name: "accept-language"}, + {Name: "accept-ranges"}, + {Name: "accept"}, + {Name: "access-control-allow-origin"}, + {Name: "age"}, + {Name: "allow"}, + {Name: "authorization"}, + {Name: "cache-control"}, + {Name: "content-disposition"}, + {Name: "content-encoding"}, + {Name: "content-language"}, + {Name: "content-length"}, + {Name: "content-location"}, + {Name: "content-range"}, + {Name: "content-type"}, + {Name: "cookie"}, + {Name: "date"}, + {Name: "etag"}, + {Name: "expect"}, + {Name: "expires"}, + {Name: "from"}, + {Name: "host"}, + {Name: "if-match"}, + {Name: "if-modified-since"}, + {Name: "if-none-match"}, + {Name: "if-range"}, + {Name: "if-unmodified-since"}, + {Name: "last-modified"}, + {Name: "link"}, + {Name: "location"}, + {Name: "max-forwards"}, + {Name: "proxy-authenticate"}, + {Name: "proxy-authorization"}, + {Name: "range"}, + {Name: "referer"}, + {Name: "refresh"}, + {Name: "retry-after"}, + {Name: "server"}, + {Name: "set-cookie"}, + {Name: "strict-transport-security"}, + {Name: "transfer-encoding"}, + {Name: "user-agent"}, + {Name: "vary"}, + {Name: "via"}, + {Name: "www-authenticate"}, +} func newStaticTable() *headerFieldTable { t := &headerFieldTable{} t.init() - t.addEntry(pair(":authority", "")) - t.addEntry(pair(":method", "GET")) - t.addEntry(pair(":method", "POST")) - t.addEntry(pair(":path", "/")) - t.addEntry(pair(":path", "/index.html")) - t.addEntry(pair(":scheme", "http")) - t.addEntry(pair(":scheme", "https")) - t.addEntry(pair(":status", "200")) - t.addEntry(pair(":status", "204")) - t.addEntry(pair(":status", "206")) - t.addEntry(pair(":status", "304")) - t.addEntry(pair(":status", "400")) - t.addEntry(pair(":status", "404")) - t.addEntry(pair(":status", "500")) - t.addEntry(pair("accept-charset", "")) - t.addEntry(pair("accept-encoding", "gzip, deflate")) - t.addEntry(pair("accept-language", "")) - t.addEntry(pair("accept-ranges", "")) - t.addEntry(pair("accept", "")) - t.addEntry(pair("access-control-allow-origin", "")) - t.addEntry(pair("age", "")) - t.addEntry(pair("allow", "")) - t.addEntry(pair("authorization", "")) - t.addEntry(pair("cache-control", "")) - t.addEntry(pair("content-disposition", "")) - t.addEntry(pair("content-encoding", "")) - t.addEntry(pair("content-language", "")) - t.addEntry(pair("content-length", "")) - t.addEntry(pair("content-location", "")) - t.addEntry(pair("content-range", "")) - t.addEntry(pair("content-type", "")) - t.addEntry(pair("cookie", "")) - t.addEntry(pair("date", "")) - t.addEntry(pair("etag", "")) - t.addEntry(pair("expect", "")) - t.addEntry(pair("expires", "")) - t.addEntry(pair("from", "")) - t.addEntry(pair("host", "")) - t.addEntry(pair("if-match", "")) - t.addEntry(pair("if-modified-since", "")) - t.addEntry(pair("if-none-match", "")) - t.addEntry(pair("if-range", "")) - t.addEntry(pair("if-unmodified-since", "")) - t.addEntry(pair("last-modified", "")) - t.addEntry(pair("link", "")) - t.addEntry(pair("location", "")) - t.addEntry(pair("max-forwards", "")) - t.addEntry(pair("proxy-authenticate", "")) - t.addEntry(pair("proxy-authorization", "")) - t.addEntry(pair("range", "")) - t.addEntry(pair("referer", "")) - t.addEntry(pair("refresh", "")) - t.addEntry(pair("retry-after", "")) - t.addEntry(pair("server", "")) - t.addEntry(pair("set-cookie", "")) - t.addEntry(pair("strict-transport-security", "")) - t.addEntry(pair("transfer-encoding", "")) - t.addEntry(pair("user-agent", "")) - t.addEntry(pair("vary", "")) - t.addEntry(pair("via", "")) - t.addEntry(pair("www-authenticate", "")) + for _, e := range staticTableEntries[:] { + t.addEntry(e) + } return t } diff --git a/cmd/vendor/golang.org/x/net/http2/http2.go b/cmd/vendor/golang.org/x/net/http2/http2.go index b6b0f9ad153..d565f40e0c1 100644 --- a/cmd/vendor/golang.org/x/net/http2/http2.go +++ b/cmd/vendor/golang.org/x/net/http2/http2.go @@ -376,12 +376,16 @@ func (s *sorter) SortStrings(ss []string) { // validPseudoPath reports whether v is a valid :path pseudo-header // value. It must be either: // -// *) a non-empty string starting with '/', but not with with "//", +// *) a non-empty string starting with '/' // *) the string '*', for OPTIONS requests. // // For now this is only used a quick check for deciding when to clean // up Opaque URLs before sending requests from the Transport. // See golang.org/issue/16847 +// +// We used to enforce that the path also didn't start with "//", but +// Google's GFE accepts such paths and Chrome sends them, so ignore +// that part of the spec. See golang.org/issue/19103. func validPseudoPath(v string) bool { - return (len(v) > 0 && v[0] == '/' && (len(v) == 1 || v[1] != '/')) || v == "*" + return (len(v) > 0 && v[0] == '/') || v == "*" } diff --git a/cmd/vendor/golang.org/x/net/http2/not_go16.go b/cmd/vendor/golang.org/x/net/http2/not_go16.go index efd2e1282cf..508cebcc4db 100644 --- a/cmd/vendor/golang.org/x/net/http2/not_go16.go +++ b/cmd/vendor/golang.org/x/net/http2/not_go16.go @@ -7,7 +7,6 @@ package http2 import ( - "crypto/tls" "net/http" "time" ) @@ -20,27 +19,3 @@ func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { return 0 } - -// isBadCipher reports whether the cipher is blacklisted by the HTTP/2 spec. -func isBadCipher(cipher uint16) bool { - switch cipher { - case tls.TLS_RSA_WITH_RC4_128_SHA, - tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, - tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: - // Reject cipher suites from Appendix A. - // "This list includes those cipher suites that do not - // offer an ephemeral key exchange and those that are - // based on the TLS null, stream or block cipher type" - return true - default: - return false - } -} diff --git a/cmd/vendor/golang.org/x/net/http2/not_go18.go b/cmd/vendor/golang.org/x/net/http2/not_go18.go index efbf83c32c4..6f8d3f86fa8 100644 --- a/cmd/vendor/golang.org/x/net/http2/not_go18.go +++ b/cmd/vendor/golang.org/x/net/http2/not_go18.go @@ -25,3 +25,5 @@ func reqGetBody(req *http.Request) func() (io.ReadCloser, error) { } func reqBodyIsNoBody(io.ReadCloser) bool { return false } + +func go18httpNoBody() io.ReadCloser { return nil } // for tests only diff --git a/cmd/vendor/golang.org/x/net/http2/not_go19.go b/cmd/vendor/golang.org/x/net/http2/not_go19.go new file mode 100644 index 00000000000..5ae07726b74 --- /dev/null +++ b/cmd/vendor/golang.org/x/net/http2/not_go19.go @@ -0,0 +1,16 @@ +// 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. + +// +build !go1.9 + +package http2 + +import ( + "net/http" +) + +func configureServer19(s *http.Server, conf *Server) error { + // not supported prior to go1.9 + return nil +} diff --git a/cmd/vendor/golang.org/x/net/http2/pipe.go b/cmd/vendor/golang.org/x/net/http2/pipe.go index 914aaf8a7f2..a6140099cb3 100644 --- a/cmd/vendor/golang.org/x/net/http2/pipe.go +++ b/cmd/vendor/golang.org/x/net/http2/pipe.go @@ -15,8 +15,8 @@ import ( // underlying buffer is an interface. (io.Pipe is always unbuffered) type pipe struct { mu sync.Mutex - c sync.Cond // c.L lazily initialized to &p.mu - b pipeBuffer + c sync.Cond // c.L lazily initialized to &p.mu + b pipeBuffer // nil when done reading err error // read error once empty. non-nil means closed. breakErr error // immediate read error (caller doesn't see rest of b) donec chan struct{} // closed on error @@ -32,6 +32,9 @@ type pipeBuffer interface { func (p *pipe) Len() int { p.mu.Lock() defer p.mu.Unlock() + if p.b == nil { + return 0 + } return p.b.Len() } @@ -47,7 +50,7 @@ func (p *pipe) Read(d []byte) (n int, err error) { if p.breakErr != nil { return 0, p.breakErr } - if p.b.Len() > 0 { + if p.b != nil && p.b.Len() > 0 { return p.b.Read(d) } if p.err != nil { @@ -55,6 +58,7 @@ func (p *pipe) Read(d []byte) (n int, err error) { p.readFn() // e.g. copy trailers p.readFn = nil // not sticky like p.err } + p.b = nil return 0, p.err } p.c.Wait() @@ -75,6 +79,9 @@ func (p *pipe) Write(d []byte) (n int, err error) { if p.err != nil { return 0, errClosedPipeWrite } + if p.breakErr != nil { + return len(d), nil // discard when there is no reader + } return p.b.Write(d) } @@ -109,6 +116,9 @@ func (p *pipe) closeWithError(dst *error, err error, fn func()) { return } p.readFn = fn + if dst == &p.breakErr { + p.b = nil + } *dst = err p.closeDoneLocked() } diff --git a/cmd/vendor/golang.org/x/net/http2/server.go b/cmd/vendor/golang.org/x/net/http2/server.go index 029ed958a42..eae143ddff1 100644 --- a/cmd/vendor/golang.org/x/net/http2/server.go +++ b/cmd/vendor/golang.org/x/net/http2/server.go @@ -126,6 +126,11 @@ type Server struct { // NewWriteScheduler constructs a write scheduler for a connection. // If nil, a default scheduler is chosen. NewWriteScheduler func() WriteScheduler + + // Internal state. This is a pointer (rather than embedded directly) + // so that we don't embed a Mutex in this struct, which will make the + // struct non-copyable, which might break some callers. + state *serverInternalState } func (s *Server) initialConnRecvWindowSize() int32 { @@ -156,6 +161,40 @@ func (s *Server) maxConcurrentStreams() uint32 { return defaultMaxStreams } +type serverInternalState struct { + mu sync.Mutex + activeConns map[*serverConn]struct{} +} + +func (s *serverInternalState) registerConn(sc *serverConn) { + if s == nil { + return // if the Server was used without calling ConfigureServer + } + s.mu.Lock() + s.activeConns[sc] = struct{}{} + s.mu.Unlock() +} + +func (s *serverInternalState) unregisterConn(sc *serverConn) { + if s == nil { + return // if the Server was used without calling ConfigureServer + } + s.mu.Lock() + delete(s.activeConns, sc) + s.mu.Unlock() +} + +func (s *serverInternalState) startGracefulShutdown() { + if s == nil { + return // if the Server was used without calling ConfigureServer + } + s.mu.Lock() + for sc := range s.activeConns { + sc.startGracefulShutdown() + } + s.mu.Unlock() +} + // ConfigureServer adds HTTP/2 support to a net/http Server. // // The configuration conf may be nil. @@ -168,9 +207,13 @@ func ConfigureServer(s *http.Server, conf *Server) error { if conf == nil { conf = new(Server) } + conf.state = &serverInternalState{activeConns: make(map[*serverConn]struct{})} if err := configureServer18(s, conf); err != nil { return err } + if err := configureServer19(s, conf); err != nil { + return err + } if s.TLSConfig == nil { s.TLSConfig = new(tls.Config) @@ -292,7 +335,7 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) { streams: make(map[uint32]*stream), readFrameCh: make(chan readFrameResult), wantWriteFrameCh: make(chan FrameWriteRequest, 8), - wantStartPushCh: make(chan startPushRequest, 8), + serveMsgCh: make(chan interface{}, 8), wroteFrameCh: make(chan frameWriteResult, 1), // buffered; one send in writeFrameAsync bodyReadCh: make(chan bodyReadMsg), // buffering doesn't matter either way doneServing: make(chan struct{}), @@ -305,6 +348,9 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) { pushEnabled: true, } + s.state.registerConn(sc) + defer s.state.unregisterConn(sc) + // The net/http package sets the write deadline from the // http.Server.WriteTimeout during the TLS handshake, but then // passes the connection off to us with the deadline already set. @@ -405,10 +451,9 @@ type serverConn struct { doneServing chan struct{} // closed when serverConn.serve ends readFrameCh chan readFrameResult // written by serverConn.readFrames wantWriteFrameCh chan FrameWriteRequest // from handlers -> serve - wantStartPushCh chan startPushRequest // from handlers -> serve wroteFrameCh chan frameWriteResult // from writeFrameAsync -> serve, tickles more frame writes bodyReadCh chan bodyReadMsg // from handlers -> serve - testHookCh chan func(int) // code to run on the serve loop + serveMsgCh chan interface{} // misc messages & code to send to / run on the serve loop flow flow // conn-wide (not stream-specific) outbound flow control inflow flow // conn-wide inbound flow control tlsState *tls.ConnectionState // shared by all handlers, like net/http @@ -440,14 +485,15 @@ type serverConn struct { inFrameScheduleLoop bool // whether we're in the scheduleFrameWrite loop needToSendGoAway bool // we need to schedule a GOAWAY frame write goAwayCode ErrCode - shutdownTimerCh <-chan time.Time // nil until used - shutdownTimer *time.Timer // nil until used - idleTimer *time.Timer // nil if unused - idleTimerCh <-chan time.Time // nil if unused + shutdownTimer *time.Timer // nil until used + idleTimer *time.Timer // nil if unused // Owned by the writeFrameAsync goroutine: headerWriteBuf bytes.Buffer hpackEncoder *hpack.Encoder + + // Used by startGracefulShutdown. + shutdownOnce sync.Once } func (sc *serverConn) maxHeaderListSize() uint32 { @@ -748,19 +794,15 @@ func (sc *serverConn) serve() { sc.setConnState(http.StateIdle) if sc.srv.IdleTimeout != 0 { - sc.idleTimer = time.NewTimer(sc.srv.IdleTimeout) + sc.idleTimer = time.AfterFunc(sc.srv.IdleTimeout, sc.onIdleTimer) defer sc.idleTimer.Stop() - sc.idleTimerCh = sc.idleTimer.C - } - - var gracefulShutdownCh <-chan struct{} - if sc.hs != nil { - gracefulShutdownCh = h1ServerShutdownChan(sc.hs) } go sc.readFrames() // closed by defer sc.conn.Close above - settingsTimer := time.NewTimer(firstSettingsTimeout) + settingsTimer := time.AfterFunc(firstSettingsTimeout, sc.onSettingsTimer) + defer settingsTimer.Stop() + loopNum := 0 for { loopNum++ @@ -771,8 +813,6 @@ func (sc *serverConn) serve() { break } sc.writeFrame(wr) - case spr := <-sc.wantStartPushCh: - sc.startPush(spr) case res := <-sc.wroteFrameCh: sc.wroteFrame(res) case res := <-sc.readFrameCh: @@ -780,26 +820,37 @@ func (sc *serverConn) serve() { return } res.readMore() - if settingsTimer.C != nil { + if settingsTimer != nil { settingsTimer.Stop() - settingsTimer.C = nil + settingsTimer = nil } case m := <-sc.bodyReadCh: sc.noteBodyRead(m.st, m.n) - case <-settingsTimer.C: - sc.logf("timeout waiting for SETTINGS frames from %v", sc.conn.RemoteAddr()) - return - case <-gracefulShutdownCh: - gracefulShutdownCh = nil - sc.startGracefulShutdown() - case <-sc.shutdownTimerCh: - sc.vlogf("GOAWAY close timer fired; closing conn from %v", sc.conn.RemoteAddr()) - return - case <-sc.idleTimerCh: - sc.vlogf("connection is idle") - sc.goAway(ErrCodeNo) - case fn := <-sc.testHookCh: - fn(loopNum) + case msg := <-sc.serveMsgCh: + switch v := msg.(type) { + case func(int): + v(loopNum) // for testing + case *serverMessage: + switch v { + case settingsTimerMsg: + sc.logf("timeout waiting for SETTINGS frames from %v", sc.conn.RemoteAddr()) + return + case idleTimerMsg: + sc.vlogf("connection is idle") + sc.goAway(ErrCodeNo) + case shutdownTimerMsg: + sc.vlogf("GOAWAY close timer fired; closing conn from %v", sc.conn.RemoteAddr()) + return + case gracefulShutdownMsg: + sc.startGracefulShutdownInternal() + default: + panic("unknown timer") + } + case *startPushRequest: + sc.startPush(v) + default: + panic(fmt.Sprintf("unexpected type %T", v)) + } } if sc.inGoAway && sc.curOpenStreams() == 0 && !sc.needToSendGoAway && !sc.writingFrame { @@ -808,6 +859,36 @@ func (sc *serverConn) serve() { } } +func (sc *serverConn) awaitGracefulShutdown(sharedCh <-chan struct{}, privateCh chan struct{}) { + select { + case <-sc.doneServing: + case <-sharedCh: + close(privateCh) + } +} + +type serverMessage int + +// Message values sent to serveMsgCh. +var ( + settingsTimerMsg = new(serverMessage) + idleTimerMsg = new(serverMessage) + shutdownTimerMsg = new(serverMessage) + gracefulShutdownMsg = new(serverMessage) +) + +func (sc *serverConn) onSettingsTimer() { sc.sendServeMsg(settingsTimerMsg) } +func (sc *serverConn) onIdleTimer() { sc.sendServeMsg(idleTimerMsg) } +func (sc *serverConn) onShutdownTimer() { sc.sendServeMsg(shutdownTimerMsg) } + +func (sc *serverConn) sendServeMsg(msg interface{}) { + sc.serveG.checkNotOn() // NOT + select { + case sc.serveMsgCh <- msg: + case <-sc.doneServing: + } +} + // readPreface reads the ClientPreface greeting from the peer // or returns an error on timeout or an invalid greeting. func (sc *serverConn) readPreface() error { @@ -1125,10 +1206,19 @@ func (sc *serverConn) scheduleFrameWrite() { sc.inFrameScheduleLoop = false } -// startGracefulShutdown sends a GOAWAY with ErrCodeNo to tell the -// client we're gracefully shutting down. The connection isn't closed -// until all current streams are done. +// startGracefulShutdown gracefully shuts down a connection. This +// sends GOAWAY with ErrCodeNo to tell the client we're gracefully +// shutting down. The connection isn't closed until all current +// streams are done. +// +// startGracefulShutdown returns immediately; it does not wait until +// the connection has shut down. func (sc *serverConn) startGracefulShutdown() { + sc.serveG.checkNotOn() // NOT + sc.shutdownOnce.Do(func() { sc.sendServeMsg(gracefulShutdownMsg) }) +} + +func (sc *serverConn) startGracefulShutdownInternal() { sc.goAwayIn(ErrCodeNo, 0) } @@ -1160,8 +1250,7 @@ func (sc *serverConn) goAwayIn(code ErrCode, forceCloseIn time.Duration) { func (sc *serverConn) shutDownIn(d time.Duration) { sc.serveG.check() - sc.shutdownTimer = time.NewTimer(d) - sc.shutdownTimerCh = sc.shutdownTimer.C + sc.shutdownTimer = time.AfterFunc(d, sc.onShutdownTimer) } func (sc *serverConn) resetStream(se StreamError) { @@ -1359,7 +1448,7 @@ func (sc *serverConn) closeStream(st *stream, err error) { sc.idleTimer.Reset(sc.srv.IdleTimeout) } if h1ServerKeepAlivesDisabled(sc.hs) { - sc.startGracefulShutdown() + sc.startGracefulShutdownInternal() } } if p := st.body; p != nil { @@ -1546,7 +1635,7 @@ func (sc *serverConn) processGoAway(f *GoAwayFrame) error { } else { sc.vlogf("http2: received GOAWAY %+v, starting graceful shutdown", f) } - sc.startGracefulShutdown() + sc.startGracefulShutdownInternal() // http://tools.ietf.org/html/rfc7540#section-6.8 // We should not create any new streams, which means we should disable push. sc.pushEnabled = false @@ -2163,6 +2252,7 @@ type responseWriterState struct { wroteHeader bool // WriteHeader called (explicitly or implicitly). Not necessarily sent to user yet. sentHeader bool // have we sent the header frame? handlerDone bool // handler has finished + dirty bool // a Write failed; don't reuse this responseWriterState sentContentLen int64 // non-zero if handler set a Content-Length header wroteBytes int64 @@ -2244,6 +2334,7 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { date: date, }) if err != nil { + rws.dirty = true return 0, err } if endStream { @@ -2265,6 +2356,7 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { if len(p) > 0 || endStream { // only send a 0 byte DATA frame if we're ending the stream. if err := rws.conn.writeDataFromHandler(rws.stream, p, endStream); err != nil { + rws.dirty = true return 0, err } } @@ -2276,6 +2368,9 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { trailers: rws.trailers, endStream: true, }) + if err != nil { + rws.dirty = true + } return len(p), err } return len(p), nil @@ -2415,7 +2510,7 @@ func cloneHeader(h http.Header) http.Header { // // * Handler calls w.Write or w.WriteString -> // * -> rws.bw (*bufio.Writer) -> -// * (Handler migth call Flush) +// * (Handler might call Flush) // * -> chunkWriter{rws} // * -> responseWriterState.writeChunk(p []byte) // * -> responseWriterState.writeChunk (most of the magic; see comment there) @@ -2454,10 +2549,19 @@ func (w *responseWriter) write(lenData int, dataB []byte, dataS string) (n int, func (w *responseWriter) handlerDone() { rws := w.rws + dirty := rws.dirty rws.handlerDone = true w.Flush() w.rws = nil - responseWriterStatePool.Put(rws) + if !dirty { + // Only recycle the pool if all prior Write calls to + // the serverConn goroutine completed successfully. If + // they returned earlier due to resets from the peer + // there might still be write goroutines outstanding + // from the serverConn referencing the rws memory. See + // issue 20704. + responseWriterStatePool.Put(rws) + } } // Push errors. @@ -2539,7 +2643,7 @@ func (w *responseWriter) push(target string, opts pushOptions) error { return fmt.Errorf("method %q must be GET or HEAD", opts.Method) } - msg := startPushRequest{ + msg := &startPushRequest{ parent: st, method: opts.Method, url: u, @@ -2552,7 +2656,7 @@ func (w *responseWriter) push(target string, opts pushOptions) error { return errClientDisconnected case <-st.cw: return errStreamClosed - case sc.wantStartPushCh <- msg: + case sc.serveMsgCh <- msg: } select { @@ -2574,7 +2678,7 @@ type startPushRequest struct { done chan error } -func (sc *serverConn) startPush(msg startPushRequest) { +func (sc *serverConn) startPush(msg *startPushRequest) { sc.serveG.check() // http://tools.ietf.org/html/rfc7540#section-6.6. @@ -2613,7 +2717,7 @@ func (sc *serverConn) startPush(msg startPushRequest) { // A server that is unable to establish a new stream identifier can send a GOAWAY // frame so that the client is forced to open a new connection for new streams. if sc.maxPushPromiseID+2 >= 1<<31 { - sc.startGracefulShutdown() + sc.startGracefulShutdownInternal() return 0, ErrPushLimitReached } sc.maxPushPromiseID += 2 @@ -2738,31 +2842,6 @@ var badTrailer = map[string]bool{ "Www-Authenticate": true, } -// h1ServerShutdownChan returns a channel that will be closed when the -// provided *http.Server wants to shut down. -// -// This is a somewhat hacky way to get at http1 innards. It works -// when the http2 code is bundled into the net/http package in the -// standard library. The alternatives ended up making the cmd/go tool -// depend on http Servers. This is the lightest option for now. -// This is tested via the TestServeShutdown* tests in net/http. -func h1ServerShutdownChan(hs *http.Server) <-chan struct{} { - if fn := testh1ServerShutdownChan; fn != nil { - return fn(hs) - } - var x interface{} = hs - type I interface { - getDoneChan() <-chan struct{} - } - if hs, ok := x.(I); ok { - return hs.getDoneChan() - } - return nil -} - -// optional test hook for h1ServerShutdownChan. -var testh1ServerShutdownChan func(hs *http.Server) <-chan struct{} - // h1ServerKeepAlivesDisabled reports whether hs has its keep-alives // disabled. See comments on h1ServerShutdownChan above for why // the code is written this way. diff --git a/cmd/vendor/golang.org/x/net/http2/transport.go b/cmd/vendor/golang.org/x/net/http2/transport.go index 84d042d469c..adb77ffabbb 100644 --- a/cmd/vendor/golang.org/x/net/http2/transport.go +++ b/cmd/vendor/golang.org/x/net/http2/transport.go @@ -18,6 +18,7 @@ import ( "io/ioutil" "log" "math" + mathrand "math/rand" "net" "net/http" "sort" @@ -86,7 +87,7 @@ type Transport struct { // MaxHeaderListSize is the http2 SETTINGS_MAX_HEADER_LIST_SIZE to // send in the initial settings frame. It is how many bytes - // of response headers are allow. Unlike the http2 spec, zero here + // of response headers are allowed. Unlike the http2 spec, zero here // means to use a default limit (currently 10MB). If you actually // want to advertise an ulimited value to the peer, Transport // interprets the highest possible value here (0xffffffff or 1<<32-1) @@ -164,15 +165,17 @@ type ClientConn struct { goAwayDebug string // goAway frame's debug data, retained as a string streams map[uint32]*clientStream // client-initiated nextStreamID uint32 + pendingRequests int // requests blocked and waiting to be sent because len(streams) == maxConcurrentStreams pings map[[8]byte]chan struct{} // in flight ping data to notification channel bw *bufio.Writer br *bufio.Reader fr *Framer lastActive time.Time // Settings from peer: (also guarded by mu) - maxFrameSize uint32 - maxConcurrentStreams uint32 - initialWindowSize uint32 + maxFrameSize uint32 + maxConcurrentStreams uint32 + peerMaxHeaderListSize uint64 + initialWindowSize uint32 hbuf bytes.Buffer // HPACK encoder writes into this henc *hpack.Encoder @@ -216,35 +219,45 @@ type clientStream struct { resTrailer *http.Header // client's Response.Trailer } -// awaitRequestCancel runs in its own goroutine and waits for the user -// to cancel a RoundTrip request, its context to expire, or for the -// request to be done (any way it might be removed from the cc.streams -// map: peer reset, successful completion, TCP connection breakage, -// etc) -func (cs *clientStream) awaitRequestCancel(req *http.Request) { +// awaitRequestCancel waits for the user to cancel a request or for the done +// channel to be signaled. A non-nil error is returned only if the request was +// canceled. +func awaitRequestCancel(req *http.Request, done <-chan struct{}) error { ctx := reqContext(req) if req.Cancel == nil && ctx.Done() == nil { - return + return nil } select { case <-req.Cancel: - cs.cancelStream() - cs.bufPipe.CloseWithError(errRequestCanceled) + return errRequestCanceled case <-ctx.Done(): + return ctx.Err() + case <-done: + return nil + } +} + +// awaitRequestCancel waits for the user to cancel a request, its context to +// expire, or for the request to be done (any way it might be removed from the +// cc.streams map: peer reset, successful completion, TCP connection breakage, +// etc). If the request is canceled, then cs will be canceled and closed. +func (cs *clientStream) awaitRequestCancel(req *http.Request) { + if err := awaitRequestCancel(req, cs.done); err != nil { cs.cancelStream() - cs.bufPipe.CloseWithError(ctx.Err()) - case <-cs.done: + cs.bufPipe.CloseWithError(err) } } func (cs *clientStream) cancelStream() { - cs.cc.mu.Lock() + cc := cs.cc + cc.mu.Lock() didReset := cs.didReset cs.didReset = true - cs.cc.mu.Unlock() + cc.mu.Unlock() if !didReset { - cs.cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) + cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) + cc.forgetStreamID(cs.ID) } } @@ -329,7 +342,7 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res } addr := authorityAddr(req.URL.Scheme, req.URL.Host) - for { + for retry := 0; ; retry++ { cc, err := t.connPool().GetClientConn(req, addr) if err != nil { t.vlogf("http2: Transport failed to get client conn for %s: %v", addr, err) @@ -337,9 +350,25 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res } traceGotConn(req, cc) res, err := cc.RoundTrip(req) - if err != nil { - if req, err = shouldRetryRequest(req, err); err == nil { - continue + if err != nil && retry <= 6 { + afterBodyWrite := false + if e, ok := err.(afterReqBodyWriteError); ok { + err = e + afterBodyWrite = true + } + if req, err = shouldRetryRequest(req, err, afterBodyWrite); err == nil { + // After the first retry, do exponential backoff with 10% jitter. + if retry == 0 { + continue + } + backoff := float64(uint(1) << (uint(retry) - 1)) + backoff += backoff * (0.1 * mathrand.Float64()) + select { + case <-time.After(time.Second * time.Duration(backoff)): + continue + case <-reqContext(req).Done(): + return nil, reqContext(req).Err() + } } } if err != nil { @@ -360,43 +389,60 @@ func (t *Transport) CloseIdleConnections() { } var ( - errClientConnClosed = errors.New("http2: client conn is closed") - errClientConnUnusable = errors.New("http2: client conn not usable") - - errClientConnGotGoAway = errors.New("http2: Transport received Server's graceful shutdown GOAWAY") - errClientConnGotGoAwayAfterSomeReqBody = errors.New("http2: Transport received Server's graceful shutdown GOAWAY; some request body already written") + errClientConnClosed = errors.New("http2: client conn is closed") + errClientConnUnusable = errors.New("http2: client conn not usable") + errClientConnGotGoAway = errors.New("http2: Transport received Server's graceful shutdown GOAWAY") ) +// afterReqBodyWriteError is a wrapper around errors returned by ClientConn.RoundTrip. +// It is used to signal that err happened after part of Request.Body was sent to the server. +type afterReqBodyWriteError struct { + err error +} + +func (e afterReqBodyWriteError) Error() string { + return e.err.Error() + "; some request body already written" +} + // shouldRetryRequest is called by RoundTrip when a request fails to get // response headers. It is always called with a non-nil error. // It returns either a request to retry (either the same request, or a // modified clone), or an error if the request can't be replayed. -func shouldRetryRequest(req *http.Request, err error) (*http.Request, error) { - switch err { - default: +func shouldRetryRequest(req *http.Request, err error, afterBodyWrite bool) (*http.Request, error) { + if !canRetryError(err) { return nil, err - case errClientConnUnusable, errClientConnGotGoAway: + } + if !afterBodyWrite { return req, nil - case errClientConnGotGoAwayAfterSomeReqBody: - // If the Body is nil (or http.NoBody), it's safe to reuse - // this request and its Body. - if req.Body == nil || reqBodyIsNoBody(req.Body) { - return req, nil - } - // Otherwise we depend on the Request having its GetBody - // func defined. - getBody := reqGetBody(req) // Go 1.8: getBody = req.GetBody - if getBody == nil { - return nil, errors.New("http2: Transport: peer server initiated graceful shutdown after some of Request.Body was written; define Request.GetBody to avoid this error") - } - body, err := getBody() - if err != nil { - return nil, err - } - newReq := *req - newReq.Body = body - return &newReq, nil } + // If the Body is nil (or http.NoBody), it's safe to reuse + // this request and its Body. + if req.Body == nil || reqBodyIsNoBody(req.Body) { + return req, nil + } + // Otherwise we depend on the Request having its GetBody + // func defined. + getBody := reqGetBody(req) // Go 1.8: getBody = req.GetBody + if getBody == nil { + return nil, fmt.Errorf("http2: Transport: cannot retry err [%v] after Request.Body was written; define Request.GetBody to avoid this error", err) + } + body, err := getBody() + if err != nil { + return nil, err + } + newReq := *req + newReq.Body = body + return &newReq, nil +} + +func canRetryError(err error) bool { + if err == errClientConnUnusable || err == errClientConnGotGoAway { + return true + } + if se, ok := err.(StreamError); ok { + return se.Code == ErrCodeRefusedStream + } + return false } func (t *Transport) dialClientConn(addr string, singleUse bool) (*ClientConn, error) { @@ -474,17 +520,18 @@ func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) { func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, error) { cc := &ClientConn{ - t: t, - tconn: c, - readerDone: make(chan struct{}), - nextStreamID: 1, - maxFrameSize: 16 << 10, // spec default - initialWindowSize: 65535, // spec default - maxConcurrentStreams: 1000, // "infinite", per spec. 1000 seems good enough. - streams: make(map[uint32]*clientStream), - singleUse: singleUse, - wantSettingsAck: true, - pings: make(map[[8]byte]chan struct{}), + t: t, + tconn: c, + readerDone: make(chan struct{}), + nextStreamID: 1, + maxFrameSize: 16 << 10, // spec default + initialWindowSize: 65535, // spec default + maxConcurrentStreams: 1000, // "infinite", per spec. 1000 seems good enough. + peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead. + streams: make(map[uint32]*clientStream), + singleUse: singleUse, + wantSettingsAck: true, + pings: make(map[[8]byte]chan struct{}), } if d := t.idleConnTimeout(); d != 0 { cc.idleTimeout = d @@ -560,6 +607,8 @@ func (cc *ClientConn) setGoAway(f *GoAwayFrame) { } } +// CanTakeNewRequest reports whether the connection can take a new request, +// meaning it has not been closed or received or sent a GOAWAY. func (cc *ClientConn) CanTakeNewRequest() bool { cc.mu.Lock() defer cc.mu.Unlock() @@ -571,8 +620,7 @@ func (cc *ClientConn) canTakeNewRequestLocked() bool { return false } return cc.goAway == nil && !cc.closed && - int64(len(cc.streams)+1) < int64(cc.maxConcurrentStreams) && - cc.nextStreamID < math.MaxInt32 + int64(cc.nextStreamID)+int64(cc.pendingRequests) < math.MaxInt32 } // onIdleTimeout is called from a time.AfterFunc goroutine. It will @@ -694,7 +742,7 @@ func checkConnHeaders(req *http.Request) error { // req.ContentLength, where 0 actually means zero (not unknown) and -1 // means unknown. func actualContentLength(req *http.Request) int64 { - if req.Body == nil { + if req.Body == nil || reqBodyIsNoBody(req.Body) { return 0 } if req.ContentLength != 0 { @@ -718,15 +766,14 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { hasTrailers := trailers != "" cc.mu.Lock() - cc.lastActive = time.Now() - if cc.closed || !cc.canTakeNewRequestLocked() { + if err := cc.awaitOpenSlotForRequest(req); err != nil { cc.mu.Unlock() - return nil, errClientConnUnusable + return nil, err } body := req.Body - hasBody := body != nil contentLen := actualContentLength(req) + hasBody := contentLen != 0 // TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere? var requestedGzip bool @@ -816,14 +863,13 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { cs.abortRequestBodyWrite(errStopReqBodyWrite) } if re.err != nil { - if re.err == errClientConnGotGoAway { - cc.mu.Lock() - if cs.startedWrite { - re.err = errClientConnGotGoAwayAfterSomeReqBody - } - cc.mu.Unlock() - } + cc.mu.Lock() + afterBodyWrite := cs.startedWrite + cc.mu.Unlock() cc.forgetStreamID(cs.ID) + if afterBodyWrite { + return nil, afterReqBodyWriteError{re.err} + } return nil, re.err } res.Request = req @@ -836,31 +882,31 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { case re := <-readLoopResCh: return handleReadLoopResponse(re) case <-respHeaderTimer: - cc.forgetStreamID(cs.ID) if !hasBody || bodyWritten { cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) } else { bodyWriter.cancel() cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel) } + cc.forgetStreamID(cs.ID) return nil, errTimeout case <-ctx.Done(): - cc.forgetStreamID(cs.ID) if !hasBody || bodyWritten { cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) } else { bodyWriter.cancel() cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel) } + cc.forgetStreamID(cs.ID) return nil, ctx.Err() case <-req.Cancel: - cc.forgetStreamID(cs.ID) if !hasBody || bodyWritten { cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) } else { bodyWriter.cancel() cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel) } + cc.forgetStreamID(cs.ID) return nil, errRequestCanceled case <-cs.peerReset: // processResetStream already removed the @@ -887,6 +933,45 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { } } +// awaitOpenSlotForRequest waits until len(streams) < maxConcurrentStreams. +// Must hold cc.mu. +func (cc *ClientConn) awaitOpenSlotForRequest(req *http.Request) error { + var waitingForConn chan struct{} + var waitingForConnErr error // guarded by cc.mu + for { + cc.lastActive = time.Now() + if cc.closed || !cc.canTakeNewRequestLocked() { + return errClientConnUnusable + } + if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) { + if waitingForConn != nil { + close(waitingForConn) + } + return nil + } + // Unfortunately, we cannot wait on a condition variable and channel at + // the same time, so instead, we spin up a goroutine to check if the + // request is canceled while we wait for a slot to open in the connection. + if waitingForConn == nil { + waitingForConn = make(chan struct{}) + go func() { + if err := awaitRequestCancel(req, waitingForConn); err != nil { + cc.mu.Lock() + waitingForConnErr = err + cc.cond.Broadcast() + cc.mu.Unlock() + } + }() + } + cc.pendingRequests++ + cc.cond.Wait() + cc.pendingRequests-- + if waitingForConnErr != nil { + return waitingForConnErr + } + } +} + // requires cc.wmu be held func (cc *ClientConn) writeHeaders(streamID uint32, endStream bool, hdrs []byte) error { first := true // first frame written (HEADERS is first, then CONTINUATION) @@ -1002,8 +1087,13 @@ func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) ( var trls []byte if hasTrailers { cc.mu.Lock() - defer cc.mu.Unlock() - trls = cc.encodeTrailers(req) + trls, err = cc.encodeTrailers(req) + cc.mu.Unlock() + if err != nil { + cc.writeStreamReset(cs.ID, ErrCodeInternal, err) + cc.forgetStreamID(cs.ID) + return err + } } cc.wmu.Lock() @@ -1106,62 +1196,86 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail } } - // 8.1.2.3 Request Pseudo-Header Fields - // The :path pseudo-header field includes the path and query parts of the - // target URI (the path-absolute production and optionally a '?' character - // followed by the query production (see Sections 3.3 and 3.4 of - // [RFC3986]). - cc.writeHeader(":authority", host) - cc.writeHeader(":method", req.Method) - if req.Method != "CONNECT" { - cc.writeHeader(":path", path) - cc.writeHeader(":scheme", req.URL.Scheme) - } - if trailers != "" { - cc.writeHeader("trailer", trailers) - } + enumerateHeaders := func(f func(name, value string)) { + // 8.1.2.3 Request Pseudo-Header Fields + // The :path pseudo-header field includes the path and query parts of the + // target URI (the path-absolute production and optionally a '?' character + // followed by the query production (see Sections 3.3 and 3.4 of + // [RFC3986]). + f(":authority", host) + f(":method", req.Method) + if req.Method != "CONNECT" { + f(":path", path) + f(":scheme", req.URL.Scheme) + } + if trailers != "" { + f("trailer", trailers) + } - var didUA bool - for k, vv := range req.Header { - lowKey := strings.ToLower(k) - switch lowKey { - case "host", "content-length": - // Host is :authority, already sent. - // Content-Length is automatic, set below. - continue - case "connection", "proxy-connection", "transfer-encoding", "upgrade", "keep-alive": - // Per 8.1.2.2 Connection-Specific Header - // Fields, don't send connection-specific - // fields. We have already checked if any - // are error-worthy so just ignore the rest. - continue - case "user-agent": - // Match Go's http1 behavior: at most one - // User-Agent. If set to nil or empty string, - // then omit it. Otherwise if not mentioned, - // include the default (below). - didUA = true - if len(vv) < 1 { + var didUA bool + for k, vv := range req.Header { + if strings.EqualFold(k, "host") || strings.EqualFold(k, "content-length") { + // Host is :authority, already sent. + // Content-Length is automatic, set below. continue - } - vv = vv[:1] - if vv[0] == "" { + } else if strings.EqualFold(k, "connection") || strings.EqualFold(k, "proxy-connection") || + strings.EqualFold(k, "transfer-encoding") || strings.EqualFold(k, "upgrade") || + strings.EqualFold(k, "keep-alive") { + // Per 8.1.2.2 Connection-Specific Header + // Fields, don't send connection-specific + // fields. We have already checked if any + // are error-worthy so just ignore the rest. continue + } else if strings.EqualFold(k, "user-agent") { + // Match Go's http1 behavior: at most one + // User-Agent. If set to nil or empty string, + // then omit it. Otherwise if not mentioned, + // include the default (below). + didUA = true + if len(vv) < 1 { + continue + } + vv = vv[:1] + if vv[0] == "" { + continue + } + + } + + for _, v := range vv { + f(k, v) } } - for _, v := range vv { - cc.writeHeader(lowKey, v) + if shouldSendReqContentLength(req.Method, contentLength) { + f("content-length", strconv.FormatInt(contentLength, 10)) + } + if addGzipHeader { + f("accept-encoding", "gzip") + } + if !didUA { + f("user-agent", defaultUserAgent) } } - if shouldSendReqContentLength(req.Method, contentLength) { - cc.writeHeader("content-length", strconv.FormatInt(contentLength, 10)) - } - if addGzipHeader { - cc.writeHeader("accept-encoding", "gzip") - } - if !didUA { - cc.writeHeader("user-agent", defaultUserAgent) + + // Do a first pass over the headers counting bytes to ensure + // we don't exceed cc.peerMaxHeaderListSize. This is done as a + // separate pass before encoding the headers to prevent + // modifying the hpack state. + hlSize := uint64(0) + enumerateHeaders(func(name, value string) { + hf := hpack.HeaderField{Name: name, Value: value} + hlSize += uint64(hf.Size()) + }) + + if hlSize > cc.peerMaxHeaderListSize { + return nil, errRequestHeaderListSize } + + // Header list size is ok. Write the headers. + enumerateHeaders(func(name, value string) { + cc.writeHeader(strings.ToLower(name), value) + }) + return cc.hbuf.Bytes(), nil } @@ -1188,17 +1302,29 @@ func shouldSendReqContentLength(method string, contentLength int64) bool { } // requires cc.mu be held. -func (cc *ClientConn) encodeTrailers(req *http.Request) []byte { +func (cc *ClientConn) encodeTrailers(req *http.Request) ([]byte, error) { cc.hbuf.Reset() + + hlSize := uint64(0) + for k, vv := range req.Trailer { + for _, v := range vv { + hf := hpack.HeaderField{Name: k, Value: v} + hlSize += uint64(hf.Size()) + } + } + if hlSize > cc.peerMaxHeaderListSize { + return nil, errRequestHeaderListSize + } + for k, vv := range req.Trailer { - // Transfer-Encoding, etc.. have already been filter at the + // Transfer-Encoding, etc.. have already been filtered at the // start of RoundTrip lowKey := strings.ToLower(k) for _, v := range vv { cc.writeHeader(lowKey, v) } } - return cc.hbuf.Bytes() + return cc.hbuf.Bytes(), nil } func (cc *ClientConn) writeHeader(name, value string) { @@ -1246,7 +1372,9 @@ func (cc *ClientConn) streamByID(id uint32, andRemove bool) *clientStream { cc.idleTimer.Reset(cc.idleTimeout) } close(cs.done) - cc.cond.Broadcast() // wake up checkResetOrDone via clientStream.awaitFlowControl + // Wake up checkResetOrDone via clientStream.awaitFlowControl and + // wake up RoundTrip if there is a pending request. + cc.cond.Broadcast() } return cs } @@ -1345,8 +1473,9 @@ func (rl *clientConnReadLoop) run() error { cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err) } if se, ok := err.(StreamError); ok { - if cs := cc.streamByID(se.StreamID, true /*ended; remove it*/); cs != nil { + if cs := cc.streamByID(se.StreamID, false); cs != nil { cs.cc.writeStreamReset(cs.ID, se.Code, err) + cs.cc.forgetStreamID(cs.ID) if se.Cause == nil { se.Cause = cc.fr.errDetail } @@ -1655,6 +1784,7 @@ func (b transportResponseBody) Close() error { cc.wmu.Lock() if !serverSentStreamEnd { cc.fr.WriteRSTStream(cs.ID, ErrCodeCancel) + cs.didReset = true } // Return connection-level flow control. if unread > 0 { @@ -1667,6 +1797,7 @@ func (b transportResponseBody) Close() error { } cs.bufPipe.BreakWithError(errClosedResponseBody) + cc.forgetStreamID(cs.ID) return nil } @@ -1701,13 +1832,15 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error { } return nil } + if !cs.firstByte { + cc.logf("protocol error: received DATA before a HEADERS frame") + rl.endStreamError(cs, StreamError{ + StreamID: f.StreamID, + Code: ErrCodeProtocol, + }) + return nil + } if f.Length > 0 { - if len(data) > 0 && cs.bufPipe.b == nil { - // Data frame after it's already closed? - cc.logf("http2: Transport received DATA frame for closed stream; closing connection") - return ConnectionError(ErrCodeProtocol) - } - // Check connection-level flow control. cc.mu.Lock() if cs.inflow.available() >= int32(f.Length) { @@ -1718,16 +1851,27 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error { } // Return any padded flow control now, since we won't // refund it later on body reads. - if pad := int32(f.Length) - int32(len(data)); pad > 0 { - cs.inflow.add(pad) - cc.inflow.add(pad) + var refund int + if pad := int(f.Length) - len(data); pad > 0 { + refund += pad + } + // Return len(data) now if the stream is already closed, + // since data will never be read. + didReset := cs.didReset + if didReset { + refund += len(data) + } + if refund > 0 { + cc.inflow.add(int32(refund)) cc.wmu.Lock() - cc.fr.WriteWindowUpdate(0, uint32(pad)) - cc.fr.WriteWindowUpdate(cs.ID, uint32(pad)) + cc.fr.WriteWindowUpdate(0, uint32(refund)) + if !didReset { + cs.inflow.add(int32(refund)) + cc.fr.WriteWindowUpdate(cs.ID, uint32(refund)) + } cc.bw.Flush() cc.wmu.Unlock() } - didReset := cs.didReset cc.mu.Unlock() if len(data) > 0 && !didReset { @@ -1810,6 +1954,8 @@ func (rl *clientConnReadLoop) processSettings(f *SettingsFrame) error { cc.maxFrameSize = s.Val case SettingMaxConcurrentStreams: cc.maxConcurrentStreams = s.Val + case SettingMaxHeaderListSize: + cc.peerMaxHeaderListSize = uint64(s.Val) case SettingInitialWindowSize: // Values above the maximum flow-control // window size of 2^31-1 MUST be treated as a @@ -1976,6 +2122,7 @@ func (cc *ClientConn) writeStreamReset(streamID uint32, code ErrCode, err error) var ( errResponseHeaderListSize = errors.New("http2: response header list larger than advertised limit") + errRequestHeaderListSize = errors.New("http2: request header list larger than peer's advertised limit") errPseudoTrailers = errors.New("http2: invalid pseudo header in trailers") ) diff --git a/cmd/vendor/golang.org/x/net/http2/writesched_priority.go b/cmd/vendor/golang.org/x/net/http2/writesched_priority.go index 01132721bdd..848fed6ec76 100644 --- a/cmd/vendor/golang.org/x/net/http2/writesched_priority.go +++ b/cmd/vendor/golang.org/x/net/http2/writesched_priority.go @@ -53,7 +53,7 @@ type PriorityWriteSchedulerConfig struct { } // NewPriorityWriteScheduler constructs a WriteScheduler that schedules -// frames by following HTTP/2 priorities as described in RFC 7340 Section 5.3. +// frames by following HTTP/2 priorities as described in RFC 7540 Section 5.3. // If cfg is nil, default options are used. func NewPriorityWriteScheduler(cfg *PriorityWriteSchedulerConfig) WriteScheduler { if cfg == nil { diff --git a/cmd/vendor/golang.org/x/net/idna/idna.go b/cmd/vendor/golang.org/x/net/idna/idna.go index ee2dbda6d0d..eb2473507b7 100644 --- a/cmd/vendor/golang.org/x/net/idna/idna.go +++ b/cmd/vendor/golang.org/x/net/idna/idna.go @@ -67,6 +67,15 @@ func VerifyDNSLength(verify bool) Option { return func(o *options) { o.verifyDNSLength = verify } } +// RemoveLeadingDots removes leading label separators. Leading runes that map to +// dots, such as U+3002, are removed as well. +// +// This is the behavior suggested by the UTS #46 and is adopted by some +// browsers. +func RemoveLeadingDots(remove bool) Option { + return func(o *options) { o.removeLeadingDots = remove } +} + // ValidateLabels sets whether to check the mandatory label validation criteria // as defined in Section 5.4 of RFC 5891. This includes testing for correct use // of hyphens ('-'), normalization, validity of runes, and the context rules. @@ -133,14 +142,16 @@ func MapForLookup() Option { o.mapping = validateAndMap StrictDomainName(true)(o) ValidateLabels(true)(o) + RemoveLeadingDots(true)(o) } } type options struct { - transitional bool - useSTD3Rules bool - validateLabels bool - verifyDNSLength bool + transitional bool + useSTD3Rules bool + validateLabels bool + verifyDNSLength bool + removeLeadingDots bool trie *idnaTrie @@ -240,21 +251,23 @@ var ( punycode = &Profile{} lookup = &Profile{options{ - transitional: true, - useSTD3Rules: true, - validateLabels: true, - trie: trie, - fromPuny: validateFromPunycode, - mapping: validateAndMap, - bidirule: bidirule.ValidString, + transitional: true, + useSTD3Rules: true, + validateLabels: true, + removeLeadingDots: true, + trie: trie, + fromPuny: validateFromPunycode, + mapping: validateAndMap, + bidirule: bidirule.ValidString, }} display = &Profile{options{ - useSTD3Rules: true, - validateLabels: true, - trie: trie, - fromPuny: validateFromPunycode, - mapping: validateAndMap, - bidirule: bidirule.ValidString, + useSTD3Rules: true, + validateLabels: true, + removeLeadingDots: true, + trie: trie, + fromPuny: validateFromPunycode, + mapping: validateAndMap, + bidirule: bidirule.ValidString, }} registration = &Profile{options{ useSTD3Rules: true, @@ -293,7 +306,9 @@ func (p *Profile) process(s string, toASCII bool) (string, error) { s, err = p.mapping(p, s) } // Remove leading empty labels. - for ; len(s) > 0 && s[0] == '.'; s = s[1:] { + if p.removeLeadingDots { + for ; len(s) > 0 && s[0] == '.'; s = s[1:] { + } } // It seems like we should only create this error on ToASCII, but the // UTS 46 conformance tests suggests we should always check this. @@ -373,23 +388,20 @@ func validateRegistration(p *Profile, s string) (string, error) { if !norm.NFC.IsNormalString(s) { return s, &labelError{s, "V1"} } - var err error for i := 0; i < len(s); { v, sz := trie.lookupString(s[i:]) - i += sz // Copy bytes not copied so far. switch p.simplify(info(v).category()) { // TODO: handle the NV8 defined in the Unicode idna data set to allow // for strict conformance to IDNA2008. case valid, deviation: case disallowed, mapped, unknown, ignored: - if err == nil { - r, _ := utf8.DecodeRuneInString(s[i:]) - err = runeError(r) - } + r, _ := utf8.DecodeRuneInString(s[i:]) + return s, runeError(r) } + i += sz } - return s, err + return s, nil } func validateAndMap(p *Profile, s string) (string, error) { @@ -408,7 +420,7 @@ func validateAndMap(p *Profile, s string) (string, error) { continue case disallowed: if err == nil { - r, _ := utf8.DecodeRuneInString(s[i:]) + r, _ := utf8.DecodeRuneInString(s[start:]) err = runeError(r) } continue diff --git a/cmd/vendor/golang.org/x/net/trace/events.go b/cmd/vendor/golang.org/x/net/trace/events.go index d8daec1a791..c646a6952e5 100644 --- a/cmd/vendor/golang.org/x/net/trace/events.go +++ b/cmd/vendor/golang.org/x/net/trace/events.go @@ -39,9 +39,9 @@ var buckets = []bucket{ } // RenderEvents renders the HTML page typically served at /debug/events. -// It does not do any auth checking; see AuthRequest for the default auth check -// used by the handler registered on http.DefaultServeMux. -// req may be nil. +// It does not do any auth checking. The request may be nil. +// +// Most users will use the Events handler. func RenderEvents(w http.ResponseWriter, req *http.Request, sensitive bool) { now := time.Now() data := &struct { diff --git a/cmd/vendor/golang.org/x/net/trace/trace.go b/cmd/vendor/golang.org/x/net/trace/trace.go index 1f250a2dbca..bb72a527e8c 100644 --- a/cmd/vendor/golang.org/x/net/trace/trace.go +++ b/cmd/vendor/golang.org/x/net/trace/trace.go @@ -64,7 +64,6 @@ package trace // import "golang.org/x/net/trace" import ( "bytes" - "context" "fmt" "html/template" "io" @@ -111,30 +110,46 @@ var AuthRequest = func(req *http.Request) (any, sensitive bool) { } func init() { - http.HandleFunc("/debug/requests", func(w http.ResponseWriter, req *http.Request) { - any, sensitive := AuthRequest(req) - if !any { - http.Error(w, "not allowed", http.StatusUnauthorized) - return - } - w.Header().Set("Content-Type", "text/html; charset=utf-8") - Render(w, req, sensitive) - }) - http.HandleFunc("/debug/events", func(w http.ResponseWriter, req *http.Request) { - any, sensitive := AuthRequest(req) - if !any { - http.Error(w, "not allowed", http.StatusUnauthorized) - return - } - w.Header().Set("Content-Type", "text/html; charset=utf-8") - RenderEvents(w, req, sensitive) - }) + // TODO(jbd): Serve Traces from /debug/traces in the future? + // There is no requirement for a request to be present to have traces. + http.HandleFunc("/debug/requests", Traces) + http.HandleFunc("/debug/events", Events) +} + +// Traces responds with traces from the program. +// The package initialization registers it in http.DefaultServeMux +// at /debug/requests. +// +// It performs authorization by running AuthRequest. +func Traces(w http.ResponseWriter, req *http.Request) { + any, sensitive := AuthRequest(req) + if !any { + http.Error(w, "not allowed", http.StatusUnauthorized) + return + } + w.Header().Set("Content-Type", "text/html; charset=utf-8") + Render(w, req, sensitive) +} + +// Events responds with a page of events collected by EventLogs. +// The package initialization registers it in http.DefaultServeMux +// at /debug/events. +// +// It performs authorization by running AuthRequest. +func Events(w http.ResponseWriter, req *http.Request) { + any, sensitive := AuthRequest(req) + if !any { + http.Error(w, "not allowed", http.StatusUnauthorized) + return + } + w.Header().Set("Content-Type", "text/html; charset=utf-8") + RenderEvents(w, req, sensitive) } // Render renders the HTML page typically served at /debug/requests. -// It does not do any auth checking; see AuthRequest for the default auth check -// used by the handler registered on http.DefaultServeMux. -// req may be nil. +// It does not do any auth checking. The request may be nil. +// +// Most users will use the Traces handler. func Render(w io.Writer, req *http.Request, sensitive bool) { data := &struct { Families []string @@ -271,18 +286,6 @@ type contextKeyT string var contextKey = contextKeyT("golang.org/x/net/trace.Trace") -// NewContext returns a copy of the parent context -// and associates it with a Trace. -func NewContext(ctx context.Context, tr Trace) context.Context { - return context.WithValue(ctx, contextKey, tr) -} - -// FromContext returns the Trace bound to the context, if any. -func FromContext(ctx context.Context) (tr Trace, ok bool) { - tr, ok = ctx.Value(contextKey).(Trace) - return -} - // Trace represents an active request. type Trace interface { // LazyLog adds x to the event log. It will be evaluated each time the diff --git a/cmd/vendor/golang.org/x/net/trace/trace_go16.go b/cmd/vendor/golang.org/x/net/trace/trace_go16.go new file mode 100644 index 00000000000..d6081911853 --- /dev/null +++ b/cmd/vendor/golang.org/x/net/trace/trace_go16.go @@ -0,0 +1,21 @@ +// 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.7 + +package trace + +import "golang.org/x/net/context" + +// NewContext returns a copy of the parent context +// and associates it with a Trace. +func NewContext(ctx context.Context, tr Trace) context.Context { + return context.WithValue(ctx, contextKey, tr) +} + +// FromContext returns the Trace bound to the context, if any. +func FromContext(ctx context.Context) (tr Trace, ok bool) { + tr, ok = ctx.Value(contextKey).(Trace) + return +} diff --git a/cmd/vendor/golang.org/x/net/trace/trace_go17.go b/cmd/vendor/golang.org/x/net/trace/trace_go17.go new file mode 100644 index 00000000000..df6e1fba7ca --- /dev/null +++ b/cmd/vendor/golang.org/x/net/trace/trace_go17.go @@ -0,0 +1,21 @@ +// 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.7 + +package trace + +import "context" + +// NewContext returns a copy of the parent context +// and associates it with a Trace. +func NewContext(ctx context.Context, tr Trace) context.Context { + return context.WithValue(ctx, contextKey, tr) +} + +// FromContext returns the Trace bound to the context, if any. +func FromContext(ctx context.Context) (tr Trace, ok bool) { + tr, ok = ctx.Value(contextKey).(Trace) + return +} diff --git a/glide.lock b/glide.lock index c7f71d4d9ea..306456f810c 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: b0a745e42cc5c2bfb0d21ee80a9efaf646fbe179aa3561c0bd7a73179d57a3f0 -updated: 2017-08-22T11:01:08.044444615-07:00 +hash: 680fead4df2e814f315fb1111c187f500faf7d9573295e331876a46aa126f8f7 +updated: 2017-09-06T14:59:05.315378166-07:00 imports: - name: github.com/beorn7/perks version: 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9 @@ -27,7 +27,7 @@ imports: - capnslog - dlopen - name: github.com/cpuguy83/go-md2man - version: 23709d0847197db6021a51fdb193e66e9222d4e7 + version: 1d903dcb749992f3741d744c0f8376b4bd7eb3e1 subpackages: - md2man - name: github.com/dgrijalva/jwt-go @@ -117,7 +117,7 @@ imports: - bcrypt - blowfish - name: golang.org/x/net - version: c8c74377599bd978aee1cf3b9b63a8634051cec2 + version: 66aacef3dd8a676686c7ae3716979581e8b03c47 subpackages: - context - http2 diff --git a/glide.yaml b/glide.yaml index 7a37090c216..b4402f5c491 100644 --- a/glide.yaml +++ b/glide.yaml @@ -85,7 +85,7 @@ import: - bcrypt - blowfish - package: golang.org/x/net - version: c8c74377599bd978aee1cf3b9b63a8634051cec2 + version: 66aacef3dd8a676686c7ae3716979581e8b03c47 subpackages: - context - http2 From 9d12ba26e0f5d1ce90141884f8336a0f93931bee Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Wed, 6 Sep 2017 15:26:52 -0700 Subject: [PATCH 3/5] README: require Go 1.9+ Signed-off-by: Gyu-Ho Lee --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 55ee92bd73d..b807a74bddd 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ See [etcdctl][etcdctl] for a simple command line client. The easiest way to get etcd is to use one of the pre-built release binaries which are available for OSX, Linux, Windows, [rkt][rkt], and Docker. Instructions for using these binaries are on the [GitHub releases page][github-release]. -For those wanting to try the very latest version, [build the latest version of etcd][dl-build] from the `master` branch. This first needs [*Go*](https://golang.org/) installed (version 1.8+ is required). All development occurs on `master`, including new features and bug fixes. Bug fixes are first targeted at `master` and subsequently ported to release branches, as described in the [branch management][branch-management] guide. +For those wanting to try the very latest version, [build the latest version of etcd][dl-build] from the `master` branch. This first needs [*Go*](https://golang.org/) installed (version 1.9+ is required). All development occurs on `master`, including new features and bug fixes. Bug fixes are first targeted at `master` and subsequently ported to release branches, as described in the [branch management][branch-management] guide. [rkt]: https://github.com/rkt/rkt/releases/ [github-release]: https://github.com/coreos/etcd/releases/ From 9a726b424db125c94264efc6e0cd471bd2f427c8 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Wed, 6 Sep 2017 15:58:07 -0700 Subject: [PATCH 4/5] *: fix leaky context creation with cancel Signed-off-by: Gyu-Ho Lee --- clientv3/balancer_test.go | 6 ++++-- clientv3/client.go | 8 +++++--- clientv3/concurrency/election.go | 2 ++ clientv3/concurrency/session.go | 1 + etcdserver/server_test.go | 3 ++- integration/cluster.go | 5 +++-- tools/functional-tester/etcd-tester/lease_stresser.go | 1 + 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/clientv3/balancer_test.go b/clientv3/balancer_test.go index cffa5d4178f..4485a474be6 100644 --- a/clientv3/balancer_test.go +++ b/clientv3/balancer_test.go @@ -84,8 +84,9 @@ func TestBalancerGetBlocking(t *testing.T) { } blockingOpts := grpc.BalancerGetOptions{BlockingWait: true} - ctx, _ := context.WithTimeout(context.Background(), time.Millisecond*100) + ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*100) _, _, err := sb.Get(ctx, blockingOpts) + cancel() if err != context.DeadlineExceeded { t.Errorf("Get() with no up endpoints should timeout, got %v", err) } @@ -124,8 +125,9 @@ func TestBalancerGetBlocking(t *testing.T) { t.Errorf("closing the only connection should triggered balancer to send the all endpoints via Notify chan so that we can establish a connection") } down2(errors.New("error")) - ctx, _ = context.WithTimeout(context.Background(), time.Millisecond*100) + ctx, cancel = context.WithTimeout(context.Background(), time.Millisecond*100) _, _, err = sb.Get(ctx, blockingOpts) + cancel() if err != context.DeadlineExceeded { t.Errorf("Get() with no up endpoints should timeout, got %v", err) } diff --git a/clientv3/client.go b/clientv3/client.go index 2f56d511ea8..e5bc4cc0049 100644 --- a/clientv3/client.go +++ b/clientv3/client.go @@ -143,8 +143,10 @@ func (c *Client) autoSync() { case <-c.ctx.Done(): return case <-time.After(c.cfg.AutoSyncInterval): - ctx, _ := context.WithTimeout(c.ctx, 5*time.Second) - if err := c.Sync(ctx); err != nil && err != c.ctx.Err() { + ctx, cancel := context.WithTimeout(c.ctx, 5*time.Second) + err := c.Sync(ctx) + cancel() + if err != nil && err != c.ctx.Err() { logger.Println("Auto sync endpoints failed:", err) } } @@ -429,7 +431,7 @@ func (c *Client) checkVersion() (err error) { errc := make(chan error, len(c.cfg.Endpoints)) ctx, cancel := context.WithCancel(c.ctx) if c.cfg.DialTimeout > 0 { - ctx, _ = context.WithTimeout(ctx, c.cfg.DialTimeout) + ctx, cancel = context.WithTimeout(ctx, c.cfg.DialTimeout) } wg.Add(len(c.cfg.Endpoints)) for _, ep := range c.cfg.Endpoints { diff --git a/clientv3/concurrency/election.go b/clientv3/concurrency/election.go index 1a6bbfc90fb..af5f72e425f 100644 --- a/clientv3/concurrency/election.go +++ b/clientv3/concurrency/election.go @@ -213,6 +213,7 @@ func (e *Election) observe(ctx context.Context, ch chan<- v3.GetResponse) { for !keyDeleted { wr, ok := <-wch if !ok { + cancel() return } for _, ev := range wr.Events { @@ -225,6 +226,7 @@ func (e *Election) observe(ctx context.Context, ch chan<- v3.GetResponse) { select { case ch <- *resp: case <-cctx.Done(): + cancel() return } } diff --git a/clientv3/concurrency/session.go b/clientv3/concurrency/session.go index 7e2ff89b4e4..c399d64a61d 100644 --- a/clientv3/concurrency/session.go +++ b/clientv3/concurrency/session.go @@ -53,6 +53,7 @@ func NewSession(client *v3.Client, opts ...SessionOption) (*Session, error) { ctx, cancel := context.WithCancel(ops.ctx) keepAlive, err := client.KeepAlive(ctx, id) if err != nil || keepAlive == nil { + cancel() return nil, err } diff --git a/etcdserver/server_test.go b/etcdserver/server_test.go index bafacad6cd3..e3ea0f9250c 100644 --- a/etcdserver/server_test.go +++ b/etcdserver/server_test.go @@ -741,8 +741,9 @@ func TestDoProposalTimeout(t *testing.T) { } srv.applyV2 = &applierV2store{store: srv.store, cluster: srv.cluster} - ctx, _ := context.WithTimeout(context.Background(), 0) + ctx, cancel := context.WithTimeout(context.Background(), 0) _, err := srv.Do(ctx, pb.Request{Method: "PUT"}) + cancel() if err != ErrTimeout { t.Fatalf("err = %v, want %v", err, ErrTimeout) } diff --git a/integration/cluster.go b/integration/cluster.go index c85eccccd05..ec9a9f49357 100644 --- a/integration/cluster.go +++ b/integration/cluster.go @@ -277,10 +277,11 @@ func (c *cluster) addMemberByURL(t *testing.T, clientURL, peerURL string) error cc := MustNewHTTPClient(t, []string{clientURL}, c.cfg.ClientTLS) ma := client.NewMembersAPI(cc) ctx, cancel := context.WithTimeout(context.Background(), requestTimeout) - if _, err := ma.Add(ctx, peerURL); err != nil { + _, err := ma.Add(ctx, peerURL) + cancel() + if err != nil { return err } - cancel() // wait for the add node entry applied in the cluster members := append(c.HTTPMembers(), client.Member{PeerURLs: []string{peerURL}, ClientURLs: []string{}}) diff --git a/tools/functional-tester/etcd-tester/lease_stresser.go b/tools/functional-tester/etcd-tester/lease_stresser.go index 1ca788410c4..ea15fd7a7ef 100644 --- a/tools/functional-tester/etcd-tester/lease_stresser.go +++ b/tools/functional-tester/etcd-tester/lease_stresser.go @@ -290,6 +290,7 @@ func (ls *leaseStresser) keepLeaseAlive(leaseID int64) { cancel() ctx, cancel = context.WithCancel(ls.ctx) stream, err = ls.lc.LeaseKeepAlive(ctx) + cancel() continue } err = stream.Send(&pb.LeaseKeepAliveRequest{ID: leaseID}) From 24498ea167f3c4dcd9762f8f5712a82fd445df88 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Wed, 6 Sep 2017 17:25:26 -0700 Subject: [PATCH 5/5] test: mask 'nil Context' for staticcheck Signed-off-by: Gyu-Ho Lee --- test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test b/test index 2c86a0f9f0c..0be80f50746 100755 --- a/test +++ b/test @@ -377,7 +377,7 @@ function fmt_pass { if [ -n "${staticcheckResult}" ]; then # TODO: resolve these after go1.8 migration # See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck - STATIC_CHECK_MASK="SA(1019|2002)" + STATIC_CHECK_MASK="SA(1012|1019|2002)" if echo "${staticcheckResult}" | egrep -v "$STATIC_CHECK_MASK"; then echo -e "staticcheck checking failed:\n${staticcheckResult}" exit 255