From 16ec976f455092fe713b1c2d7371724b8f8c953d Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Fri, 23 Feb 2024 17:08:38 -0500 Subject: [PATCH] manager/allocator: delete cnmallocator package It is only needed to integrate Swarmkit into Moby networking and no Swarmkit package imports it. It is also the only package remaining which imports from github.com/docker/docker. Delete it to break the module dependency cycle with Moby. The code will be moved over to the https://github.com/moby/moby repo to live closer to the libnetwork logic that it is so tightly integrated into. Signed-off-by: Cory Snider --- go.mod | 4 - go.sum | 9 - .../allocator/cnmallocator/allocator_test.go | 11 - .../allocator/cnmallocator/drivers_darwin.go | 16 - .../allocator/cnmallocator/drivers_ipam.go | 53 - .../cnmallocator/drivers_network_linux.go | 27 - .../cnmallocator/drivers_network_windows.go | 27 - .../cnmallocator/drivers_unsupported.go | 15 - manager/allocator/cnmallocator/manager.go | 78 - .../cnmallocator/networkallocator.go | 978 ------- .../cnmallocator/networkallocator_test.go | 788 ------ manager/allocator/cnmallocator/provider.go | 91 - .../allocator/cnmallocator/provider_test.go | 30 - .../github.com/containerd/containerd/LICENSE | 191 -- .../github.com/containerd/containerd/NOTICE | 16 - .../containerd/containerd/log/context.go | 120 - vendor/github.com/docker/docker/AUTHORS | 2406 ----------------- vendor/github.com/docker/docker/LICENSE | 191 -- vendor/github.com/docker/docker/NOTICE | 19 - .../github.com/docker/docker/errdefs/defs.go | 69 - .../github.com/docker/docker/errdefs/doc.go | 8 - .../docker/docker/errdefs/helpers.go | 279 -- .../docker/docker/errdefs/http_helpers.go | 46 - vendor/github.com/docker/docker/errdefs/is.go | 107 - .../docker/libnetwork/bitmap/sequence.go | 585 ---- .../libnetwork/discoverapi/discoverapi.go | 58 - .../docker/libnetwork/driverapi/driverapi.go | 208 -- .../docker/libnetwork/driverapi/errors.go | 56 - .../docker/libnetwork/driverapi/ipamdata.go | 103 - .../drivers/bridge/brmanager/brmanager.go | 78 - .../docker/libnetwork/drivers/host/host.go | 93 - .../drivers/ipvlan/ivmanager/ivmanager.go | 78 - .../drivers/macvlan/mvmanager/mvmanager.go | 78 - .../drivers/overlay/overlayutils/utils.go | 64 - .../drivers/overlay/ovmanager/ovmanager.go | 216 -- .../libnetwork/drivers/remote/api/api.go | 221 -- .../libnetwork/drivers/remote/driver.go | 435 --- .../docker/libnetwork/drvregistry/ipams.go | 84 - .../docker/libnetwork/drvregistry/networks.go | 90 - .../docker/libnetwork/ipam/allocator.go | 409 --- .../docker/libnetwork/ipam/structures.go | 168 -- .../docker/docker/libnetwork/ipam/utils.go | 48 - .../docker/libnetwork/ipamapi/contract.go | 74 - .../docker/libnetwork/ipamapi/labels.go | 10 - .../libnetwork/ipams/builtin/builtin.go | 41 - .../libnetwork/ipams/builtin/builtin_unix.go | 12 - .../ipams/builtin/builtin_windows.go | 17 - .../docker/libnetwork/ipams/null/null.go | 67 - .../docker/libnetwork/ipams/remote/api/api.go | 94 - .../docker/libnetwork/ipams/remote/remote.go | 172 -- .../ipams/windowsipam/windowsipam.go | 86 - .../docker/libnetwork/ipamutils/utils.go | 123 - .../docker/docker/libnetwork/ipbits/ipbits.go | 41 - .../docker/libnetwork/ipbits/uint128.go | 62 - .../docker/libnetwork/netlabel/labels.go | 52 - .../docker/docker/libnetwork/scope/scope.go | 12 - .../docker/docker/libnetwork/types/types.go | 478 ---- .../docker/docker/pkg/homedir/homedir.go | 44 - .../docker/pkg/homedir/homedir_linux.go | 105 - .../docker/pkg/homedir/homedir_others.go | 32 - .../docker/docker/pkg/homedir/homedir_unix.go | 8 - .../docker/pkg/homedir/homedir_windows.go | 6 - .../docker/docker/pkg/ioutils/buffer.go | 51 - .../docker/docker/pkg/ioutils/bytespipe.go | 187 -- .../docker/docker/pkg/ioutils/fswriters.go | 161 -- .../docker/docker/pkg/ioutils/readers.go | 151 -- .../docker/docker/pkg/ioutils/writeflusher.go | 92 - .../docker/docker/pkg/ioutils/writers.go | 66 - .../docker/docker/pkg/plugingetter/getter.go | 52 - .../docker/docker/pkg/plugins/client.go | 270 -- .../docker/docker/pkg/plugins/discovery.go | 178 -- .../docker/pkg/plugins/discovery_unix.go | 31 - .../docker/pkg/plugins/discovery_windows.go | 11 - .../docker/docker/pkg/plugins/errors.go | 33 - .../docker/docker/pkg/plugins/plugins.go | 345 --- .../docker/pkg/plugins/transport/http.go | 41 - .../docker/pkg/plugins/transport/mimetype.go | 6 - .../docker/docker/pkg/rootless/rootless.go | 11 - .../github.com/docker/go-connections/LICENSE | 191 -- .../docker/go-connections/sockets/README.md | 0 .../go-connections/sockets/inmem_socket.go | 81 - .../docker/go-connections/sockets/proxy.go | 28 - .../docker/go-connections/sockets/sockets.go | 37 - .../go-connections/sockets/sockets_unix.go | 39 - .../go-connections/sockets/sockets_windows.go | 28 - .../go-connections/sockets/tcp_socket.go | 22 - .../go-connections/sockets/unix_socket.go | 126 - .../go-connections/tlsconfig/certpool.go | 16 - .../docker/go-connections/tlsconfig/config.go | 261 -- .../tlsconfig/config_client_ciphers.go | 14 - .../github.com/ishidawataru/sctp/.gitignore | 16 - .../github.com/ishidawataru/sctp/.travis.yml | 29 - .../github.com/ishidawataru/sctp/GO_LICENSE | 27 - vendor/github.com/ishidawataru/sctp/LICENSE | 201 -- vendor/github.com/ishidawataru/sctp/NOTICE | 3 - vendor/github.com/ishidawataru/sctp/README.md | 18 - .../ishidawataru/sctp/ipsock_linux.go | 222 -- vendor/github.com/ishidawataru/sctp/sctp.go | 737 ----- .../ishidawataru/sctp/sctp_linux.go | 309 --- .../ishidawataru/sctp/sctp_unsupported.go | 98 - vendor/modules.txt | 43 - 101 files changed, 14419 deletions(-) delete mode 100644 manager/allocator/cnmallocator/allocator_test.go delete mode 100644 manager/allocator/cnmallocator/drivers_darwin.go delete mode 100644 manager/allocator/cnmallocator/drivers_ipam.go delete mode 100644 manager/allocator/cnmallocator/drivers_network_linux.go delete mode 100644 manager/allocator/cnmallocator/drivers_network_windows.go delete mode 100644 manager/allocator/cnmallocator/drivers_unsupported.go delete mode 100644 manager/allocator/cnmallocator/manager.go delete mode 100644 manager/allocator/cnmallocator/networkallocator.go delete mode 100644 manager/allocator/cnmallocator/networkallocator_test.go delete mode 100644 manager/allocator/cnmallocator/provider.go delete mode 100644 manager/allocator/cnmallocator/provider_test.go delete mode 100644 vendor/github.com/containerd/containerd/LICENSE delete mode 100644 vendor/github.com/containerd/containerd/NOTICE delete mode 100644 vendor/github.com/containerd/containerd/log/context.go delete mode 100644 vendor/github.com/docker/docker/AUTHORS delete mode 100644 vendor/github.com/docker/docker/LICENSE delete mode 100644 vendor/github.com/docker/docker/NOTICE delete mode 100644 vendor/github.com/docker/docker/errdefs/defs.go delete mode 100644 vendor/github.com/docker/docker/errdefs/doc.go delete mode 100644 vendor/github.com/docker/docker/errdefs/helpers.go delete mode 100644 vendor/github.com/docker/docker/errdefs/http_helpers.go delete mode 100644 vendor/github.com/docker/docker/errdefs/is.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/bitmap/sequence.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/discoverapi/discoverapi.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/driverapi/driverapi.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/driverapi/errors.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/driverapi/ipamdata.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/drivers/bridge/brmanager/brmanager.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/drivers/host/host.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/drivers/ipvlan/ivmanager/ivmanager.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/drivers/macvlan/mvmanager/mvmanager.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/drivers/overlay/overlayutils/utils.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/drivers/overlay/ovmanager/ovmanager.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/drivers/remote/api/api.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/drivers/remote/driver.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/drvregistry/ipams.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/drvregistry/networks.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipam/allocator.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipam/structures.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipam/utils.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipamapi/contract.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipamapi/labels.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipams/builtin/builtin.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipams/builtin/builtin_unix.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipams/builtin/builtin_windows.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipams/null/null.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipams/remote/api/api.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipams/remote/remote.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipams/windowsipam/windowsipam.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipamutils/utils.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipbits/ipbits.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/ipbits/uint128.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/netlabel/labels.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/scope/scope.go delete mode 100644 vendor/github.com/docker/docker/libnetwork/types/types.go delete mode 100644 vendor/github.com/docker/docker/pkg/homedir/homedir.go delete mode 100644 vendor/github.com/docker/docker/pkg/homedir/homedir_linux.go delete mode 100644 vendor/github.com/docker/docker/pkg/homedir/homedir_others.go delete mode 100644 vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go delete mode 100644 vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go delete mode 100644 vendor/github.com/docker/docker/pkg/ioutils/buffer.go delete mode 100644 vendor/github.com/docker/docker/pkg/ioutils/bytespipe.go delete mode 100644 vendor/github.com/docker/docker/pkg/ioutils/fswriters.go delete mode 100644 vendor/github.com/docker/docker/pkg/ioutils/readers.go delete mode 100644 vendor/github.com/docker/docker/pkg/ioutils/writeflusher.go delete mode 100644 vendor/github.com/docker/docker/pkg/ioutils/writers.go delete mode 100644 vendor/github.com/docker/docker/pkg/plugingetter/getter.go delete mode 100644 vendor/github.com/docker/docker/pkg/plugins/client.go delete mode 100644 vendor/github.com/docker/docker/pkg/plugins/discovery.go delete mode 100644 vendor/github.com/docker/docker/pkg/plugins/discovery_unix.go delete mode 100644 vendor/github.com/docker/docker/pkg/plugins/discovery_windows.go delete mode 100644 vendor/github.com/docker/docker/pkg/plugins/errors.go delete mode 100644 vendor/github.com/docker/docker/pkg/plugins/plugins.go delete mode 100644 vendor/github.com/docker/docker/pkg/plugins/transport/http.go delete mode 100644 vendor/github.com/docker/docker/pkg/plugins/transport/mimetype.go delete mode 100644 vendor/github.com/docker/docker/pkg/rootless/rootless.go delete mode 100644 vendor/github.com/docker/go-connections/LICENSE delete mode 100644 vendor/github.com/docker/go-connections/sockets/README.md delete mode 100644 vendor/github.com/docker/go-connections/sockets/inmem_socket.go delete mode 100644 vendor/github.com/docker/go-connections/sockets/proxy.go delete mode 100644 vendor/github.com/docker/go-connections/sockets/sockets.go delete mode 100644 vendor/github.com/docker/go-connections/sockets/sockets_unix.go delete mode 100644 vendor/github.com/docker/go-connections/sockets/sockets_windows.go delete mode 100644 vendor/github.com/docker/go-connections/sockets/tcp_socket.go delete mode 100644 vendor/github.com/docker/go-connections/sockets/unix_socket.go delete mode 100644 vendor/github.com/docker/go-connections/tlsconfig/certpool.go delete mode 100644 vendor/github.com/docker/go-connections/tlsconfig/config.go delete mode 100644 vendor/github.com/docker/go-connections/tlsconfig/config_client_ciphers.go delete mode 100644 vendor/github.com/ishidawataru/sctp/.gitignore delete mode 100644 vendor/github.com/ishidawataru/sctp/.travis.yml delete mode 100644 vendor/github.com/ishidawataru/sctp/GO_LICENSE delete mode 100644 vendor/github.com/ishidawataru/sctp/LICENSE delete mode 100644 vendor/github.com/ishidawataru/sctp/NOTICE delete mode 100644 vendor/github.com/ishidawataru/sctp/README.md delete mode 100644 vendor/github.com/ishidawataru/sctp/ipsock_linux.go delete mode 100644 vendor/github.com/ishidawataru/sctp/sctp.go delete mode 100644 vendor/github.com/ishidawataru/sctp/sctp_linux.go delete mode 100644 vendor/github.com/ishidawataru/sctp/sctp_unsupported.go diff --git a/go.mod b/go.mod index 7fdd3ea8b1..8a71a6cc12 100644 --- a/go.mod +++ b/go.mod @@ -10,8 +10,6 @@ require ( github.com/cloudflare/cfssl v1.6.4 github.com/container-storage-interface/spec v1.2.0 github.com/distribution/reference v0.5.0 - github.com/docker/docker v24.0.0-rc.2.0.20230908212318-6ce5aa1cd5a4+incompatible // master (v25.0.0-dev) - github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea // indirect github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c github.com/docker/go-metrics v0.0.1 github.com/dustin/go-humanize v1.0.0 // indirect @@ -61,7 +59,6 @@ require ( github.com/akutz/gosync v0.1.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/containerd/containerd v1.6.22 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-logr/logr v1.2.4 // indirect @@ -70,7 +67,6 @@ require ( github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/ishidawataru/sctp v0.0.0-20230406120618-7ff4192f6ff2 // indirect github.com/jmoiron/sqlx v1.3.3 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/nxadm/tail v1.4.8 // indirect diff --git a/go.sum b/go.sum index 64500bc7a5..d85a0bb411 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,6 @@ github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOi github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= github.com/container-storage-interface/spec v1.2.0 h1:bD9KIVgaVKKkQ/UbVUY9kCaH/CJbhNxe0eeB4JeJV2s= github.com/container-storage-interface/spec v1.2.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4= -github.com/containerd/containerd v1.6.22 h1:rGTIBxPJusM0evF6wKgIzuD+tV70nmx9eEjzHVm1JzI= -github.com/containerd/containerd v1.6.22/go.mod h1:BQAJdahvGz8xboAvxKg9hsDYIovn79Ea318anowQ1/o= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -84,10 +82,6 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/docker v24.0.0-rc.2.0.20230908212318-6ce5aa1cd5a4+incompatible h1:sqXunZ6IkpGcR9Kgj8R4MaCXNBZYhlcXxe4BGC8tJAI= -github.com/docker/docker v24.0.0-rc.2.0.20230908212318-6ce5aa1cd5a4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea h1:+4n+kUVbPdu6qMI9SUnSKMC+D50gNW4L7Lhk9tI2lVo= -github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8= github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8= @@ -223,8 +217,6 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/ishidawataru/sctp v0.0.0-20230406120618-7ff4192f6ff2 h1:i2fYnDurfLlJH8AyyMOnkLHnHeP8Ff/DDpuZA/D3bPo= -github.com/ishidawataru/sctp v0.0.0-20230406120618-7ff4192f6ff2/go.mod h1:co9pwDoBCm1kGxawmb4sPq0cSIOOWNPT4KnHotMP1Zg= github.com/jmoiron/sqlx v1.3.3 h1:j82X0bf7oQ27XeqxicSZsTU5suPwKElg3oyxNn43iTk= github.com/jmoiron/sqlx v1.3.3/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= @@ -684,7 +676,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/manager/allocator/cnmallocator/allocator_test.go b/manager/allocator/cnmallocator/allocator_test.go deleted file mode 100644 index f89192748f..0000000000 --- a/manager/allocator/cnmallocator/allocator_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package cnmallocator - -import ( - "testing" - - "github.com/moby/swarmkit/v2/manager/allocator" -) - -func TestAllocator(t *testing.T) { - allocator.RunAllocatorTests(t, NewProvider(nil)) -} diff --git a/manager/allocator/cnmallocator/drivers_darwin.go b/manager/allocator/cnmallocator/drivers_darwin.go deleted file mode 100644 index 9b4922ef92..0000000000 --- a/manager/allocator/cnmallocator/drivers_darwin.go +++ /dev/null @@ -1,16 +0,0 @@ -package cnmallocator - -import ( - "github.com/docker/docker/libnetwork/driverapi" - "github.com/docker/docker/libnetwork/drivers/overlay/ovmanager" - "github.com/moby/swarmkit/v2/manager/allocator/networkallocator" -) - -var initializers = map[string]func(driverapi.Registerer) error{ - "overlay": ovmanager.Register, -} - -// PredefinedNetworks returns the list of predefined network structures -func (*Provider) PredefinedNetworks() []networkallocator.PredefinedNetworkData { - return nil -} diff --git a/manager/allocator/cnmallocator/drivers_ipam.go b/manager/allocator/cnmallocator/drivers_ipam.go deleted file mode 100644 index 8e75071de9..0000000000 --- a/manager/allocator/cnmallocator/drivers_ipam.go +++ /dev/null @@ -1,53 +0,0 @@ -package cnmallocator - -import ( - "context" - "strconv" - "strings" - - "github.com/docker/docker/libnetwork/ipamapi" - builtinIpam "github.com/docker/docker/libnetwork/ipams/builtin" - nullIpam "github.com/docker/docker/libnetwork/ipams/null" - "github.com/docker/docker/libnetwork/ipamutils" - "github.com/moby/swarmkit/v2/log" - "github.com/moby/swarmkit/v2/manager/allocator/networkallocator" -) - -func initIPAMDrivers(r ipamapi.Registerer, netConfig *networkallocator.Config) error { - var addressPool []*ipamutils.NetworkToSplit - var str strings.Builder - str.WriteString("Subnetlist - ") - // Extract defaultAddrPool param info and construct ipamutils.NetworkToSplit - // from the info. We will be using it to call Libnetwork API - // We also need to log new address pool info whenever swarm init - // happens with default address pool option - if netConfig != nil { - for _, p := range netConfig.DefaultAddrPool { - addressPool = append(addressPool, &ipamutils.NetworkToSplit{ - Base: p, - Size: int(netConfig.SubnetSize), - }) - str.WriteString(p + ",") - } - str.WriteString(": Size ") - str.WriteString(strconv.Itoa(int(netConfig.SubnetSize))) - - } - if err := ipamutils.ConfigGlobalScopeDefaultNetworks(addressPool); err != nil { - return err - } - if addressPool != nil { - log.G(context.TODO()).Infof("Swarm initialized global default address pool to: " + str.String()) - } - - for _, fn := range [](func(ipamapi.Registerer) error){ - builtinIpam.Register, - nullIpam.Register, - } { - if err := fn(r); err != nil { - return err - } - } - - return nil -} diff --git a/manager/allocator/cnmallocator/drivers_network_linux.go b/manager/allocator/cnmallocator/drivers_network_linux.go deleted file mode 100644 index 67349d95fd..0000000000 --- a/manager/allocator/cnmallocator/drivers_network_linux.go +++ /dev/null @@ -1,27 +0,0 @@ -package cnmallocator - -import ( - "github.com/docker/docker/libnetwork/driverapi" - "github.com/docker/docker/libnetwork/drivers/bridge/brmanager" - "github.com/docker/docker/libnetwork/drivers/host" - "github.com/docker/docker/libnetwork/drivers/ipvlan/ivmanager" - "github.com/docker/docker/libnetwork/drivers/macvlan/mvmanager" - "github.com/docker/docker/libnetwork/drivers/overlay/ovmanager" - "github.com/moby/swarmkit/v2/manager/allocator/networkallocator" -) - -var initializers = map[string]func(driverapi.Registerer) error{ - "overlay": ovmanager.Register, - "macvlan": mvmanager.Register, - "bridge": brmanager.Register, - "ipvlan": ivmanager.Register, - "host": host.Register, -} - -// PredefinedNetworks returns the list of predefined network structures -func (*Provider) PredefinedNetworks() []networkallocator.PredefinedNetworkData { - return []networkallocator.PredefinedNetworkData{ - {Name: "bridge", Driver: "bridge"}, - {Name: "host", Driver: "host"}, - } -} diff --git a/manager/allocator/cnmallocator/drivers_network_windows.go b/manager/allocator/cnmallocator/drivers_network_windows.go deleted file mode 100644 index 4fca3db291..0000000000 --- a/manager/allocator/cnmallocator/drivers_network_windows.go +++ /dev/null @@ -1,27 +0,0 @@ -package cnmallocator - -import ( - "github.com/docker/docker/libnetwork/driverapi" - "github.com/docker/docker/libnetwork/drivers/overlay/ovmanager" - "github.com/moby/swarmkit/v2/manager/allocator/networkallocator" -) - -var initializers = map[string]func(driverapi.Registerer) error{ - "overlay": ovmanager.Register, - "internal": stubManager("internal"), - "l2bridge": stubManager("l2bridge"), - "nat": stubManager("nat"), -} - -// PredefinedNetworks returns the list of predefined network structures -func (*Provider) PredefinedNetworks() []networkallocator.PredefinedNetworkData { - return []networkallocator.PredefinedNetworkData{ - {Name: "nat", Driver: "nat"}, - } -} - -func stubManager(ntype string) func(driverapi.Registerer) error { - return func(r driverapi.Registerer) error { - return RegisterManager(r, ntype) - } -} diff --git a/manager/allocator/cnmallocator/drivers_unsupported.go b/manager/allocator/cnmallocator/drivers_unsupported.go deleted file mode 100644 index 795369b099..0000000000 --- a/manager/allocator/cnmallocator/drivers_unsupported.go +++ /dev/null @@ -1,15 +0,0 @@ -//go:build !linux && !darwin && !windows -// +build !linux,!darwin,!windows - -package cnmallocator - -import ( - "github.com/moby/swarmkit/v2/manager/allocator/networkallocator" -) - -const initializers = nil - -// PredefinedNetworks returns the list of predefined network structures -func (*Provider) PredefinedNetworks() []networkallocator.PredefinedNetworkData { - return nil -} diff --git a/manager/allocator/cnmallocator/manager.go b/manager/allocator/cnmallocator/manager.go deleted file mode 100644 index a9af3820f2..0000000000 --- a/manager/allocator/cnmallocator/manager.go +++ /dev/null @@ -1,78 +0,0 @@ -package cnmallocator - -import ( - "github.com/docker/docker/libnetwork/driverapi" - "github.com/docker/docker/libnetwork/scope" - "github.com/docker/docker/libnetwork/types" -) - -type manager struct { - networkType string -} - -// RegisterManager registers a new instance of the manager driver for networkType with r. -func RegisterManager(r driverapi.Registerer, networkType string) error { - return r.RegisterDriver(networkType, &manager{networkType: networkType}, driverapi.Capability{ - DataScope: scope.Local, - ConnectivityScope: scope.Local, - }) -} - -func (d *manager) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) { - return nil, types.NotImplementedErrorf("not implemented") -} - -func (d *manager) NetworkFree(id string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *manager) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *manager) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) { -} - -func (d *manager) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) { - return "", nil -} - -func (d *manager) DeleteNetwork(nid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *manager) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *manager) DeleteEndpoint(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *manager) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) { - return nil, types.NotImplementedErrorf("not implemented") -} - -func (d *manager) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *manager) Leave(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *manager) Type() string { - return d.networkType -} - -func (d *manager) IsBuiltIn() bool { - return true -} - -func (d *manager) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *manager) RevokeExternalConnectivity(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} diff --git a/manager/allocator/cnmallocator/networkallocator.go b/manager/allocator/cnmallocator/networkallocator.go deleted file mode 100644 index 2bf3d3a424..0000000000 --- a/manager/allocator/cnmallocator/networkallocator.go +++ /dev/null @@ -1,978 +0,0 @@ -package cnmallocator - -import ( - "context" - "fmt" - "net" - "strings" - - "github.com/docker/docker/libnetwork/driverapi" - "github.com/docker/docker/libnetwork/drivers/remote" - "github.com/docker/docker/libnetwork/drvregistry" - "github.com/docker/docker/libnetwork/ipamapi" - remoteipam "github.com/docker/docker/libnetwork/ipams/remote" - "github.com/docker/docker/libnetwork/netlabel" - "github.com/docker/docker/libnetwork/scope" - "github.com/docker/docker/pkg/plugingetter" - "github.com/moby/swarmkit/v2/api" - "github.com/moby/swarmkit/v2/log" - "github.com/moby/swarmkit/v2/manager/allocator/networkallocator" - "github.com/pkg/errors" -) - -const ( - // DefaultDriver defines the name of the driver to be used by - // default if a network without any driver name specified is - // created. - DefaultDriver = "overlay" -) - -// cnmNetworkAllocator acts as the controller for all network related operations -// like managing network and IPAM drivers and also creating and -// deleting networks and the associated resources. -type cnmNetworkAllocator struct { - // The plugin getter instance used to get network and IPAM driver plugins. - pg plugingetter.PluginGetter - - // The driver registry for all internal and external IPAM drivers. - ipamRegistry drvregistry.IPAMs - - // The driver registry for all internal and external network drivers. - networkRegistry drvregistry.Networks - - // Local network state used by cnmNetworkAllocator to do network management. - networks map[string]*network - - // Allocator state to indicate if allocation has been - // successfully completed for this service. - services map[string]struct{} - - // Allocator state to indicate if allocation has been - // successfully completed for this task. - tasks map[string]struct{} - - // Allocator state to indicate if allocation has been - // successfully completed for this node on this network. - // outer map key: node id - // inner map key: network id - nodes map[string]map[string]struct{} -} - -// Local in-memory state related to network that need to be tracked by cnmNetworkAllocator -type network struct { - // A local cache of the store object. - nw *api.Network - - // pools is used to save the internal poolIDs needed when - // releasing the pool. - pools map[string]string - - // endpoints is a map of endpoint IP to the poolID from which it - // was allocated. - endpoints map[string]string - - // isNodeLocal indicates whether the scope of the network's resources - // is local to the node. If true, it means the resources can only be - // allocated locally by the node where the network will be deployed. - // In this the swarm manager will skip the allocations. - isNodeLocal bool -} - -type networkDriver struct { - driver driverapi.Driver - name string - capability *driverapi.Capability -} - -// NewAllocator returns a new NetworkAllocator handle -func (p *Provider) NewAllocator(netConfig *networkallocator.Config) (networkallocator.NetworkAllocator, error) { - na := &cnmNetworkAllocator{ - networks: make(map[string]*network), - services: make(map[string]struct{}), - tasks: make(map[string]struct{}), - nodes: make(map[string]map[string]struct{}), - pg: p.pg, - } - - for ntype, i := range initializers { - if err := i(&na.networkRegistry); err != nil { - return nil, fmt.Errorf("failed to register %q network driver: %w", ntype, err) - } - } - if err := remote.Register(&na.networkRegistry, p.pg); err != nil { - return nil, fmt.Errorf("failed to initialize network driver plugins: %w", err) - } - - if err := initIPAMDrivers(&na.ipamRegistry, netConfig); err != nil { - return nil, err - } - if err := remoteipam.Register(&na.ipamRegistry, p.pg); err != nil { - return nil, fmt.Errorf("failed to initialize IPAM driver plugins: %w", err) - } - - return na, nil -} - -// Allocate allocates all the necessary resources both general -// and driver-specific which may be specified in the NetworkSpec -func (na *cnmNetworkAllocator) Allocate(n *api.Network) error { - if _, ok := na.networks[n.ID]; ok { - return fmt.Errorf("network %s already allocated", n.ID) - } - - d, err := na.resolveDriver(n) - if err != nil { - return err - } - - nw := &network{ - nw: n, - endpoints: make(map[string]string), - isNodeLocal: d.capability.DataScope == scope.Local, - } - - // No swarm-level allocation can be provided by the network driver for - // node-local networks. Only thing needed is populating the driver's name - // in the driver's state. - if nw.isNodeLocal { - n.DriverState = &api.Driver{ - Name: d.name, - } - // In order to support backward compatibility with older daemon - // versions which assumes the network attachment to contains - // non nil IPAM attribute, passing an empty object - n.IPAM = &api.IPAMOptions{Driver: &api.Driver{}} - } else { - nw.pools, err = na.allocatePools(n) - if err != nil { - return errors.Wrapf(err, "failed allocating pools and gateway IP for network %s", n.ID) - } - - if err := na.allocateDriverState(n); err != nil { - na.freePools(n, nw.pools) - return errors.Wrapf(err, "failed while allocating driver state for network %s", n.ID) - } - } - - na.networks[n.ID] = nw - - return nil -} - -func (na *cnmNetworkAllocator) getNetwork(id string) *network { - return na.networks[id] -} - -// Deallocate frees all the general and driver specific resources -// which were assigned to the passed network. -func (na *cnmNetworkAllocator) Deallocate(n *api.Network) error { - localNet := na.getNetwork(n.ID) - if localNet == nil { - return fmt.Errorf("could not get networker state for network %s", n.ID) - } - - // No swarm-level resource deallocation needed for node-local networks - if localNet.isNodeLocal { - delete(na.networks, n.ID) - return nil - } - - if err := na.freeDriverState(n); err != nil { - return errors.Wrapf(err, "failed to free driver state for network %s", n.ID) - } - - delete(na.networks, n.ID) - - return na.freePools(n, localNet.pools) -} - -// AllocateService allocates all the network resources such as virtual -// IP needed by the service. -func (na *cnmNetworkAllocator) AllocateService(s *api.Service) (err error) { - defer func() { - if err != nil { - na.DeallocateService(s) - } - }() - - if s.Endpoint == nil { - s.Endpoint = &api.Endpoint{} - } - s.Endpoint.Spec = s.Spec.Endpoint.Copy() - - // If ResolutionMode is DNSRR do not try allocating VIPs, but - // free any VIP from previous state. - if s.Spec.Endpoint != nil && s.Spec.Endpoint.Mode == api.ResolutionModeDNSRoundRobin { - for _, vip := range s.Endpoint.VirtualIPs { - if err := na.deallocateVIP(vip); err != nil { - // don't bail here, deallocate as many as possible. - log.L.WithError(err). - WithField("vip.network", vip.NetworkID). - WithField("vip.addr", vip.Addr).Error("error deallocating vip") - } - } - - s.Endpoint.VirtualIPs = nil - - delete(na.services, s.ID) - return nil - } - - specNetworks := serviceNetworks(s) - - // Allocate VIPs for all the pre-populated endpoint attachments - eVIPs := s.Endpoint.VirtualIPs[:0] - -vipLoop: - for _, eAttach := range s.Endpoint.VirtualIPs { - if na.IsVIPOnIngressNetwork(eAttach) && networkallocator.IsIngressNetworkNeeded(s) { - if err = na.allocateVIP(eAttach); err != nil { - return err - } - eVIPs = append(eVIPs, eAttach) - continue vipLoop - - } - for _, nAttach := range specNetworks { - if nAttach.Target == eAttach.NetworkID { - log.L.WithFields(log.Fields{"service_id": s.ID, "vip": eAttach.Addr}).Debug("allocate vip") - if err = na.allocateVIP(eAttach); err != nil { - return err - } - eVIPs = append(eVIPs, eAttach) - continue vipLoop - } - } - // If the network of the VIP is not part of the service spec, - // deallocate the vip - na.deallocateVIP(eAttach) - } - -networkLoop: - for _, nAttach := range specNetworks { - for _, vip := range s.Endpoint.VirtualIPs { - if vip.NetworkID == nAttach.Target { - continue networkLoop - } - } - - vip := &api.Endpoint_VirtualIP{NetworkID: nAttach.Target} - if err = na.allocateVIP(vip); err != nil { - return err - } - - eVIPs = append(eVIPs, vip) - } - - if len(eVIPs) > 0 { - na.services[s.ID] = struct{}{} - } else { - delete(na.services, s.ID) - } - - s.Endpoint.VirtualIPs = eVIPs - return nil -} - -// DeallocateService de-allocates all the network resources such as -// virtual IP associated with the service. -func (na *cnmNetworkAllocator) DeallocateService(s *api.Service) error { - if s.Endpoint == nil { - return nil - } - - for _, vip := range s.Endpoint.VirtualIPs { - if err := na.deallocateVIP(vip); err != nil { - // don't bail here, deallocate as many as possible. - log.L.WithError(err). - WithField("vip.network", vip.NetworkID). - WithField("vip.addr", vip.Addr).Error("error deallocating vip") - } - } - s.Endpoint.VirtualIPs = nil - - delete(na.services, s.ID) - - return nil -} - -// IsAllocated returns if the passed network has been allocated or not. -func (na *cnmNetworkAllocator) IsAllocated(n *api.Network) bool { - _, ok := na.networks[n.ID] - return ok -} - -// IsTaskAllocated returns if the passed task has its network resources allocated or not. -func (na *cnmNetworkAllocator) IsTaskAllocated(t *api.Task) bool { - // If the task is not found in the allocated set, then it is - // not allocated. - if _, ok := na.tasks[t.ID]; !ok { - return false - } - - // If Networks is empty there is no way this Task is allocated. - if len(t.Networks) == 0 { - return false - } - - // To determine whether the task has its resources allocated, - // we just need to look at one global scope network (in case of - // multi-network attachment). This is because we make sure we - // allocate for every network or we allocate for none. - - // Find the first global scope network - for _, nAttach := range t.Networks { - // If the network is not allocated, the task cannot be allocated. - localNet, ok := na.networks[nAttach.Network.ID] - if !ok { - return false - } - - // Nothing else to check for local scope network - if localNet.isNodeLocal { - continue - } - - // Addresses empty. Task is not allocated. - if len(nAttach.Addresses) == 0 { - return false - } - - // The allocated IP address not found in local endpoint state. Not allocated. - if _, ok := localNet.endpoints[nAttach.Addresses[0]]; !ok { - return false - } - } - - return true -} - -// IsServiceAllocated returns false if the passed service needs to have network resources allocated/updated. -func (na *cnmNetworkAllocator) IsServiceAllocated(s *api.Service, flags ...func(*networkallocator.ServiceAllocationOpts)) bool { - specNetworks := serviceNetworks(s) - - // If endpoint mode is VIP and allocator does not have the - // service in VIP allocated set then it needs to be allocated. - if len(specNetworks) != 0 && - (s.Spec.Endpoint == nil || - s.Spec.Endpoint.Mode == api.ResolutionModeVirtualIP) { - - if _, ok := na.services[s.ID]; !ok { - return false - } - - if s.Endpoint == nil || len(s.Endpoint.VirtualIPs) == 0 { - return false - } - - // If the spec has networks which don't have a corresponding VIP, - // the service needs to be allocated. - networkLoop: - for _, net := range specNetworks { - for _, vip := range s.Endpoint.VirtualIPs { - if vip.NetworkID == net.Target { - continue networkLoop - } - } - return false - } - } - - // If the spec no longer has networks attached and has a vip allocated - // from previous spec the service needs to allocated. - if s.Endpoint != nil { - vipLoop: - for _, vip := range s.Endpoint.VirtualIPs { - if na.IsVIPOnIngressNetwork(vip) && networkallocator.IsIngressNetworkNeeded(s) { - // This checks the condition when ingress network is needed - // but allocation has not been done. - if _, ok := na.services[s.ID]; !ok { - return false - } - continue vipLoop - } - for _, net := range specNetworks { - if vip.NetworkID == net.Target { - continue vipLoop - } - } - return false - } - } - - // If the endpoint mode is DNSRR and allocator has the service - // in VIP allocated set then we return to be allocated to make - // sure the allocator triggers networkallocator to free up the - // resources if any. - if s.Spec.Endpoint != nil && s.Spec.Endpoint.Mode == api.ResolutionModeDNSRoundRobin { - if _, ok := na.services[s.ID]; ok { - return false - } - } - - return true -} - -// AllocateTask allocates all the endpoint resources for all the -// networks that a task is attached to. -func (na *cnmNetworkAllocator) AllocateTask(t *api.Task) error { - for i, nAttach := range t.Networks { - if localNet := na.getNetwork(nAttach.Network.ID); localNet != nil && localNet.isNodeLocal { - continue - } - if err := na.allocateNetworkIPs(nAttach); err != nil { - if err := na.releaseEndpoints(t.Networks[:i]); err != nil { - log.G(context.TODO()).WithError(err).Errorf("failed to release IP addresses while rolling back allocation for task %s network %s", t.ID, nAttach.Network.ID) - } - return errors.Wrapf(err, "failed to allocate network IP for task %s network %s", t.ID, nAttach.Network.ID) - } - } - - na.tasks[t.ID] = struct{}{} - - return nil -} - -// DeallocateTask releases all the endpoint resources for all the -// networks that a task is attached to. -func (na *cnmNetworkAllocator) DeallocateTask(t *api.Task) error { - delete(na.tasks, t.ID) - return na.releaseEndpoints(t.Networks) -} - -// IsAttachmentAllocated returns if the passed node and network has resources allocated or not. -func (na *cnmNetworkAllocator) IsAttachmentAllocated(node *api.Node, networkAttachment *api.NetworkAttachment) bool { - if node == nil { - return false - } - - if networkAttachment == nil || networkAttachment.Network == nil { - return false - } - - // If the node is not found in the allocated set, then it is - // not allocated. - if _, ok := na.nodes[node.ID]; !ok { - return false - } - - // If the network is not found in the allocated set, then it is - // not allocated. - if _, ok := na.nodes[node.ID][networkAttachment.Network.ID]; !ok { - return false - } - - // If the network is not allocated, the node cannot be allocated. - localNet, ok := na.networks[networkAttachment.Network.ID] - if !ok { - return false - } - - // Addresses empty, not allocated. - if len(networkAttachment.Addresses) == 0 { - return false - } - - // The allocated IP address not found in local endpoint state. Not allocated. - if _, ok := localNet.endpoints[networkAttachment.Addresses[0]]; !ok { - return false - } - - return true -} - -// AllocateAttachment allocates the IP addresses for a LB in a network -// on a given node -func (na *cnmNetworkAllocator) AllocateAttachment(node *api.Node, networkAttachment *api.NetworkAttachment) error { - - if err := na.allocateNetworkIPs(networkAttachment); err != nil { - return err - } - - if na.nodes[node.ID] == nil { - na.nodes[node.ID] = make(map[string]struct{}) - } - na.nodes[node.ID][networkAttachment.Network.ID] = struct{}{} - - return nil -} - -// DeallocateAttachment deallocates the IP addresses for a LB in a network to -// which the node is attached. -func (na *cnmNetworkAllocator) DeallocateAttachment(node *api.Node, networkAttachment *api.NetworkAttachment) error { - - delete(na.nodes[node.ID], networkAttachment.Network.ID) - if len(na.nodes[node.ID]) == 0 { - delete(na.nodes, node.ID) - } - - return na.releaseEndpoints([]*api.NetworkAttachment{networkAttachment}) -} - -func (na *cnmNetworkAllocator) releaseEndpoints(networks []*api.NetworkAttachment) error { - for _, nAttach := range networks { - localNet := na.getNetwork(nAttach.Network.ID) - if localNet == nil { - return fmt.Errorf("could not find network allocator state for network %s", nAttach.Network.ID) - } - - if localNet.isNodeLocal { - continue - } - - ipam, _, _, err := na.resolveIPAM(nAttach.Network) - if err != nil { - return errors.Wrap(err, "failed to resolve IPAM while releasing") - } - - // Do not fail and bail out if we fail to release IP - // address here. Keep going and try releasing as many - // addresses as possible. - for _, addr := range nAttach.Addresses { - // Retrieve the poolID and immediately nuke - // out the mapping. - poolID := localNet.endpoints[addr] - delete(localNet.endpoints, addr) - - ip, _, err := net.ParseCIDR(addr) - if err != nil { - log.G(context.TODO()).Errorf("Could not parse IP address %s while releasing", addr) - continue - } - - if err := ipam.ReleaseAddress(poolID, ip); err != nil { - log.G(context.TODO()).WithError(err).Errorf("IPAM failure while releasing IP address %s", addr) - } - } - - // Clear out the address list when we are done with - // this network. - nAttach.Addresses = nil - } - - return nil -} - -// allocate virtual IP for a single endpoint attachment of the service. -func (na *cnmNetworkAllocator) allocateVIP(vip *api.Endpoint_VirtualIP) error { - var opts map[string]string - localNet := na.getNetwork(vip.NetworkID) - if localNet == nil { - return errors.New("networkallocator: could not find local network state") - } - - if localNet.isNodeLocal { - return nil - } - - // If this IP is already allocated in memory we don't need to - // do anything. - if _, ok := localNet.endpoints[vip.Addr]; ok { - return nil - } - - ipam, _, _, err := na.resolveIPAM(localNet.nw) - if err != nil { - return errors.Wrap(err, "failed to resolve IPAM while allocating") - } - - var addr net.IP - if vip.Addr != "" { - var err error - - addr, _, err = net.ParseCIDR(vip.Addr) - if err != nil { - return err - } - } - if localNet.nw.IPAM != nil && localNet.nw.IPAM.Driver != nil { - // set ipam allocation method to serial - opts = setIPAMSerialAlloc(localNet.nw.IPAM.Driver.Options) - } - - for _, poolID := range localNet.pools { - ip, _, err := ipam.RequestAddress(poolID, addr, opts) - if err != nil && err != ipamapi.ErrNoAvailableIPs && err != ipamapi.ErrIPOutOfRange { - return errors.Wrap(err, "could not allocate VIP from IPAM") - } - - // If we got an address then we are done. - if err == nil { - ipStr := ip.String() - localNet.endpoints[ipStr] = poolID - vip.Addr = ipStr - return nil - } - } - - return errors.New("could not find an available IP while allocating VIP") -} - -func (na *cnmNetworkAllocator) deallocateVIP(vip *api.Endpoint_VirtualIP) error { - localNet := na.getNetwork(vip.NetworkID) - if localNet == nil { - return errors.New("networkallocator: could not find local network state") - } - if localNet.isNodeLocal { - return nil - } - ipam, _, _, err := na.resolveIPAM(localNet.nw) - if err != nil { - return errors.Wrap(err, "failed to resolve IPAM while allocating") - } - - // Retrieve the poolID and immediately nuke - // out the mapping. - poolID := localNet.endpoints[vip.Addr] - delete(localNet.endpoints, vip.Addr) - - ip, _, err := net.ParseCIDR(vip.Addr) - if err != nil { - log.G(context.TODO()).Errorf("Could not parse VIP address %s while releasing", vip.Addr) - return err - } - - if err := ipam.ReleaseAddress(poolID, ip); err != nil { - log.G(context.TODO()).WithError(err).Errorf("IPAM failure while releasing VIP address %s", vip.Addr) - return err - } - - return nil -} - -// allocate the IP addresses for a single network attachment of the task. -func (na *cnmNetworkAllocator) allocateNetworkIPs(nAttach *api.NetworkAttachment) error { - var ip *net.IPNet - var opts map[string]string - - ipam, _, _, err := na.resolveIPAM(nAttach.Network) - if err != nil { - return errors.Wrap(err, "failed to resolve IPAM while allocating") - } - - localNet := na.getNetwork(nAttach.Network.ID) - if localNet == nil { - return fmt.Errorf("could not find network allocator state for network %s", nAttach.Network.ID) - } - - addresses := nAttach.Addresses - if len(addresses) == 0 { - addresses = []string{""} - } - - for i, rawAddr := range addresses { - var addr net.IP - if rawAddr != "" { - var err error - addr, _, err = net.ParseCIDR(rawAddr) - if err != nil { - addr = net.ParseIP(rawAddr) - - if addr == nil { - return errors.Wrapf(err, "could not parse address string %s", rawAddr) - } - } - } - // Set the ipam options if the network has an ipam driver. - if localNet.nw.IPAM != nil && localNet.nw.IPAM.Driver != nil { - // set ipam allocation method to serial - opts = setIPAMSerialAlloc(localNet.nw.IPAM.Driver.Options) - } - - for _, poolID := range localNet.pools { - var err error - - ip, _, err = ipam.RequestAddress(poolID, addr, opts) - if err != nil && err != ipamapi.ErrNoAvailableIPs && err != ipamapi.ErrIPOutOfRange { - return errors.Wrap(err, "could not allocate IP from IPAM") - } - - // If we got an address then we are done. - if err == nil { - ipStr := ip.String() - localNet.endpoints[ipStr] = poolID - addresses[i] = ipStr - nAttach.Addresses = addresses - return nil - } - } - } - - return errors.New("could not find an available IP") -} - -func (na *cnmNetworkAllocator) freeDriverState(n *api.Network) error { - d, err := na.resolveDriver(n) - if err != nil { - return err - } - - return d.driver.NetworkFree(n.ID) -} - -func (na *cnmNetworkAllocator) allocateDriverState(n *api.Network) error { - d, err := na.resolveDriver(n) - if err != nil { - return err - } - - options := make(map[string]string) - // reconcile the driver specific options from the network spec - // and from the operational state retrieved from the store - if n.Spec.DriverConfig != nil { - for k, v := range n.Spec.DriverConfig.Options { - options[k] = v - } - } - if n.DriverState != nil { - for k, v := range n.DriverState.Options { - options[k] = v - } - } - - // Construct IPAM data for driver consumption. - ipv4Data := make([]driverapi.IPAMData, 0, len(n.IPAM.Configs)) - for _, ic := range n.IPAM.Configs { - if ic.Family == api.IPAMConfig_IPV6 { - continue - } - - _, subnet, err := net.ParseCIDR(ic.Subnet) - if err != nil { - return errors.Wrapf(err, "error parsing subnet %s while allocating driver state", ic.Subnet) - } - - gwIP := net.ParseIP(ic.Gateway) - gwNet := &net.IPNet{ - IP: gwIP, - Mask: subnet.Mask, - } - - data := driverapi.IPAMData{ - Pool: subnet, - Gateway: gwNet, - } - - ipv4Data = append(ipv4Data, data) - } - - ds, err := d.driver.NetworkAllocate(n.ID, options, ipv4Data, nil) - if err != nil { - return err - } - - // Update network object with the obtained driver state. - n.DriverState = &api.Driver{ - Name: d.name, - Options: ds, - } - - return nil -} - -// Resolve network driver -func (na *cnmNetworkAllocator) resolveDriver(n *api.Network) (*networkDriver, error) { - dName := DefaultDriver - if n.Spec.DriverConfig != nil && n.Spec.DriverConfig.Name != "" { - dName = n.Spec.DriverConfig.Name - } - - d, drvcap := na.networkRegistry.Driver(dName) - if d == nil { - err := na.loadDriver(dName) - if err != nil { - return nil, err - } - - d, drvcap = na.networkRegistry.Driver(dName) - if d == nil { - return nil, fmt.Errorf("could not resolve network driver %s", dName) - } - } - - return &networkDriver{driver: d, capability: &drvcap, name: dName}, nil -} - -func (na *cnmNetworkAllocator) loadDriver(name string) error { - if na.pg == nil { - return errors.New("plugin store is uninitialized") - } - _, err := na.pg.Get(name, driverapi.NetworkPluginEndpointType, plugingetter.Lookup) - return err -} - -// Resolve the IPAM driver -func (na *cnmNetworkAllocator) resolveIPAM(n *api.Network) (ipamapi.Ipam, string, map[string]string, error) { - dName := ipamapi.DefaultIPAM - if n.Spec.IPAM != nil && n.Spec.IPAM.Driver != nil && n.Spec.IPAM.Driver.Name != "" { - dName = n.Spec.IPAM.Driver.Name - } - - var dOptions map[string]string - if n.Spec.IPAM != nil && n.Spec.IPAM.Driver != nil && len(n.Spec.IPAM.Driver.Options) != 0 { - dOptions = n.Spec.IPAM.Driver.Options - } - - ipam, _ := na.ipamRegistry.IPAM(dName) - if ipam == nil { - return nil, "", nil, fmt.Errorf("could not resolve IPAM driver %s", dName) - } - - return ipam, dName, dOptions, nil -} - -func (na *cnmNetworkAllocator) freePools(n *api.Network, pools map[string]string) error { - ipam, _, _, err := na.resolveIPAM(n) - if err != nil { - return errors.Wrapf(err, "failed to resolve IPAM while freeing pools for network %s", n.ID) - } - - releasePools(ipam, n.IPAM.Configs, pools) - return nil -} - -func releasePools(ipam ipamapi.Ipam, icList []*api.IPAMConfig, pools map[string]string) { - for _, ic := range icList { - if err := ipam.ReleaseAddress(pools[ic.Subnet], net.ParseIP(ic.Gateway)); err != nil { - log.G(context.TODO()).WithError(err).Errorf("Failed to release address %s", ic.Subnet) - } - } - - for k, p := range pools { - if err := ipam.ReleasePool(p); err != nil { - log.G(context.TODO()).WithError(err).Errorf("Failed to release pool %s", k) - } - } -} - -func (na *cnmNetworkAllocator) allocatePools(n *api.Network) (map[string]string, error) { - ipam, dName, dOptions, err := na.resolveIPAM(n) - if err != nil { - return nil, err - } - - // We don't support user defined address spaces yet so just - // retrieve default address space names for the driver. - _, asName, err := ipam.GetDefaultAddressSpaces() - if err != nil { - return nil, err - } - - pools := make(map[string]string) - - var ipamConfigs []*api.IPAMConfig - - // If there is non-nil IPAM state always prefer those subnet - // configs over Spec configs. - if n.IPAM != nil { - ipamConfigs = n.IPAM.Configs - } else if n.Spec.IPAM != nil { - ipamConfigs = make([]*api.IPAMConfig, len(n.Spec.IPAM.Configs)) - copy(ipamConfigs, n.Spec.IPAM.Configs) - } - - // Append an empty slot for subnet allocation if there are no - // IPAM configs from either spec or state. - if len(ipamConfigs) == 0 { - ipamConfigs = append(ipamConfigs, &api.IPAMConfig{Family: api.IPAMConfig_IPV4}) - } - - // Update the runtime IPAM configurations with initial state - n.IPAM = &api.IPAMOptions{ - Driver: &api.Driver{Name: dName, Options: dOptions}, - Configs: ipamConfigs, - } - - for i, ic := range ipamConfigs { - poolID, poolIP, meta, err := ipam.RequestPool(asName, ic.Subnet, ic.Range, dOptions, false) - if err != nil { - // Rollback by releasing all the resources allocated so far. - releasePools(ipam, ipamConfigs[:i], pools) - return nil, err - } - pools[poolIP.String()] = poolID - - // The IPAM contract allows the IPAM driver to autonomously - // provide a network gateway in response to the pool request. - // But if the network spec contains a gateway, we will allocate - // it irrespective of whether the ipam driver returned one already. - // If none of the above is true, we need to allocate one now, and - // let the driver know this request is for the network gateway. - var ( - gwIP *net.IPNet - ip net.IP - ) - if gws, ok := meta[netlabel.Gateway]; ok { - if ip, gwIP, err = net.ParseCIDR(gws); err != nil { - return nil, fmt.Errorf("failed to parse gateway address (%v) returned by ipam driver: %v", gws, err) - } - gwIP.IP = ip - } - if dOptions == nil { - dOptions = make(map[string]string) - } - dOptions[ipamapi.RequestAddressType] = netlabel.Gateway - // set ipam allocation method to serial - dOptions = setIPAMSerialAlloc(dOptions) - defer delete(dOptions, ipamapi.RequestAddressType) - - if ic.Gateway != "" || gwIP == nil { - gwIP, _, err = ipam.RequestAddress(poolID, net.ParseIP(ic.Gateway), dOptions) - if err != nil { - // Rollback by releasing all the resources allocated so far. - releasePools(ipam, ipamConfigs[:i], pools) - return nil, err - } - } - - if ic.Subnet == "" { - ic.Subnet = poolIP.String() - } - - if ic.Gateway == "" { - ic.Gateway = gwIP.IP.String() - } - - } - - return pools, nil -} - -func serviceNetworks(s *api.Service) []*api.NetworkAttachmentConfig { - // Always prefer NetworkAttachmentConfig in the TaskSpec - if len(s.Spec.Task.Networks) == 0 && len(s.Spec.Networks) != 0 { - return s.Spec.Networks - } - return s.Spec.Task.Networks -} - -// IsVIPOnIngressNetwork check if the vip is in ingress network -func (na *cnmNetworkAllocator) IsVIPOnIngressNetwork(vip *api.Endpoint_VirtualIP) bool { - if vip == nil { - return false - } - - localNet := na.getNetwork(vip.NetworkID) - if localNet != nil && localNet.nw != nil { - return networkallocator.IsIngressNetwork(localNet.nw) - } - return false -} - -// IsBuiltInDriver returns whether the passed driver is an internal network driver -func IsBuiltInDriver(name string) bool { - n := strings.ToLower(name) - _, ok := initializers[n] - return ok -} - -// setIPAMSerialAlloc sets the ipam allocation method to serial -func setIPAMSerialAlloc(opts map[string]string) map[string]string { - if opts == nil { - opts = make(map[string]string) - } - if _, ok := opts[ipamapi.AllocSerialPrefix]; !ok { - opts[ipamapi.AllocSerialPrefix] = "true" - } - return opts -} diff --git a/manager/allocator/cnmallocator/networkallocator_test.go b/manager/allocator/cnmallocator/networkallocator_test.go deleted file mode 100644 index a71ed9780f..0000000000 --- a/manager/allocator/cnmallocator/networkallocator_test.go +++ /dev/null @@ -1,788 +0,0 @@ -package cnmallocator - -import ( - "fmt" - "net" - "testing" - - "github.com/docker/docker/libnetwork/types" - "github.com/moby/swarmkit/v2/api" - "github.com/moby/swarmkit/v2/manager/allocator/networkallocator" - "github.com/stretchr/testify/assert" -) - -func newNetworkAllocator(t *testing.T) networkallocator.NetworkAllocator { - na, err := (&Provider{}).NewAllocator(nil) - assert.NoError(t, err) - assert.NotNil(t, na) - return na -} - -func TestNew(t *testing.T) { - newNetworkAllocator(t) -} - -func TestAllocateInvalidIPAM(t *testing.T) { - na := newNetworkAllocator(t) - n := &api.Network{ - ID: "testID", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - DriverConfig: &api.Driver{}, - IPAM: &api.IPAMOptions{ - Driver: &api.Driver{ - Name: "invalidipam,", - }, - }, - }, - } - err := na.Allocate(n) - assert.Error(t, err) -} - -func TestAllocateInvalidDriver(t *testing.T) { - na := newNetworkAllocator(t) - n := &api.Network{ - ID: "testID", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - DriverConfig: &api.Driver{ - Name: "invaliddriver", - }, - }, - } - - err := na.Allocate(n) - assert.Error(t, err) -} - -func TestNetworkDoubleAllocate(t *testing.T) { - na := newNetworkAllocator(t) - n := &api.Network{ - ID: "testID", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - }, - } - - err := na.Allocate(n) - assert.NoError(t, err) - - err = na.Allocate(n) - assert.Error(t, err) -} - -func TestAllocateEmptyConfig(t *testing.T) { - na1 := newNetworkAllocator(t) - na2 := newNetworkAllocator(t) - n1 := &api.Network{ - ID: "testID1", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test1", - }, - }, - } - - n2 := &api.Network{ - ID: "testID2", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test2", - }, - }, - } - - err := na1.Allocate(n1) - assert.NoError(t, err) - assert.NotEqual(t, n1.IPAM.Configs, nil) - assert.Equal(t, len(n1.IPAM.Configs), 1) - assert.Equal(t, n1.IPAM.Configs[0].Range, "") - assert.Equal(t, len(n1.IPAM.Configs[0].Reserved), 0) - - _, subnet11, err := net.ParseCIDR(n1.IPAM.Configs[0].Subnet) - assert.NoError(t, err) - - gwip11 := net.ParseIP(n1.IPAM.Configs[0].Gateway) - assert.NotEqual(t, gwip11, nil) - - err = na1.Allocate(n2) - assert.NoError(t, err) - assert.NotEqual(t, n2.IPAM.Configs, nil) - assert.Equal(t, len(n2.IPAM.Configs), 1) - assert.Equal(t, n2.IPAM.Configs[0].Range, "") - assert.Equal(t, len(n2.IPAM.Configs[0].Reserved), 0) - - _, subnet21, err := net.ParseCIDR(n2.IPAM.Configs[0].Subnet) - assert.NoError(t, err) - - gwip21 := net.ParseIP(n2.IPAM.Configs[0].Gateway) - assert.NotEqual(t, gwip21, nil) - - // Allocate n1 ans n2 with another allocator instance but in - // intentionally reverse order. - err = na2.Allocate(n2) - assert.NoError(t, err) - assert.NotEqual(t, n2.IPAM.Configs, nil) - assert.Equal(t, len(n2.IPAM.Configs), 1) - assert.Equal(t, n2.IPAM.Configs[0].Range, "") - assert.Equal(t, len(n2.IPAM.Configs[0].Reserved), 0) - - _, subnet22, err := net.ParseCIDR(n2.IPAM.Configs[0].Subnet) - assert.NoError(t, err) - assert.Equal(t, subnet21, subnet22) - - gwip22 := net.ParseIP(n2.IPAM.Configs[0].Gateway) - assert.Equal(t, gwip21, gwip22) - - err = na2.Allocate(n1) - assert.NoError(t, err) - assert.NotEqual(t, n1.IPAM.Configs, nil) - assert.Equal(t, len(n1.IPAM.Configs), 1) - assert.Equal(t, n1.IPAM.Configs[0].Range, "") - assert.Equal(t, len(n1.IPAM.Configs[0].Reserved), 0) - - _, subnet12, err := net.ParseCIDR(n1.IPAM.Configs[0].Subnet) - assert.NoError(t, err) - assert.Equal(t, subnet11, subnet12) - - gwip12 := net.ParseIP(n1.IPAM.Configs[0].Gateway) - assert.Equal(t, gwip11, gwip12) -} - -func TestAllocateWithOneSubnet(t *testing.T) { - na := newNetworkAllocator(t) - n := &api.Network{ - ID: "testID", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - DriverConfig: &api.Driver{}, - IPAM: &api.IPAMOptions{ - Driver: &api.Driver{}, - Configs: []*api.IPAMConfig{ - { - Subnet: "192.168.1.0/24", - }, - }, - }, - }, - } - - err := na.Allocate(n) - assert.NoError(t, err) - assert.Equal(t, len(n.IPAM.Configs), 1) - assert.Equal(t, n.IPAM.Configs[0].Range, "") - assert.Equal(t, len(n.IPAM.Configs[0].Reserved), 0) - assert.Equal(t, n.IPAM.Configs[0].Subnet, "192.168.1.0/24") - - ip := net.ParseIP(n.IPAM.Configs[0].Gateway) - assert.NotEqual(t, ip, nil) -} - -func TestAllocateWithOneSubnetGateway(t *testing.T) { - na := newNetworkAllocator(t) - n := &api.Network{ - ID: "testID", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - DriverConfig: &api.Driver{}, - IPAM: &api.IPAMOptions{ - Driver: &api.Driver{}, - Configs: []*api.IPAMConfig{ - { - Subnet: "192.168.1.0/24", - Gateway: "192.168.1.1", - }, - }, - }, - }, - } - - err := na.Allocate(n) - assert.NoError(t, err) - assert.Equal(t, len(n.IPAM.Configs), 1) - assert.Equal(t, n.IPAM.Configs[0].Range, "") - assert.Equal(t, len(n.IPAM.Configs[0].Reserved), 0) - assert.Equal(t, n.IPAM.Configs[0].Subnet, "192.168.1.0/24") - assert.Equal(t, n.IPAM.Configs[0].Gateway, "192.168.1.1") -} - -func TestAllocateWithOneSubnetInvalidGateway(t *testing.T) { - na := newNetworkAllocator(t) - n := &api.Network{ - ID: "testID", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - DriverConfig: &api.Driver{}, - IPAM: &api.IPAMOptions{ - Driver: &api.Driver{}, - Configs: []*api.IPAMConfig{ - { - Subnet: "192.168.1.0/24", - Gateway: "192.168.2.1", - }, - }, - }, - }, - } - - err := na.Allocate(n) - assert.Error(t, err) -} - -// TestAllocateWithSmallSubnet validates that /32 subnets don't produce an error, -// as /31 and /32 subnets are supported by docker daemon, starting with -// https://github.com/moby/moby/commit/3a938df4b570aad3bfb4d5342379582e872fc1a3, -func TestAllocateWithSmallSubnet(t *testing.T) { - na := newNetworkAllocator(t) - n := &api.Network{ - ID: "testID", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - DriverConfig: &api.Driver{}, - IPAM: &api.IPAMOptions{ - Driver: &api.Driver{}, - Configs: []*api.IPAMConfig{ - { - Subnet: "1.1.1.1/32", - }, - }, - }, - }, - } - - err := na.Allocate(n) - assert.NoError(t, err) -} - -func TestAllocateWithTwoSubnetsNoGateway(t *testing.T) { - na := newNetworkAllocator(t) - n := &api.Network{ - ID: "testID", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - DriverConfig: &api.Driver{}, - IPAM: &api.IPAMOptions{ - Driver: &api.Driver{}, - Configs: []*api.IPAMConfig{ - { - Subnet: "192.168.1.0/24", - }, - { - Subnet: "192.168.2.0/24", - }, - }, - }, - }, - } - - err := na.Allocate(n) - assert.NoError(t, err) - assert.Equal(t, len(n.IPAM.Configs), 2) - assert.Equal(t, n.IPAM.Configs[0].Range, "") - assert.Equal(t, len(n.IPAM.Configs[0].Reserved), 0) - assert.Equal(t, n.IPAM.Configs[0].Subnet, "192.168.1.0/24") - assert.Equal(t, n.IPAM.Configs[1].Range, "") - assert.Equal(t, len(n.IPAM.Configs[1].Reserved), 0) - assert.Equal(t, n.IPAM.Configs[1].Subnet, "192.168.2.0/24") - - ip := net.ParseIP(n.IPAM.Configs[0].Gateway) - assert.NotEqual(t, ip, nil) - ip = net.ParseIP(n.IPAM.Configs[1].Gateway) - assert.NotEqual(t, ip, nil) -} - -func TestFree(t *testing.T) { - na := newNetworkAllocator(t) - n := &api.Network{ - ID: "testID", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - DriverConfig: &api.Driver{}, - IPAM: &api.IPAMOptions{ - Driver: &api.Driver{}, - Configs: []*api.IPAMConfig{ - { - Subnet: "192.168.1.0/24", - Gateway: "192.168.1.1", - }, - }, - }, - }, - } - - err := na.Allocate(n) - assert.NoError(t, err) - - err = na.Deallocate(n) - assert.NoError(t, err) - - // Reallocate again to make sure it succeeds. - err = na.Allocate(n) - assert.NoError(t, err) -} - -func TestAllocateTaskFree(t *testing.T) { - na1 := newNetworkAllocator(t) - na2 := newNetworkAllocator(t) - n1 := &api.Network{ - ID: "testID1", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test1", - }, - DriverConfig: &api.Driver{}, - IPAM: &api.IPAMOptions{ - Driver: &api.Driver{}, - Configs: []*api.IPAMConfig{ - { - Subnet: "192.168.1.0/24", - Gateway: "192.168.1.1", - }, - }, - }, - }, - } - - n2 := &api.Network{ - ID: "testID2", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test2", - }, - DriverConfig: &api.Driver{}, - IPAM: &api.IPAMOptions{ - Driver: &api.Driver{}, - Configs: []*api.IPAMConfig{ - { - Subnet: "192.168.2.0/24", - Gateway: "192.168.2.1", - }, - }, - }, - }, - } - - task1 := &api.Task{ - Networks: []*api.NetworkAttachment{ - { - Network: n1, - }, - { - Network: n2, - }, - }, - } - - task2 := &api.Task{ - Networks: []*api.NetworkAttachment{ - { - Network: n1, - }, - { - Network: n2, - }, - }, - } - - err := na1.Allocate(n1) - assert.NoError(t, err) - - err = na1.Allocate(n2) - assert.NoError(t, err) - - err = na1.AllocateTask(task1) - assert.NoError(t, err) - assert.Equal(t, len(task1.Networks[0].Addresses), 1) - assert.Equal(t, len(task1.Networks[1].Addresses), 1) - - _, subnet1, _ := net.ParseCIDR("192.168.1.0/24") - _, subnet2, _ := net.ParseCIDR("192.168.2.0/24") - - // variable coding: network/task/allocator - ip111, _, err := net.ParseCIDR(task1.Networks[0].Addresses[0]) - assert.NoError(t, err) - - ip211, _, err := net.ParseCIDR(task1.Networks[1].Addresses[0]) - assert.NoError(t, err) - - assert.Equal(t, subnet1.Contains(ip111), true) - assert.Equal(t, subnet2.Contains(ip211), true) - - err = na1.AllocateTask(task2) - assert.NoError(t, err) - assert.Equal(t, len(task2.Networks[0].Addresses), 1) - assert.Equal(t, len(task2.Networks[1].Addresses), 1) - - ip121, _, err := net.ParseCIDR(task2.Networks[0].Addresses[0]) - assert.NoError(t, err) - - ip221, _, err := net.ParseCIDR(task2.Networks[1].Addresses[0]) - assert.NoError(t, err) - - assert.Equal(t, subnet1.Contains(ip121), true) - assert.Equal(t, subnet2.Contains(ip221), true) - - // Now allocate the same the same tasks in a second allocator - // but intentionally in reverse order. - err = na2.Allocate(n1) - assert.NoError(t, err) - - err = na2.Allocate(n2) - assert.NoError(t, err) - - err = na2.AllocateTask(task2) - assert.NoError(t, err) - assert.Equal(t, len(task2.Networks[0].Addresses), 1) - assert.Equal(t, len(task2.Networks[1].Addresses), 1) - - ip122, _, err := net.ParseCIDR(task2.Networks[0].Addresses[0]) - assert.NoError(t, err) - - ip222, _, err := net.ParseCIDR(task2.Networks[1].Addresses[0]) - assert.NoError(t, err) - - assert.Equal(t, subnet1.Contains(ip122), true) - assert.Equal(t, subnet2.Contains(ip222), true) - assert.Equal(t, ip121, ip122) - assert.Equal(t, ip221, ip222) - - err = na2.AllocateTask(task1) - assert.NoError(t, err) - assert.Equal(t, len(task1.Networks[0].Addresses), 1) - assert.Equal(t, len(task1.Networks[1].Addresses), 1) - - ip112, _, err := net.ParseCIDR(task1.Networks[0].Addresses[0]) - assert.NoError(t, err) - - ip212, _, err := net.ParseCIDR(task1.Networks[1].Addresses[0]) - assert.NoError(t, err) - - assert.Equal(t, subnet1.Contains(ip112), true) - assert.Equal(t, subnet2.Contains(ip212), true) - assert.Equal(t, ip111, ip112) - assert.Equal(t, ip211, ip212) - - // Deallocate task - err = na1.DeallocateTask(task1) - assert.NoError(t, err) - assert.Equal(t, len(task1.Networks[0].Addresses), 0) - assert.Equal(t, len(task1.Networks[1].Addresses), 0) - - // Try allocation after free - err = na1.AllocateTask(task1) - assert.NoError(t, err) - assert.Equal(t, len(task1.Networks[0].Addresses), 1) - assert.Equal(t, len(task1.Networks[1].Addresses), 1) - - ip111, _, err = net.ParseCIDR(task1.Networks[0].Addresses[0]) - assert.NoError(t, err) - - ip211, _, err = net.ParseCIDR(task1.Networks[1].Addresses[0]) - assert.NoError(t, err) - - assert.Equal(t, subnet1.Contains(ip111), true) - assert.Equal(t, subnet2.Contains(ip211), true) - - err = na1.DeallocateTask(task1) - assert.NoError(t, err) - assert.Equal(t, len(task1.Networks[0].Addresses), 0) - assert.Equal(t, len(task1.Networks[1].Addresses), 0) - - // Try to free endpoints on an already freed task - err = na1.DeallocateTask(task1) - assert.NoError(t, err) -} - -func TestAllocateService(t *testing.T) { - na := newNetworkAllocator(t) - n := &api.Network{ - ID: "testID", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - }, - } - - s := &api.Service{ - ID: "testID1", - Spec: api.ServiceSpec{ - Task: api.TaskSpec{ - Networks: []*api.NetworkAttachmentConfig{ - { - Target: "testID", - }, - }, - }, - Endpoint: &api.EndpointSpec{ - Ports: []*api.PortConfig{ - { - Name: "http", - TargetPort: 80, - }, - { - Name: "https", - TargetPort: 443, - }, - }, - }, - }, - } - - err := na.Allocate(n) - assert.NoError(t, err) - assert.NotEqual(t, n.IPAM.Configs, nil) - assert.Equal(t, len(n.IPAM.Configs), 1) - assert.Equal(t, n.IPAM.Configs[0].Range, "") - assert.Equal(t, len(n.IPAM.Configs[0].Reserved), 0) - - _, subnet, err := net.ParseCIDR(n.IPAM.Configs[0].Subnet) - assert.NoError(t, err) - - gwip := net.ParseIP(n.IPAM.Configs[0].Gateway) - assert.NotEqual(t, gwip, nil) - - err = na.AllocateService(s) - assert.NoError(t, err) - assert.Len(t, s.Endpoint.Ports, 0) // Network allocator is not responsible for allocating ports. - - assert.Equal(t, 1, len(s.Endpoint.VirtualIPs)) - - assert.Equal(t, s.Endpoint.Spec, s.Spec.Endpoint) - - ip, _, err := net.ParseCIDR(s.Endpoint.VirtualIPs[0].Addr) - assert.NoError(t, err) - - assert.Equal(t, true, subnet.Contains(ip)) -} - -func TestDeallocateServiceAllocateIngressMode(t *testing.T) { - na := newNetworkAllocator(t) - - n := &api.Network{ - ID: "testNetID1", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - Ingress: true, - }, - } - - err := na.Allocate(n) - assert.NoError(t, err) - - s := &api.Service{ - ID: "testID1", - Spec: api.ServiceSpec{ - Endpoint: &api.EndpointSpec{ - Ports: []*api.PortConfig{ - { - Name: "some_tcp", - TargetPort: 1234, - PublishedPort: 1234, - PublishMode: api.PublishModeIngress, - }, - }, - }, - }, - Endpoint: &api.Endpoint{}, - } - - s.Endpoint.VirtualIPs = append(s.Endpoint.VirtualIPs, - &api.Endpoint_VirtualIP{NetworkID: n.ID}) - - err = na.AllocateService(s) - assert.NoError(t, err) - assert.Len(t, s.Endpoint.VirtualIPs, 1) - - err = na.DeallocateService(s) - assert.NoError(t, err) - assert.Len(t, s.Endpoint.Ports, 0) - assert.Len(t, s.Endpoint.VirtualIPs, 0) - // Allocate again. - s.Endpoint.VirtualIPs = append(s.Endpoint.VirtualIPs, - &api.Endpoint_VirtualIP{NetworkID: n.ID}) - - err = na.AllocateService(s) - assert.NoError(t, err) - assert.Len(t, s.Endpoint.VirtualIPs, 1) -} - -func TestServiceNetworkUpdate(t *testing.T) { - na := newNetworkAllocator(t) - - n1 := &api.Network{ - ID: "testID1", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - }, - } - - n2 := &api.Network{ - ID: "testID2", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test2", - }, - }, - } - - // Allocate both networks - err := na.Allocate(n1) - assert.NoError(t, err) - - err = na.Allocate(n2) - assert.NoError(t, err) - - // Attach a network to a service spec nd allocate a service - s := &api.Service{ - ID: "testID1", - Spec: api.ServiceSpec{ - Task: api.TaskSpec{ - Networks: []*api.NetworkAttachmentConfig{ - { - Target: "testID1", - }, - }, - }, - Endpoint: &api.EndpointSpec{ - Mode: api.ResolutionModeVirtualIP, - }, - }, - } - - err = na.AllocateService(s) - assert.NoError(t, err) - assert.True(t, na.IsServiceAllocated(s)) - assert.Len(t, s.Endpoint.VirtualIPs, 1) - - // Now update the same service with another network - s.Spec.Task.Networks = append(s.Spec.Task.Networks, &api.NetworkAttachmentConfig{Target: "testID2"}) - - assert.False(t, na.IsServiceAllocated(s)) - err = na.AllocateService(s) - assert.NoError(t, err) - - assert.True(t, na.IsServiceAllocated(s)) - assert.Len(t, s.Endpoint.VirtualIPs, 2) - - s.Spec.Task.Networks = s.Spec.Task.Networks[:1] - - // Check if service needs update and allocate with updated service spec - assert.False(t, na.IsServiceAllocated(s)) - - err = na.AllocateService(s) - assert.NoError(t, err) - assert.True(t, na.IsServiceAllocated(s)) - assert.Len(t, s.Endpoint.VirtualIPs, 1) - - s.Spec.Task.Networks = s.Spec.Task.Networks[:0] - // Check if service needs update with all the networks removed and allocate with updated service spec - assert.False(t, na.IsServiceAllocated(s)) - - err = na.AllocateService(s) - assert.NoError(t, err) - assert.True(t, na.IsServiceAllocated(s)) - assert.Len(t, s.Endpoint.VirtualIPs, 0) - - // Attach a network and allocate service - s.Spec.Task.Networks = append(s.Spec.Task.Networks, &api.NetworkAttachmentConfig{Target: "testID2"}) - assert.False(t, na.IsServiceAllocated(s)) - - err = na.AllocateService(s) - assert.NoError(t, err) - - assert.True(t, na.IsServiceAllocated(s)) - assert.Len(t, s.Endpoint.VirtualIPs, 1) - -} - -type mockIpam struct { - actualIpamOptions map[string]string -} - -func (a *mockIpam) GetDefaultAddressSpaces() (string, string, error) { - return "defaultAS", "defaultAS", nil -} - -func (a *mockIpam) RequestPool(addressSpace, pool, subPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) { - a.actualIpamOptions = options - - poolCidr, _ := types.ParseCIDR(pool) - return fmt.Sprintf("%s/%s", "defaultAS", pool), poolCidr, nil, nil -} - -func (a *mockIpam) ReleasePool(poolID string) error { - return nil -} - -func (a *mockIpam) RequestAddress(poolID string, ip net.IP, opts map[string]string) (*net.IPNet, map[string]string, error) { - return nil, nil, nil -} - -func (a *mockIpam) ReleaseAddress(poolID string, ip net.IP) error { - return nil -} - -func (a *mockIpam) IsBuiltIn() bool { - return true -} - -func TestCorrectlyPassIPAMOptions(t *testing.T) { - var err error - expectedIpamOptions := map[string]string{"network-name": "freddie"} - - na := newNetworkAllocator(t) - ipamDriver := &mockIpam{} - - err = na.(*cnmNetworkAllocator).ipamRegistry.RegisterIpamDriver("mockipam", ipamDriver) - assert.NoError(t, err) - - n := &api.Network{ - ID: "testID", - Spec: api.NetworkSpec{ - Annotations: api.Annotations{ - Name: "test", - }, - DriverConfig: &api.Driver{}, - IPAM: &api.IPAMOptions{ - Driver: &api.Driver{ - Name: "mockipam", - Options: expectedIpamOptions, - }, - Configs: []*api.IPAMConfig{ - { - Subnet: "192.168.1.0/24", - Gateway: "192.168.1.1", - }, - }, - }, - }, - } - err = na.Allocate(n) - - assert.Equal(t, expectedIpamOptions, ipamDriver.actualIpamOptions) - assert.NoError(t, err) -} diff --git a/manager/allocator/cnmallocator/provider.go b/manager/allocator/cnmallocator/provider.go deleted file mode 100644 index 331505d629..0000000000 --- a/manager/allocator/cnmallocator/provider.go +++ /dev/null @@ -1,91 +0,0 @@ -package cnmallocator - -import ( - "strings" - - "github.com/docker/docker/libnetwork/driverapi" - "github.com/docker/docker/libnetwork/drivers/overlay/overlayutils" - "github.com/docker/docker/libnetwork/ipamapi" - "github.com/docker/docker/pkg/plugingetter" - "github.com/moby/swarmkit/v2/api" - "github.com/moby/swarmkit/v2/manager/allocator/networkallocator" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -type Provider struct { - pg plugingetter.PluginGetter -} - -var _ networkallocator.Provider = &Provider{} - -// NewProvider returns a new cnmallocator provider. -func NewProvider(pg plugingetter.PluginGetter) *Provider { - return &Provider{pg: pg} -} - -// ValidateIPAMDriver implements networkallocator.NetworkProvider. -func (p *Provider) ValidateIPAMDriver(driver *api.Driver) error { - if driver == nil { - // It is ok to not specify the driver. We will choose - // a default driver. - return nil - } - - if driver.Name == "" { - return status.Errorf(codes.InvalidArgument, "driver name: if driver is specified name is required") - } - if strings.ToLower(driver.Name) == ipamapi.DefaultIPAM { - return nil - } - return p.validatePluginDriver(driver, ipamapi.PluginEndpointType) -} - -// ValidateIngressNetworkDriver implements networkallocator.NetworkProvider. -func (p *Provider) ValidateIngressNetworkDriver(driver *api.Driver) error { - if driver != nil && driver.Name != "overlay" { - return status.Errorf(codes.Unimplemented, "only overlay driver is currently supported for ingress network") - } - return p.ValidateNetworkDriver(driver) -} - -// ValidateNetworkDriver implements networkallocator.NetworkProvider. -func (p *Provider) ValidateNetworkDriver(driver *api.Driver) error { - if driver == nil { - // It is ok to not specify the driver. We will choose - // a default driver. - return nil - } - - if driver.Name == "" { - return status.Errorf(codes.InvalidArgument, "driver name: if driver is specified name is required") - } - - // First check against the known drivers - if IsBuiltInDriver(driver.Name) { - return nil - } - - return p.validatePluginDriver(driver, driverapi.NetworkPluginEndpointType) -} - -func (p *Provider) validatePluginDriver(driver *api.Driver, pluginType string) error { - if p.pg == nil { - return status.Errorf(codes.InvalidArgument, "plugin %s not supported", driver.Name) - } - - plug, err := p.pg.Get(driver.Name, pluginType, plugingetter.Lookup) - if err != nil { - return status.Errorf(codes.InvalidArgument, "error during lookup of plugin %s", driver.Name) - } - - if plug.IsV1() { - return status.Errorf(codes.InvalidArgument, "legacy plugin %s of type %s is not supported in swarm mode", driver.Name, pluginType) - } - - return nil -} - -func (p *Provider) SetDefaultVXLANUDPPort(port uint32) error { - return overlayutils.ConfigVXLANUDPPort(port) -} diff --git a/manager/allocator/cnmallocator/provider_test.go b/manager/allocator/cnmallocator/provider_test.go deleted file mode 100644 index 357642e592..0000000000 --- a/manager/allocator/cnmallocator/provider_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package cnmallocator - -import ( - "testing" - - "github.com/moby/swarmkit/v2/api" - "github.com/moby/swarmkit/v2/testutils" - "github.com/stretchr/testify/assert" - "google.golang.org/grpc/codes" -) - -func TestValidateDriver(t *testing.T) { - p := NewProvider(nil) - - for _, tt := range []struct { - name string - validator func(*api.Driver) error - }{ - {"IPAM", p.ValidateIPAMDriver}, - {"Network", p.ValidateNetworkDriver}, - } { - t.Run(tt.name, func(t *testing.T) { - assert.NoError(t, tt.validator(nil)) - - err := tt.validator(&api.Driver{Name: ""}) - assert.Error(t, err) - assert.Equal(t, codes.InvalidArgument, testutils.ErrorCode(err)) - }) - } -} diff --git a/vendor/github.com/containerd/containerd/LICENSE b/vendor/github.com/containerd/containerd/LICENSE deleted file mode 100644 index 584149b6ee..0000000000 --- a/vendor/github.com/containerd/containerd/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ - - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - Copyright The containerd Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/containerd/containerd/NOTICE b/vendor/github.com/containerd/containerd/NOTICE deleted file mode 100644 index 8915f02773..0000000000 --- a/vendor/github.com/containerd/containerd/NOTICE +++ /dev/null @@ -1,16 +0,0 @@ -Docker -Copyright 2012-2015 Docker, Inc. - -This product includes software developed at Docker, Inc. (https://www.docker.com). - -The following is courtesy of our legal counsel: - - -Use and transfer of Docker may be subject to certain restrictions by the -United States and other governments. -It is your responsibility to ensure that your use and/or transfer does not -violate applicable laws. - -For more information, please see https://www.bis.doc.gov - -See also https://www.apache.org/dev/crypto.html and/or seek legal counsel. diff --git a/vendor/github.com/containerd/containerd/log/context.go b/vendor/github.com/containerd/containerd/log/context.go deleted file mode 100644 index b63c602f42..0000000000 --- a/vendor/github.com/containerd/containerd/log/context.go +++ /dev/null @@ -1,120 +0,0 @@ -/* - Copyright The containerd Authors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package log - -import ( - "context" - "fmt" - - "github.com/sirupsen/logrus" -) - -var ( - // G is an alias for GetLogger. - // - // We may want to define this locally to a package to get package tagged log - // messages. - G = GetLogger - - // L is an alias for the standard logger. - L = logrus.NewEntry(logrus.StandardLogger()) -) - -type ( - loggerKey struct{} - - // Fields type to pass to `WithFields`, alias from `logrus`. - Fields = logrus.Fields - - // Level is a logging level - Level = logrus.Level -) - -const ( - // RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to - // ensure the formatted time is always the same number of characters. - RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00" - - // TextFormat represents the text logging format - TextFormat = "text" - - // JSONFormat represents the JSON logging format - JSONFormat = "json" - - // TraceLevel level. - TraceLevel = logrus.TraceLevel - - // DebugLevel level. - DebugLevel = logrus.DebugLevel - - // InfoLevel level. - InfoLevel = logrus.InfoLevel -) - -// SetLevel sets log level globally. -func SetLevel(level string) error { - lvl, err := logrus.ParseLevel(level) - if err != nil { - return err - } - - logrus.SetLevel(lvl) - return nil -} - -// GetLevel returns the current log level. -func GetLevel() Level { - return logrus.GetLevel() -} - -// SetFormat sets log output format -func SetFormat(format string) error { - switch format { - case TextFormat: - logrus.SetFormatter(&logrus.TextFormatter{ - TimestampFormat: RFC3339NanoFixed, - FullTimestamp: true, - }) - case JSONFormat: - logrus.SetFormatter(&logrus.JSONFormatter{ - TimestampFormat: RFC3339NanoFixed, - }) - default: - return fmt.Errorf("unknown log format: %s", format) - } - - return nil -} - -// WithLogger returns a new context with the provided logger. Use in -// combination with logger.WithField(s) for great effect. -func WithLogger(ctx context.Context, logger *logrus.Entry) context.Context { - e := logger.WithContext(ctx) - return context.WithValue(ctx, loggerKey{}, e) -} - -// GetLogger retrieves the current logger from the context. If no logger is -// available, the default logger is returned. -func GetLogger(ctx context.Context) *logrus.Entry { - logger := ctx.Value(loggerKey{}) - - if logger == nil { - return L.WithContext(ctx) - } - - return logger.(*logrus.Entry) -} diff --git a/vendor/github.com/docker/docker/AUTHORS b/vendor/github.com/docker/docker/AUTHORS deleted file mode 100644 index 30e61bcbc2..0000000000 --- a/vendor/github.com/docker/docker/AUTHORS +++ /dev/null @@ -1,2406 +0,0 @@ -# File @generated by hack/generate-authors.sh. DO NOT EDIT. -# This file lists all contributors to the repository. -# See hack/generate-authors.sh to make modifications. - -Aanand Prasad -Aaron Davidson -Aaron Feng -Aaron Hnatiw -Aaron Huslage -Aaron L. Xu -Aaron Lehmann -Aaron Welch -Abel Muiño -Abhijeet Kasurde -Abhinandan Prativadi -Abhinav Ajgaonkar -Abhishek Chanda -Abhishek Sharma -Abin Shahab -Abirdcfly -Ada Mancini -Adam Avilla -Adam Dobrawy -Adam Eijdenberg -Adam Kunk -Adam Miller -Adam Mills -Adam Pointer -Adam Singer -Adam Thornton -Adam Walz -Adam Williams -AdamKorcz -Addam Hardy -Aditi Rajagopal -Aditya -Adnan Khan -Adolfo Ochagavía -Adria Casas -Adrian Moisey -Adrian Mouat -Adrian Oprea -Adrien Folie -Adrien Gallouët -Ahmed Kamal -Ahmet Alp Balkan -Aidan Feldman -Aidan Hobson Sayers -AJ Bowen -Ajey Charantimath -ajneu -Akash Gupta -Akhil Mohan -Akihiro Matsushima -Akihiro Suda -Akim Demaille -Akira Koyasu -Akshay Karle -Akshay Moghe -Al Tobey -alambike -Alan Hoyle -Alan Scherger -Alan Thompson -Albert Callarisa -Albert Zhang -Albin Kerouanton -Alec Benson -Alejandro González Hevia -Aleksa Sarai -Aleksandr Chebotov -Aleksandrs Fadins -Alena Prokharchyk -Alessandro Boch -Alessio Biancalana -Alex Chan -Alex Chen -Alex Coventry -Alex Crawford -Alex Ellis -Alex Gaynor -Alex Goodman -Alex Nordlund -Alex Olshansky -Alex Samorukov -Alex Stockinger -Alex Warhawk -Alexander Artemenko -Alexander Boyd -Alexander Larsson -Alexander Midlash -Alexander Morozov -Alexander Polakov -Alexander Shopov -Alexandre Beslic -Alexandre Garnier -Alexandre González -Alexandre Jomin -Alexandru Sfirlogea -Alexei Margasov -Alexey Guskov -Alexey Kotlyarov -Alexey Shamrin -Alexis Ries -Alexis Thomas -Alfred Landrum -Ali Dehghani -Alicia Lauerman -Alihan Demir -Allen Madsen -Allen Sun -almoehi -Alvaro Saurin -Alvin Deng -Alvin Richards -amangoel -Amen Belayneh -Ameya Gawde -Amir Goldstein -Amit Bakshi -Amit Krishnan -Amit Shukla -Amr Gawish -Amy Lindburg -Anand Patil -AnandkumarPatel -Anatoly Borodin -Anca Iordache -Anchal Agrawal -Anda Xu -Anders Janmyr -Andre Dublin <81dublin@gmail.com> -Andre Granovsky -Andrea Denisse Gómez -Andrea Luzzardi -Andrea Turli -Andreas Elvers -Andreas Köhler -Andreas Savvides -Andreas Tiefenthaler -Andrei Gherzan -Andrei Ushakov -Andrei Vagin -Andrew C. Bodine -Andrew Clay Shafer -Andrew Duckworth -Andrew France -Andrew Gerrand -Andrew Guenther -Andrew He -Andrew Hsu -Andrew Kim -Andrew Kuklewicz -Andrew Macgregor -Andrew Macpherson -Andrew Martin -Andrew McDonnell -Andrew Munsell -Andrew Pennebaker -Andrew Po -Andrew Weiss -Andrew Williams -Andrews Medina -Andrey Kolomentsev -Andrey Petrov -Andrey Stolbovsky -André Martins -Andy Chambers -andy diller -Andy Goldstein -Andy Kipp -Andy Lindeman -Andy Rothfusz -Andy Smith -Andy Wilson -Andy Zhang -Aneesh Kulkarni -Anes Hasicic -Angel Velazquez -Anil Belur -Anil Madhavapeddy -Ankit Jain -Ankush Agarwal -Anonmily -Anran Qiao -Anshul Pundir -Anthon van der Neut -Anthony Baire -Anthony Bishopric -Anthony Dahanne -Anthony Sottile -Anton Löfgren -Anton Nikitin -Anton Polonskiy -Anton Tiurin -Antonio Murdaca -Antonis Kalipetis -Antony Messerli -Anuj Bahuguna -Anuj Varma -Anusha Ragunathan -Anyu Wang -apocas -Arash Deshmeh -arcosx -ArikaChen -Arko Dasgupta -Arnaud Lefebvre -Arnaud Porterie -Arnaud Rebillout -Artem Khramov -Arthur Barr -Arthur Gautier -Artur Meyster -Arun Gupta -Asad Saeeduddin -Asbjørn Enge -Austin Vazquez -averagehuman -Avi Das -Avi Kivity -Avi Miller -Avi Vaid -ayoshitake -Azat Khuyiyakhmetov -Bao Yonglei -Bardia Keyoumarsi -Barnaby Gray -Barry Allard -Bartłomiej Piotrowski -Bastiaan Bakker -Bastien Pascard -bdevloed -Bearice Ren -Ben Bonnefoy -Ben Firshman -Ben Golub -Ben Gould -Ben Hall -Ben Langfeld -Ben Sargent -Ben Severson -Ben Toews -Ben Wiklund -Benjamin Atkin -Benjamin Baker -Benjamin Boudreau -Benjamin Böhmke -Benjamin Wang -Benjamin Yolken -Benny Ng -Benoit Chesneau -Bernerd Schaefer -Bernhard M. Wiedemann -Bert Goethals -Bertrand Roussel -Bevisy Zhang -Bharath Thiruveedula -Bhiraj Butala -Bhumika Bayani -Bilal Amarni -Bill Wang -Billy Ridgway -Bily Zhang -Bin Liu -Bingshen Wang -Bjorn Neergaard -Blake Geno -Boaz Shuster -bobby abbott -Bojun Zhu -Boqin Qin -Boris Pruessmann -Boshi Lian -Bouke Haarsma -Boyd Hemphill -boynux -Bradley Cicenas -Bradley Wright -Brandon Liu -Brandon Philips -Brandon Rhodes -Brendan Dixon -Brent Salisbury -Brett Higgins -Brett Kochendorfer -Brett Milford -Brett Randall -Brian (bex) Exelbierd -Brian Bland -Brian DeHamer -Brian Dorsey -Brian Flad -Brian Goff -Brian McCallister -Brian Olsen -Brian Schwind -Brian Shumate -Brian Torres-Gil -Brian Trump -Brice Jaglin -Briehan Lombaard -Brielle Broder -Bruno Bigras -Bruno Binet -Bruno Gazzera -Bruno Renié -Bruno Tavares -Bryan Bess -Bryan Boreham -Bryan Matsuo -Bryan Murphy -Burke Libbey -Byung Kang -Caleb Spare -Calen Pennington -Cameron Boehmer -Cameron Sparr -Cameron Spear -Campbell Allen -Candid Dauth -Cao Weiwei -Carl Henrik Lunde -Carl Loa Odin -Carl X. Su -Carlo Mion -Carlos Alexandro Becker -Carlos de Paula -Carlos Sanchez -Carol Fager-Higgins -Cary -Casey Bisson -Catalin Pirvu -Ce Gao -Cedric Davies -Cezar Sa Espinola -Chad Swenson -Chance Zibolski -Chander Govindarajan -Chanhun Jeong -Chao Wang -Charles Chan -Charles Hooper -Charles Law -Charles Lindsay -Charles Merriam -Charles Sarrazin -Charles Smith -Charlie Drage -Charlie Lewis -Chase Bolt -ChaYoung You -Chee Hau Lim -Chen Chao -Chen Chuanliang -Chen Hanxiao -Chen Min -Chen Mingjie -Chen Qiu -Cheng-mean Liu -Chengfei Shang -Chengguang Xu -Chenyang Yan -chenyuzhu -Chetan Birajdar -Chewey -Chia-liang Kao -chli -Cholerae Hu -Chris Alfonso -Chris Armstrong -Chris Dias -Chris Dituri -Chris Fordham -Chris Gavin -Chris Gibson -Chris Khoo -Chris Kreussling (Flatbush Gardener) -Chris McKinnel -Chris McKinnel -Chris Price -Chris Seto -Chris Snow -Chris St. Pierre -Chris Stivers -Chris Swan -Chris Telfer -Chris Wahl -Chris Weyl -Chris White -Christian Becker -Christian Berendt -Christian Brauner -Christian Böhme -Christian Muehlhaeuser -Christian Persson -Christian Rotzoll -Christian Simon -Christian Stefanescu -Christoph Ziebuhr -Christophe Mehay -Christophe Troestler -Christophe Vidal -Christopher Biscardi -Christopher Crone -Christopher Currie -Christopher Jones -Christopher Latham -Christopher Rigor -Christy Norman -Chun Chen -Ciro S. Costa -Clayton Coleman -Clint Armstrong -Clinton Kitson -clubby789 -Cody Roseborough -Coenraad Loubser -Colin Dunklau -Colin Hebert -Colin Panisset -Colin Rice -Colin Walters -Collin Guarino -Colm Hally -companycy -Conor Evans -Corbin Coleman -Corey Farrell -Cory Forsyth -Cory Snider -cressie176 -Cristian Ariza -Cristian Staretu -cristiano balducci -Cristina Yenyxe Gonzalez Garcia -Cruceru Calin-Cristian -cui fliter -CUI Wei -Cuong Manh Le -Cyprian Gracz -Cyril F -Da McGrady -Daan van Berkel -Daehyeok Mun -Dafydd Crosby -dalanlan -Damian Smyth -Damien Nadé -Damien Nozay -Damjan Georgievski -Dan Anolik -Dan Buch -Dan Cotora -Dan Feldman -Dan Griffin -Dan Hirsch -Dan Keder -Dan Levy -Dan McPherson -Dan Plamadeala -Dan Stine -Dan Williams -Dani Hodovic -Dani Louca -Daniel Antlinger -Daniel Black -Daniel Dao -Daniel Exner -Daniel Farrell -Daniel Garcia -Daniel Gasienica -Daniel Grunwell -Daniel Helfand -Daniel Hiltgen -Daniel J Walsh -Daniel Menet -Daniel Mizyrycki -Daniel Nephin -Daniel Norberg -Daniel Nordberg -Daniel P. Berrangé -Daniel Robinson -Daniel S -Daniel Sweet -Daniel Von Fange -Daniel Watkins -Daniel X Moore -Daniel YC Lin -Daniel Zhang -Daniele Rondina -Danny Berger -Danny Milosavljevic -Danny Yates -Danyal Khaliq -Darren Coxall -Darren Shepherd -Darren Stahl -Dattatraya Kumbhar -Davanum Srinivas -Dave Barboza -Dave Goodchild -Dave Henderson -Dave MacDonald -Dave Tucker -David Anderson -David Bellotti -David Calavera -David Chung -David Corking -David Cramer -David Currie -David Davis -David Dooling -David Gageot -David Gebler -David Glasser -David Lawrence -David Lechner -David M. Karr -David Mackey -David Manouchehri -David Mat -David Mcanulty -David McKay -David O'Rourke -David P Hilton -David Pelaez -David R. Jenni -David Röthlisberger -David Sheets -David Sissitka -David Trott -David Wang <00107082@163.com> -David Williamson -David Xia -David Young -Davide Ceretti -Dawn Chen -dbdd -dcylabs -Debayan De -Deborah Gertrude Digges -deed02392 -Deep Debroy -Deng Guangxing -Deni Bertovic -Denis Defreyne -Denis Gladkikh -Denis Ollier -Dennis Chen -Dennis Chen -Dennis Docter -Derek -Derek -Derek Ch -Derek McGowan -Deric Crago -Deshi Xiao -Devon Estes -Devvyn Murphy -Dharmit Shah -Dhawal Yogesh Bhanushali -Dhilip Kumars -Diego Romero -Diego Siqueira -Dieter Reuter -Dillon Dixon -Dima Stopel -Dimitri John Ledkov -Dimitris Mandalidis -Dimitris Rozakis -Dimitry Andric -Dinesh Subhraveti -Ding Fei -dingwei -Diogo Monica -DiuDiugirl -Djibril Koné -Djordje Lukic -dkumor -Dmitri Logvinenko -Dmitri Shuralyov -Dmitry Demeshchuk -Dmitry Gusev -Dmitry Kononenko -Dmitry Sharshakov -Dmitry Shyshkin -Dmitry Smirnov -Dmitry V. Krivenok -Dmitry Vorobev -Dmytro Iakovliev -docker-unir[bot] -Dolph Mathews -Dominic Tubach -Dominic Yin -Dominik Dingel -Dominik Finkbeiner -Dominik Honnef -Don Kirkby -Don Kjer -Don Spaulding -Donald Huang -Dong Chen -Donghwa Kim -Donovan Jones -Dorin Geman -Doron Podoleanu -Doug Davis -Doug MacEachern -Doug Tangren -Douglas Curtis -Dr Nic Williams -dragon788 -Dražen Lučanin -Drew Erny -Drew Hubl -Dustin Sallings -Ed Costello -Edmund Wagner -Eiichi Tsukata -Eike Herzbach -Eivin Giske Skaaren -Eivind Uggedal -Elan Ruusamäe -Elango Sivanandam -Elena Morozova -Eli Uriegas -Elias Faxö -Elias Koromilas -Elias Probst -Elijah Zupancic -eluck -Elvir Kuric -Emil Davtyan -Emil Hernvall -Emily Maier -Emily Rose -Emir Ozer -Eng Zer Jun -Enguerran -Eohyung Lee -epeterso -er0k -Eric Barch -Eric Curtin -Eric G. Noriega -Eric Hanchrow -Eric Lee -Eric Mountain -Eric Myhre -Eric Paris -Eric Rafaloff -Eric Rosenberg -Eric Sage -Eric Soderstrom -Eric Yang -Eric-Olivier Lamey -Erica Windisch -Erich Cordoba -Erik Bray -Erik Dubbelboer -Erik Hollensbe -Erik Inge Bolsø -Erik Kristensen -Erik Sipsma -Erik St. Martin -Erik Weathers -Erno Hopearuoho -Erwin van der Koogh -Espen Suenson -Ethan Bell -Ethan Mosbaugh -Euan Harris -Euan Kemp -Eugen Krizo -Eugene Yakubovich -Evan Allrich -Evan Carmi -Evan Hazlett -Evan Krall -Evan Lezar -Evan Phoenix -Evan Wies -Evelyn Xu -Everett Toews -Evgeniy Makhrov -Evgeny Shmarnev -Evgeny Vereshchagin -Ewa Czechowska -Eystein Måløy Stenberg -ezbercih -Ezra Silvera -Fabian Kramm -Fabian Lauer -Fabian Raetz -Fabiano Rosas -Fabio Falci -Fabio Kung -Fabio Rapposelli -Fabio Rehm -Fabrizio Regini -Fabrizio Soppelsa -Faiz Khan -falmp -Fangming Fang -Fangyuan Gao <21551127@zju.edu.cn> -fanjiyun -Fareed Dudhia -Fathi Boudra -Federico Gimenez -Felipe Oliveira -Felipe Ruhland -Felix Abecassis -Felix Geisendörfer -Felix Hupfeld -Felix Rabe -Felix Ruess -Felix Schindler -Feng Yan -Fengtu Wang -Ferenc Szabo -Fernando -Fero Volar -Feroz Salam -Ferran Rodenas -Filipe Brandenburger -Filipe Oliveira -Flavio Castelli -Flavio Crisciani -Florian -Florian Klein -Florian Maier -Florian Noeding -Florian Schmaus -Florian Weingarten -Florin Asavoaie -Florin Patan -fonglh -Foysal Iqbal -Francesc Campoy -Francesco Degrassi -Francesco Mari -Francis Chuang -Francisco Carriedo -Francisco Souza -Frank Groeneveld -Frank Herrmann -Frank Macreery -Frank Rosquin -Frank Yang -Fred Lifton -Frederick F. Kautz IV -Frederico F. de Oliveira -Frederik Loeffert -Frederik Nordahl Jul Sabroe -Freek Kalter -Frieder Bluemle -frobnicaty <92033765+frobnicaty@users.noreply.github.com> -Frédéric Dalleau -Fu JinLin -Félix Baylac-Jacqué -Félix Cantournet -Gabe Rosenhouse -Gabor Nagy -Gabriel Adrian Samfira -Gabriel Goller -Gabriel L. Somlo -Gabriel Linder -Gabriel Monroy -Gabriel Nicolas Avellaneda -Gaetan de Villele -Galen Sampson -Gang Qiao -Gareth Rushgrove -Garrett Barboza -Gary Schaetz -Gaurav -Gaurav Singh -Gaël PORTAY -Genki Takiuchi -GennadySpb -Geoff Levand -Geoffrey Bachelet -Geon Kim -George Kontridze -George MacRorie -George Xie -Georgi Hristozov -Georgy Yakovlev -Gereon Frey -German DZ -Gert van Valkenhoef -Gerwim Feiken -Ghislain Bourgeois -Giampaolo Mancini -Gianluca Borello -Gildas Cuisinier -Giovan Isa Musthofa -gissehel -Giuseppe Mazzotta -Giuseppe Scrivano -Gleb Fotengauer-Malinovskiy -Gleb M Borisov -Glyn Normington -GoBella -Goffert van Gool -Goldwyn Rodrigues -Gopikannan Venugopalsamy -Gosuke Miyashita -Gou Rao -Govinda Fichtner -Grant Millar -Grant Reaber -Graydon Hoare -Greg Fausak -Greg Pflaum -Greg Stephens -Greg Thornton -Grzegorz Jaśkiewicz -Guilhem Lettron -Guilherme Salgado -Guillaume Dufour -Guillaume J. Charmes -Gunadhya S. <6939749+gunadhya@users.noreply.github.com> -Guoqiang QI -guoxiuyan -Guri -Gurjeet Singh -Guruprasad -Gustav Sinder -gwx296173 -Günter Zöchbauer -Haichao Yang -haikuoliu -haining.cao -Hakan Özler -Hamish Hutchings -Hannes Ljungberg -Hans Kristian Flaatten -Hans Rødtang -Hao Shu Wei -Hao Zhang <21521210@zju.edu.cn> -Harald Albers -Harald Niesche -Harley Laue -Harold Cooper -Harrison Turton -Harry Zhang -Harshal Patil -Harshal Patil -He Simei -He Xiaoxi -He Xin -heartlock <21521209@zju.edu.cn> -Hector Castro -Helen Xie -Henning Sprang -Hiroshi Hatake -Hiroyuki Sasagawa -Hobofan -Hollie Teal -Hong Xu -Hongbin Lu -Hongxu Jia -Honza Pokorny -Hsing-Hui Hsu -Hsing-Yu (David) Chen -hsinko <21551195@zju.edu.cn> -Hu Keping -Hu Tao -HuanHuan Ye -Huanzhong Zhang -Huayi Zhang -Hugo Barrera -Hugo Duncan -Hugo Marisco <0x6875676f@gmail.com> -Hui Kang -Hunter Blanks -huqun -Huu Nguyen -Hyeongkyu Lee -Hyzhou Zhy -Iago López Galeiras -Ian Bishop -Ian Bull -Ian Calvert -Ian Campbell -Ian Chen -Ian Lee -Ian Main -Ian Philpot -Ian Truslove -Iavael -Icaro Seara -Ignacio Capurro -Igor Dolzhikov -Igor Karpovich -Iliana Weller -Ilkka Laukkanen -Illia Antypenko -Illo Abdulrahim -Ilya Dmitrichenko -Ilya Gusev -Ilya Khlopotov -imre Fitos -inglesp -Ingo Gottwald -Innovimax -Isaac Dupree -Isabel Jimenez -Isaiah Grace -Isao Jonas -Iskander Sharipov -Ivan Babrou -Ivan Fraixedes -Ivan Grcic -Ivan Markin -J Bruni -J. Nunn -Jack Danger Canty -Jack Laxson -Jacob Atzen -Jacob Edelman -Jacob Tomlinson -Jacob Vallejo -Jacob Wen -Jaime Cepeda -Jaivish Kothari -Jake Champlin -Jake Moshenko -Jake Sanders -Jakub Drahos -Jakub Guzik -James Allen -James Carey -James Carr -James DeFelice -James Harrison Fisher -James Kyburz -James Kyle -James Lal -James Mills -James Nesbitt -James Nugent -James Sanders -James Turnbull -James Watkins-Harvey -Jamie Hannaford -Jamshid Afshar -Jan Breig -Jan Chren -Jan Garcia -Jan Götte -Jan Keromnes -Jan Koprowski -Jan Pazdziora -Jan Toebes -Jan-Gerd Tenberge -Jan-Jaap Driessen -Jana Radhakrishnan -Jannick Fahlbusch -Januar Wayong -Jared Biel -Jared Hocutt -Jaroslaw Zabiello -Jasmine Hegman -Jason A. Donenfeld -Jason Divock -Jason Giedymin -Jason Green -Jason Hall -Jason Heiss -Jason Livesay -Jason McVetta -Jason Plum -Jason Shepherd -Jason Smith -Jason Sommer -Jason Stangroome -Javier Bassi -jaxgeller -Jay -Jay Kamat -Jay Lim -Jean Rouge -Jean-Baptiste Barth -Jean-Baptiste Dalido -Jean-Christophe Berthon -Jean-Michel Rouet -Jean-Paul Calderone -Jean-Pierre Huynh -Jean-Tiare Le Bigot -Jeeva S. Chelladhurai -Jeff Anderson -Jeff Hajewski -Jeff Johnston -Jeff Lindsay -Jeff Mickey -Jeff Minard -Jeff Nickoloff -Jeff Silberman -Jeff Welch -Jeff Zvier -Jeffrey Bolle -Jeffrey Morgan -Jeffrey van Gogh -Jenny Gebske -Jeremy Chambers -Jeremy Grosser -Jeremy Huntwork -Jeremy Price -Jeremy Qian -Jeremy Unruh -Jeremy Yallop -Jeroen Franse -Jeroen Jacobs -Jesse Dearing -Jesse Dubay -Jessica Frazelle -Jeyanthinath Muthuram -Jezeniel Zapanta -Jhon Honce -Ji.Zhilong -Jian Liao -Jian Zhang -Jiang Jinyang -Jianyong Wu -Jie Luo -Jie Ma -Jihyun Hwang -Jilles Oldenbeuving -Jim Alateras -Jim Carroll -Jim Ehrismann -Jim Galasyn -Jim Lin -Jim Minter -Jim Perrin -Jimmy Cuadra -Jimmy Puckett -Jimmy Song -Jinsoo Park -Jintao Zhang -Jiri Appl -Jiri Popelka -Jiuyue Ma -Jiří Župka -Joakim Roubert -Joao Fernandes -Joao Trindade -Joe Beda -Joe Doliner -Joe Ferguson -Joe Gordon -Joe Shaw -Joe Van Dyk -Joel Friedly -Joel Handwell -Joel Hansson -Joel Wurtz -Joey Geiger -Joey Geiger -Joey Gibson -Joffrey F -Johan Euphrosine -Johan Rydberg -Johanan Lieberman -Johannes 'fish' Ziemke -John Costa -John Feminella -John Gardiner Myers -John Gossman -John Harris -John Howard -John Laswell -John Maguire -John Mulhausen -John OBrien III -John Starks -John Stephens -John Tims -John V. Martinez -John Warwick -John Willis -Jon Johnson -Jon Surrell -Jon Wedaman -Jonas Dohse -Jonas Heinrich -Jonas Pfenniger -Jonathan A. Schweder -Jonathan A. Sternberg -Jonathan Boulle -Jonathan Camp -Jonathan Choy -Jonathan Dowland -Jonathan Lebon -Jonathan Lomas -Jonathan McCrohan -Jonathan Mueller -Jonathan Pares -Jonathan Rudenberg -Jonathan Stoppani -Jonh Wendell -Joni Sar -Joost Cassee -Jordan Arentsen -Jordan Jennings -Jordan Sissel -Jordi Massaguer Pla -Jorge Marin -Jorit Kleine-Möllhoff -Jose Diaz-Gonzalez -Joseph Anthony Pasquale Holsten -Joseph Hager -Joseph Kern -Joseph Rothrock -Josh -Josh Bodah -Josh Bonczkowski -Josh Chorlton -Josh Eveleth -Josh Hawn -Josh Horwitz -Josh Poimboeuf -Josh Soref -Josh Wilson -Josiah Kiehl -José Tomás Albornoz -Joyce Jang -JP -Julian Taylor -Julien Barbier -Julien Bisconti -Julien Bordellier -Julien Dubois -Julien Kassar -Julien Maitrehenry -Julien Pervillé -Julien Pivotto -Julio Guerra -Julio Montes -Jun Du -Jun-Ru Chang -junxu -Jussi Nummelin -Justas Brazauskas -Justen Martin -Justin Chadwell -Justin Cormack -Justin Force -Justin Keller <85903732+jk-vb@users.noreply.github.com> -Justin Menga -Justin Plock -Justin Simonelis -Justin Terry -Justyn Temme -Jyrki Puttonen -Jérémy Leherpeur -Jérôme Petazzoni -Jörg Thalheim -K. Heller -Kai Blin -Kai Qiang Wu (Kennan) -Kaijie Chen -Kamil Domański -Kamjar Gerami -Kanstantsin Shautsou -Kara Alexandra -Karan Lyons -Kareem Khazem -kargakis -Karl Grzeszczak -Karol Duleba -Karthik Karanth -Karthik Nayak -Kasper Fabæch Brandt -Kate Heddleston -Katie McLaughlin -Kato Kazuyoshi -Katrina Owen -Kawsar Saiyeed -Kay Yan -kayrus -Kazuhiro Sera -Kazuyoshi Kato -Ke Li -Ke Xu -Kei Ohmura -Keith Hudgins -Keli Hu -Ken Cochrane -Ken Herner -Ken ICHIKAWA -Ken Reese -Kenfe-Mickaël Laventure -Kenjiro Nakayama -Kent Johnson -Kenta Tada -Kevin "qwazerty" Houdebert -Kevin Alvarez -Kevin Burke -Kevin Clark -Kevin Feyrer -Kevin J. Lynagh -Kevin Jing Qiu -Kevin Kern -Kevin Menard -Kevin Meredith -Kevin P. Kucharczyk -Kevin Parsons -Kevin Richardson -Kevin Shi -Kevin Wallace -Kevin Yap -Keyvan Fatehi -kies -Kim BKC Carlbacker -Kim Eik -Kimbro Staken -Kir Kolyshkin -Kiran Gangadharan -Kirill SIbirev -Kirk Easterson -knappe -Kohei Tsuruta -Koichi Shiraishi -Konrad Kleine -Konrad Ponichtera -Konstantin Gribov -Konstantin L -Konstantin Pelykh -Kostadin Plachkov -kpcyrd -Krasi Georgiev -Krasimir Georgiev -Kris-Mikael Krister -Kristian Haugene -Kristina Zabunova -Krystian Wojcicki -Kunal Kushwaha -Kunal Tyagi -Kyle Conroy -Kyle Linden -Kyle Squizzato -Kyle Wuolle -kyu -Lachlan Coote -Lai Jiangshan -Lajos Papp -Lakshan Perera -Lalatendu Mohanty -Lance Chen -Lance Kinley -Lars Butler -Lars Kellogg-Stedman -Lars R. Damerow -Lars-Magnus Skog -Laszlo Meszaros -Laura Brehm -Laura Frank -Laurent Bernaille -Laurent Erignoux -Laurie Voss -Leandro Motta Barros -Leandro Siqueira -Lee Calcote -Lee Chao <932819864@qq.com> -Lee, Meng-Han -Lei Gong -Lei Jitang -Leiiwang -Len Weincier -Lennie -Leo Gallucci -Leonardo Nodari -Leonardo Taccari -Leszek Kowalski -Levi Blackstone -Levi Gross -Levi Harrison -Lewis Daly -Lewis Marshall -Lewis Peckover -Li Yi -Liam Macgillavry -Liana Lo -Liang Mingqiang -Liang-Chi Hsieh -liangwei -Liao Qingwei -Lifubang -Lihua Tang -Lily Guo -limeidan -Lin Lu -LingFaKe -Linus Heckemann -Liran Tal -Liron Levin -Liu Bo -Liu Hua -liwenqi -lixiaobing10051267 -Liz Zhang -LIZAO LI -Lizzie Dixon <_@lizzie.io> -Lloyd Dewolf -Lokesh Mandvekar -longliqiang88 <394564827@qq.com> -Lorenz Leutgeb -Lorenzo Fontana -Lotus Fenn -Louis Delossantos -Louis Opter -Luca Favatella -Luca Marturana -Luca Orlandi -Luca-Bogdan Grigorescu -Lucas Chan -Lucas Chi -Lucas Molas -Lucas Silvestre -Luciano Mores -Luis Henrique Mulinari -Luis Martínez de Bartolomé Izquierdo -Luiz Svoboda -Lukas Heeren -Lukas Waslowski -lukaspustina -Lukasz Zajaczkowski -Luke Marsden -Lyn -Lynda O'Leary -Lénaïc Huard -Ma Müller -Ma Shimiao -Mabin -Madhan Raj Mookkandy -Madhav Puri -Madhu Venugopal -Mageee -Mahesh Tiyyagura -malnick -Malte Janduda -Manfred Touron -Manfred Zabarauskas -Manjunath A Kumatagi -Mansi Nahar -Manuel Meurer -Manuel Rüger -Manuel Woelker -mapk0y -Marc Abramowitz -Marc Kuo -Marc Tamsky -Marcel Edmund Franke -Marcelo Horacio Fortino -Marcelo Salazar -Marco Hennings -Marcus Cobden -Marcus Farkas -Marcus Linke -Marcus Martins -Marcus Ramberg -Marek Goldmann -Marian Marinov -Marianna Tessel -Mario Loriedo -Marius Gundersen -Marius Sturm -Marius Voila -Mark Allen -Mark Feit -Mark Jeromin -Mark McGranaghan -Mark McKinstry -Mark Milstein -Mark Oates -Mark Parker -Mark Vainomaa -Mark West -Markan Patel -Marko Mikulicic -Marko Tibold -Markus Fix -Markus Kortlang -Martijn Dwars -Martijn van Oosterhout -Martin Braun -Martin Dojcak -Martin Honermeyer -Martin Kelly -Martin Mosegaard Amdisen -Martin Muzatko -Martin Redmond -Maru Newby -Mary Anthony -Masahito Zembutsu -Masato Ohba -Masayuki Morita -Mason Malone -Mateusz Sulima -Mathias Monnerville -Mathieu Champlon -Mathieu Le Marec - Pasquet -Mathieu Parent -Mathieu Paturel -Matt Apperson -Matt Bachmann -Matt Bajor -Matt Bentley -Matt Haggard -Matt Hoyle -Matt McCormick -Matt Moore -Matt Morrison <3maven@gmail.com> -Matt Richardson -Matt Rickard -Matt Robenolt -Matt Schurenko -Matt Williams -Matthew Heon -Matthew Lapworth -Matthew Mayer -Matthew Mosesohn -Matthew Mueller -Matthew Riley -Matthias Klumpp -Matthias Kühnle -Matthias Rampke -Matthieu Fronton -Matthieu Hauglustaine -Mattias Jernberg -Mauricio Garavaglia -mauriyouth -Max Harmathy -Max Shytikov -Max Timchenko -Maxim Fedchyshyn -Maxim Ivanov -Maxim Kulkin -Maxim Treskin -Maxime Petazzoni -Maximiliano Maccanti -Maxwell -Meaglith Ma -meejah -Megan Kostick -Mehul Kar -Mei ChunTao -Mengdi Gao -Menghui Chen -Mert Yazıcıoğlu -mgniu -Micah Zoltu -Michael A. Smith -Michael Beskin -Michael Bridgen -Michael Brown -Michael Chiang -Michael Crosby -Michael Currie -Michael Friis -Michael Gorsuch -Michael Grauer -Michael Holzheu -Michael Hudson-Doyle -Michael Huettermann -Michael Irwin -Michael Kuehn -Michael Käufl -Michael Neale -Michael Nussbaum -Michael Prokop -Michael Scharf -Michael Spetsiotis -Michael Stapelberg -Michael Steinert -Michael Thies -Michael Weidmann -Michael West -Michael Zhao -Michal Fojtik -Michal Gebauer -Michal Jemala -Michal Kostrzewa -Michal Minář -Michal Rostecki -Michal Wieczorek -Michaël Pailloncy -Michał Czeraszkiewicz -Michał Gryko -Michał Kosek -Michiel de Jong -Mickaël Fortunato -Mickaël Remars -Miguel Angel Fernández -Miguel Morales -Miguel Perez -Mihai Borobocea -Mihuleacc Sergiu -Mikael Davranche -Mike Brown -Mike Bush -Mike Casas -Mike Chelen -Mike Danese -Mike Dillon -Mike Dougherty -Mike Estes -Mike Gaffney -Mike Goelzer -Mike Leone -Mike Lundy -Mike MacCana -Mike Naberezny -Mike Snitzer -mikelinjie <294893458@qq.com> -Mikhail Sobolev -Miklos Szegedi -Milas Bowman -Milind Chawre -Miloslav Trmač -mingqing -Mingzhen Feng -Misty Stanley-Jones -Mitch Capper -Mizuki Urushida -mlarcher -Mohammad Banikazemi -Mohammad Nasirifar -Mohammed Aaqib Ansari -Mohit Soni -Moorthy RS -Morgan Bauer -Morgante Pell -Morgy93 -Morten Siebuhr -Morton Fox -Moysés Borges -mrfly -Mrunal Patel -Muayyad Alsadi -Muhammad Zohaib Aslam -Mustafa Akın -Muthukumar R -Máximo Cuadros -Médi-Rémi Hashim -Nace Oroz -Nahum Shalman -Nakul Pathak -Nalin Dahyabhai -Nan Monnand Deng -Naoki Orii -Natalie Parker -Natanael Copa -Natasha Jarus -Nate Brennand -Nate Eagleson -Nate Jones -Nathan Carlson -Nathan Herald -Nathan Hsieh -Nathan Kleyn -Nathan LeClaire -Nathan McCauley -Nathan Williams -Naveed Jamil -Neal McBurnett -Neil Horman -Neil Peterson -Nelson Chen -Neyazul Haque -Nghia Tran -Niall O'Higgins -Nicholas E. Rabenau -Nick Adcock -Nick DeCoursin -Nick Irvine -Nick Neisen -Nick Parker -Nick Payne -Nick Russo -Nick Santos -Nick Stenning -Nick Stinemates -Nick Wood -NickrenREN -Nicola Kabar -Nicolas Borboën -Nicolas De Loof -Nicolas Dudebout -Nicolas Goy -Nicolas Kaiser -Nicolas Sterchele -Nicolas V Castet -Nicolás Hock Isaza -Niel Drummond -Nigel Poulton -Nik Nyby -Nikhil Chawla -NikolaMandic -Nikolas Garofil -Nikolay Edigaryev -Nikolay Milovanov -ningmingxiao -Nirmal Mehta -Nishant Totla -NIWA Hideyuki -Noah Meyerhans -Noah Treuhaft -NobodyOnSE -noducks -Nolan Darilek -Nolan Miles -Noriki Nakamura -nponeccop -Nurahmadie -Nuutti Kotivuori -nzwsch -O.S. Tezer -objectified -Odin Ugedal -Oguz Bilgic -Oh Jinkyun -Ohad Schneider -ohmystack -Ole Reifschneider -Oliver Neal -Oliver Reason -Olivier Gambier -Olle Jonsson -Olli Janatuinen -Olly Pomeroy -Omri Shiv -Onur Filiz -Oriol Francès -Oscar Bonilla <6f6231@gmail.com> -oscar.chen <2972789494@qq.com> -Oskar Niburski -Otto Kekäläinen -Ouyang Liduo -Ovidio Mallo -Panagiotis Moustafellos -Paolo G. Giarrusso -Pascal -Pascal Bach -Pascal Borreli -Pascal Hartig -Patrick Böänziger -Patrick Devine -Patrick Haas -Patrick Hemmer -Patrick Stapleton -Patrik Cyvoct -pattichen -Paul "TBBle" Hampson -Paul -paul -Paul Annesley -Paul Bellamy -Paul Bowsher -Paul Furtado -Paul Hammond -Paul Jimenez -Paul Kehrer -Paul Lietar -Paul Liljenberg -Paul Morie -Paul Nasrat -Paul Seiffert -Paul Weaver -Paulo Gomes -Paulo Ribeiro -Pavel Lobashov -Pavel Matěja -Pavel Pletenev -Pavel Pospisil -Pavel Sutyrin -Pavel Tikhomirov -Pavlos Ratis -Pavol Vargovcik -Pawel Konczalski -Paweł Gronowski -Peeyush Gupta -Peggy Li -Pei Su -Peng Tao -Penghan Wang -Per Weijnitz -perhapszzy@sina.com -Pete Woods -Peter Bourgon -Peter Braden -Peter Bücker -Peter Choi -Peter Dave Hello -Peter Edge -Peter Ericson -Peter Esbensen -Peter Jaffe -Peter Kang -Peter Malmgren -Peter Salvatore -Peter Volpe -Peter Waller -Petr Švihlík -Petros Angelatos -Phil -Phil Estes -Phil Sphicas -Phil Spitler -Philip Alexander Etling -Philip K. Warren -Philip Monroe -Philipp Gillé -Philipp Wahala -Philipp Weissensteiner -Phillip Alexander -phineas -pidster -Piergiuliano Bossi -Pierre -Pierre Carrier -Pierre Dal-Pra -Pierre Wacrenier -Pierre-Alain RIVIERE -Piotr Bogdan -Piotr Karbowski -Porjo -Poul Kjeldager Sørensen -Pradeep Chhetri -Pradip Dhara -Pradipta Kr. Banerjee -Prasanna Gautam -Pratik Karki -Prayag Verma -Priya Wadhwa -Projjol Banerji -Przemek Hejman -Puneet Pruthi -Pure White -pysqz -Qiang Huang -Qin TianHuan -Qinglan Peng -Quan Tian -qudongfang -Quentin Brossard -Quentin Perez -Quentin Tayssier -r0n22 -Radostin Stoyanov -Rafal Jeczalik -Rafe Colton -Raghavendra K T -Raghuram Devarakonda -Raja Sami -Rajat Pandit -Rajdeep Dua -Ralf Sippl -Ralle -Ralph Bean -Ramkumar Ramachandra -Ramon Brooker -Ramon van Alteren -RaviTeja Pothana -Ray Tsang -ReadmeCritic -realityone -Recursive Madman -Reficul -Regan McCooey -Remi Rampin -Remy Suen -Renato Riccieri Santos Zannon -Renaud Gaubert -Rhys Hiltner -Ri Xu -Ricardo N Feliciano -Rich Horwood -Rich Moyse -Rich Seymour -Richard Burnison -Richard Harvey -Richard Mathie -Richard Metzler -Richard Scothern -Richo Healey -Rick Bradley -Rick van de Loo -Rick Wieman -Rik Nijessen -Riku Voipio -Riley Guerin -Ritesh H Shukla -Riyaz Faizullabhoy -Rob Cowsill <42620235+rcowsill@users.noreply.github.com> -Rob Gulewich -Rob Vesse -Robert Bachmann -Robert Bittle -Robert Obryk -Robert Schneider -Robert Shade -Robert Stern -Robert Terhaar -Robert Wallis -Robert Wang -Roberto G. Hashioka -Roberto Muñoz Fernández -Robin Naundorf -Robin Schneider -Robin Speekenbrink -Robin Thoni -robpc -Rodolfo Carvalho -Rodrigo Campos -Rodrigo Vaz -Roel Van Nyen -Roger Peppe -Rohit Jnagal -Rohit Kadam -Rohit Kapur -Rojin George -Roland Huß -Roland Kammerer -Roland Moriz -Roma Sokolov -Roman Dudin -Roman Mazur -Roman Strashkin -Roman Volosatovs -Roman Zabaluev -Ron Smits -Ron Williams -Rong Gao -Rong Zhang -Rongxiang Song -Rony Weng -root -root -root -root -Rory Hunter -Rory McCune -Ross Boucher -Rovanion Luckey -Roy Reznik -Royce Remer -Rozhnov Alexandr -Rudolph Gottesheim -Rui Cao -Rui Lopes -Ruilin Li -Runshen Zhu -Russ Magee -Ryan Abrams -Ryan Anderson -Ryan Aslett -Ryan Barry -Ryan Belgrave -Ryan Campbell -Ryan Detzel -Ryan Fowler -Ryan Liu -Ryan McLaughlin -Ryan O'Donnell -Ryan Seto -Ryan Shea -Ryan Simmen -Ryan Stelly -Ryan Thomas -Ryan Trauntvein -Ryan Wallner -Ryan Zhang -ryancooper7 -RyanDeng -Ryo Nakao -Ryoga Saito -Rémy Greinhofer -s. rannou -Sabin Basyal -Sachin Joshi -Sagar Hani -Sainath Grandhi -Sakeven Jiang -Salahuddin Khan -Sally O'Malley -Sam Abed -Sam Alba -Sam Bailey -Sam J Sharpe -Sam Neirinck -Sam Reis -Sam Rijs -Sam Whited -Sambuddha Basu -Sami Wagiaalla -Samuel Andaya -Samuel Dion-Girardeau -Samuel Karp -Samuel PHAN -sanchayanghosh -Sandeep Bansal -Sankar சங்கர் -Sanket Saurav -Santhosh Manohar -sapphiredev -Sargun Dhillon -Sascha Andres -Sascha Grunert -SataQiu -Satnam Singh -Satoshi Amemiya -Satoshi Tagomori -Scott Bessler -Scott Collier -Scott Johnston -Scott Percival -Scott Stamp -Scott Walls -sdreyesg -Sean Christopherson -Sean Cronin -Sean Lee -Sean McIntyre -Sean OMeara -Sean P. Kane -Sean Rodman -Sebastiaan van Steenis -Sebastiaan van Stijn -Sebastian Höffner -Sebastian Radloff -Sebastian Thomschke -Sebastien Goasguen -Senthil Kumar Selvaraj -Senthil Kumaran -SeongJae Park -Seongyeol Lim -Serge Hallyn -Sergey Alekseev -Sergey Evstifeev -Sergii Kabashniuk -Sergio Lopez -Serhat Gülçiçek -SeungUkLee -Sevki Hasirci -Shane Canon -Shane da Silva -Shaun Kaasten -shaunol -Shawn Landden -Shawn Siefkas -shawnhe -Shayan Pooya -Shayne Wang -Shekhar Gulati -Sheng Yang -Shengbo Song -Shengjing Zhu -Shev Yan -Shih-Yuan Lee -Shihao Xia -Shijiang Wei -Shijun Qin -Shishir Mahajan -Shoubhik Bose -Shourya Sarcar -Shu-Wai Chow -shuai-z -Shukui Yang -Sian Lerk Lau -Siarhei Rasiukevich -Sidhartha Mani -sidharthamani -Silas Sewell -Silvan Jegen -Simão Reis -Simon Barendse -Simon Eskildsen -Simon Ferquel -Simon Leinen -Simon Menke -Simon Taranto -Simon Vikstrom -Sindhu S -Sjoerd Langkemper -skanehira -Smark Meng -Solganik Alexander -Solomon Hykes -Song Gao -Soshi Katsuta -Sotiris Salloumis -Soulou -Spencer Brown -Spencer Smith -Spike Curtis -Sridatta Thatipamala -Sridhar Ratnakumar -Srini Brahmaroutu -Srinivasan Srivatsan -Staf Wagemakers -Stanislav Bondarenko -Stanislav Levin -Steeve Morin -Stefan Berger -Stefan J. Wernli -Stefan Praszalowicz -Stefan S. -Stefan Scherer -Stefan Staudenmeyer -Stefan Weil -Steffen Butzer -Stephan Spindler -Stephen Benjamin -Stephen Crosby -Stephen Day -Stephen Drake -Stephen Rust -Steve Desmond -Steve Dougherty -Steve Durrheimer -Steve Francia -Steve Koch -Steven Burgess -Steven Erenst -Steven Hartland -Steven Iveson -Steven Merrill -Steven Richards -Steven Taylor -Stéphane Este-Gracias -Stig Larsson -Su Wang -Subhajit Ghosh -Sujith Haridasan -Sun Gengze <690388648@qq.com> -Sun Jianbo -Sune Keller -Sunny Gogoi -Suryakumar Sudar -Sven Dowideit -Swapnil Daingade -Sylvain Baubeau -Sylvain Bellemare -Sébastien -Sébastien HOUZÉ -Sébastien Luttringer -Sébastien Stormacq -Sören Tempel -Tabakhase -Tadej Janež -Takuto Sato -tang0th -Tangi Colin -Tatsuki Sugiura -Tatsushi Inagaki -Taylan Isikdemir -Taylor Jones -Ted M. Young -Tehmasp Chaudhri -Tejaswini Duggaraju -Tejesh Mehta -Terry Chu -terryding77 <550147740@qq.com> -Thatcher Peskens -theadactyl -Thell 'Bo' Fowler -Thermionix -Thiago Alves Silva -Thijs Terlouw -Thomas Bikeev -Thomas Frössman -Thomas Gazagnaire -Thomas Graf -Thomas Grainger -Thomas Hansen -Thomas Ledos -Thomas Leonard -Thomas Léveil -Thomas Orozco -Thomas Riccardi -Thomas Schroeter -Thomas Sjögren -Thomas Swift -Thomas Tanaka -Thomas Texier -Ti Zhou -Tiago Seabra -Tianon Gravi -Tianyi Wang -Tibor Vass -Tiffany Jernigan -Tiffany Low -Till Claassen -Till Wegmüller -Tim -Tim Bart -Tim Bosse -Tim Dettrick -Tim Düsterhus -Tim Hockin -Tim Potter -Tim Ruffles -Tim Smith -Tim Terhorst -Tim Wagner -Tim Wang -Tim Waugh -Tim Wraight -Tim Zju <21651152@zju.edu.cn> -timchenxiaoyu <837829664@qq.com> -timfeirg -Timo Rothenpieler -Timothy Hobbs -tjwebb123 -tobe -Tobias Bieniek -Tobias Bradtke -Tobias Gesellchen -Tobias Klauser -Tobias Munk -Tobias Pfandzelter -Tobias Schmidt -Tobias Schwab -Todd Crane -Todd Lunter -Todd Whiteman -Toli Kuznets -Tom Barlow -Tom Booth -Tom Denham -Tom Fotherby -Tom Howe -Tom Hulihan -Tom Maaswinkel -Tom Parker -Tom Sweeney -Tom Wilkie -Tom X. Tobin -Tom Zhao -Tomas Janousek -Tomas Kral -Tomas Tomecek -Tomasz Kopczynski -Tomasz Lipinski -Tomasz Nurkiewicz -Tomek Mańko -Tommaso Visconti -Tomoya Tabuchi -Tomáš Hrčka -tonic -Tonny Xu -Tony Abboud -Tony Daws -Tony Miller -toogley -Torstein Husebø -Toshiaki Makita -Tõnis Tiigi -Trace Andreason -tracylihui <793912329@qq.com> -Trapier Marshall -Travis Cline -Travis Thieman -Trent Ogren -Trevor -Trevor Pounds -Trevor Sullivan -Trishna Guha -Tristan Carel -Troy Denton -Tudor Brindus -Ty Alexander -Tycho Andersen -Tyler Brock -Tyler Brown -Tzu-Jung Lee -uhayate -Ulysse Carion -Umesh Yadav -Utz Bacher -vagrant -Vaidas Jablonskis -Valentin Kulesh -vanderliang -Velko Ivanov -Veres Lajos -Victor Algaze -Victor Coisne -Victor Costan -Victor I. Wood -Victor Lyuboslavsky -Victor Marmol -Victor Palma -Victor Vieux -Victoria Bialas -Vijaya Kumar K -Vikas Choudhary -Vikram bir Singh -Viktor Stanchev -Viktor Vojnovski -VinayRaghavanKS -Vincent Batts -Vincent Bernat -Vincent Boulineau -Vincent Demeester -Vincent Giersch -Vincent Mayers -Vincent Woo -Vinod Kulkarni -Vishal Doshi -Vishnu Kannan -Vitaly Ostrosablin -Vitor Anjos -Vitor Monteiro -Vivek Agarwal -Vivek Dasgupta -Vivek Goyal -Vladimir Bulyga -Vladimir Kirillov -Vladimir Pouzanov -Vladimir Rutsky -Vladimir Varankin -VladimirAus -Vladislav Kolesnikov -Vlastimil Zeman -Vojtech Vitek (V-Teq) -Walter Leibbrandt -Walter Stanish -Wang Chao -Wang Guoliang -Wang Jie -Wang Long -Wang Ping -Wang Xing -Wang Yuexiao -Wang Yumu <37442693@qq.com> -wanghuaiqing -Ward Vandewege -WarheadsSE -Wassim Dhif -Wataru Ishida -Wayne Chang -Wayne Song -Weerasak Chongnguluam -Wei Fu -Wei Wu -Wei-Ting Kuo -weipeng -weiyan -Weiyang Zhu -Wen Cheng Ma -Wendel Fleming -Wenjun Tang -Wenkai Yin -wenlxie -Wenxuan Zhao -Wenyu You <21551128@zju.edu.cn> -Wenzhi Liang -Wes Morgan -Wesley Pettit -Wewang Xiaorenfine -Wiktor Kwapisiewicz -Will Dietz -Will Rouesnel -Will Weaver -willhf -William Delanoue -William Henry -William Hubbs -William Martin -William Riancho -William Thurston -Wilson Júnior -Wing-Kam Wong -WiseTrem -Wolfgang Nagele -Wolfgang Powisch -Wonjun Kim -WuLonghui -xamyzhao -Xia Wu -Xian Chaobo -Xianglin Gao -Xianjie -Xianlu Bird -Xiao YongBiao -Xiao Zhang -XiaoBing Jiang -Xiaodong Liu -Xiaodong Zhang -Xiaohua Ding -Xiaoxi He -Xiaoxu Chen -Xiaoyu Zhang -xichengliudui <1693291525@qq.com> -xiekeyang -Ximo Guanter Gonzálbez -xin.li -Xinbo Weng -Xinfeng Liu -Xinzi Zhou -Xiuming Chen -Xuecong Liao -xuzhaokui -Yadnyawalkya Tale -Yahya -yalpul -YAMADA Tsuyoshi -Yamasaki Masahide -Yamazaki Masashi -Yan Feng -Yan Zhu -Yang Bai -Yang Li -Yang Pengfei -yangchenliang -Yann Autissier -Yanqiang Miao -Yao Zaiyong -Yash Murty -Yassine Tijani -Yasunori Mahata -Yazhong Liu -Yestin Sun -Yi EungJun -Yibai Zhang -Yihang Ho -Ying Li -Yohei Ueda -Yong Tang -Yongxin Li -Yongzhi Pan -Yosef Fertel -You-Sheng Yang (楊有勝) -youcai -Youcef YEKHLEF -Youfu Zhang -Yu Changchun -Yu Chengxia -Yu Peng -Yu-Ju Hong -Yuan Sun -Yuanhong Peng -Yue Zhang -Yufei Xiong -Yuhao Fang -Yuichiro Kaneko -YujiOshima -Yunxiang Huang -Yurii Rashkovskii -Yusuf Tarık Günaydın -Yves Blusseau <90z7oey02@sneakemail.com> -Yves Junqueira -Zac Dover -Zach Borboa -Zach Gershman -Zachary Jaffee -Zain Memon -Zaiste! -Zane DeGraffenried -Zefan Li -Zen Lin(Zhinan Lin) -Zhang Kun -Zhang Wei -Zhang Wentao -zhangguanzhang -ZhangHang -zhangxianwei -Zhenan Ye <21551168@zju.edu.cn> -zhenghenghuo -Zhenhai Gao -Zhenkun Bi -ZhiPeng Lu -zhipengzuo -Zhou Hao -Zhoulin Xie -Zhu Guihua -Zhu Kunjia -Zhuoyun Wei -Ziheng Liu -Zilin Du -zimbatm -Ziming Dong -ZJUshuaizhou <21551191@zju.edu.cn> -zmarouf -Zoltan Tombol -Zou Yu -zqh -Zuhayr Elahi -Zunayed Ali -Álvaro Lázaro -Átila Camurça Alves -吴小白 <296015668@qq.com> -尹吉峰 -屈骏 -徐俊杰 -慕陶 -搏通 -黄艳红00139573 -정재영 diff --git a/vendor/github.com/docker/docker/LICENSE b/vendor/github.com/docker/docker/LICENSE deleted file mode 100644 index 6d8d58fb67..0000000000 --- a/vendor/github.com/docker/docker/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ - - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - Copyright 2013-2018 Docker, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/docker/docker/NOTICE b/vendor/github.com/docker/docker/NOTICE deleted file mode 100644 index 58b19b6d15..0000000000 --- a/vendor/github.com/docker/docker/NOTICE +++ /dev/null @@ -1,19 +0,0 @@ -Docker -Copyright 2012-2017 Docker, Inc. - -This product includes software developed at Docker, Inc. (https://www.docker.com). - -This product contains software (https://github.com/creack/pty) developed -by Keith Rarick, licensed under the MIT License. - -The following is courtesy of our legal counsel: - - -Use and transfer of Docker may be subject to certain restrictions by the -United States and other governments. -It is your responsibility to ensure that your use and/or transfer does not -violate applicable laws. - -For more information, please see https://www.bis.doc.gov - -See also https://www.apache.org/dev/crypto.html and/or seek legal counsel. diff --git a/vendor/github.com/docker/docker/errdefs/defs.go b/vendor/github.com/docker/docker/errdefs/defs.go deleted file mode 100644 index a5523c3e95..0000000000 --- a/vendor/github.com/docker/docker/errdefs/defs.go +++ /dev/null @@ -1,69 +0,0 @@ -package errdefs - -// ErrNotFound signals that the requested object doesn't exist -type ErrNotFound interface { - NotFound() -} - -// ErrInvalidParameter signals that the user input is invalid -type ErrInvalidParameter interface { - InvalidParameter() -} - -// ErrConflict signals that some internal state conflicts with the requested action and can't be performed. -// A change in state should be able to clear this error. -type ErrConflict interface { - Conflict() -} - -// ErrUnauthorized is used to signify that the user is not authorized to perform a specific action -type ErrUnauthorized interface { - Unauthorized() -} - -// ErrUnavailable signals that the requested action/subsystem is not available. -type ErrUnavailable interface { - Unavailable() -} - -// ErrForbidden signals that the requested action cannot be performed under any circumstances. -// When a ErrForbidden is returned, the caller should never retry the action. -type ErrForbidden interface { - Forbidden() -} - -// ErrSystem signals that some internal error occurred. -// An example of this would be a failed mount request. -type ErrSystem interface { - System() -} - -// ErrNotModified signals that an action can't be performed because it's already in the desired state -type ErrNotModified interface { - NotModified() -} - -// ErrNotImplemented signals that the requested action/feature is not implemented on the system as configured. -type ErrNotImplemented interface { - NotImplemented() -} - -// ErrUnknown signals that the kind of error that occurred is not known. -type ErrUnknown interface { - Unknown() -} - -// ErrCancelled signals that the action was cancelled. -type ErrCancelled interface { - Cancelled() -} - -// ErrDeadline signals that the deadline was reached before the action completed. -type ErrDeadline interface { - DeadlineExceeded() -} - -// ErrDataLoss indicates that data was lost or there is data corruption. -type ErrDataLoss interface { - DataLoss() -} diff --git a/vendor/github.com/docker/docker/errdefs/doc.go b/vendor/github.com/docker/docker/errdefs/doc.go deleted file mode 100644 index c211f174fc..0000000000 --- a/vendor/github.com/docker/docker/errdefs/doc.go +++ /dev/null @@ -1,8 +0,0 @@ -// Package errdefs defines a set of error interfaces that packages should use for communicating classes of errors. -// Errors that cross the package boundary should implement one (and only one) of these interfaces. -// -// Packages should not reference these interfaces directly, only implement them. -// To check if a particular error implements one of these interfaces, there are helper -// functions provided (e.g. `Is`) which can be used rather than asserting the interfaces directly. -// If you must assert on these interfaces, be sure to check the causal chain (`err.Cause()`). -package errdefs // import "github.com/docker/docker/errdefs" diff --git a/vendor/github.com/docker/docker/errdefs/helpers.go b/vendor/github.com/docker/docker/errdefs/helpers.go deleted file mode 100644 index 042de4b7b8..0000000000 --- a/vendor/github.com/docker/docker/errdefs/helpers.go +++ /dev/null @@ -1,279 +0,0 @@ -package errdefs - -import "context" - -type errNotFound struct{ error } - -func (errNotFound) NotFound() {} - -func (e errNotFound) Cause() error { - return e.error -} - -func (e errNotFound) Unwrap() error { - return e.error -} - -// NotFound is a helper to create an error of the class with the same name from any error type -func NotFound(err error) error { - if err == nil || IsNotFound(err) { - return err - } - return errNotFound{err} -} - -type errInvalidParameter struct{ error } - -func (errInvalidParameter) InvalidParameter() {} - -func (e errInvalidParameter) Cause() error { - return e.error -} - -func (e errInvalidParameter) Unwrap() error { - return e.error -} - -// InvalidParameter is a helper to create an error of the class with the same name from any error type -func InvalidParameter(err error) error { - if err == nil || IsInvalidParameter(err) { - return err - } - return errInvalidParameter{err} -} - -type errConflict struct{ error } - -func (errConflict) Conflict() {} - -func (e errConflict) Cause() error { - return e.error -} - -func (e errConflict) Unwrap() error { - return e.error -} - -// Conflict is a helper to create an error of the class with the same name from any error type -func Conflict(err error) error { - if err == nil || IsConflict(err) { - return err - } - return errConflict{err} -} - -type errUnauthorized struct{ error } - -func (errUnauthorized) Unauthorized() {} - -func (e errUnauthorized) Cause() error { - return e.error -} - -func (e errUnauthorized) Unwrap() error { - return e.error -} - -// Unauthorized is a helper to create an error of the class with the same name from any error type -func Unauthorized(err error) error { - if err == nil || IsUnauthorized(err) { - return err - } - return errUnauthorized{err} -} - -type errUnavailable struct{ error } - -func (errUnavailable) Unavailable() {} - -func (e errUnavailable) Cause() error { - return e.error -} - -func (e errUnavailable) Unwrap() error { - return e.error -} - -// Unavailable is a helper to create an error of the class with the same name from any error type -func Unavailable(err error) error { - if err == nil || IsUnavailable(err) { - return err - } - return errUnavailable{err} -} - -type errForbidden struct{ error } - -func (errForbidden) Forbidden() {} - -func (e errForbidden) Cause() error { - return e.error -} - -func (e errForbidden) Unwrap() error { - return e.error -} - -// Forbidden is a helper to create an error of the class with the same name from any error type -func Forbidden(err error) error { - if err == nil || IsForbidden(err) { - return err - } - return errForbidden{err} -} - -type errSystem struct{ error } - -func (errSystem) System() {} - -func (e errSystem) Cause() error { - return e.error -} - -func (e errSystem) Unwrap() error { - return e.error -} - -// System is a helper to create an error of the class with the same name from any error type -func System(err error) error { - if err == nil || IsSystem(err) { - return err - } - return errSystem{err} -} - -type errNotModified struct{ error } - -func (errNotModified) NotModified() {} - -func (e errNotModified) Cause() error { - return e.error -} - -func (e errNotModified) Unwrap() error { - return e.error -} - -// NotModified is a helper to create an error of the class with the same name from any error type -func NotModified(err error) error { - if err == nil || IsNotModified(err) { - return err - } - return errNotModified{err} -} - -type errNotImplemented struct{ error } - -func (errNotImplemented) NotImplemented() {} - -func (e errNotImplemented) Cause() error { - return e.error -} - -func (e errNotImplemented) Unwrap() error { - return e.error -} - -// NotImplemented is a helper to create an error of the class with the same name from any error type -func NotImplemented(err error) error { - if err == nil || IsNotImplemented(err) { - return err - } - return errNotImplemented{err} -} - -type errUnknown struct{ error } - -func (errUnknown) Unknown() {} - -func (e errUnknown) Cause() error { - return e.error -} - -func (e errUnknown) Unwrap() error { - return e.error -} - -// Unknown is a helper to create an error of the class with the same name from any error type -func Unknown(err error) error { - if err == nil || IsUnknown(err) { - return err - } - return errUnknown{err} -} - -type errCancelled struct{ error } - -func (errCancelled) Cancelled() {} - -func (e errCancelled) Cause() error { - return e.error -} - -func (e errCancelled) Unwrap() error { - return e.error -} - -// Cancelled is a helper to create an error of the class with the same name from any error type -func Cancelled(err error) error { - if err == nil || IsCancelled(err) { - return err - } - return errCancelled{err} -} - -type errDeadline struct{ error } - -func (errDeadline) DeadlineExceeded() {} - -func (e errDeadline) Cause() error { - return e.error -} - -func (e errDeadline) Unwrap() error { - return e.error -} - -// Deadline is a helper to create an error of the class with the same name from any error type -func Deadline(err error) error { - if err == nil || IsDeadline(err) { - return err - } - return errDeadline{err} -} - -type errDataLoss struct{ error } - -func (errDataLoss) DataLoss() {} - -func (e errDataLoss) Cause() error { - return e.error -} - -func (e errDataLoss) Unwrap() error { - return e.error -} - -// DataLoss is a helper to create an error of the class with the same name from any error type -func DataLoss(err error) error { - if err == nil || IsDataLoss(err) { - return err - } - return errDataLoss{err} -} - -// FromContext returns the error class from the passed in context -func FromContext(ctx context.Context) error { - e := ctx.Err() - if e == nil { - return nil - } - - if e == context.Canceled { - return Cancelled(e) - } - if e == context.DeadlineExceeded { - return Deadline(e) - } - return Unknown(e) -} diff --git a/vendor/github.com/docker/docker/errdefs/http_helpers.go b/vendor/github.com/docker/docker/errdefs/http_helpers.go deleted file mode 100644 index ebcd789302..0000000000 --- a/vendor/github.com/docker/docker/errdefs/http_helpers.go +++ /dev/null @@ -1,46 +0,0 @@ -package errdefs - -import ( - "net/http" -) - -// FromStatusCode creates an errdef error, based on the provided HTTP status-code -func FromStatusCode(err error, statusCode int) error { - if err == nil { - return nil - } - switch statusCode { - case http.StatusNotFound: - err = NotFound(err) - case http.StatusBadRequest: - err = InvalidParameter(err) - case http.StatusConflict: - err = Conflict(err) - case http.StatusUnauthorized: - err = Unauthorized(err) - case http.StatusServiceUnavailable: - err = Unavailable(err) - case http.StatusForbidden: - err = Forbidden(err) - case http.StatusNotModified: - err = NotModified(err) - case http.StatusNotImplemented: - err = NotImplemented(err) - case http.StatusInternalServerError: - if !IsSystem(err) && !IsUnknown(err) && !IsDataLoss(err) && !IsDeadline(err) && !IsCancelled(err) { - err = System(err) - } - default: - switch { - case statusCode >= 200 && statusCode < 400: - // it's a client error - case statusCode >= 400 && statusCode < 500: - err = InvalidParameter(err) - case statusCode >= 500 && statusCode < 600: - err = System(err) - default: - err = Unknown(err) - } - } - return err -} diff --git a/vendor/github.com/docker/docker/errdefs/is.go b/vendor/github.com/docker/docker/errdefs/is.go deleted file mode 100644 index 461cba5f88..0000000000 --- a/vendor/github.com/docker/docker/errdefs/is.go +++ /dev/null @@ -1,107 +0,0 @@ -package errdefs - -type causer interface { - Cause() error -} - -func getImplementer(err error) error { - switch e := err.(type) { - case - ErrNotFound, - ErrInvalidParameter, - ErrConflict, - ErrUnauthorized, - ErrUnavailable, - ErrForbidden, - ErrSystem, - ErrNotModified, - ErrNotImplemented, - ErrCancelled, - ErrDeadline, - ErrDataLoss, - ErrUnknown: - return err - case causer: - return getImplementer(e.Cause()) - default: - return err - } -} - -// IsNotFound returns if the passed in error is an ErrNotFound -func IsNotFound(err error) bool { - _, ok := getImplementer(err).(ErrNotFound) - return ok -} - -// IsInvalidParameter returns if the passed in error is an ErrInvalidParameter -func IsInvalidParameter(err error) bool { - _, ok := getImplementer(err).(ErrInvalidParameter) - return ok -} - -// IsConflict returns if the passed in error is an ErrConflict -func IsConflict(err error) bool { - _, ok := getImplementer(err).(ErrConflict) - return ok -} - -// IsUnauthorized returns if the passed in error is an ErrUnauthorized -func IsUnauthorized(err error) bool { - _, ok := getImplementer(err).(ErrUnauthorized) - return ok -} - -// IsUnavailable returns if the passed in error is an ErrUnavailable -func IsUnavailable(err error) bool { - _, ok := getImplementer(err).(ErrUnavailable) - return ok -} - -// IsForbidden returns if the passed in error is an ErrForbidden -func IsForbidden(err error) bool { - _, ok := getImplementer(err).(ErrForbidden) - return ok -} - -// IsSystem returns if the passed in error is an ErrSystem -func IsSystem(err error) bool { - _, ok := getImplementer(err).(ErrSystem) - return ok -} - -// IsNotModified returns if the passed in error is a NotModified error -func IsNotModified(err error) bool { - _, ok := getImplementer(err).(ErrNotModified) - return ok -} - -// IsNotImplemented returns if the passed in error is an ErrNotImplemented -func IsNotImplemented(err error) bool { - _, ok := getImplementer(err).(ErrNotImplemented) - return ok -} - -// IsUnknown returns if the passed in error is an ErrUnknown -func IsUnknown(err error) bool { - _, ok := getImplementer(err).(ErrUnknown) - return ok -} - -// IsCancelled returns if the passed in error is an ErrCancelled -func IsCancelled(err error) bool { - _, ok := getImplementer(err).(ErrCancelled) - return ok -} - -// IsDeadline returns if the passed in error is an ErrDeadline -func IsDeadline(err error) bool { - _, ok := getImplementer(err).(ErrDeadline) - return ok -} - -// IsDataLoss returns if the passed in error is an ErrDataLoss -func IsDataLoss(err error) bool { - _, ok := getImplementer(err).(ErrDataLoss) - return ok -} diff --git a/vendor/github.com/docker/docker/libnetwork/bitmap/sequence.go b/vendor/github.com/docker/docker/libnetwork/bitmap/sequence.go deleted file mode 100644 index 2644c5d354..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/bitmap/sequence.go +++ /dev/null @@ -1,585 +0,0 @@ -// Package bitmap provides a datatype for long vectors of bits. -package bitmap - -import ( - "encoding/binary" - "encoding/json" - "errors" - "fmt" -) - -// block sequence constants -// If needed we can think of making these configurable -const ( - blockLen = uint32(32) - blockBytes = uint64(blockLen / 8) - blockMAX = uint32(1<%s", s.block, s.count, nextBlock) -} - -// GetAvailableBit returns the position of the first unset bit in the bitmask represented by this sequence -func (s *sequence) getAvailableBit(from uint64) (uint64, uint64, error) { - if s.block == blockMAX || s.count == 0 { - return invalidPos, invalidPos, ErrNoBitAvailable - } - bits := from - bitSel := blockFirstBit >> from - for bitSel > 0 && s.block&bitSel != 0 { - bitSel >>= 1 - bits++ - } - // Check if the loop exited because it could not - // find any available bit int block starting from - // "from". Return invalid pos in that case. - if bitSel == 0 { - return invalidPos, invalidPos, ErrNoBitAvailable - } - return bits / 8, bits % 8, nil -} - -// GetCopy returns a copy of the linked list rooted at this node -func (s *sequence) getCopy() *sequence { - n := &sequence{block: s.block, count: s.count} - pn := n - ps := s.next - for ps != nil { - pn.next = &sequence{block: ps.block, count: ps.count} - pn = pn.next - ps = ps.next - } - return n -} - -// Equal checks if this sequence is equal to the passed one -func (s *sequence) equal(o *sequence) bool { - this := s - other := o - for this != nil { - if other == nil { - return false - } - if this.block != other.block || this.count != other.count { - return false - } - this = this.next - other = other.next - } - return other == nil -} - -// ToByteArray converts the sequence into a byte array -func (s *sequence) toByteArray() ([]byte, error) { - var bb []byte - - p := s - b := make([]byte, 12) - for p != nil { - binary.BigEndian.PutUint32(b[0:], p.block) - binary.BigEndian.PutUint64(b[4:], p.count) - bb = append(bb, b...) - p = p.next - } - - return bb, nil -} - -// fromByteArray construct the sequence from the byte array -func (s *sequence) fromByteArray(data []byte) error { - l := len(data) - if l%12 != 0 { - return fmt.Errorf("cannot deserialize byte sequence of length %d (%v)", l, data) - } - - p := s - i := 0 - for { - p.block = binary.BigEndian.Uint32(data[i : i+4]) - p.count = binary.BigEndian.Uint64(data[i+4 : i+12]) - i += 12 - if i == l { - break - } - p.next = &sequence{} - p = p.next - } - - return nil -} - -// SetAnyInRange sets the first unset bit in the range [start, end] and returns -// the ordinal of the set bit. -// -// When serial=true, the bitmap is scanned starting from the ordinal following -// the bit most recently set by [Bitmap.SetAny] or [Bitmap.SetAnyInRange]. -func (h *Bitmap) SetAnyInRange(start, end uint64, serial bool) (uint64, error) { - if end < start || end >= h.bits { - return invalidPos, fmt.Errorf("invalid bit range [%d, %d)", start, end) - } - if h.Unselected() == 0 { - return invalidPos, ErrNoBitAvailable - } - return h.set(0, start, end, true, false, serial) -} - -// SetAny sets the first unset bit in the sequence and returns the ordinal of -// the set bit. -// -// When serial=true, the bitmap is scanned starting from the ordinal following -// the bit most recently set by [Bitmap.SetAny] or [Bitmap.SetAnyInRange]. -func (h *Bitmap) SetAny(serial bool) (uint64, error) { - if h.Unselected() == 0 { - return invalidPos, ErrNoBitAvailable - } - return h.set(0, 0, h.bits-1, true, false, serial) -} - -// Set atomically sets the corresponding bit in the sequence -func (h *Bitmap) Set(ordinal uint64) error { - if err := h.validateOrdinal(ordinal); err != nil { - return err - } - _, err := h.set(ordinal, 0, 0, false, false, false) - return err -} - -// Unset atomically unsets the corresponding bit in the sequence -func (h *Bitmap) Unset(ordinal uint64) error { - if err := h.validateOrdinal(ordinal); err != nil { - return err - } - _, err := h.set(ordinal, 0, 0, false, true, false) - return err -} - -// IsSet atomically checks if the ordinal bit is set. In case ordinal -// is outside of the bit sequence limits, false is returned. -func (h *Bitmap) IsSet(ordinal uint64) bool { - if err := h.validateOrdinal(ordinal); err != nil { - return false - } - _, _, err := checkIfAvailable(h.head, ordinal) - return err != nil -} - -// set/reset the bit -func (h *Bitmap) set(ordinal, start, end uint64, any bool, release bool, serial bool) (uint64, error) { - var ( - bitPos uint64 - bytePos uint64 - ret uint64 - err error - ) - - curr := uint64(0) - if serial { - curr = h.curr - } - // Get position if available - if release { - bytePos, bitPos = ordinalToPos(ordinal) - } else { - if any { - bytePos, bitPos, err = getAvailableFromCurrent(h.head, start, curr, end) - ret = posToOrdinal(bytePos, bitPos) - if err == nil { - h.curr = ret + 1 - } - } else { - bytePos, bitPos, err = checkIfAvailable(h.head, ordinal) - ret = ordinal - } - } - if err != nil { - return ret, err - } - - h.head = pushReservation(bytePos, bitPos, h.head, release) - if release { - h.unselected++ - } else { - h.unselected-- - } - - return ret, nil -} - -// checks is needed because to cover the case where the number of bits is not a multiple of blockLen -func (h *Bitmap) validateOrdinal(ordinal uint64) error { - if ordinal >= h.bits { - return errors.New("bit does not belong to the sequence") - } - return nil -} - -// MarshalBinary encodes h into a binary representation. -func (h *Bitmap) MarshalBinary() ([]byte, error) { - ba := make([]byte, 16) - binary.BigEndian.PutUint64(ba[0:], h.bits) - binary.BigEndian.PutUint64(ba[8:], h.unselected) - bm, err := h.head.toByteArray() - if err != nil { - return nil, fmt.Errorf("failed to serialize head: %v", err) - } - ba = append(ba, bm...) - - return ba, nil -} - -// UnmarshalBinary decodes a binary representation of a Bitmap value which was -// generated using [Bitmap.MarshalBinary]. -// -// The scan position for serial [Bitmap.SetAny] and [Bitmap.SetAnyInRange] -// operations is neither unmarshaled nor reset. -func (h *Bitmap) UnmarshalBinary(ba []byte) error { - if ba == nil { - return errors.New("nil byte array") - } - - nh := &sequence{} - err := nh.fromByteArray(ba[16:]) - if err != nil { - return fmt.Errorf("failed to deserialize head: %v", err) - } - - h.head = nh - h.bits = binary.BigEndian.Uint64(ba[0:8]) - h.unselected = binary.BigEndian.Uint64(ba[8:16]) - return nil -} - -// Bits returns the length of the bit sequence -func (h *Bitmap) Bits() uint64 { - return h.bits -} - -// Unselected returns the number of bits which are not selected -func (h *Bitmap) Unselected() uint64 { - return h.unselected -} - -func (h *Bitmap) String() string { - return fmt.Sprintf("Bits: %d, Unselected: %d, Sequence: %s Curr:%d", - h.bits, h.unselected, h.head.toString(), h.curr) -} - -// MarshalJSON encodes h into a JSON message -func (h *Bitmap) MarshalJSON() ([]byte, error) { - b, err := h.MarshalBinary() - if err != nil { - return nil, err - } - return json.Marshal(b) -} - -// UnmarshalJSON decodes JSON message into h -func (h *Bitmap) UnmarshalJSON(data []byte) error { - var b []byte - if err := json.Unmarshal(data, &b); err != nil { - return err - } - return h.UnmarshalBinary(b) -} - -// getFirstAvailable looks for the first unset bit in passed mask starting from start -func getFirstAvailable(head *sequence, start uint64) (uint64, uint64, error) { - // Find sequence which contains the start bit - byteStart, bitStart := ordinalToPos(start) - current, _, precBlocks, inBlockBytePos := findSequence(head, byteStart) - // Derive the this sequence offsets - byteOffset := byteStart - inBlockBytePos - bitOffset := inBlockBytePos*8 + bitStart - for current != nil { - if current.block != blockMAX { - // If the current block is not full, check if there is any bit - // from the current bit in the current block. If not, before proceeding to the - // next block node, make sure we check for available bit in the next - // instance of the same block. Due to RLE same block signature will be - // compressed. - retry: - bytePos, bitPos, err := current.getAvailableBit(bitOffset) - if err != nil && precBlocks == current.count-1 { - // This is the last instance in the same block node, - // so move to the next block. - goto next - } - if err != nil { - // There are some more instances of the same block, so add the offset - // and be optimistic that you will find the available bit in the next - // instance of the same block. - bitOffset = 0 - byteOffset += blockBytes - precBlocks++ - goto retry - } - return byteOffset + bytePos, bitPos, err - } - // Moving to next block: Reset bit offset. - next: - bitOffset = 0 - byteOffset += (current.count * blockBytes) - (precBlocks * blockBytes) - precBlocks = 0 - current = current.next - } - return invalidPos, invalidPos, ErrNoBitAvailable -} - -// getAvailableFromCurrent will look for available ordinal from the current ordinal. -// If none found then it will loop back to the start to check of the available bit. -// This can be further optimized to check from start till curr in case of a rollover -func getAvailableFromCurrent(head *sequence, start, curr, end uint64) (uint64, uint64, error) { - var bytePos, bitPos uint64 - var err error - if curr != 0 && curr > start { - bytePos, bitPos, err = getFirstAvailable(head, curr) - ret := posToOrdinal(bytePos, bitPos) - if end < ret || err != nil { - goto begin - } - return bytePos, bitPos, nil - } - -begin: - bytePos, bitPos, err = getFirstAvailable(head, start) - ret := posToOrdinal(bytePos, bitPos) - if end < ret || err != nil { - return invalidPos, invalidPos, ErrNoBitAvailable - } - return bytePos, bitPos, nil -} - -// checkIfAvailable checks if the bit correspondent to the specified ordinal is unset -// If the ordinal is beyond the sequence limits, a negative response is returned -func checkIfAvailable(head *sequence, ordinal uint64) (uint64, uint64, error) { - bytePos, bitPos := ordinalToPos(ordinal) - - // Find the sequence containing this byte - current, _, _, inBlockBytePos := findSequence(head, bytePos) - if current != nil { - // Check whether the bit corresponding to the ordinal address is unset - bitSel := blockFirstBit >> (inBlockBytePos*8 + bitPos) - if current.block&bitSel == 0 { - return bytePos, bitPos, nil - } - } - - return invalidPos, invalidPos, ErrBitAllocated -} - -// Given the byte position and the sequences list head, return the pointer to the -// sequence containing the byte (current), the pointer to the previous sequence, -// the number of blocks preceding the block containing the byte inside the current sequence. -// If bytePos is outside of the list, function will return (nil, nil, 0, invalidPos) -func findSequence(head *sequence, bytePos uint64) (*sequence, *sequence, uint64, uint64) { - // Find the sequence containing this byte - previous := head - current := head - n := bytePos - for current.next != nil && n >= (current.count*blockBytes) { // Nil check for less than 32 addresses masks - n -= (current.count * blockBytes) - previous = current - current = current.next - } - - // If byte is outside of the list, let caller know - if n >= (current.count * blockBytes) { - return nil, nil, 0, invalidPos - } - - // Find the byte position inside the block and the number of blocks - // preceding the block containing the byte inside this sequence - precBlocks := n / blockBytes - inBlockBytePos := bytePos % blockBytes - - return current, previous, precBlocks, inBlockBytePos -} - -// PushReservation pushes the bit reservation inside the bitmask. -// Given byte and bit positions, identify the sequence (current) which holds the block containing the affected bit. -// Create a new block with the modified bit according to the operation (allocate/release). -// Create a new sequence containing the new block and insert it in the proper position. -// Remove current sequence if empty. -// Check if new sequence can be merged with neighbour (previous/next) sequences. -// -// Identify "current" sequence containing block: -// -// [prev seq] [current seq] [next seq] -// -// Based on block position, resulting list of sequences can be any of three forms: -// -// block position Resulting list of sequences -// -// A) block is first in current: [prev seq] [new] [modified current seq] [next seq] -// B) block is last in current: [prev seq] [modified current seq] [new] [next seq] -// C) block is in the middle of current: [prev seq] [curr pre] [new] [curr post] [next seq] -func pushReservation(bytePos, bitPos uint64, head *sequence, release bool) *sequence { - // Store list's head - newHead := head - - // Find the sequence containing this byte - current, previous, precBlocks, inBlockBytePos := findSequence(head, bytePos) - if current == nil { - return newHead - } - - // Construct updated block - bitSel := blockFirstBit >> (inBlockBytePos*8 + bitPos) - newBlock := current.block - if release { - newBlock &^= bitSel - } else { - newBlock |= bitSel - } - - // Quit if it was a redundant request - if current.block == newBlock { - return newHead - } - - // Current sequence inevitably looses one block, upadate count - current.count-- - - // Create new sequence - newSequence := &sequence{block: newBlock, count: 1} - - // Insert the new sequence in the list based on block position - if precBlocks == 0 { // First in sequence (A) - newSequence.next = current - if current == head { - newHead = newSequence - previous = newHead - } else { - previous.next = newSequence - } - removeCurrentIfEmpty(&newHead, newSequence, current) - mergeSequences(previous) - } else if precBlocks == current.count { // Last in sequence (B) - newSequence.next = current.next - current.next = newSequence - mergeSequences(current) - } else { // In between the sequence (C) - currPre := &sequence{block: current.block, count: precBlocks, next: newSequence} - currPost := current - currPost.count -= precBlocks - newSequence.next = currPost - if currPost == head { - newHead = currPre - } else { - previous.next = currPre - } - // No merging or empty current possible here - } - - return newHead -} - -// Removes the current sequence from the list if empty, adjusting the head pointer if needed -func removeCurrentIfEmpty(head **sequence, previous, current *sequence) { - if current.count == 0 { - if current == *head { - *head = current.next - } else { - previous.next = current.next - } - } -} - -// Given a pointer to a sequence, it checks if it can be merged with any following sequences -// It stops when no more merging is possible. -// TODO: Optimization: only attempt merge from start to end sequence, no need to scan till the end of the list -func mergeSequences(seq *sequence) { - if seq != nil { - // Merge all what possible from seq - for seq.next != nil && seq.block == seq.next.block { - seq.count += seq.next.count - seq.next = seq.next.next - } - // Move to next - mergeSequences(seq.next) - } -} - -func getNumBlocks(numBits uint64) uint64 { - numBlocks := numBits / uint64(blockLen) - if numBits%uint64(blockLen) != 0 { - numBlocks++ - } - return numBlocks -} - -func ordinalToPos(ordinal uint64) (uint64, uint64) { - return ordinal / 8, ordinal % 8 -} - -func posToOrdinal(bytePos, bitPos uint64) uint64 { - return bytePos*8 + bitPos -} diff --git a/vendor/github.com/docker/docker/libnetwork/discoverapi/discoverapi.go b/vendor/github.com/docker/docker/libnetwork/discoverapi/discoverapi.go deleted file mode 100644 index 8ee2f3edcb..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/discoverapi/discoverapi.go +++ /dev/null @@ -1,58 +0,0 @@ -package discoverapi - -// Discover is an interface to be implemented by the component interested in receiving discover events -// like new node joining the cluster or datastore updates -type Discover interface { - // DiscoverNew is a notification for a new discovery event, Example:a new node joining a cluster - DiscoverNew(dType DiscoveryType, data interface{}) error - - // DiscoverDelete is a notification for a discovery delete event, Example:a node leaving a cluster - DiscoverDelete(dType DiscoveryType, data interface{}) error -} - -// DiscoveryType represents the type of discovery element the DiscoverNew function is invoked on -type DiscoveryType int - -const ( - // NodeDiscovery represents Node join/leave events provided by discovery - NodeDiscovery = iota + 1 - // EncryptionKeysConfig represents the initial key(s) for performing datapath encryption - EncryptionKeysConfig - // EncryptionKeysUpdate represents an update to the datapath encryption key(s) - EncryptionKeysUpdate -) - -// NodeDiscoveryData represents the structure backing the node discovery data json string -type NodeDiscoveryData struct { - Address string - BindAddress string - Self bool -} - -// DatastoreConfigData is the data for the datastore update event message -type DatastoreConfigData struct { - Scope string - Provider string - Address string - Config interface{} -} - -// DriverEncryptionConfig contains the initial datapath encryption key(s) -// Key in first position is the primary key, the one to be used in tx. -// Original key and tag types are []byte and uint64 -type DriverEncryptionConfig struct { - Keys [][]byte - Tags []uint64 -} - -// DriverEncryptionUpdate carries an update to the encryption key(s) as: -// a new key and/or set a primary key and/or a removal of an existing key. -// Original key and tag types are []byte and uint64 -type DriverEncryptionUpdate struct { - Key []byte - Tag uint64 - Primary []byte - PrimaryTag uint64 - Prune []byte - PruneTag uint64 -} diff --git a/vendor/github.com/docker/docker/libnetwork/driverapi/driverapi.go b/vendor/github.com/docker/docker/libnetwork/driverapi/driverapi.go deleted file mode 100644 index 9a79e558f2..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/driverapi/driverapi.go +++ /dev/null @@ -1,208 +0,0 @@ -package driverapi - -import "net" - -// NetworkPluginEndpointType represents the Endpoint Type used by Plugin system -const NetworkPluginEndpointType = "NetworkDriver" - -// Driver is an interface that every plugin driver needs to implement. -type Driver interface { - // NetworkAllocate invokes the driver method to allocate network - // specific resources passing network id and network specific config. - // It returns a key,value pair of network specific driver allocations - // to the caller. - NetworkAllocate(nid string, options map[string]string, ipV4Data, ipV6Data []IPAMData) (map[string]string, error) - - // NetworkFree invokes the driver method to free network specific resources - // associated with a given network id. - NetworkFree(nid string) error - - // CreateNetwork invokes the driver method to create a network - // passing the network id and network specific config. The - // config mechanism will eventually be replaced with labels - // which are yet to be introduced. The driver can return a - // list of table names for which it is interested in receiving - // notification when a CRUD operation is performed on any - // entry in that table. This will be ignored for local scope - // drivers. - CreateNetwork(nid string, options map[string]interface{}, nInfo NetworkInfo, ipV4Data, ipV6Data []IPAMData) error - - // DeleteNetwork invokes the driver method to delete network passing - // the network id. - DeleteNetwork(nid string) error - - // CreateEndpoint invokes the driver method to create an endpoint - // passing the network id, endpoint id endpoint information and driver - // specific config. The endpoint information can be either consumed by - // the driver or populated by the driver. The config mechanism will - // eventually be replaced with labels which are yet to be introduced. - CreateEndpoint(nid, eid string, ifInfo InterfaceInfo, options map[string]interface{}) error - - // DeleteEndpoint invokes the driver method to delete an endpoint - // passing the network id and endpoint id. - DeleteEndpoint(nid, eid string) error - - // EndpointOperInfo retrieves from the driver the operational data related to the specified endpoint - EndpointOperInfo(nid, eid string) (map[string]interface{}, error) - - // Join method is invoked when a Sandbox is attached to an endpoint. - Join(nid, eid string, sboxKey string, jinfo JoinInfo, options map[string]interface{}) error - - // Leave method is invoked when a Sandbox detaches from an endpoint. - Leave(nid, eid string) error - - // ProgramExternalConnectivity invokes the driver method which does the necessary - // programming to allow the external connectivity dictated by the passed options - ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error - - // RevokeExternalConnectivity asks the driver to remove any external connectivity - // programming that was done so far - RevokeExternalConnectivity(nid, eid string) error - - // EventNotify notifies the driver when a CRUD operation has - // happened on a table of its interest as soon as this node - // receives such an event in the gossip layer. This method is - // only invoked for the global scope driver. - EventNotify(event EventType, nid string, tableName string, key string, value []byte) - - // DecodeTableEntry passes the driver a key, value pair from table it registered - // with libnetwork. Driver should return {object ID, map[string]string} tuple. - // If DecodeTableEntry is called for a table associated with NetworkObject or - // EndpointObject the return object ID should be the network id or endpoint id - // associated with that entry. map should have information about the object that - // can be presented to the user. - // For example: overlay driver returns the VTEP IP of the host that has the endpoint - // which is shown in 'network inspect --verbose' - DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) - - // Type returns the type of this driver, the network type this driver manages - Type() string - - // IsBuiltIn returns true if it is a built-in driver - IsBuiltIn() bool -} - -// NetworkInfo provides a go interface for drivers to provide network -// specific information to libnetwork. -type NetworkInfo interface { - // TableEventRegister registers driver interest in a given - // table name. - TableEventRegister(tableName string, objType ObjectType) error - - // UpdateIPamConfig updates the networks IPAM configuration - // based on information from the driver. In windows, the OS (HNS) chooses - // the IP address space if the user does not specify an address space. - UpdateIpamConfig(ipV4Data []IPAMData) -} - -// InterfaceInfo provides a go interface for drivers to retrieve -// network information to interface resources. -type InterfaceInfo interface { - // SetMacAddress allows the driver to set the mac address to the endpoint interface - // during the call to CreateEndpoint, if the mac address is not already set. - SetMacAddress(mac net.HardwareAddr) error - - // SetIPAddress allows the driver to set the ip address to the endpoint interface - // during the call to CreateEndpoint, if the address is not already set. - // The API is to be used to assign both the IPv4 and IPv6 address types. - SetIPAddress(ip *net.IPNet) error - - // MacAddress returns the MAC address. - MacAddress() net.HardwareAddr - - // Address returns the IPv4 address. - Address() *net.IPNet - - // AddressIPv6 returns the IPv6 address. - AddressIPv6() *net.IPNet -} - -// InterfaceNameInfo provides a go interface for the drivers to assign names -// to interfaces. -type InterfaceNameInfo interface { - // SetNames method assigns the srcName and dstPrefix for the interface. - SetNames(srcName, dstPrefix string) error -} - -// JoinInfo represents a set of resources that the driver has the ability to provide during -// join time. -type JoinInfo interface { - // InterfaceName returns an InterfaceNameInfo go interface to facilitate - // setting the names for the interface. - InterfaceName() InterfaceNameInfo - - // SetGateway sets the default IPv4 gateway when a container joins the endpoint. - SetGateway(net.IP) error - - // SetGatewayIPv6 sets the default IPv6 gateway when a container joins the endpoint. - SetGatewayIPv6(net.IP) error - - // AddStaticRoute adds a route to the sandbox. - // It may be used in addition to or instead of a default gateway (as above). - AddStaticRoute(destination *net.IPNet, routeType int, nextHop net.IP) error - - // DisableGatewayService tells libnetwork not to provide Default GW for the container - DisableGatewayService() - - // AddTableEntry adds a table entry to the gossip layer - // passing the table name, key and an opaque value. - AddTableEntry(tableName string, key string, value []byte) error -} - -// Registerer provides a way for network drivers to be dynamically registered. -type Registerer interface { - RegisterDriver(name string, driver Driver, capability Capability) error -} - -// Capability represents the high level capabilities of the drivers which libnetwork can make use of -type Capability struct { - DataScope string - ConnectivityScope string -} - -// IPAMData represents the per-network ip related -// operational information libnetwork will send -// to the network driver during CreateNetwork() -type IPAMData struct { - AddressSpace string - Pool *net.IPNet - Gateway *net.IPNet - AuxAddresses map[string]*net.IPNet -} - -// EventType defines a type for the CRUD event -type EventType uint8 - -const ( - // Create event is generated when a table entry is created, - Create EventType = 1 + iota - // Update event is generated when a table entry is updated. - Update - // Delete event is generated when a table entry is deleted. - Delete -) - -// ObjectType represents the type of object driver wants to store in libnetwork's networkDB -type ObjectType int - -const ( - // EndpointObject should be set for libnetwork endpoint object related data - EndpointObject ObjectType = 1 + iota - // NetworkObject should be set for libnetwork network object related data - NetworkObject - // OpaqueObject is for driver specific data with no corresponding libnetwork object - OpaqueObject -) - -// IsValidType validates the passed in type against the valid object types -func IsValidType(objType ObjectType) bool { - switch objType { - case EndpointObject: - fallthrough - case NetworkObject: - fallthrough - case OpaqueObject: - return true - } - return false -} diff --git a/vendor/github.com/docker/docker/libnetwork/driverapi/errors.go b/vendor/github.com/docker/docker/libnetwork/driverapi/errors.go deleted file mode 100644 index 041ef41506..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/driverapi/errors.go +++ /dev/null @@ -1,56 +0,0 @@ -package driverapi - -import ( - "fmt" -) - -// ErrNoNetwork is returned if no network with the specified id exists -type ErrNoNetwork string - -func (enn ErrNoNetwork) Error() string { - return fmt.Sprintf("No network (%s) exists", string(enn)) -} - -// NotFound denotes the type of this error -func (enn ErrNoNetwork) NotFound() {} - -// ErrEndpointExists is returned if more than one endpoint is added to the network -type ErrEndpointExists string - -func (ee ErrEndpointExists) Error() string { - return fmt.Sprintf("Endpoint (%s) already exists (Only one endpoint allowed)", string(ee)) -} - -// Forbidden denotes the type of this error -func (ee ErrEndpointExists) Forbidden() {} - -// ErrNotImplemented is returned when a Driver has not implemented an API yet -type ErrNotImplemented struct{} - -func (eni *ErrNotImplemented) Error() string { - return "The API is not implemented yet" -} - -// NotImplemented denotes the type of this error -func (eni *ErrNotImplemented) NotImplemented() {} - -// ErrNoEndpoint is returned if no endpoint with the specified id exists -type ErrNoEndpoint string - -func (ene ErrNoEndpoint) Error() string { - return fmt.Sprintf("No endpoint (%s) exists", string(ene)) -} - -// NotFound denotes the type of this error -func (ene ErrNoEndpoint) NotFound() {} - -// ErrActiveRegistration represents an error when a driver is registered to a networkType that is previously registered -type ErrActiveRegistration string - -// Error interface for ErrActiveRegistration -func (ar ErrActiveRegistration) Error() string { - return fmt.Sprintf("Driver already registered for type %q", string(ar)) -} - -// Forbidden denotes the type of this error -func (ar ErrActiveRegistration) Forbidden() {} diff --git a/vendor/github.com/docker/docker/libnetwork/driverapi/ipamdata.go b/vendor/github.com/docker/docker/libnetwork/driverapi/ipamdata.go deleted file mode 100644 index c7ce4e309a..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/driverapi/ipamdata.go +++ /dev/null @@ -1,103 +0,0 @@ -package driverapi - -import ( - "encoding/json" - "fmt" - "net" - - "github.com/docker/docker/libnetwork/types" -) - -// MarshalJSON encodes IPAMData into json message -func (i *IPAMData) MarshalJSON() ([]byte, error) { - m := map[string]interface{}{} - m["AddressSpace"] = i.AddressSpace - if i.Pool != nil { - m["Pool"] = i.Pool.String() - } - if i.Gateway != nil { - m["Gateway"] = i.Gateway.String() - } - if i.AuxAddresses != nil { - am := make(map[string]string, len(i.AuxAddresses)) - for k, v := range i.AuxAddresses { - am[k] = v.String() - } - m["AuxAddresses"] = am - } - return json.Marshal(m) -} - -// UnmarshalJSON decodes a json message into IPAMData -func (i *IPAMData) UnmarshalJSON(data []byte) error { - var ( - m map[string]interface{} - err error - ) - if err := json.Unmarshal(data, &m); err != nil { - return err - } - i.AddressSpace = m["AddressSpace"].(string) - if v, ok := m["Pool"]; ok { - if i.Pool, err = types.ParseCIDR(v.(string)); err != nil { - return err - } - } - if v, ok := m["Gateway"]; ok { - if i.Gateway, err = types.ParseCIDR(v.(string)); err != nil { - return err - } - } - if v, ok := m["AuxAddresses"]; ok { - b, _ := json.Marshal(v) - var am map[string]string - if err = json.Unmarshal(b, &am); err != nil { - return err - } - i.AuxAddresses = make(map[string]*net.IPNet, len(am)) - for k, v := range am { - if i.AuxAddresses[k], err = types.ParseCIDR(v); err != nil { - return err - } - } - } - return nil -} - -// Validate checks whether the IPAMData structure contains congruent data -func (i *IPAMData) Validate() error { - var isV6 bool - if i.Pool == nil { - return types.InvalidParameterErrorf("invalid pool") - } - if i.Gateway == nil { - return types.InvalidParameterErrorf("invalid gateway address") - } - isV6 = i.IsV6() - if isV6 && i.Gateway.IP.To4() != nil || !isV6 && i.Gateway.IP.To4() == nil { - return types.InvalidParameterErrorf("incongruent ip versions for pool and gateway") - } - for k, sip := range i.AuxAddresses { - if isV6 && sip.IP.To4() != nil || !isV6 && sip.IP.To4() == nil { - return types.InvalidParameterErrorf("incongruent ip versions for pool and secondary ip address %s", k) - } - } - if !i.Pool.Contains(i.Gateway.IP) { - return types.InvalidParameterErrorf("invalid gateway address (%s) does not belong to the pool (%s)", i.Gateway, i.Pool) - } - for k, sip := range i.AuxAddresses { - if !i.Pool.Contains(sip.IP) { - return types.InvalidParameterErrorf("invalid secondary address %s (%s) does not belong to the pool (%s)", k, i.Gateway, i.Pool) - } - } - return nil -} - -// IsV6 returns whether this is an IPv6 IPAMData structure -func (i *IPAMData) IsV6() bool { - return nil == i.Pool.IP.To4() -} - -func (i *IPAMData) String() string { - return fmt.Sprintf("AddressSpace: %s\nPool: %v\nGateway: %v\nAddresses: %v", i.AddressSpace, i.Pool, i.Gateway, i.AuxAddresses) -} diff --git a/vendor/github.com/docker/docker/libnetwork/drivers/bridge/brmanager/brmanager.go b/vendor/github.com/docker/docker/libnetwork/drivers/bridge/brmanager/brmanager.go deleted file mode 100644 index 75f4520427..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/drivers/bridge/brmanager/brmanager.go +++ /dev/null @@ -1,78 +0,0 @@ -package brmanager - -import ( - "github.com/docker/docker/libnetwork/driverapi" - "github.com/docker/docker/libnetwork/scope" - "github.com/docker/docker/libnetwork/types" -) - -const networkType = "bridge" - -type driver struct{} - -// Register registers a new instance of the bridge manager driver with r. -func Register(r driverapi.Registerer) error { - return r.RegisterDriver(networkType, &driver{}, driverapi.Capability{ - DataScope: scope.Local, - ConnectivityScope: scope.Local, - }) -} - -func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) { - return nil, types.NotImplementedErrorf("not implemented") -} - -func (d *driver) NetworkFree(id string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) { -} - -func (d *driver) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) { - return "", nil -} - -func (d *driver) DeleteNetwork(nid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) DeleteEndpoint(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) { - return nil, types.NotImplementedErrorf("not implemented") -} - -func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) Leave(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) Type() string { - return networkType -} - -func (d *driver) IsBuiltIn() bool { - return true -} - -func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) RevokeExternalConnectivity(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} diff --git a/vendor/github.com/docker/docker/libnetwork/drivers/host/host.go b/vendor/github.com/docker/docker/libnetwork/drivers/host/host.go deleted file mode 100644 index bdb38af8d8..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/drivers/host/host.go +++ /dev/null @@ -1,93 +0,0 @@ -package host - -import ( - "sync" - - "github.com/docker/docker/libnetwork/driverapi" - "github.com/docker/docker/libnetwork/scope" - "github.com/docker/docker/libnetwork/types" -) - -const NetworkType = "host" - -type driver struct { - network string - sync.Mutex -} - -func Register(r driverapi.Registerer) error { - return r.RegisterDriver(NetworkType, &driver{}, driverapi.Capability{ - DataScope: scope.Local, - ConnectivityScope: scope.Local, - }) -} - -func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) { - return nil, types.NotImplementedErrorf("not implemented") -} - -func (d *driver) NetworkFree(id string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) { -} - -func (d *driver) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) { - return "", nil -} - -func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error { - d.Lock() - defer d.Unlock() - - if d.network != "" { - return types.ForbiddenErrorf("only one instance of %q network is allowed", NetworkType) - } - - d.network = id - - return nil -} - -func (d *driver) DeleteNetwork(nid string) error { - return types.ForbiddenErrorf("network of type %q cannot be deleted", NetworkType) -} - -func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error { - return nil -} - -func (d *driver) DeleteEndpoint(nid, eid string) error { - return nil -} - -func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) { - return make(map[string]interface{}), nil -} - -// Join method is invoked when a Sandbox is attached to an endpoint. -func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error { - return nil -} - -// Leave method is invoked when a Sandbox detaches from an endpoint. -func (d *driver) Leave(nid, eid string) error { - return nil -} - -func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error { - return nil -} - -func (d *driver) RevokeExternalConnectivity(nid, eid string) error { - return nil -} - -func (d *driver) Type() string { - return NetworkType -} - -func (d *driver) IsBuiltIn() bool { - return true -} diff --git a/vendor/github.com/docker/docker/libnetwork/drivers/ipvlan/ivmanager/ivmanager.go b/vendor/github.com/docker/docker/libnetwork/drivers/ipvlan/ivmanager/ivmanager.go deleted file mode 100644 index 979e60127e..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/drivers/ipvlan/ivmanager/ivmanager.go +++ /dev/null @@ -1,78 +0,0 @@ -package ivmanager - -import ( - "github.com/docker/docker/libnetwork/driverapi" - "github.com/docker/docker/libnetwork/scope" - "github.com/docker/docker/libnetwork/types" -) - -const networkType = "ipvlan" - -type driver struct{} - -// Register registers a new instance of the ipvlan manager driver. -func Register(r driverapi.Registerer) error { - return r.RegisterDriver(networkType, &driver{}, driverapi.Capability{ - DataScope: scope.Local, - ConnectivityScope: scope.Global, - }) -} - -func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) { - return nil, types.NotImplementedErrorf("not implemented") -} - -func (d *driver) NetworkFree(id string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) { -} - -func (d *driver) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) { - return "", nil -} - -func (d *driver) DeleteNetwork(nid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) DeleteEndpoint(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) { - return nil, types.NotImplementedErrorf("not implemented") -} - -func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) Leave(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) Type() string { - return networkType -} - -func (d *driver) IsBuiltIn() bool { - return true -} - -func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) RevokeExternalConnectivity(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} diff --git a/vendor/github.com/docker/docker/libnetwork/drivers/macvlan/mvmanager/mvmanager.go b/vendor/github.com/docker/docker/libnetwork/drivers/macvlan/mvmanager/mvmanager.go deleted file mode 100644 index 283693ce8f..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/drivers/macvlan/mvmanager/mvmanager.go +++ /dev/null @@ -1,78 +0,0 @@ -package mvmanager - -import ( - "github.com/docker/docker/libnetwork/driverapi" - "github.com/docker/docker/libnetwork/scope" - "github.com/docker/docker/libnetwork/types" -) - -const networkType = "macvlan" - -type driver struct{} - -// Register registers a new instance of the macvlan manager driver. -func Register(r driverapi.Registerer) error { - return r.RegisterDriver(networkType, &driver{}, driverapi.Capability{ - DataScope: scope.Local, - ConnectivityScope: scope.Global, - }) -} - -func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) { - return nil, types.NotImplementedErrorf("not implemented") -} - -func (d *driver) NetworkFree(id string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) { -} - -func (d *driver) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) { - return "", nil -} - -func (d *driver) DeleteNetwork(nid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) DeleteEndpoint(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) { - return nil, types.NotImplementedErrorf("not implemented") -} - -func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) Leave(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) Type() string { - return networkType -} - -func (d *driver) IsBuiltIn() bool { - return true -} - -func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) RevokeExternalConnectivity(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} diff --git a/vendor/github.com/docker/docker/libnetwork/drivers/overlay/overlayutils/utils.go b/vendor/github.com/docker/docker/libnetwork/drivers/overlay/overlayutils/utils.go deleted file mode 100644 index 2ce3c237dc..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/drivers/overlay/overlayutils/utils.go +++ /dev/null @@ -1,64 +0,0 @@ -// Package overlayutils provides utility functions for overlay networks -package overlayutils - -import ( - "fmt" - "strconv" - "strings" - "sync" -) - -var ( - mutex sync.RWMutex - vxlanUDPPort = defaultVXLANUDPPort -) - -const defaultVXLANUDPPort uint32 = 4789 - -// ConfigVXLANUDPPort configures the VXLAN UDP port (data path port) number. -// If no port is set, the default (4789) is returned. Valid port numbers are -// between 1024 and 49151. -func ConfigVXLANUDPPort(vxlanPort uint32) error { - if vxlanPort == 0 { - vxlanPort = defaultVXLANUDPPort - } - // IANA procedures for each range in detail - // The Well Known Ports, aka the System Ports, from 0-1023 - // The Registered Ports, aka the User Ports, from 1024-49151 - // The Dynamic Ports, aka the Private Ports, from 49152-65535 - // So we can allow range between 1024 to 49151 - if vxlanPort < 1024 || vxlanPort > 49151 { - return fmt.Errorf("VXLAN UDP port number is not in valid range (1024-49151): %d", vxlanPort) - } - mutex.Lock() - vxlanUDPPort = vxlanPort - mutex.Unlock() - return nil -} - -// VXLANUDPPort returns Vxlan UDP port number -func VXLANUDPPort() uint32 { - mutex.RLock() - defer mutex.RUnlock() - return vxlanUDPPort -} - -// AppendVNIList appends the VNI values encoded as a CSV string to slice. -func AppendVNIList(vnis []uint32, csv string) ([]uint32, error) { - for { - var ( - vniStr string - found bool - ) - vniStr, csv, found = strings.Cut(csv, ",") - vni, err := strconv.Atoi(vniStr) - if err != nil { - return vnis, fmt.Errorf("invalid vxlan id value %q passed", vniStr) - } - - vnis = append(vnis, uint32(vni)) - if !found { - return vnis, nil - } - } -} diff --git a/vendor/github.com/docker/docker/libnetwork/drivers/overlay/ovmanager/ovmanager.go b/vendor/github.com/docker/docker/libnetwork/drivers/overlay/ovmanager/ovmanager.go deleted file mode 100644 index ab6193f449..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/drivers/overlay/ovmanager/ovmanager.go +++ /dev/null @@ -1,216 +0,0 @@ -package ovmanager - -import ( - "context" - "fmt" - "net" - "strconv" - "sync" - - "github.com/containerd/containerd/log" - "github.com/docker/docker/libnetwork/bitmap" - "github.com/docker/docker/libnetwork/driverapi" - "github.com/docker/docker/libnetwork/drivers/overlay/overlayutils" - "github.com/docker/docker/libnetwork/netlabel" - "github.com/docker/docker/libnetwork/scope" - "github.com/docker/docker/libnetwork/types" -) - -const ( - networkType = "overlay" - // The lowest VNI value to auto-assign. Windows does not support VXLAN IDs - // which overlap the range of 802.1Q VLAN IDs [0, 4095]. - vxlanIDStart = 4096 - // The largest VNI value permitted by RFC 7348. - vxlanIDEnd = (1 << 24) - 1 -) - -type networkTable map[string]*network - -type driver struct { - mu sync.Mutex - networks networkTable - vxlanIdm *bitmap.Bitmap -} - -type subnet struct { - subnetIP *net.IPNet - gwIP *net.IPNet - vni uint32 -} - -type network struct { - id string - driver *driver - subnets []*subnet -} - -// Register registers a new instance of the overlay driver. -func Register(r driverapi.Registerer) error { - return r.RegisterDriver(networkType, newDriver(), driverapi.Capability{ - DataScope: scope.Global, - ConnectivityScope: scope.Global, - }) -} - -func newDriver() *driver { - return &driver{ - networks: networkTable{}, - vxlanIdm: bitmap.New(vxlanIDEnd + 1), // The full range of valid vxlan IDs: [0, 2^24). - } -} - -func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) { - if id == "" { - return nil, fmt.Errorf("invalid network id for overlay network") - } - - if ipV4Data == nil { - return nil, fmt.Errorf("empty ipv4 data passed during overlay network creation") - } - - n := &network{ - id: id, - driver: d, - subnets: []*subnet{}, - } - - opts := make(map[string]string) - vxlanIDList := make([]uint32, 0, len(ipV4Data)) - for key, val := range option { - if key == netlabel.OverlayVxlanIDList { - log.G(context.TODO()).Debugf("overlay network option: %s", val) - var err error - vxlanIDList, err = overlayutils.AppendVNIList(vxlanIDList, val) - if err != nil { - return nil, err - } - } else { - opts[key] = val - } - } - - d.mu.Lock() - defer d.mu.Unlock() - for i, ipd := range ipV4Data { - s := &subnet{ - subnetIP: ipd.Pool, - gwIP: ipd.Gateway, - } - - if len(vxlanIDList) > i { // The VNI for this subnet was specified in the network options. - s.vni = vxlanIDList[i] - err := d.vxlanIdm.Set(uint64(s.vni)) // Mark VNI as in-use. - if err != nil { - // The VNI is already in use by another subnet/network. - n.releaseVxlanID() - return nil, fmt.Errorf("could not assign vxlan id %v to pool %s: %v", s.vni, s.subnetIP, err) - } - } else { - // Allocate an available VNI for the subnet, outside the range of 802.1Q VLAN IDs. - vni, err := d.vxlanIdm.SetAnyInRange(vxlanIDStart, vxlanIDEnd, true) - if err != nil { - n.releaseVxlanID() - return nil, fmt.Errorf("could not obtain vxlan id for pool %s: %v", s.subnetIP, err) - } - s.vni = uint32(vni) - } - - n.subnets = append(n.subnets, s) - } - - val := strconv.FormatUint(uint64(n.subnets[0].vni), 10) - for _, s := range n.subnets[1:] { - val = val + "," + strconv.FormatUint(uint64(s.vni), 10) - } - opts[netlabel.OverlayVxlanIDList] = val - - if _, ok := d.networks[id]; ok { - n.releaseVxlanID() - return nil, fmt.Errorf("network %s already exists", id) - } - d.networks[id] = n - - return opts, nil -} - -func (d *driver) NetworkFree(id string) error { - if id == "" { - return fmt.Errorf("invalid network id passed while freeing overlay network") - } - - d.mu.Lock() - defer d.mu.Unlock() - n, ok := d.networks[id] - - if !ok { - return fmt.Errorf("overlay network with id %s not found", id) - } - - // Release all vxlan IDs in one shot. - n.releaseVxlanID() - - delete(d.networks, id) - - return nil -} - -func (n *network) releaseVxlanID() { - for _, s := range n.subnets { - n.driver.vxlanIdm.Unset(uint64(s.vni)) - s.vni = 0 - } -} - -func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) { -} - -func (d *driver) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) { - return "", nil -} - -func (d *driver) DeleteNetwork(nid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) DeleteEndpoint(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) { - return nil, types.NotImplementedErrorf("not implemented") -} - -// Join method is invoked when a Sandbox is attached to an endpoint. -func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -// Leave method is invoked when a Sandbox detaches from an endpoint. -func (d *driver) Leave(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) Type() string { - return networkType -} - -func (d *driver) IsBuiltIn() bool { - return true -} - -func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error { - return types.NotImplementedErrorf("not implemented") -} - -func (d *driver) RevokeExternalConnectivity(nid, eid string) error { - return types.NotImplementedErrorf("not implemented") -} diff --git a/vendor/github.com/docker/docker/libnetwork/drivers/remote/api/api.go b/vendor/github.com/docker/docker/libnetwork/drivers/remote/api/api.go deleted file mode 100644 index d6d1757be0..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/drivers/remote/api/api.go +++ /dev/null @@ -1,221 +0,0 @@ -/* -Package api represents all requests and responses suitable for conversation -with a remote driver. -*/ -package api - -import ( - "net" - - "github.com/docker/docker/libnetwork/discoverapi" - "github.com/docker/docker/libnetwork/driverapi" -) - -// Response is the basic response structure used in all responses. -type Response struct { - Err string -} - -// GetError returns the error from the response, if any. -func (r *Response) GetError() string { - return r.Err -} - -// GetCapabilityResponse is the response of GetCapability request -type GetCapabilityResponse struct { - Response - Scope string - ConnectivityScope string -} - -// AllocateNetworkRequest requests allocation of new network by manager -type AllocateNetworkRequest struct { - // A network ID that remote plugins are expected to store for future - // reference. - NetworkID string - - // A free form map->object interface for communication of options. - Options map[string]string - - // IPAMData contains the address pool information for this network - IPv4Data, IPv6Data []driverapi.IPAMData -} - -// AllocateNetworkResponse is the response to the AllocateNetworkRequest. -type AllocateNetworkResponse struct { - Response - // A free form plugin specific string->string object to be sent in - // CreateNetworkRequest call in the libnetwork agents - Options map[string]string -} - -// FreeNetworkRequest is the request to free allocated network in the manager -type FreeNetworkRequest struct { - // The ID of the network to be freed. - NetworkID string -} - -// FreeNetworkResponse is the response to a request for freeing a network. -type FreeNetworkResponse struct { - Response -} - -// CreateNetworkRequest requests a new network. -type CreateNetworkRequest struct { - // A network ID that remote plugins are expected to store for future - // reference. - NetworkID string - - // A free form map->object interface for communication of options. - Options map[string]interface{} - - // IPAMData contains the address pool information for this network - IPv4Data, IPv6Data []driverapi.IPAMData -} - -// CreateNetworkResponse is the response to the CreateNetworkRequest. -type CreateNetworkResponse struct { - Response -} - -// DeleteNetworkRequest is the request to delete an existing network. -type DeleteNetworkRequest struct { - // The ID of the network to delete. - NetworkID string -} - -// DeleteNetworkResponse is the response to a request for deleting a network. -type DeleteNetworkResponse struct { - Response -} - -// CreateEndpointRequest is the request to create an endpoint within a network. -type CreateEndpointRequest struct { - // Provided at create time, this will be the network id referenced. - NetworkID string - // The ID of the endpoint for later reference. - EndpointID string - Interface *EndpointInterface - Options map[string]interface{} -} - -// EndpointInterface represents an interface endpoint. -type EndpointInterface struct { - Address string - AddressIPv6 string - MacAddress string -} - -// CreateEndpointResponse is the response to the CreateEndpoint action. -type CreateEndpointResponse struct { - Response - Interface *EndpointInterface -} - -// Interface is the representation of a linux interface. -type Interface struct { - Address *net.IPNet - AddressIPv6 *net.IPNet - MacAddress net.HardwareAddr -} - -// DeleteEndpointRequest describes the API for deleting an endpoint. -type DeleteEndpointRequest struct { - NetworkID string - EndpointID string -} - -// DeleteEndpointResponse is the response to the DeleteEndpoint action. -type DeleteEndpointResponse struct { - Response -} - -// EndpointInfoRequest retrieves information about the endpoint from the network driver. -type EndpointInfoRequest struct { - NetworkID string - EndpointID string -} - -// EndpointInfoResponse is the response to an EndpointInfoRequest. -type EndpointInfoResponse struct { - Response - Value map[string]interface{} -} - -// JoinRequest describes the API for joining an endpoint to a sandbox. -type JoinRequest struct { - NetworkID string - EndpointID string - SandboxKey string - Options map[string]interface{} -} - -// InterfaceName is the struct representation of a pair of devices with source -// and destination, for the purposes of putting an endpoint into a container. -type InterfaceName struct { - SrcName string - DstName string - DstPrefix string -} - -// StaticRoute is the plain JSON representation of a static route. -type StaticRoute struct { - Destination string - RouteType int - NextHop string -} - -// JoinResponse is the response to a JoinRequest. -type JoinResponse struct { - Response - InterfaceName *InterfaceName - Gateway string - GatewayIPv6 string - StaticRoutes []StaticRoute - DisableGatewayService bool -} - -// LeaveRequest describes the API for detaching an endpoint from a sandbox. -type LeaveRequest struct { - NetworkID string - EndpointID string -} - -// LeaveResponse is the answer to LeaveRequest. -type LeaveResponse struct { - Response -} - -// ProgramExternalConnectivityRequest describes the API for programming the external connectivity for the given endpoint. -type ProgramExternalConnectivityRequest struct { - NetworkID string - EndpointID string - Options map[string]interface{} -} - -// ProgramExternalConnectivityResponse is the answer to ProgramExternalConnectivityRequest. -type ProgramExternalConnectivityResponse struct { - Response -} - -// RevokeExternalConnectivityRequest describes the API for revoking the external connectivity for the given endpoint. -type RevokeExternalConnectivityRequest struct { - NetworkID string - EndpointID string -} - -// RevokeExternalConnectivityResponse is the answer to RevokeExternalConnectivityRequest. -type RevokeExternalConnectivityResponse struct { - Response -} - -// DiscoveryNotification represents a discovery notification -type DiscoveryNotification struct { - DiscoveryType discoverapi.DiscoveryType - DiscoveryData interface{} -} - -// DiscoveryResponse is used by libnetwork to log any plugin error processing the discovery notifications -type DiscoveryResponse struct { - Response -} diff --git a/vendor/github.com/docker/docker/libnetwork/drivers/remote/driver.go b/vendor/github.com/docker/docker/libnetwork/drivers/remote/driver.go deleted file mode 100644 index f9932263a6..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/drivers/remote/driver.go +++ /dev/null @@ -1,435 +0,0 @@ -package remote - -import ( - "context" - "fmt" - "net" - - "github.com/containerd/containerd/log" - "github.com/docker/docker/libnetwork/discoverapi" - "github.com/docker/docker/libnetwork/driverapi" - "github.com/docker/docker/libnetwork/drivers/remote/api" - "github.com/docker/docker/libnetwork/scope" - "github.com/docker/docker/libnetwork/types" - "github.com/docker/docker/pkg/plugingetter" - "github.com/docker/docker/pkg/plugins" - "github.com/pkg/errors" -) - -// remote driver must implement the discover-API. -var _ discoverapi.Discover = (*driver)(nil) - -type driver struct { - endpoint *plugins.Client - networkType string -} - -type maybeError interface { - GetError() string -} - -func newDriver(name string, client *plugins.Client) *driver { - return &driver{networkType: name, endpoint: client} -} - -// Register makes sure a remote driver is registered with r when a network -// driver plugin is activated. -func Register(r driverapi.Registerer, pg plugingetter.PluginGetter) error { - newPluginHandler := func(name string, client *plugins.Client) { - // negotiate driver capability with client - d := newDriver(name, client) - c, err := d.getCapabilities() - if err != nil { - log.G(context.TODO()).Errorf("error getting capability for %s due to %v", name, err) - return - } - if err = r.RegisterDriver(name, d, *c); err != nil { - log.G(context.TODO()).Errorf("error registering driver for %s due to %v", name, err) - } - } - - // Unit test code is unaware of a true PluginStore. So we fall back to v1 plugins. - handleFunc := plugins.Handle - if pg != nil { - handleFunc = pg.Handle - activePlugins := pg.GetAllManagedPluginsByCap(driverapi.NetworkPluginEndpointType) - for _, ap := range activePlugins { - client, err := getPluginClient(ap) - if err != nil { - return err - } - newPluginHandler(ap.Name(), client) - } - } - handleFunc(driverapi.NetworkPluginEndpointType, newPluginHandler) - - return nil -} - -func getPluginClient(p plugingetter.CompatPlugin) (*plugins.Client, error) { - if v1, ok := p.(plugingetter.PluginWithV1Client); ok { - return v1.Client(), nil - } - - pa, ok := p.(plugingetter.PluginAddr) - if !ok { - return nil, errors.Errorf("unknown plugin type %T", p) - } - - if pa.Protocol() != plugins.ProtocolSchemeHTTPV1 { - return nil, errors.Errorf("unsupported plugin protocol %s", pa.Protocol()) - } - - addr := pa.Addr() - client, err := plugins.NewClientWithTimeout(addr.Network()+"://"+addr.String(), nil, pa.Timeout()) - if err != nil { - return nil, errors.Wrap(err, "error creating plugin client") - } - return client, nil -} - -// Get capability from client -func (d *driver) getCapabilities() (*driverapi.Capability, error) { - var capResp api.GetCapabilityResponse - if err := d.call("GetCapabilities", nil, &capResp); err != nil { - return nil, err - } - - c := &driverapi.Capability{} - switch capResp.Scope { - case scope.Global, scope.Local: - c.DataScope = capResp.Scope - default: - return nil, fmt.Errorf("invalid capability: expecting 'local' or 'global', got %s", capResp.Scope) - } - - switch capResp.ConnectivityScope { - case scope.Global, scope.Local: - c.ConnectivityScope = capResp.ConnectivityScope - case "": - c.ConnectivityScope = c.DataScope - default: - return nil, fmt.Errorf("invalid capability: expecting 'local' or 'global', got %s", capResp.Scope) - } - - return c, nil -} - -// Config is not implemented for remote drivers, since it is assumed -// to be supplied to the remote process out-of-band (e.g., as command -// line arguments). -func (d *driver) Config(option map[string]interface{}) error { - return &driverapi.ErrNotImplemented{} -} - -func (d *driver) call(methodName string, arg interface{}, retVal maybeError) error { - method := driverapi.NetworkPluginEndpointType + "." + methodName - err := d.endpoint.Call(method, arg, retVal) - if err != nil { - return err - } - if e := retVal.GetError(); e != "" { - return fmt.Errorf("remote: %s", e) - } - return nil -} - -func (d *driver) NetworkAllocate(id string, options map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) { - create := &api.AllocateNetworkRequest{ - NetworkID: id, - Options: options, - IPv4Data: ipV4Data, - IPv6Data: ipV6Data, - } - retVal := api.AllocateNetworkResponse{} - err := d.call("AllocateNetwork", create, &retVal) - return retVal.Options, err -} - -func (d *driver) NetworkFree(id string) error { - fr := &api.FreeNetworkRequest{NetworkID: id} - return d.call("FreeNetwork", fr, &api.FreeNetworkResponse{}) -} - -func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) { -} - -func (d *driver) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) { - return "", nil -} - -func (d *driver) CreateNetwork(id string, options map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error { - create := &api.CreateNetworkRequest{ - NetworkID: id, - Options: options, - IPv4Data: ipV4Data, - IPv6Data: ipV6Data, - } - return d.call("CreateNetwork", create, &api.CreateNetworkResponse{}) -} - -func (d *driver) DeleteNetwork(nid string) error { - return d.call("DeleteNetwork", &api.DeleteNetworkRequest{NetworkID: nid}, &api.DeleteNetworkResponse{}) -} - -func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error { - if ifInfo == nil { - return errors.New("must not be called with nil InterfaceInfo") - } - - reqIface := &api.EndpointInterface{} - if ifInfo.Address() != nil { - reqIface.Address = ifInfo.Address().String() - } - if ifInfo.AddressIPv6() != nil { - reqIface.AddressIPv6 = ifInfo.AddressIPv6().String() - } - if ifInfo.MacAddress() != nil { - reqIface.MacAddress = ifInfo.MacAddress().String() - } - - create := &api.CreateEndpointRequest{ - NetworkID: nid, - EndpointID: eid, - Interface: reqIface, - Options: epOptions, - } - var res api.CreateEndpointResponse - if err := d.call("CreateEndpoint", create, &res); err != nil { - return err - } - - inIface, err := parseInterface(res) - if err != nil { - return err - } - if inIface == nil { - // Remote driver did not set any field - return nil - } - - if inIface.MacAddress != nil { - if err := ifInfo.SetMacAddress(inIface.MacAddress); err != nil { - return errorWithRollback(fmt.Sprintf("driver modified interface MAC address: %v", err), d.DeleteEndpoint(nid, eid)) - } - } - if inIface.Address != nil { - if err := ifInfo.SetIPAddress(inIface.Address); err != nil { - return errorWithRollback(fmt.Sprintf("driver modified interface address: %v", err), d.DeleteEndpoint(nid, eid)) - } - } - if inIface.AddressIPv6 != nil { - if err := ifInfo.SetIPAddress(inIface.AddressIPv6); err != nil { - return errorWithRollback(fmt.Sprintf("driver modified interface address: %v", err), d.DeleteEndpoint(nid, eid)) - } - } - - return nil -} - -func errorWithRollback(msg string, err error) error { - rollback := "rolled back" - if err != nil { - rollback = "failed to roll back: " + err.Error() - } - return fmt.Errorf("%s; %s", msg, rollback) -} - -func (d *driver) DeleteEndpoint(nid, eid string) error { - deleteRequest := &api.DeleteEndpointRequest{ - NetworkID: nid, - EndpointID: eid, - } - return d.call("DeleteEndpoint", deleteRequest, &api.DeleteEndpointResponse{}) -} - -func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) { - info := &api.EndpointInfoRequest{ - NetworkID: nid, - EndpointID: eid, - } - var res api.EndpointInfoResponse - if err := d.call("EndpointOperInfo", info, &res); err != nil { - return nil, err - } - return res.Value, nil -} - -// Join method is invoked when a Sandbox is attached to an endpoint. -func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error { - join := &api.JoinRequest{ - NetworkID: nid, - EndpointID: eid, - SandboxKey: sboxKey, - Options: options, - } - var ( - res api.JoinResponse - err error - ) - if err = d.call("Join", join, &res); err != nil { - return err - } - - ifaceName := res.InterfaceName - if iface := jinfo.InterfaceName(); iface != nil && ifaceName != nil { - if err := iface.SetNames(ifaceName.SrcName, ifaceName.DstPrefix); err != nil { - return errorWithRollback(fmt.Sprintf("failed to set interface name: %s", err), d.Leave(nid, eid)) - } - } - - var addr net.IP - if res.Gateway != "" { - if addr = net.ParseIP(res.Gateway); addr == nil { - return fmt.Errorf(`unable to parse Gateway "%s"`, res.Gateway) - } - if jinfo.SetGateway(addr) != nil { - return errorWithRollback(fmt.Sprintf("failed to set gateway: %v", addr), d.Leave(nid, eid)) - } - } - if res.GatewayIPv6 != "" { - if addr = net.ParseIP(res.GatewayIPv6); addr == nil { - return fmt.Errorf(`unable to parse GatewayIPv6 "%s"`, res.GatewayIPv6) - } - if jinfo.SetGatewayIPv6(addr) != nil { - return errorWithRollback(fmt.Sprintf("failed to set gateway IPv6: %v", addr), d.Leave(nid, eid)) - } - } - if len(res.StaticRoutes) > 0 { - routes, err := parseStaticRoutes(res) - if err != nil { - return err - } - for _, route := range routes { - if jinfo.AddStaticRoute(route.Destination, route.RouteType, route.NextHop) != nil { - return errorWithRollback(fmt.Sprintf("failed to set static route: %v", route), d.Leave(nid, eid)) - } - } - } - if res.DisableGatewayService { - jinfo.DisableGatewayService() - } - return nil -} - -// Leave method is invoked when a Sandbox detaches from an endpoint. -func (d *driver) Leave(nid, eid string) error { - leave := &api.LeaveRequest{ - NetworkID: nid, - EndpointID: eid, - } - return d.call("Leave", leave, &api.LeaveResponse{}) -} - -// ProgramExternalConnectivity is invoked to program the rules to allow external connectivity for the endpoint. -func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error { - data := &api.ProgramExternalConnectivityRequest{ - NetworkID: nid, - EndpointID: eid, - Options: options, - } - err := d.call("ProgramExternalConnectivity", data, &api.ProgramExternalConnectivityResponse{}) - if err != nil && plugins.IsNotFound(err) { - // It is not mandatory yet to support this method - return nil - } - return err -} - -// RevokeExternalConnectivity method is invoked to remove any external connectivity programming related to the endpoint. -func (d *driver) RevokeExternalConnectivity(nid, eid string) error { - data := &api.RevokeExternalConnectivityRequest{ - NetworkID: nid, - EndpointID: eid, - } - err := d.call("RevokeExternalConnectivity", data, &api.RevokeExternalConnectivityResponse{}) - if err != nil && plugins.IsNotFound(err) { - // It is not mandatory yet to support this method - return nil - } - return err -} - -func (d *driver) Type() string { - return d.networkType -} - -func (d *driver) IsBuiltIn() bool { - return false -} - -// DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster -func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error { - if dType != discoverapi.NodeDiscovery { - return nil - } - notif := &api.DiscoveryNotification{ - DiscoveryType: dType, - DiscoveryData: data, - } - return d.call("DiscoverNew", notif, &api.DiscoveryResponse{}) -} - -// DiscoverDelete is a notification for a discovery delete event, such as a node leaving a cluster -func (d *driver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error { - if dType != discoverapi.NodeDiscovery { - return nil - } - notif := &api.DiscoveryNotification{ - DiscoveryType: dType, - DiscoveryData: data, - } - return d.call("DiscoverDelete", notif, &api.DiscoveryResponse{}) -} - -func parseStaticRoutes(r api.JoinResponse) ([]*types.StaticRoute, error) { - routes := make([]*types.StaticRoute, len(r.StaticRoutes)) - for i, inRoute := range r.StaticRoutes { - var err error - outRoute := &types.StaticRoute{RouteType: inRoute.RouteType} - - if inRoute.Destination != "" { - if outRoute.Destination, err = types.ParseCIDR(inRoute.Destination); err != nil { - return nil, err - } - } - - if inRoute.NextHop != "" { - outRoute.NextHop = net.ParseIP(inRoute.NextHop) - if outRoute.NextHop == nil { - return nil, fmt.Errorf("failed to parse nexthop IP %s", inRoute.NextHop) - } - } - - routes[i] = outRoute - } - return routes, nil -} - -// parseInterfaces validates all the parameters of an Interface and returns them. -func parseInterface(r api.CreateEndpointResponse) (*api.Interface, error) { - var outIf *api.Interface - - inIf := r.Interface - if inIf != nil { - var err error - outIf = &api.Interface{} - if inIf.Address != "" { - if outIf.Address, err = types.ParseCIDR(inIf.Address); err != nil { - return nil, err - } - } - if inIf.AddressIPv6 != "" { - if outIf.AddressIPv6, err = types.ParseCIDR(inIf.AddressIPv6); err != nil { - return nil, err - } - } - if inIf.MacAddress != "" { - if outIf.MacAddress, err = net.ParseMAC(inIf.MacAddress); err != nil { - return nil, err - } - } - } - - return outIf, nil -} diff --git a/vendor/github.com/docker/docker/libnetwork/drvregistry/ipams.go b/vendor/github.com/docker/docker/libnetwork/drvregistry/ipams.go deleted file mode 100644 index ba21810f5a..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/drvregistry/ipams.go +++ /dev/null @@ -1,84 +0,0 @@ -package drvregistry - -import ( - "errors" - "strings" - "sync" - - "github.com/docker/docker/libnetwork/ipamapi" - "github.com/docker/docker/libnetwork/types" -) - -type ipamDriver struct { - driver ipamapi.Ipam - capability *ipamapi.Capability -} - -// IPAMs is a registry of IPAM drivers. The zero value is an empty IPAM driver -// registry, ready to use. -type IPAMs struct { - mu sync.Mutex - drivers map[string]ipamDriver -} - -var _ ipamapi.Registerer = (*IPAMs)(nil) - -// IPAM returns the actual IPAM driver instance and its capability which registered with the passed name. -func (ir *IPAMs) IPAM(name string) (ipamapi.Ipam, *ipamapi.Capability) { - ir.mu.Lock() - defer ir.mu.Unlock() - - d := ir.drivers[name] - return d.driver, d.capability -} - -// RegisterIpamDriverWithCapabilities registers the IPAM driver discovered with specified capabilities. -func (ir *IPAMs) RegisterIpamDriverWithCapabilities(name string, driver ipamapi.Ipam, caps *ipamapi.Capability) error { - if strings.TrimSpace(name) == "" { - return errors.New("ipam driver name string cannot be empty") - } - - ir.mu.Lock() - defer ir.mu.Unlock() - - dd, ok := ir.drivers[name] - if ok && dd.driver.IsBuiltIn() { - return types.ForbiddenErrorf("ipam driver %q already registered", name) - } - - if ir.drivers == nil { - ir.drivers = make(map[string]ipamDriver) - } - ir.drivers[name] = ipamDriver{driver: driver, capability: caps} - - return nil -} - -// RegisterIpamDriver registers the IPAM driver discovered with default capabilities. -func (ir *IPAMs) RegisterIpamDriver(name string, driver ipamapi.Ipam) error { - return ir.RegisterIpamDriverWithCapabilities(name, driver, &ipamapi.Capability{}) -} - -// IPAMWalkFunc defines the IPAM driver table walker function signature. -type IPAMWalkFunc func(name string, driver ipamapi.Ipam, cap *ipamapi.Capability) bool - -// WalkIPAMs walks the IPAM drivers registered in the registry and invokes the passed walk function and each one of them. -func (ir *IPAMs) WalkIPAMs(ifn IPAMWalkFunc) { - type ipamVal struct { - name string - data ipamDriver - } - - ir.mu.Lock() - ivl := make([]ipamVal, 0, len(ir.drivers)) - for k, v := range ir.drivers { - ivl = append(ivl, ipamVal{name: k, data: v}) - } - ir.mu.Unlock() - - for _, iv := range ivl { - if ifn(iv.name, iv.data.driver, iv.data.capability) { - break - } - } -} diff --git a/vendor/github.com/docker/docker/libnetwork/drvregistry/networks.go b/vendor/github.com/docker/docker/libnetwork/drvregistry/networks.go deleted file mode 100644 index 83d507b1ec..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/drvregistry/networks.go +++ /dev/null @@ -1,90 +0,0 @@ -package drvregistry - -import ( - "errors" - "strings" - "sync" - - "github.com/docker/docker/libnetwork/driverapi" -) - -// DriverWalkFunc defines the network driver table walker function signature. -type DriverWalkFunc func(name string, driver driverapi.Driver, capability driverapi.Capability) bool - -type driverData struct { - driver driverapi.Driver - capability driverapi.Capability -} - -// Networks is a registry of network drivers. The zero value is an empty network -// driver registry, ready to use. -type Networks struct { - // Notify is called whenever a network driver is registered. - Notify driverapi.Registerer - - mu sync.Mutex - drivers map[string]driverData -} - -var _ driverapi.Registerer = (*Networks)(nil) - -// WalkDrivers walks the network drivers registered in the registry and invokes the passed walk function and each one of them. -func (nr *Networks) WalkDrivers(dfn DriverWalkFunc) { - type driverVal struct { - name string - data driverData - } - - nr.mu.Lock() - dvl := make([]driverVal, 0, len(nr.drivers)) - for k, v := range nr.drivers { - dvl = append(dvl, driverVal{name: k, data: v}) - } - nr.mu.Unlock() - - for _, dv := range dvl { - if dfn(dv.name, dv.data.driver, dv.data.capability) { - break - } - } -} - -// Driver returns the network driver instance registered under name, and its capability. -func (nr *Networks) Driver(name string) (driverapi.Driver, driverapi.Capability) { - nr.mu.Lock() - defer nr.mu.Unlock() - - d := nr.drivers[name] - return d.driver, d.capability -} - -// RegisterDriver registers the network driver with nr. -func (nr *Networks) RegisterDriver(ntype string, driver driverapi.Driver, capability driverapi.Capability) error { - if strings.TrimSpace(ntype) == "" { - return errors.New("network type string cannot be empty") - } - - nr.mu.Lock() - dd, ok := nr.drivers[ntype] - nr.mu.Unlock() - - if ok && dd.driver.IsBuiltIn() { - return driverapi.ErrActiveRegistration(ntype) - } - - if nr.Notify != nil { - if err := nr.Notify.RegisterDriver(ntype, driver, capability); err != nil { - return err - } - } - - nr.mu.Lock() - defer nr.mu.Unlock() - - if nr.drivers == nil { - nr.drivers = make(map[string]driverData) - } - nr.drivers[ntype] = driverData{driver: driver, capability: capability} - - return nil -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipam/allocator.go b/vendor/github.com/docker/docker/libnetwork/ipam/allocator.go deleted file mode 100644 index 544a600c82..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipam/allocator.go +++ /dev/null @@ -1,409 +0,0 @@ -package ipam - -import ( - "context" - "fmt" - "net" - "net/netip" - "strings" - - "github.com/containerd/containerd/log" - "github.com/docker/docker/libnetwork/bitmap" - "github.com/docker/docker/libnetwork/ipamapi" - "github.com/docker/docker/libnetwork/ipbits" - "github.com/docker/docker/libnetwork/types" -) - -const ( - localAddressSpace = "LocalDefault" - globalAddressSpace = "GlobalDefault" -) - -// Allocator provides per address space ipv4/ipv6 book keeping -type Allocator struct { - // The address spaces - local, global *addrSpace -} - -// NewAllocator returns an instance of libnetwork ipam -func NewAllocator(lcAs, glAs []*net.IPNet) (*Allocator, error) { - var ( - a Allocator - err error - ) - a.local, err = newAddrSpace(lcAs) - if err != nil { - return nil, fmt.Errorf("could not construct local address space: %w", err) - } - a.global, err = newAddrSpace(glAs) - if err != nil { - return nil, fmt.Errorf("could not construct global address space: %w", err) - } - return &a, nil -} - -func newAddrSpace(predefined []*net.IPNet) (*addrSpace, error) { - pdf := make([]netip.Prefix, len(predefined)) - for i, n := range predefined { - var ok bool - pdf[i], ok = toPrefix(n) - if !ok { - return nil, fmt.Errorf("network at index %d (%v) is not in canonical form", i, n) - } - } - return &addrSpace{ - subnets: map[netip.Prefix]*PoolData{}, - predefined: pdf, - }, nil -} - -// GetDefaultAddressSpaces returns the local and global default address spaces -func (a *Allocator) GetDefaultAddressSpaces() (string, string, error) { - return localAddressSpace, globalAddressSpace, nil -} - -// RequestPool returns an address pool along with its unique id. -// addressSpace must be a valid address space name and must not be the empty string. -// If requestedPool is the empty string then the default predefined pool for addressSpace will be used, otherwise pool must be a valid IP address and length in CIDR notation. -// If requestedSubPool is not empty, it must be a valid IP address and length in CIDR notation which is a sub-range of requestedPool. -// requestedSubPool must be empty if requestedPool is empty. -func (a *Allocator) RequestPool(addressSpace, requestedPool, requestedSubPool string, _ map[string]string, v6 bool) (poolID string, pool *net.IPNet, meta map[string]string, err error) { - log.G(context.TODO()).Debugf("RequestPool(%s, %s, %s, _, %t)", addressSpace, requestedPool, requestedSubPool, v6) - - parseErr := func(err error) error { - return types.InternalErrorf("failed to parse pool request for address space %q pool %q subpool %q: %v", addressSpace, requestedPool, requestedSubPool, err) - } - - if addressSpace == "" { - return "", nil, nil, parseErr(ipamapi.ErrInvalidAddressSpace) - } - aSpace, err := a.getAddrSpace(addressSpace) - if err != nil { - return "", nil, nil, err - } - if requestedPool == "" && requestedSubPool != "" { - return "", nil, nil, parseErr(ipamapi.ErrInvalidSubPool) - } - - k := PoolID{AddressSpace: addressSpace} - if requestedPool == "" { - k.Subnet, err = aSpace.allocatePredefinedPool(v6) - if err != nil { - return "", nil, nil, err - } - return k.String(), toIPNet(k.Subnet), nil, nil - } - - if k.Subnet, err = netip.ParsePrefix(requestedPool); err != nil { - return "", nil, nil, parseErr(ipamapi.ErrInvalidPool) - } - - if requestedSubPool != "" { - k.ChildSubnet, err = netip.ParsePrefix(requestedSubPool) - if err != nil { - return "", nil, nil, parseErr(ipamapi.ErrInvalidSubPool) - } - } - - k.Subnet, k.ChildSubnet = k.Subnet.Masked(), k.ChildSubnet.Masked() - // Prior to https://github.com/moby/moby/pull/44968, libnetwork would happily accept a ChildSubnet with a bigger - // mask than its parent subnet. In such case, it was producing IP addresses based on the parent subnet, and the - // child subnet was not allocated from the address pool. Following condition take care of restoring this behavior - // for networks created before upgrading to v24.0. - if k.ChildSubnet.IsValid() && k.ChildSubnet.Bits() < k.Subnet.Bits() { - k.ChildSubnet = k.Subnet - } - - err = aSpace.allocateSubnet(k.Subnet, k.ChildSubnet) - if err != nil { - return "", nil, nil, err - } - - return k.String(), toIPNet(k.Subnet), nil, nil -} - -// ReleasePool releases the address pool identified by the passed id -func (a *Allocator) ReleasePool(poolID string) error { - log.G(context.TODO()).Debugf("ReleasePool(%s)", poolID) - k, err := PoolIDFromString(poolID) - if err != nil { - return types.InvalidParameterErrorf("invalid pool id: %s", poolID) - } - - aSpace, err := a.getAddrSpace(k.AddressSpace) - if err != nil { - return err - } - - return aSpace.releaseSubnet(k.Subnet, k.ChildSubnet) -} - -// Given the address space, returns the local or global PoolConfig based on whether the -// address space is local or global. AddressSpace locality is registered with IPAM out of band. -func (a *Allocator) getAddrSpace(as string) (*addrSpace, error) { - switch as { - case localAddressSpace: - return a.local, nil - case globalAddressSpace: - return a.global, nil - } - return nil, types.InvalidParameterErrorf("cannot find address space %s", as) -} - -func newPoolData(pool netip.Prefix) *PoolData { - ones, bits := pool.Bits(), pool.Addr().BitLen() - numAddresses := uint64(1 << uint(bits-ones)) - - // Allow /64 subnet - if pool.Addr().Is6() && numAddresses == 0 { - numAddresses-- - } - - // Generate the new address masks. - h := bitmap.New(numAddresses) - - // Pre-reserve the network address on IPv4 networks large - // enough to have one (i.e., anything bigger than a /31. - if !(pool.Addr().Is4() && numAddresses <= 2) { - h.Set(0) - } - - // Pre-reserve the broadcast address on IPv4 networks large - // enough to have one (i.e., anything bigger than a /31). - if pool.Addr().Is4() && numAddresses > 2 { - h.Set(numAddresses - 1) - } - - return &PoolData{addrs: h, children: map[netip.Prefix]struct{}{}} -} - -// getPredefineds returns the predefined subnets for the address space. -// -// It should not be called concurrently with any other method on the addrSpace. -func (aSpace *addrSpace) getPredefineds() []netip.Prefix { - i := aSpace.predefinedStartIndex - // defensive in case the list changed since last update - if i >= len(aSpace.predefined) { - i = 0 - } - return append(aSpace.predefined[i:], aSpace.predefined[:i]...) -} - -// updatePredefinedStartIndex rotates the predefined subnet list by amt. -// -// It should not be called concurrently with any other method on the addrSpace. -func (aSpace *addrSpace) updatePredefinedStartIndex(amt int) { - i := aSpace.predefinedStartIndex + amt - if i < 0 || i >= len(aSpace.predefined) { - i = 0 - } - aSpace.predefinedStartIndex = i -} - -func (aSpace *addrSpace) allocatePredefinedPool(ipV6 bool) (netip.Prefix, error) { - aSpace.Lock() - defer aSpace.Unlock() - - for i, nw := range aSpace.getPredefineds() { - if ipV6 != nw.Addr().Is6() { - continue - } - // Checks whether pool has already been allocated - if _, ok := aSpace.subnets[nw]; ok { - continue - } - // Shouldn't be necessary, but check prevents IP collisions should - // predefined pools overlap for any reason. - if !aSpace.contains(nw) { - aSpace.updatePredefinedStartIndex(i + 1) - err := aSpace.allocateSubnetL(nw, netip.Prefix{}) - if err != nil { - return netip.Prefix{}, err - } - return nw, nil - } - } - - v := 4 - if ipV6 { - v = 6 - } - return netip.Prefix{}, types.NotFoundErrorf("could not find an available, non-overlapping IPv%d address pool among the defaults to assign to the network", v) -} - -// RequestAddress returns an address from the specified pool ID -func (a *Allocator) RequestAddress(poolID string, prefAddress net.IP, opts map[string]string) (*net.IPNet, map[string]string, error) { - log.G(context.TODO()).Debugf("RequestAddress(%s, %v, %v)", poolID, prefAddress, opts) - k, err := PoolIDFromString(poolID) - if err != nil { - return nil, nil, types.InvalidParameterErrorf("invalid pool id: %s", poolID) - } - - aSpace, err := a.getAddrSpace(k.AddressSpace) - if err != nil { - return nil, nil, err - } - var pref netip.Addr - if prefAddress != nil { - var ok bool - pref, ok = netip.AddrFromSlice(prefAddress) - if !ok { - return nil, nil, types.InvalidParameterErrorf("invalid preferred address: %v", prefAddress) - } - } - p, err := aSpace.requestAddress(k.Subnet, k.ChildSubnet, pref.Unmap(), opts) - if err != nil { - return nil, nil, err - } - return &net.IPNet{ - IP: p.AsSlice(), - Mask: net.CIDRMask(k.Subnet.Bits(), k.Subnet.Addr().BitLen()), - }, nil, nil -} - -func (aSpace *addrSpace) requestAddress(nw, sub netip.Prefix, prefAddress netip.Addr, opts map[string]string) (netip.Addr, error) { - aSpace.Lock() - defer aSpace.Unlock() - - p, ok := aSpace.subnets[nw] - if !ok { - return netip.Addr{}, types.NotFoundErrorf("cannot find address pool for poolID:%v/%v", nw, sub) - } - - if prefAddress != (netip.Addr{}) && !nw.Contains(prefAddress) { - return netip.Addr{}, ipamapi.ErrIPOutOfRange - } - - if sub != (netip.Prefix{}) { - if _, ok := p.children[sub]; !ok { - return netip.Addr{}, types.NotFoundErrorf("cannot find address pool for poolID:%v/%v", nw, sub) - } - } - - // In order to request for a serial ip address allocation, callers can pass in the option to request - // IP allocation serially or first available IP in the subnet - serial := opts[ipamapi.AllocSerialPrefix] == "true" - ip, err := getAddress(nw, p.addrs, prefAddress, sub, serial) - if err != nil { - return netip.Addr{}, err - } - - return ip, nil -} - -// ReleaseAddress releases the address from the specified pool ID -func (a *Allocator) ReleaseAddress(poolID string, address net.IP) error { - log.G(context.TODO()).Debugf("ReleaseAddress(%s, %v)", poolID, address) - k, err := PoolIDFromString(poolID) - if err != nil { - return types.InvalidParameterErrorf("invalid pool id: %s", poolID) - } - - aSpace, err := a.getAddrSpace(k.AddressSpace) - if err != nil { - return err - } - - addr, ok := netip.AddrFromSlice(address) - if !ok { - return types.InvalidParameterErrorf("invalid address: %v", address) - } - - return aSpace.releaseAddress(k.Subnet, k.ChildSubnet, addr.Unmap()) -} - -func (aSpace *addrSpace) releaseAddress(nw, sub netip.Prefix, address netip.Addr) error { - aSpace.Lock() - defer aSpace.Unlock() - - p, ok := aSpace.subnets[nw] - if !ok { - return types.NotFoundErrorf("cannot find address pool for %v/%v", nw, sub) - } - if sub != (netip.Prefix{}) { - if _, ok := p.children[sub]; !ok { - return types.NotFoundErrorf("cannot find address pool for poolID:%v/%v", nw, sub) - } - } - - if !address.IsValid() { - return types.InvalidParameterErrorf("invalid address") - } - - if !nw.Contains(address) { - return ipamapi.ErrIPOutOfRange - } - - defer log.G(context.TODO()).Debugf("Released address Address:%v Sequence:%s", address, p.addrs) - - return p.addrs.Unset(hostID(address, uint(nw.Bits()))) -} - -func getAddress(base netip.Prefix, bitmask *bitmap.Bitmap, prefAddress netip.Addr, ipr netip.Prefix, serial bool) (netip.Addr, error) { - var ( - ordinal uint64 - err error - ) - - log.G(context.TODO()).Debugf("Request address PoolID:%v %s Serial:%v PrefAddress:%v ", base, bitmask, serial, prefAddress) - - if bitmask.Unselected() == 0 { - return netip.Addr{}, ipamapi.ErrNoAvailableIPs - } - if ipr == (netip.Prefix{}) && prefAddress == (netip.Addr{}) { - ordinal, err = bitmask.SetAny(serial) - } else if prefAddress != (netip.Addr{}) { - ordinal = hostID(prefAddress, uint(base.Bits())) - err = bitmask.Set(ordinal) - } else { - start, end := subnetRange(base, ipr) - ordinal, err = bitmask.SetAnyInRange(start, end, serial) - } - - switch err { - case nil: - // Convert IP ordinal for this subnet into IP address - return ipbits.Add(base.Addr(), ordinal, 0), nil - case bitmap.ErrBitAllocated: - return netip.Addr{}, ipamapi.ErrIPAlreadyAllocated - case bitmap.ErrNoBitAvailable: - return netip.Addr{}, ipamapi.ErrNoAvailableIPs - default: - return netip.Addr{}, err - } -} - -// DumpDatabase dumps the internal info -func (a *Allocator) DumpDatabase() string { - aspaces := map[string]*addrSpace{ - localAddressSpace: a.local, - globalAddressSpace: a.global, - } - - var b strings.Builder - for _, as := range []string{localAddressSpace, globalAddressSpace} { - fmt.Fprintf(&b, "\n### %s\n", as) - b.WriteString(aspaces[as].DumpDatabase()) - } - return b.String() -} - -func (aSpace *addrSpace) DumpDatabase() string { - aSpace.Lock() - defer aSpace.Unlock() - - var b strings.Builder - for k, config := range aSpace.subnets { - fmt.Fprintf(&b, "%v: %v\n", k, config) - fmt.Fprintf(&b, " Bitmap: %v\n", config.addrs) - for k := range config.children { - fmt.Fprintf(&b, " - Subpool: %v\n", k) - } - } - return b.String() -} - -// IsBuiltIn returns true for builtin drivers -func (a *Allocator) IsBuiltIn() bool { - return true -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipam/structures.go b/vendor/github.com/docker/docker/libnetwork/ipam/structures.go deleted file mode 100644 index 451d5a9253..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipam/structures.go +++ /dev/null @@ -1,168 +0,0 @@ -package ipam - -import ( - "fmt" - "net/netip" - "strings" - "sync" - - "github.com/docker/docker/libnetwork/bitmap" - "github.com/docker/docker/libnetwork/ipamapi" - "github.com/docker/docker/libnetwork/types" -) - -// PoolID is the pointer to the configured pools in each address space -type PoolID struct { - AddressSpace string - SubnetKey -} - -// PoolData contains the configured pool data -type PoolData struct { - addrs *bitmap.Bitmap - children map[netip.Prefix]struct{} - - // Whether to implicitly release the pool once it no longer has any children. - autoRelease bool -} - -// SubnetKey is the composite key to an address pool within an address space. -type SubnetKey struct { - Subnet, ChildSubnet netip.Prefix -} - -// addrSpace contains the pool configurations for the address space -type addrSpace struct { - // Master subnet pools, indexed by the value's stringified PoolData.Pool field. - subnets map[netip.Prefix]*PoolData - - // Predefined pool for the address space - predefined []netip.Prefix - predefinedStartIndex int - - sync.Mutex -} - -// PoolIDFromString creates a new PoolID and populates the SubnetKey object -// reading it from the given string. -func PoolIDFromString(str string) (pID PoolID, err error) { - if str == "" { - return pID, types.InvalidParameterErrorf("invalid string form for subnetkey: %s", str) - } - - p := strings.Split(str, "/") - if len(p) != 3 && len(p) != 5 { - return pID, types.InvalidParameterErrorf("invalid string form for subnetkey: %s", str) - } - pID.AddressSpace = p[0] - pID.Subnet, err = netip.ParsePrefix(p[1] + "/" + p[2]) - if err != nil { - return pID, types.InvalidParameterErrorf("invalid string form for subnetkey: %s", str) - } - if len(p) == 5 { - pID.ChildSubnet, err = netip.ParsePrefix(p[3] + "/" + p[4]) - if err != nil { - return pID, types.InvalidParameterErrorf("invalid string form for subnetkey: %s", str) - } - } - - return pID, nil -} - -// String returns the string form of the SubnetKey object -func (s *PoolID) String() string { - if s.ChildSubnet == (netip.Prefix{}) { - return s.AddressSpace + "/" + s.Subnet.String() - } else { - return s.AddressSpace + "/" + s.Subnet.String() + "/" + s.ChildSubnet.String() - } -} - -// String returns the string form of the PoolData object -func (p *PoolData) String() string { - return fmt.Sprintf("PoolData[Children: %d]", len(p.children)) -} - -// allocateSubnet adds the subnet k to the address space. -func (aSpace *addrSpace) allocateSubnet(nw, sub netip.Prefix) error { - aSpace.Lock() - defer aSpace.Unlock() - - // Check if already allocated - if pool, ok := aSpace.subnets[nw]; ok { - var childExists bool - if sub != (netip.Prefix{}) { - _, childExists = pool.children[sub] - } - if sub == (netip.Prefix{}) || childExists { - // This means the same pool is already allocated. allocateSubnet is called when there - // is request for a pool/subpool. It should ensure there is no overlap with existing pools - return ipamapi.ErrPoolOverlap - } - } - - return aSpace.allocateSubnetL(nw, sub) -} - -func (aSpace *addrSpace) allocateSubnetL(nw, sub netip.Prefix) error { - // If master pool, check for overlap - if sub == (netip.Prefix{}) { - if aSpace.contains(nw) { - return ipamapi.ErrPoolOverlap - } - // This is a new master pool, add it along with corresponding bitmask - aSpace.subnets[nw] = newPoolData(nw) - return nil - } - - // This is a new non-master pool (subPool) - if nw.Addr().BitLen() != sub.Addr().BitLen() { - return fmt.Errorf("pool and subpool are of incompatible address families") - } - - // Look for parent pool - pp, ok := aSpace.subnets[nw] - if !ok { - // Parent pool does not exist, add it along with corresponding bitmask - pp = newPoolData(nw) - pp.autoRelease = true - aSpace.subnets[nw] = pp - } - pp.children[sub] = struct{}{} - return nil -} - -func (aSpace *addrSpace) releaseSubnet(nw, sub netip.Prefix) error { - aSpace.Lock() - defer aSpace.Unlock() - - p, ok := aSpace.subnets[nw] - if !ok { - return ipamapi.ErrBadPool - } - - if sub != (netip.Prefix{}) { - if _, ok := p.children[sub]; !ok { - return ipamapi.ErrBadPool - } - delete(p.children, sub) - } else { - p.autoRelease = true - } - - if len(p.children) == 0 && p.autoRelease { - delete(aSpace.subnets, nw) - } - - return nil -} - -// contains checks whether nw is a superset or subset of any of the existing subnets in this address space. -func (aSpace *addrSpace) contains(nw netip.Prefix) bool { - for pool := range aSpace.subnets { - if nw.Contains(pool.Addr()) || pool.Contains(nw.Addr()) { - return true - } - } - return false -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipam/utils.go b/vendor/github.com/docker/docker/libnetwork/ipam/utils.go deleted file mode 100644 index 4e7d72c2e0..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipam/utils.go +++ /dev/null @@ -1,48 +0,0 @@ -package ipam - -import ( - "net" - "net/netip" - - "github.com/docker/docker/libnetwork/ipbits" -) - -func toIPNet(p netip.Prefix) *net.IPNet { - if !p.IsValid() { - return nil - } - return &net.IPNet{ - IP: p.Addr().AsSlice(), - Mask: net.CIDRMask(p.Bits(), p.Addr().BitLen()), - } -} - -func toPrefix(n *net.IPNet) (netip.Prefix, bool) { - if ll := len(n.Mask); ll != net.IPv4len && ll != net.IPv6len { - return netip.Prefix{}, false - } - - addr, ok := netip.AddrFromSlice(n.IP) - if !ok { - return netip.Prefix{}, false - } - - ones, bits := n.Mask.Size() - if ones == 0 && bits == 0 { - return netip.Prefix{}, false - } - - return netip.PrefixFrom(addr.Unmap(), ones), true -} - -func hostID(addr netip.Addr, bits uint) uint64 { - return ipbits.Field(addr, bits, uint(addr.BitLen())) -} - -// subnetRange returns the amount to add to network.Addr() in order to yield the -// first and last addresses in subnet, respectively. -func subnetRange(network, subnet netip.Prefix) (start, end uint64) { - start = hostID(subnet.Addr(), uint(network.Bits())) - end = start + (1 << uint64(subnet.Addr().BitLen()-subnet.Bits())) - 1 - return start, end -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipamapi/contract.go b/vendor/github.com/docker/docker/libnetwork/ipamapi/contract.go deleted file mode 100644 index 86f3414bfe..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipamapi/contract.go +++ /dev/null @@ -1,74 +0,0 @@ -// Package ipamapi specifies the contract the IPAM service (built-in or remote) needs to satisfy. -package ipamapi - -import ( - "net" - - "github.com/docker/docker/libnetwork/types" -) - -// IPAM plugin types -const ( - // DefaultIPAM is the name of the built-in default ipam driver - DefaultIPAM = "default" - // NullIPAM is the name of the built-in null ipam driver - NullIPAM = "null" - // PluginEndpointType represents the Endpoint Type used by Plugin system - PluginEndpointType = "IpamDriver" - // RequestAddressType represents the Address Type used when requesting an address - RequestAddressType = "RequestAddressType" -) - -// Registerer provides a callback interface for registering IPAM instances into libnetwork. -type Registerer interface { - // RegisterIpamDriver provides a way for drivers to dynamically register with libnetwork - RegisterIpamDriver(name string, driver Ipam) error - // RegisterIpamDriverWithCapabilities provides a way for drivers to dynamically register with libnetwork and specify capabilities - RegisterIpamDriverWithCapabilities(name string, driver Ipam, capability *Capability) error -} - -// Well-known errors returned by IPAM -var ( - ErrInvalidAddressSpace = types.InvalidParameterErrorf("invalid address space") - ErrInvalidPool = types.InvalidParameterErrorf("invalid address pool") - ErrInvalidSubPool = types.InvalidParameterErrorf("invalid address subpool") - ErrNoAvailableIPs = types.UnavailableErrorf("no available addresses on this pool") - ErrNoIPReturned = types.UnavailableErrorf("no address returned") - ErrIPAlreadyAllocated = types.ForbiddenErrorf("Address already in use") - ErrIPOutOfRange = types.InvalidParameterErrorf("requested address is out of range") - ErrPoolOverlap = types.ForbiddenErrorf("Pool overlaps with other one on this address space") - ErrBadPool = types.InvalidParameterErrorf("address space does not contain specified address pool") -) - -// Ipam represents the interface the IPAM service plugins must implement -// in order to allow injection/modification of IPAM database. -type Ipam interface { - // GetDefaultAddressSpaces returns the default local and global address spaces for this ipam - GetDefaultAddressSpaces() (string, string, error) - // RequestPool returns an address pool along with its unique id. Address space is a mandatory field - // which denotes a set of non-overlapping pools. requestedPool describes the pool of addresses in CIDR notation. - // requestedSubPool indicates a smaller range of addresses from the pool, for now it is specified in CIDR notation. - // Both requestedPool and requestedSubPool are non-mandatory fields. When they are not specified, Ipam driver may choose to - // return a self chosen pool for this request. In such case the v6 flag needs to be set appropriately so - // that the driver would return the expected ip version pool. - RequestPool(addressSpace, requestedPool, requestedSubPool string, options map[string]string, v6 bool) (poolID string, pool *net.IPNet, meta map[string]string, err error) - // ReleasePool releases the address pool identified by the passed id - ReleasePool(poolID string) error - // RequestAddress request an address from the specified pool ID. Input options or required IP can be passed. - RequestAddress(string, net.IP, map[string]string) (*net.IPNet, map[string]string, error) - // ReleaseAddress releases the address from the specified pool ID. - ReleaseAddress(string, net.IP) error - - // IsBuiltIn returns true if it is a built-in driver. - IsBuiltIn() bool -} - -// Capability represents the requirements and capabilities of the IPAM driver -type Capability struct { - // Whether on address request, libnetwork must - // specify the endpoint MAC address - RequiresMACAddress bool - // Whether of daemon start, libnetwork must replay the pool - // request and the address request for current local networks - RequiresRequestReplay bool -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipamapi/labels.go b/vendor/github.com/docker/docker/libnetwork/ipamapi/labels.go deleted file mode 100644 index e5c7d1cc7e..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipamapi/labels.go +++ /dev/null @@ -1,10 +0,0 @@ -package ipamapi - -const ( - // Prefix constant marks the reserved label space for libnetwork - Prefix = "com.docker.network" - - // AllocSerialPrefix constant marks the reserved label space for libnetwork ipam - // allocation ordering.(serial/first available) - AllocSerialPrefix = Prefix + ".ipam.serial" -) diff --git a/vendor/github.com/docker/docker/libnetwork/ipams/builtin/builtin.go b/vendor/github.com/docker/docker/libnetwork/ipams/builtin/builtin.go deleted file mode 100644 index 66b28a70d2..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipams/builtin/builtin.go +++ /dev/null @@ -1,41 +0,0 @@ -package builtin - -import ( - "net" - - "github.com/docker/docker/libnetwork/ipam" - "github.com/docker/docker/libnetwork/ipamapi" - "github.com/docker/docker/libnetwork/ipamutils" -) - -// defaultAddressPool Stores user configured subnet list -var defaultAddressPool []*net.IPNet - -// registerBuiltin registers the built-in ipam driver with libnetwork. -func registerBuiltin(ic ipamapi.Registerer) error { - var localAddressPool []*net.IPNet - if len(defaultAddressPool) > 0 { - localAddressPool = append([]*net.IPNet(nil), defaultAddressPool...) - } else { - localAddressPool = ipamutils.GetLocalScopeDefaultNetworks() - } - - a, err := ipam.NewAllocator(localAddressPool, ipamutils.GetGlobalScopeDefaultNetworks()) - if err != nil { - return err - } - - cps := &ipamapi.Capability{RequiresRequestReplay: true} - - return ic.RegisterIpamDriverWithCapabilities(ipamapi.DefaultIPAM, a, cps) -} - -// SetDefaultIPAddressPool stores default address pool. -func SetDefaultIPAddressPool(addressPool []*ipamutils.NetworkToSplit) error { - nets, err := ipamutils.SplitNetworks(addressPool) - if err != nil { - return err - } - defaultAddressPool = nets - return nil -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipams/builtin/builtin_unix.go b/vendor/github.com/docker/docker/libnetwork/ipams/builtin/builtin_unix.go deleted file mode 100644 index c063cb4e9d..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipams/builtin/builtin_unix.go +++ /dev/null @@ -1,12 +0,0 @@ -//go:build linux || freebsd || darwin - -package builtin - -import ( - "github.com/docker/docker/libnetwork/ipamapi" -) - -// Register registers the built-in ipam service with libnetwork. -func Register(r ipamapi.Registerer) error { - return registerBuiltin(r) -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipams/builtin/builtin_windows.go b/vendor/github.com/docker/docker/libnetwork/ipams/builtin/builtin_windows.go deleted file mode 100644 index cb364a8fe7..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipams/builtin/builtin_windows.go +++ /dev/null @@ -1,17 +0,0 @@ -//go:build windows - -package builtin - -import ( - "github.com/docker/docker/libnetwork/ipamapi" - "github.com/docker/docker/libnetwork/ipams/windowsipam" -) - -// Register registers the built-in ipam services with libnetwork. -func Register(r ipamapi.Registerer) error { - if err := registerBuiltin(r); err != nil { - return err - } - - return windowsipam.Register(windowsipam.DefaultIPAM, r) -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipams/null/null.go b/vendor/github.com/docker/docker/libnetwork/ipams/null/null.go deleted file mode 100644 index 1ca4a7f51c..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipams/null/null.go +++ /dev/null @@ -1,67 +0,0 @@ -// Package null implements the null ipam driver. Null ipam driver satisfies ipamapi contract, -// but does not effectively reserve/allocate any address pool or address -package null - -import ( - "net" - - "github.com/docker/docker/libnetwork/ipamapi" - "github.com/docker/docker/libnetwork/types" -) - -const ( - defaultAddressSpace = "null" - defaultPoolCIDR = "0.0.0.0/0" - defaultPoolID = defaultAddressSpace + "/" + defaultPoolCIDR -) - -var defaultPool, _ = types.ParseCIDR(defaultPoolCIDR) - -type allocator struct{} - -func (a *allocator) GetDefaultAddressSpaces() (string, string, error) { - return defaultAddressSpace, defaultAddressSpace, nil -} - -func (a *allocator) RequestPool(addressSpace, requestedPool, requestedSubPool string, _ map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) { - if addressSpace != defaultAddressSpace { - return "", nil, nil, types.InvalidParameterErrorf("unknown address space: %s", addressSpace) - } - if requestedPool != "" { - return "", nil, nil, types.InvalidParameterErrorf("null ipam driver does not handle specific address pool requests") - } - if requestedSubPool != "" { - return "", nil, nil, types.InvalidParameterErrorf("null ipam driver does not handle specific address subpool requests") - } - if v6 { - return "", nil, nil, types.InvalidParameterErrorf("null ipam driver does not handle IPv6 address pool pool requests") - } - return defaultPoolID, defaultPool, nil, nil -} - -func (a *allocator) ReleasePool(poolID string) error { - return nil -} - -func (a *allocator) RequestAddress(poolID string, ip net.IP, opts map[string]string) (*net.IPNet, map[string]string, error) { - if poolID != defaultPoolID { - return nil, nil, types.InvalidParameterErrorf("unknown pool id: %s", poolID) - } - return nil, nil, nil -} - -func (a *allocator) ReleaseAddress(poolID string, ip net.IP) error { - if poolID != defaultPoolID { - return types.InvalidParameterErrorf("unknown pool id: %s", poolID) - } - return nil -} - -func (a *allocator) IsBuiltIn() bool { - return true -} - -// Register registers the null ipam driver with r. -func Register(r ipamapi.Registerer) error { - return r.RegisterIpamDriver(ipamapi.NullIPAM, &allocator{}) -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipams/remote/api/api.go b/vendor/github.com/docker/docker/libnetwork/ipams/remote/api/api.go deleted file mode 100644 index c84d604af1..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipams/remote/api/api.go +++ /dev/null @@ -1,94 +0,0 @@ -// Package api defines the data structure to be used in the request/response -// messages between libnetwork and the remote ipam plugin -package api - -import "github.com/docker/docker/libnetwork/ipamapi" - -// Response is the basic response structure used in all responses -type Response struct { - Error string -} - -// IsSuccess returns whether the plugin response is successful -func (r *Response) IsSuccess() bool { - return r.Error == "" -} - -// GetError returns the error from the response, if any. -func (r *Response) GetError() string { - return r.Error -} - -// GetCapabilityResponse is the response of GetCapability request -type GetCapabilityResponse struct { - Response - RequiresMACAddress bool - RequiresRequestReplay bool -} - -// ToCapability converts the capability response into the internal ipam driver capability structure -func (capRes GetCapabilityResponse) ToCapability() *ipamapi.Capability { - return &ipamapi.Capability{ - RequiresMACAddress: capRes.RequiresMACAddress, - RequiresRequestReplay: capRes.RequiresRequestReplay, - } -} - -// GetAddressSpacesResponse is the response to the “get default address spaces“ request message -type GetAddressSpacesResponse struct { - Response - LocalDefaultAddressSpace string - GlobalDefaultAddressSpace string -} - -// RequestPoolRequest represents the expected data in a “request address pool“ request message -type RequestPoolRequest struct { - AddressSpace string - Pool string - SubPool string - Options map[string]string - V6 bool -} - -// RequestPoolResponse represents the response message to a “request address pool“ request -type RequestPoolResponse struct { - Response - PoolID string - Pool string // CIDR format - Data map[string]string -} - -// ReleasePoolRequest represents the expected data in a “release address pool“ request message -type ReleasePoolRequest struct { - PoolID string -} - -// ReleasePoolResponse represents the response message to a “release address pool“ request -type ReleasePoolResponse struct { - Response -} - -// RequestAddressRequest represents the expected data in a “request address“ request message -type RequestAddressRequest struct { - PoolID string - Address string - Options map[string]string -} - -// RequestAddressResponse represents the expected data in the response message to a “request address“ request -type RequestAddressResponse struct { - Response - Address string // in CIDR format - Data map[string]string -} - -// ReleaseAddressRequest represents the expected data in a “release address“ request message -type ReleaseAddressRequest struct { - PoolID string - Address string -} - -// ReleaseAddressResponse represents the response message to a “release address“ request -type ReleaseAddressResponse struct { - Response -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipams/remote/remote.go b/vendor/github.com/docker/docker/libnetwork/ipams/remote/remote.go deleted file mode 100644 index 55031ff5e1..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipams/remote/remote.go +++ /dev/null @@ -1,172 +0,0 @@ -package remote - -import ( - "context" - "fmt" - "net" - - "github.com/containerd/containerd/log" - "github.com/docker/docker/libnetwork/ipamapi" - "github.com/docker/docker/libnetwork/ipams/remote/api" - "github.com/docker/docker/libnetwork/types" - "github.com/docker/docker/pkg/plugingetter" - "github.com/docker/docker/pkg/plugins" - "github.com/pkg/errors" -) - -type allocator struct { - endpoint *plugins.Client - name string -} - -// PluginResponse is the interface for the plugin request responses -type PluginResponse interface { - IsSuccess() bool - GetError() string -} - -func newAllocator(name string, client *plugins.Client) ipamapi.Ipam { - a := &allocator{name: name, endpoint: client} - return a -} - -// Register registers a remote ipam when its plugin is activated. -func Register(cb ipamapi.Registerer, pg plugingetter.PluginGetter) error { - newPluginHandler := func(name string, client *plugins.Client) { - a := newAllocator(name, client) - if cps, err := a.(*allocator).getCapabilities(); err == nil { - if err := cb.RegisterIpamDriverWithCapabilities(name, a, cps); err != nil { - log.G(context.TODO()).Errorf("error registering remote ipam driver %s due to %v", name, err) - } - } else { - log.G(context.TODO()).Infof("remote ipam driver %s does not support capabilities", name) - log.G(context.TODO()).Debug(err) - if err := cb.RegisterIpamDriver(name, a); err != nil { - log.G(context.TODO()).Errorf("error registering remote ipam driver %s due to %v", name, err) - } - } - } - - // Unit test code is unaware of a true PluginStore. So we fall back to v1 plugins. - handleFunc := plugins.Handle - if pg != nil { - handleFunc = pg.Handle - activePlugins := pg.GetAllManagedPluginsByCap(ipamapi.PluginEndpointType) - for _, ap := range activePlugins { - client, err := getPluginClient(ap) - if err != nil { - return err - } - newPluginHandler(ap.Name(), client) - } - } - handleFunc(ipamapi.PluginEndpointType, newPluginHandler) - return nil -} - -func getPluginClient(p plugingetter.CompatPlugin) (*plugins.Client, error) { - if v1, ok := p.(plugingetter.PluginWithV1Client); ok { - return v1.Client(), nil - } - - pa, ok := p.(plugingetter.PluginAddr) - if !ok { - return nil, errors.Errorf("unknown plugin type %T", p) - } - - if pa.Protocol() != plugins.ProtocolSchemeHTTPV1 { - return nil, errors.Errorf("unsupported plugin protocol %s", pa.Protocol()) - } - - addr := pa.Addr() - client, err := plugins.NewClientWithTimeout(addr.Network()+"://"+addr.String(), nil, pa.Timeout()) - if err != nil { - return nil, errors.Wrap(err, "error creating plugin client") - } - return client, nil -} - -func (a *allocator) call(methodName string, arg interface{}, retVal PluginResponse) error { - method := ipamapi.PluginEndpointType + "." + methodName - err := a.endpoint.Call(method, arg, retVal) - if err != nil { - return err - } - if !retVal.IsSuccess() { - return fmt.Errorf("remote: %s", retVal.GetError()) - } - return nil -} - -func (a *allocator) getCapabilities() (*ipamapi.Capability, error) { - var res api.GetCapabilityResponse - if err := a.call("GetCapabilities", nil, &res); err != nil { - return nil, err - } - return res.ToCapability(), nil -} - -// GetDefaultAddressSpaces returns the local and global default address spaces -func (a *allocator) GetDefaultAddressSpaces() (string, string, error) { - res := &api.GetAddressSpacesResponse{} - if err := a.call("GetDefaultAddressSpaces", nil, res); err != nil { - return "", "", err - } - return res.LocalDefaultAddressSpace, res.GlobalDefaultAddressSpace, nil -} - -// RequestPool requests an address pool in the specified address space -func (a *allocator) RequestPool(addressSpace, requestedPool, requestedSubPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) { - req := &api.RequestPoolRequest{AddressSpace: addressSpace, Pool: requestedPool, SubPool: requestedSubPool, Options: options, V6: v6} - res := &api.RequestPoolResponse{} - if err := a.call("RequestPool", req, res); err != nil { - return "", nil, nil, err - } - retPool, err := types.ParseCIDR(res.Pool) - return res.PoolID, retPool, res.Data, err -} - -// ReleasePool removes an address pool from the specified address space -func (a *allocator) ReleasePool(poolID string) error { - req := &api.ReleasePoolRequest{PoolID: poolID} - res := &api.ReleasePoolResponse{} - return a.call("ReleasePool", req, res) -} - -// RequestAddress requests an address from the address pool -func (a *allocator) RequestAddress(poolID string, address net.IP, options map[string]string) (*net.IPNet, map[string]string, error) { - var ( - prefAddress string - retAddress *net.IPNet - err error - ) - if address != nil { - prefAddress = address.String() - } - req := &api.RequestAddressRequest{PoolID: poolID, Address: prefAddress, Options: options} - res := &api.RequestAddressResponse{} - if err := a.call("RequestAddress", req, res); err != nil { - return nil, nil, err - } - if res.Address != "" { - retAddress, err = types.ParseCIDR(res.Address) - } else { - return nil, nil, ipamapi.ErrNoIPReturned - } - return retAddress, res.Data, err -} - -// ReleaseAddress releases the address from the specified address pool -func (a *allocator) ReleaseAddress(poolID string, address net.IP) error { - var relAddress string - if address != nil { - relAddress = address.String() - } - req := &api.ReleaseAddressRequest{PoolID: poolID, Address: relAddress} - res := &api.ReleaseAddressResponse{} - return a.call("ReleaseAddress", req, res) -} - -func (a *allocator) IsBuiltIn() bool { - return false -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipams/windowsipam/windowsipam.go b/vendor/github.com/docker/docker/libnetwork/ipams/windowsipam/windowsipam.go deleted file mode 100644 index be112d70bc..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipams/windowsipam/windowsipam.go +++ /dev/null @@ -1,86 +0,0 @@ -package windowsipam - -import ( - "context" - "net" - - "github.com/containerd/containerd/log" - "github.com/docker/docker/libnetwork/ipamapi" - "github.com/docker/docker/libnetwork/types" -) - -const ( - localAddressSpace = "LocalDefault" - globalAddressSpace = "GlobalDefault" -) - -// DefaultIPAM defines the default ipam-driver for local-scoped windows networks -const DefaultIPAM = "windows" - -var defaultPool, _ = types.ParseCIDR("0.0.0.0/0") - -type allocator struct{} - -// Register registers the built-in ipam service with libnetwork -func Register(ipamName string, r ipamapi.Registerer) error { - return r.RegisterIpamDriver(ipamName, &allocator{}) -} - -func (a *allocator) GetDefaultAddressSpaces() (string, string, error) { - return localAddressSpace, globalAddressSpace, nil -} - -// RequestPool returns an address pool along with its unique id. This is a null ipam driver. It allocates the -// subnet user asked and does not validate anything. Doesn't support subpool allocation -func (a *allocator) RequestPool(addressSpace, requestedPool, requestedSubPool string, options map[string]string, v6 bool) (string, *net.IPNet, map[string]string, error) { - log.G(context.TODO()).Debugf("RequestPool(%s, %s, %s, %v, %t)", addressSpace, requestedPool, requestedSubPool, options, v6) - if requestedSubPool != "" || v6 { - return "", nil, nil, types.InternalErrorf("This request is not supported by null ipam driver") - } - - var ipNet *net.IPNet - var err error - - if requestedPool != "" { - _, ipNet, err = net.ParseCIDR(requestedPool) - if err != nil { - return "", nil, nil, err - } - } else { - ipNet = defaultPool - } - - return ipNet.String(), ipNet, nil, nil -} - -// ReleasePool releases the address pool - always succeeds -func (a *allocator) ReleasePool(poolID string) error { - log.G(context.TODO()).Debugf("ReleasePool(%s)", poolID) - return nil -} - -// RequestAddress returns an address from the specified pool ID. -// Always allocate the 0.0.0.0/32 ip if no preferred address was specified -func (a *allocator) RequestAddress(poolID string, prefAddress net.IP, opts map[string]string) (*net.IPNet, map[string]string, error) { - log.G(context.TODO()).Debugf("RequestAddress(%s, %v, %v)", poolID, prefAddress, opts) - _, ipNet, err := net.ParseCIDR(poolID) - if err != nil { - return nil, nil, err - } - - if prefAddress != nil { - return &net.IPNet{IP: prefAddress, Mask: ipNet.Mask}, nil, nil - } - - return nil, nil, nil -} - -// ReleaseAddress releases the address - always succeeds -func (a *allocator) ReleaseAddress(poolID string, address net.IP) error { - log.G(context.TODO()).Debugf("ReleaseAddress(%s, %v)", poolID, address) - return nil -} - -func (a *allocator) IsBuiltIn() bool { - return true -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipamutils/utils.go b/vendor/github.com/docker/docker/libnetwork/ipamutils/utils.go deleted file mode 100644 index 107f80755d..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipamutils/utils.go +++ /dev/null @@ -1,123 +0,0 @@ -// Package ipamutils provides utility functions for ipam management -package ipamutils - -import ( - "fmt" - "net" - "sync" -) - -var ( - // predefinedLocalScopeDefaultNetworks contains a list of 31 IPv4 private networks with host size 16 and 12 - // (172.17-31.x.x/16, 192.168.x.x/20) which do not overlap with the networks in `PredefinedGlobalScopeDefaultNetworks` - predefinedLocalScopeDefaultNetworks []*net.IPNet - // predefinedGlobalScopeDefaultNetworks contains a list of 64K IPv4 private networks with host size 8 - // (10.x.x.x/24) which do not overlap with the networks in `PredefinedLocalScopeDefaultNetworks` - predefinedGlobalScopeDefaultNetworks []*net.IPNet - mutex sync.Mutex - localScopeDefaultNetworks = []*NetworkToSplit{ - {"172.17.0.0/16", 16}, - {"172.18.0.0/16", 16}, - {"172.19.0.0/16", 16}, - {"172.20.0.0/14", 16}, - {"172.24.0.0/14", 16}, - {"172.28.0.0/14", 16}, - {"192.168.0.0/16", 20}, - } - globalScopeDefaultNetworks = []*NetworkToSplit{{"10.0.0.0/8", 24}} -) - -// NetworkToSplit represent a network that has to be split in chunks with mask length Size. -// Each subnet in the set is derived from the Base pool. Base is to be passed -// in CIDR format. -// Example: a Base "10.10.0.0/16 with Size 24 will define the set of 256 -// 10.10.[0-255].0/24 address pools -type NetworkToSplit struct { - Base string `json:"base"` - Size int `json:"size"` -} - -func init() { - var err error - if predefinedGlobalScopeDefaultNetworks, err = SplitNetworks(globalScopeDefaultNetworks); err != nil { - panic("failed to initialize the global scope default address pool: " + err.Error()) - } - - if predefinedLocalScopeDefaultNetworks, err = SplitNetworks(localScopeDefaultNetworks); err != nil { - panic("failed to initialize the local scope default address pool: " + err.Error()) - } -} - -// ConfigGlobalScopeDefaultNetworks configures global default pool. -// Ideally this will be called from SwarmKit as part of swarm init -func ConfigGlobalScopeDefaultNetworks(defaultAddressPool []*NetworkToSplit) error { - if defaultAddressPool == nil { - return nil - } - mutex.Lock() - defer mutex.Unlock() - defaultNetworks, err := SplitNetworks(defaultAddressPool) - if err != nil { - return err - } - predefinedGlobalScopeDefaultNetworks = defaultNetworks - return nil -} - -// GetGlobalScopeDefaultNetworks returns a copy of the global-sopce network list. -func GetGlobalScopeDefaultNetworks() []*net.IPNet { - mutex.Lock() - defer mutex.Unlock() - return append([]*net.IPNet(nil), predefinedGlobalScopeDefaultNetworks...) -} - -// GetLocalScopeDefaultNetworks returns a copy of the default local-scope network list. -func GetLocalScopeDefaultNetworks() []*net.IPNet { - return append([]*net.IPNet(nil), predefinedLocalScopeDefaultNetworks...) -} - -// SplitNetworks takes a slice of networks, split them accordingly and returns them -func SplitNetworks(list []*NetworkToSplit) ([]*net.IPNet, error) { - localPools := make([]*net.IPNet, 0, len(list)) - - for _, p := range list { - _, b, err := net.ParseCIDR(p.Base) - if err != nil { - return nil, fmt.Errorf("invalid base pool %q: %v", p.Base, err) - } - ones, _ := b.Mask.Size() - if p.Size <= 0 || p.Size < ones { - return nil, fmt.Errorf("invalid pools size: %d", p.Size) - } - localPools = append(localPools, splitNetwork(p.Size, b)...) - } - return localPools, nil -} - -func splitNetwork(size int, base *net.IPNet) []*net.IPNet { - one, bits := base.Mask.Size() - mask := net.CIDRMask(size, bits) - n := 1 << uint(size-one) - s := uint(bits - size) - list := make([]*net.IPNet, 0, n) - - for i := 0; i < n; i++ { - ip := copyIP(base.IP) - addIntToIP(ip, uint(i<= 0; i-- { - array[i] |= (byte)(ordinal & 0xff) - ordinal >>= 8 - } -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipbits/ipbits.go b/vendor/github.com/docker/docker/libnetwork/ipbits/ipbits.go deleted file mode 100644 index ab2c04ed31..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipbits/ipbits.go +++ /dev/null @@ -1,41 +0,0 @@ -// Package ipbits contains utilities for manipulating [netip.Addr] values as -// numbers or bitfields. -package ipbits - -import ( - "encoding/binary" - "net/netip" -) - -// Add returns ip + (x << shift). -func Add(ip netip.Addr, x uint64, shift uint) netip.Addr { - if ip.Is4() { - a := ip.As4() - addr := binary.BigEndian.Uint32(a[:]) - addr += uint32(x) << shift - binary.BigEndian.PutUint32(a[:], addr) - return netip.AddrFrom4(a) - } else { - a := ip.As16() - addr := uint128From16(a) - addr = addr.add(uint128From(x).lsh(shift)) - addr.fill16(&a) - return netip.AddrFrom16(a) - } -} - -// Field returns the value of the bitfield [u, v] in ip as an integer, -// where bit 0 is the most-significant bit of ip. -// -// The result is undefined if u > v, if v-u > 64, or if u or v is larger than -// ip.BitLen(). -func Field(ip netip.Addr, u, v uint) uint64 { - if ip.Is4() { - mask := ^uint32(0) >> u - a := ip.As4() - return uint64((binary.BigEndian.Uint32(a[:]) & mask) >> (32 - v)) - } else { - mask := uint128From(0).not().rsh(u) - return uint128From16(ip.As16()).and(mask).rsh(128 - v).uint64() - } -} diff --git a/vendor/github.com/docker/docker/libnetwork/ipbits/uint128.go b/vendor/github.com/docker/docker/libnetwork/ipbits/uint128.go deleted file mode 100644 index 56700d03a0..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/ipbits/uint128.go +++ /dev/null @@ -1,62 +0,0 @@ -package ipbits - -import ( - "encoding/binary" - "math/bits" -) - -type uint128 struct{ hi, lo uint64 } - -func uint128From16(b [16]byte) uint128 { - return uint128{ - hi: binary.BigEndian.Uint64(b[:8]), - lo: binary.BigEndian.Uint64(b[8:]), - } -} - -func uint128From(x uint64) uint128 { - return uint128{lo: x} -} - -func (x uint128) add(y uint128) uint128 { - lo, carry := bits.Add64(x.lo, y.lo, 0) - hi, _ := bits.Add64(x.hi, y.hi, carry) - return uint128{hi: hi, lo: lo} -} - -func (x uint128) lsh(n uint) uint128 { - if n > 64 { - return uint128{hi: x.lo << (n - 64)} - } - return uint128{ - hi: x.hi<>(64-n), - lo: x.lo << n, - } -} - -func (x uint128) rsh(n uint) uint128 { - if n > 64 { - return uint128{lo: x.hi >> (n - 64)} - } - return uint128{ - hi: x.hi >> n, - lo: x.lo>>n | x.hi<<(64-n), - } -} - -func (x uint128) and(y uint128) uint128 { - return uint128{hi: x.hi & y.hi, lo: x.lo & y.lo} -} - -func (x uint128) not() uint128 { - return uint128{hi: ^x.hi, lo: ^x.lo} -} - -func (x uint128) fill16(a *[16]byte) { - binary.BigEndian.PutUint64(a[:8], x.hi) - binary.BigEndian.PutUint64(a[8:], x.lo) -} - -func (x uint128) uint64() uint64 { - return x.lo -} diff --git a/vendor/github.com/docker/docker/libnetwork/netlabel/labels.go b/vendor/github.com/docker/docker/libnetwork/netlabel/labels.go deleted file mode 100644 index 2885addaa6..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/netlabel/labels.go +++ /dev/null @@ -1,52 +0,0 @@ -package netlabel - -const ( - // Prefix constant marks the reserved label space for libnetwork - Prefix = "com.docker.network" - - // DriverPrefix constant marks the reserved label space for libnetwork drivers - DriverPrefix = Prefix + ".driver" - - // DriverPrivatePrefix constant marks the reserved label space - // for internal libnetwork drivers - DriverPrivatePrefix = DriverPrefix + ".private" - - // GenericData constant that helps to identify an option as a Generic constant - GenericData = Prefix + ".generic" - - // PortMap constant represents Port Mapping - PortMap = Prefix + ".portmap" - - // MacAddress constant represents Mac Address config of a Container - MacAddress = Prefix + ".endpoint.macaddress" - - // ExposedPorts constant represents the container's Exposed Ports - ExposedPorts = Prefix + ".endpoint.exposedports" - - // DNSServers A list of DNS servers associated with the endpoint - DNSServers = Prefix + ".endpoint.dnsservers" - - // EnableIPv6 constant represents enabling IPV6 at network level - EnableIPv6 = Prefix + ".enable_ipv6" - - // DriverMTU constant represents the MTU size for the network driver - DriverMTU = DriverPrefix + ".mtu" - - // OverlayVxlanIDList constant represents a list of VXLAN Ids as csv - OverlayVxlanIDList = DriverPrefix + ".overlay.vxlanid_list" - - // Gateway represents the gateway for the network - Gateway = Prefix + ".gateway" - - // Internal constant represents that the network is internal which disables default gateway service - Internal = Prefix + ".internal" - - // ContainerIfacePrefix can be used to override the interface prefix used inside the container - ContainerIfacePrefix = Prefix + ".container_iface_prefix" - - // HostIP is the Source-IP Address used to SNAT container traffic - HostIP = Prefix + ".host_ipv4" - - // LocalKVClient constants represents the local kv store client - LocalKVClient = DriverPrivatePrefix + "localkv_client" -) diff --git a/vendor/github.com/docker/docker/libnetwork/scope/scope.go b/vendor/github.com/docker/docker/libnetwork/scope/scope.go deleted file mode 100644 index 4b105836f4..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/scope/scope.go +++ /dev/null @@ -1,12 +0,0 @@ -package scope - -// Data scopes. -const ( - // Local indicates to store the KV object in local datastore such as boltdb - Local = "local" - // Global indicates to store the KV object in global datastore - Global = "global" - // Swarm is not indicating a datastore location. It is defined here - // along with the other two scopes just for consistency. - Swarm = "swarm" -) diff --git a/vendor/github.com/docker/docker/libnetwork/types/types.go b/vendor/github.com/docker/docker/libnetwork/types/types.go deleted file mode 100644 index d8a80b9256..0000000000 --- a/vendor/github.com/docker/docker/libnetwork/types/types.go +++ /dev/null @@ -1,478 +0,0 @@ -// Package types contains types that are common across libnetwork project -package types - -import ( - "bytes" - "fmt" - "net" - "strconv" - "strings" - - "github.com/docker/docker/errdefs" - "github.com/ishidawataru/sctp" -) - -// constants for the IP address type -// Deprecated: use the consts defined in github.com/docker/docker/libnetwork/resolvconf -const ( - IP = iota // IPv4 and IPv6 - IPv4 - IPv6 -) - -// EncryptionKey is the libnetwork representation of the key distributed by the lead -// manager. -type EncryptionKey struct { - Subsystem string - Algorithm int32 - Key []byte - LamportTime uint64 -} - -// QosPolicy represents a quality of service policy on an endpoint -type QosPolicy struct { - MaxEgressBandwidth uint64 -} - -// TransportPort represents a local Layer 4 endpoint -type TransportPort struct { - Proto Protocol - Port uint16 -} - -// Equal checks if this instance of Transportport is equal to the passed one -func (t *TransportPort) Equal(o *TransportPort) bool { - if t == o { - return true - } - - if o == nil { - return false - } - - if t.Proto != o.Proto || t.Port != o.Port { - return false - } - - return true -} - -// GetCopy returns a copy of this TransportPort structure instance -func (t *TransportPort) GetCopy() TransportPort { - return TransportPort{Proto: t.Proto, Port: t.Port} -} - -// String returns the TransportPort structure in string form -func (t *TransportPort) String() string { - return fmt.Sprintf("%s/%d", t.Proto.String(), t.Port) -} - -// PortBinding represents a port binding between the container and the host -type PortBinding struct { - Proto Protocol - IP net.IP - Port uint16 - HostIP net.IP - HostPort uint16 - HostPortEnd uint16 -} - -// HostAddr returns the host side transport address -func (p PortBinding) HostAddr() (net.Addr, error) { - switch p.Proto { - case UDP: - return &net.UDPAddr{IP: p.HostIP, Port: int(p.HostPort)}, nil - case TCP: - return &net.TCPAddr{IP: p.HostIP, Port: int(p.HostPort)}, nil - case SCTP: - return &sctp.SCTPAddr{IPAddrs: []net.IPAddr{{IP: p.HostIP}}, Port: int(p.HostPort)}, nil - default: - return nil, fmt.Errorf("invalid transport protocol: %s", p.Proto.String()) - } -} - -// ContainerAddr returns the container side transport address -func (p PortBinding) ContainerAddr() (net.Addr, error) { - switch p.Proto { - case UDP: - return &net.UDPAddr{IP: p.IP, Port: int(p.Port)}, nil - case TCP: - return &net.TCPAddr{IP: p.IP, Port: int(p.Port)}, nil - case SCTP: - return &sctp.SCTPAddr{IPAddrs: []net.IPAddr{{IP: p.IP}}, Port: int(p.Port)}, nil - default: - return nil, fmt.Errorf("invalid transport protocol: %s", p.Proto.String()) - } -} - -// GetCopy returns a copy of this PortBinding structure instance -func (p *PortBinding) GetCopy() PortBinding { - return PortBinding{ - Proto: p.Proto, - IP: GetIPCopy(p.IP), - Port: p.Port, - HostIP: GetIPCopy(p.HostIP), - HostPort: p.HostPort, - HostPortEnd: p.HostPortEnd, - } -} - -// String returns the PortBinding structure in string form -func (p *PortBinding) String() string { - ret := fmt.Sprintf("%s/", p.Proto) - if p.IP != nil { - ret += p.IP.String() - } - ret = fmt.Sprintf("%s:%d/", ret, p.Port) - if p.HostIP != nil { - ret += p.HostIP.String() - } - ret = fmt.Sprintf("%s:%d", ret, p.HostPort) - return ret -} - -const ( - // ICMP is for the ICMP ip protocol - ICMP = 1 - // TCP is for the TCP ip protocol - TCP = 6 - // UDP is for the UDP ip protocol - UDP = 17 - // SCTP is for the SCTP ip protocol - SCTP = 132 -) - -// Protocol represents an IP protocol number -type Protocol uint8 - -func (p Protocol) String() string { - switch p { - case ICMP: - return "icmp" - case TCP: - return "tcp" - case UDP: - return "udp" - case SCTP: - return "sctp" - default: - return strconv.Itoa(int(p)) - } -} - -// ParseProtocol returns the respective Protocol type for the passed string -func ParseProtocol(s string) Protocol { - switch strings.ToLower(s) { - case "icmp": - return ICMP - case "udp": - return UDP - case "tcp": - return TCP - case "sctp": - return SCTP - default: - return 0 - } -} - -// GetMacCopy returns a copy of the passed MAC address -func GetMacCopy(from net.HardwareAddr) net.HardwareAddr { - if from == nil { - return nil - } - to := make(net.HardwareAddr, len(from)) - copy(to, from) - return to -} - -// GetIPCopy returns a copy of the passed IP address -func GetIPCopy(from net.IP) net.IP { - if from == nil { - return nil - } - to := make(net.IP, len(from)) - copy(to, from) - return to -} - -// GetIPNetCopy returns a copy of the passed IP Network -func GetIPNetCopy(from *net.IPNet) *net.IPNet { - if from == nil { - return nil - } - bm := make(net.IPMask, len(from.Mask)) - copy(bm, from.Mask) - return &net.IPNet{IP: GetIPCopy(from.IP), Mask: bm} -} - -// GetIPNetCanonical returns the canonical form for the passed network -func GetIPNetCanonical(nw *net.IPNet) *net.IPNet { - if nw == nil { - return nil - } - c := GetIPNetCopy(nw) - c.IP = c.IP.Mask(nw.Mask) - return c -} - -// CompareIPNet returns equal if the two IP Networks are equal -func CompareIPNet(a, b *net.IPNet) bool { - if a == b { - return true - } - if a == nil || b == nil { - return false - } - return a.IP.Equal(b.IP) && bytes.Equal(a.Mask, b.Mask) -} - -// IsIPNetValid returns true if the ipnet is a valid network/mask -// combination. Otherwise returns false. -func IsIPNetValid(nw *net.IPNet) bool { - return nw.String() != "0.0.0.0/0" -} - -var v4inV6MaskPrefix = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} - -// compareIPMask checks if the passed ip and mask are semantically compatible. -// It returns the byte indexes for the address and mask so that caller can -// do bitwise operations without modifying address representation. -func compareIPMask(ip net.IP, mask net.IPMask) (is int, ms int, err error) { - // Find the effective starting of address and mask - if len(ip) == net.IPv6len && ip.To4() != nil { - is = 12 - } - if len(ip[is:]) == net.IPv4len && len(mask) == net.IPv6len && bytes.Equal(mask[:12], v4inV6MaskPrefix) { - ms = 12 - } - // Check if address and mask are semantically compatible - if len(ip[is:]) != len(mask[ms:]) { - err = fmt.Errorf("ip and mask are not compatible: (%#v, %#v)", ip, mask) - } - return -} - -// GetHostPartIP returns the host portion of the ip address identified by the mask. -// IP address representation is not modified. If address and mask are not compatible -// an error is returned. -func GetHostPartIP(ip net.IP, mask net.IPMask) (net.IP, error) { - // Find the effective starting of address and mask - is, ms, err := compareIPMask(ip, mask) - if err != nil { - return nil, fmt.Errorf("cannot compute host portion ip address because %s", err) - } - - // Compute host portion - out := GetIPCopy(ip) - for i := 0; i < len(mask[ms:]); i++ { - out[is+i] &= ^mask[ms+i] - } - - return out, nil -} - -// GetBroadcastIP returns the broadcast ip address for the passed network (ip and mask). -// IP address representation is not modified. If address and mask are not compatible -// an error is returned. -func GetBroadcastIP(ip net.IP, mask net.IPMask) (net.IP, error) { - // Find the effective starting of address and mask - is, ms, err := compareIPMask(ip, mask) - if err != nil { - return nil, fmt.Errorf("cannot compute broadcast ip address because %s", err) - } - - // Compute broadcast address - out := GetIPCopy(ip) - for i := 0; i < len(mask[ms:]); i++ { - out[is+i] |= ^mask[ms+i] - } - - return out, nil -} - -// ParseCIDR returns the *net.IPNet represented by the passed CIDR notation -func ParseCIDR(cidr string) (n *net.IPNet, e error) { - var i net.IP - if i, n, e = net.ParseCIDR(cidr); e == nil { - n.IP = i - } - return -} - -const ( - // NEXTHOP indicates a StaticRoute with an IP next hop. - NEXTHOP = iota - - // CONNECTED indicates a StaticRoute with an interface for directly connected peers. - CONNECTED -) - -// StaticRoute is a statically-provisioned IP route. -type StaticRoute struct { - Destination *net.IPNet - - RouteType int // NEXT_HOP or CONNECTED - - // NextHop will be resolved by the kernel (i.e. as a loose hop). - NextHop net.IP -} - -// GetCopy returns a copy of this StaticRoute structure -func (r *StaticRoute) GetCopy() *StaticRoute { - d := GetIPNetCopy(r.Destination) - nh := GetIPCopy(r.NextHop) - return &StaticRoute{ - Destination: d, - RouteType: r.RouteType, - NextHop: nh, - } -} - -// InterfaceStatistics represents the interface's statistics -type InterfaceStatistics struct { - RxBytes uint64 - RxPackets uint64 - RxErrors uint64 - RxDropped uint64 - TxBytes uint64 - TxPackets uint64 - TxErrors uint64 - TxDropped uint64 -} - -func (is *InterfaceStatistics) String() string { - return fmt.Sprintf("\nRxBytes: %d, RxPackets: %d, RxErrors: %d, RxDropped: %d, TxBytes: %d, TxPackets: %d, TxErrors: %d, TxDropped: %d", - is.RxBytes, is.RxPackets, is.RxErrors, is.RxDropped, is.TxBytes, is.TxPackets, is.TxErrors, is.TxDropped) -} - -/****************************** - * Well-known Error Interfaces - ******************************/ - -// MaskableError is an interface for errors which can be ignored by caller -type MaskableError interface { - // Maskable makes implementer into MaskableError type - Maskable() -} - -// InvalidParameterError is an interface for errors originated by a bad request -type InvalidParameterError interface { - // InvalidParameter makes implementer into InvalidParameterError type - InvalidParameter() -} - -// NotFoundError is an interface for errors raised because a needed resource is not available -type NotFoundError interface { - // NotFound makes implementer into NotFoundError type - NotFound() -} - -// ForbiddenError is an interface for errors which denote a valid request that cannot be honored -type ForbiddenError interface { - // Forbidden makes implementer into ForbiddenError type - Forbidden() -} - -// UnavailableError is an interface for errors returned when the required service is not available -type UnavailableError interface { - // Unavailable makes implementer into UnavailableError type - Unavailable() -} - -// NotImplementedError is an interface for errors raised because of requested functionality is not yet implemented -type NotImplementedError interface { - // NotImplemented makes implementer into NotImplementedError type - NotImplemented() -} - -// InternalError is an interface for errors raised because of an internal error -type InternalError interface { - // Internal makes implementer into InternalError type - Internal() -} - -/****************************** - * Well-known Error Formatters - ******************************/ - -// InvalidParameterErrorf creates an instance of InvalidParameterError -func InvalidParameterErrorf(format string, params ...interface{}) error { - return errdefs.InvalidParameter(fmt.Errorf(format, params...)) -} - -// NotFoundErrorf creates an instance of NotFoundError -func NotFoundErrorf(format string, params ...interface{}) error { - return notFound(fmt.Sprintf(format, params...)) -} - -// ForbiddenErrorf creates an instance of ForbiddenError -func ForbiddenErrorf(format string, params ...interface{}) error { - return forbidden(fmt.Sprintf(format, params...)) -} - -// UnavailableErrorf creates an instance of UnavailableError -func UnavailableErrorf(format string, params ...interface{}) error { - return unavailable(fmt.Sprintf(format, params...)) -} - -// NotImplementedErrorf creates an instance of NotImplementedError -func NotImplementedErrorf(format string, params ...interface{}) error { - return notImpl(fmt.Sprintf(format, params...)) -} - -// InternalErrorf creates an instance of InternalError -func InternalErrorf(format string, params ...interface{}) error { - return internal(fmt.Sprintf(format, params...)) -} - -// InternalMaskableErrorf creates an instance of InternalError and MaskableError -func InternalMaskableErrorf(format string, params ...interface{}) error { - return maskInternal(fmt.Sprintf(format, params...)) -} - -/*********************** - * Internal Error Types - ***********************/ -type notFound string - -func (nf notFound) Error() string { - return string(nf) -} -func (nf notFound) NotFound() {} - -type forbidden string - -func (frb forbidden) Error() string { - return string(frb) -} -func (frb forbidden) Forbidden() {} - -type unavailable string - -func (ns unavailable) Error() string { - return string(ns) -} -func (ns unavailable) Unavailable() {} - -type notImpl string - -func (ni notImpl) Error() string { - return string(ni) -} -func (ni notImpl) NotImplemented() {} - -type internal string - -func (nt internal) Error() string { - return string(nt) -} -func (nt internal) Internal() {} - -type maskInternal string - -func (mnt maskInternal) Error() string { - return string(mnt) -} -func (mnt maskInternal) Internal() {} -func (mnt maskInternal) Maskable() {} diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir.go b/vendor/github.com/docker/docker/pkg/homedir/homedir.go deleted file mode 100644 index 590683206c..0000000000 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir.go +++ /dev/null @@ -1,44 +0,0 @@ -package homedir - -import ( - "os" - "os/user" - "runtime" -) - -// Key returns the env var name for the user's home dir based on -// the platform being run on. -// -// Deprecated: this function is no longer used, and will be removed in the next release. -func Key() string { - return envKeyName -} - -// Get returns the home directory of the current user with the help of -// environment variables depending on the target operating system. -// Returned path should be used with "path/filepath" to form new paths. -// -// On non-Windows platforms, it falls back to nss lookups, if the home -// directory cannot be obtained from environment-variables. -// -// If linking statically with cgo enabled against glibc, ensure the -// osusergo build tag is used. -// -// If needing to do nss lookups, do not disable cgo or set osusergo. -func Get() string { - home, _ := os.UserHomeDir() - if home == "" && runtime.GOOS != "windows" { - if u, err := user.Current(); err == nil { - return u.HomeDir - } - } - return home -} - -// GetShortcutString returns the string that is shortcut to user's home directory -// in the native shell of the platform running on. -// -// Deprecated: this function is no longer used, and will be removed in the next release. -func GetShortcutString() string { - return homeShortCut -} diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir_linux.go b/vendor/github.com/docker/docker/pkg/homedir/homedir_linux.go deleted file mode 100644 index ded1c7c8c6..0000000000 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir_linux.go +++ /dev/null @@ -1,105 +0,0 @@ -package homedir // import "github.com/docker/docker/pkg/homedir" - -import ( - "errors" - "os" - "path/filepath" - "strings" -) - -// GetRuntimeDir returns XDG_RUNTIME_DIR. -// XDG_RUNTIME_DIR is typically configured via pam_systemd. -// GetRuntimeDir returns non-nil error if XDG_RUNTIME_DIR is not set. -// -// See also https://standards.freedesktop.org/basedir-spec/latest/ar01s03.html -func GetRuntimeDir() (string, error) { - if xdgRuntimeDir := os.Getenv("XDG_RUNTIME_DIR"); xdgRuntimeDir != "" { - return xdgRuntimeDir, nil - } - return "", errors.New("could not get XDG_RUNTIME_DIR") -} - -// StickRuntimeDirContents sets the sticky bit on files that are under -// XDG_RUNTIME_DIR, so that the files won't be periodically removed by the system. -// -// StickyRuntimeDir returns slice of sticked files. -// StickyRuntimeDir returns nil error if XDG_RUNTIME_DIR is not set. -// -// See also https://standards.freedesktop.org/basedir-spec/latest/ar01s03.html -func StickRuntimeDirContents(files []string) ([]string, error) { - runtimeDir, err := GetRuntimeDir() - if err != nil { - // ignore error if runtimeDir is empty - return nil, nil - } - runtimeDir, err = filepath.Abs(runtimeDir) - if err != nil { - return nil, err - } - var sticked []string - for _, f := range files { - f, err = filepath.Abs(f) - if err != nil { - return sticked, err - } - if strings.HasPrefix(f, runtimeDir+"/") { - if err = stick(f); err != nil { - return sticked, err - } - sticked = append(sticked, f) - } - } - return sticked, nil -} - -func stick(f string) error { - st, err := os.Stat(f) - if err != nil { - return err - } - m := st.Mode() - m |= os.ModeSticky - return os.Chmod(f, m) -} - -// GetDataHome returns XDG_DATA_HOME. -// GetDataHome returns $HOME/.local/share and nil error if XDG_DATA_HOME is not set. -// If HOME and XDG_DATA_HOME are not set, getpwent(3) is consulted to determine the users home directory. -// -// See also https://standards.freedesktop.org/basedir-spec/latest/ar01s03.html -func GetDataHome() (string, error) { - if xdgDataHome := os.Getenv("XDG_DATA_HOME"); xdgDataHome != "" { - return xdgDataHome, nil - } - home := Get() - if home == "" { - return "", errors.New("could not get either XDG_DATA_HOME or HOME") - } - return filepath.Join(home, ".local", "share"), nil -} - -// GetConfigHome returns XDG_CONFIG_HOME. -// GetConfigHome returns $HOME/.config and nil error if XDG_CONFIG_HOME is not set. -// If HOME and XDG_CONFIG_HOME are not set, getpwent(3) is consulted to determine the users home directory. -// -// See also https://standards.freedesktop.org/basedir-spec/latest/ar01s03.html -func GetConfigHome() (string, error) { - if xdgConfigHome := os.Getenv("XDG_CONFIG_HOME"); xdgConfigHome != "" { - return xdgConfigHome, nil - } - home := Get() - if home == "" { - return "", errors.New("could not get either XDG_CONFIG_HOME or HOME") - } - return filepath.Join(home, ".config"), nil -} - -// GetLibHome returns $HOME/.local/lib -// If HOME is not set, getpwent(3) is consulted to determine the users home directory. -func GetLibHome() (string, error) { - home := Get() - if home == "" { - return "", errors.New("could not get HOME") - } - return filepath.Join(home, ".local/lib"), nil -} diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go b/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go deleted file mode 100644 index 4eeb26b5dc..0000000000 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir_others.go +++ /dev/null @@ -1,32 +0,0 @@ -//go:build !linux - -package homedir // import "github.com/docker/docker/pkg/homedir" - -import ( - "errors" -) - -// GetRuntimeDir is unsupported on non-linux system. -func GetRuntimeDir() (string, error) { - return "", errors.New("homedir.GetRuntimeDir() is not supported on this system") -} - -// StickRuntimeDirContents is unsupported on non-linux system. -func StickRuntimeDirContents(files []string) ([]string, error) { - return nil, errors.New("homedir.StickRuntimeDirContents() is not supported on this system") -} - -// GetDataHome is unsupported on non-linux system. -func GetDataHome() (string, error) { - return "", errors.New("homedir.GetDataHome() is not supported on this system") -} - -// GetConfigHome is unsupported on non-linux system. -func GetConfigHome() (string, error) { - return "", errors.New("homedir.GetConfigHome() is not supported on this system") -} - -// GetLibHome is unsupported on non-linux system. -func GetLibHome() (string, error) { - return "", errors.New("homedir.GetLibHome() is not supported on this system") -} diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go b/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go deleted file mode 100644 index feae4d736c..0000000000 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir_unix.go +++ /dev/null @@ -1,8 +0,0 @@ -//go:build !windows - -package homedir // import "github.com/docker/docker/pkg/homedir" - -const ( - envKeyName = "HOME" - homeShortCut = "~" -) diff --git a/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go b/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go deleted file mode 100644 index 37f4ee6701..0000000000 --- a/vendor/github.com/docker/docker/pkg/homedir/homedir_windows.go +++ /dev/null @@ -1,6 +0,0 @@ -package homedir // import "github.com/docker/docker/pkg/homedir" - -const ( - envKeyName = "USERPROFILE" - homeShortCut = "%USERPROFILE%" // be careful while using in format functions -) diff --git a/vendor/github.com/docker/docker/pkg/ioutils/buffer.go b/vendor/github.com/docker/docker/pkg/ioutils/buffer.go deleted file mode 100644 index 466f79294b..0000000000 --- a/vendor/github.com/docker/docker/pkg/ioutils/buffer.go +++ /dev/null @@ -1,51 +0,0 @@ -package ioutils // import "github.com/docker/docker/pkg/ioutils" - -import ( - "errors" - "io" -) - -var errBufferFull = errors.New("buffer is full") - -type fixedBuffer struct { - buf []byte - pos int - lastRead int -} - -func (b *fixedBuffer) Write(p []byte) (int, error) { - n := copy(b.buf[b.pos:cap(b.buf)], p) - b.pos += n - - if n < len(p) { - if b.pos == cap(b.buf) { - return n, errBufferFull - } - return n, io.ErrShortWrite - } - return n, nil -} - -func (b *fixedBuffer) Read(p []byte) (int, error) { - n := copy(p, b.buf[b.lastRead:b.pos]) - b.lastRead += n - return n, nil -} - -func (b *fixedBuffer) Len() int { - return b.pos - b.lastRead -} - -func (b *fixedBuffer) Cap() int { - return cap(b.buf) -} - -func (b *fixedBuffer) Reset() { - b.pos = 0 - b.lastRead = 0 - b.buf = b.buf[:0] -} - -func (b *fixedBuffer) String() string { - return string(b.buf[b.lastRead:b.pos]) -} diff --git a/vendor/github.com/docker/docker/pkg/ioutils/bytespipe.go b/vendor/github.com/docker/docker/pkg/ioutils/bytespipe.go deleted file mode 100644 index c1cfa62fd2..0000000000 --- a/vendor/github.com/docker/docker/pkg/ioutils/bytespipe.go +++ /dev/null @@ -1,187 +0,0 @@ -package ioutils // import "github.com/docker/docker/pkg/ioutils" - -import ( - "errors" - "io" - "sync" -) - -// maxCap is the highest capacity to use in byte slices that buffer data. -const maxCap = 1e6 - -// minCap is the lowest capacity to use in byte slices that buffer data -const minCap = 64 - -// blockThreshold is the minimum number of bytes in the buffer which will cause -// a write to BytesPipe to block when allocating a new slice. -const blockThreshold = 1e6 - -var ( - // ErrClosed is returned when Write is called on a closed BytesPipe. - ErrClosed = errors.New("write to closed BytesPipe") - - bufPools = make(map[int]*sync.Pool) - bufPoolsLock sync.Mutex -) - -// BytesPipe is io.ReadWriteCloser which works similarly to pipe(queue). -// All written data may be read at most once. Also, BytesPipe allocates -// and releases new byte slices to adjust to current needs, so the buffer -// won't be overgrown after peak loads. -type BytesPipe struct { - mu sync.Mutex - wait *sync.Cond - buf []*fixedBuffer - bufLen int - closeErr error // error to return from next Read. set to nil if not closed. - readBlock bool // check read BytesPipe is Wait() or not -} - -// NewBytesPipe creates new BytesPipe, initialized by specified slice. -// If buf is nil, then it will be initialized with slice which cap is 64. -// buf will be adjusted in a way that len(buf) == 0, cap(buf) == cap(buf). -func NewBytesPipe() *BytesPipe { - bp := &BytesPipe{} - bp.buf = append(bp.buf, getBuffer(minCap)) - bp.wait = sync.NewCond(&bp.mu) - return bp -} - -// Write writes p to BytesPipe. -// It can allocate new []byte slices in a process of writing. -func (bp *BytesPipe) Write(p []byte) (int, error) { - bp.mu.Lock() - defer bp.mu.Unlock() - - written := 0 -loop0: - for { - if bp.closeErr != nil { - return written, ErrClosed - } - - if len(bp.buf) == 0 { - bp.buf = append(bp.buf, getBuffer(64)) - } - // get the last buffer - b := bp.buf[len(bp.buf)-1] - - n, err := b.Write(p) - written += n - bp.bufLen += n - - // errBufferFull is an error we expect to get if the buffer is full - if err != nil && err != errBufferFull { - bp.wait.Broadcast() - return written, err - } - - // if there was enough room to write all then break - if len(p) == n { - break - } - - // more data: write to the next slice - p = p[n:] - - // make sure the buffer doesn't grow too big from this write - for bp.bufLen >= blockThreshold { - if bp.readBlock { - bp.wait.Broadcast() - } - bp.wait.Wait() - if bp.closeErr != nil { - continue loop0 - } - } - - // add new byte slice to the buffers slice and continue writing - nextCap := b.Cap() * 2 - if nextCap > maxCap { - nextCap = maxCap - } - bp.buf = append(bp.buf, getBuffer(nextCap)) - } - bp.wait.Broadcast() - return written, nil -} - -// CloseWithError causes further reads from a BytesPipe to return immediately. -func (bp *BytesPipe) CloseWithError(err error) error { - bp.mu.Lock() - if err != nil { - bp.closeErr = err - } else { - bp.closeErr = io.EOF - } - bp.wait.Broadcast() - bp.mu.Unlock() - return nil -} - -// Close causes further reads from a BytesPipe to return immediately. -func (bp *BytesPipe) Close() error { - return bp.CloseWithError(nil) -} - -// Read reads bytes from BytesPipe. -// Data could be read only once. -func (bp *BytesPipe) Read(p []byte) (n int, err error) { - bp.mu.Lock() - defer bp.mu.Unlock() - if bp.bufLen == 0 { - if bp.closeErr != nil { - return 0, bp.closeErr - } - bp.readBlock = true - bp.wait.Wait() - bp.readBlock = false - if bp.bufLen == 0 && bp.closeErr != nil { - return 0, bp.closeErr - } - } - - for bp.bufLen > 0 { - b := bp.buf[0] - read, _ := b.Read(p) // ignore error since fixedBuffer doesn't really return an error - n += read - bp.bufLen -= read - - if b.Len() == 0 { - // it's empty so return it to the pool and move to the next one - returnBuffer(b) - bp.buf[0] = nil - bp.buf = bp.buf[1:] - } - - if len(p) == read { - break - } - - p = p[read:] - } - - bp.wait.Broadcast() - return -} - -func returnBuffer(b *fixedBuffer) { - b.Reset() - bufPoolsLock.Lock() - pool := bufPools[b.Cap()] - bufPoolsLock.Unlock() - if pool != nil { - pool.Put(b) - } -} - -func getBuffer(size int) *fixedBuffer { - bufPoolsLock.Lock() - pool, ok := bufPools[size] - if !ok { - pool = &sync.Pool{New: func() interface{} { return &fixedBuffer{buf: make([]byte, 0, size)} }} - bufPools[size] = pool - } - bufPoolsLock.Unlock() - return pool.Get().(*fixedBuffer) -} diff --git a/vendor/github.com/docker/docker/pkg/ioutils/fswriters.go b/vendor/github.com/docker/docker/pkg/ioutils/fswriters.go deleted file mode 100644 index 82671d8cd5..0000000000 --- a/vendor/github.com/docker/docker/pkg/ioutils/fswriters.go +++ /dev/null @@ -1,161 +0,0 @@ -package ioutils // import "github.com/docker/docker/pkg/ioutils" - -import ( - "io" - "os" - "path/filepath" -) - -// NewAtomicFileWriter returns WriteCloser so that writing to it writes to a -// temporary file and closing it atomically changes the temporary file to -// destination path. Writing and closing concurrently is not allowed. -func NewAtomicFileWriter(filename string, perm os.FileMode) (io.WriteCloser, error) { - f, err := os.CreateTemp(filepath.Dir(filename), ".tmp-"+filepath.Base(filename)) - if err != nil { - return nil, err - } - - abspath, err := filepath.Abs(filename) - if err != nil { - return nil, err - } - return &atomicFileWriter{ - f: f, - fn: abspath, - perm: perm, - }, nil -} - -// AtomicWriteFile atomically writes data to a file named by filename. -func AtomicWriteFile(filename string, data []byte, perm os.FileMode) error { - f, err := NewAtomicFileWriter(filename, perm) - if err != nil { - return err - } - n, err := f.Write(data) - if err == nil && n < len(data) { - err = io.ErrShortWrite - f.(*atomicFileWriter).writeErr = err - } - if err1 := f.Close(); err == nil { - err = err1 - } - return err -} - -type atomicFileWriter struct { - f *os.File - fn string - writeErr error - perm os.FileMode -} - -func (w *atomicFileWriter) Write(dt []byte) (int, error) { - n, err := w.f.Write(dt) - if err != nil { - w.writeErr = err - } - return n, err -} - -func (w *atomicFileWriter) Close() (retErr error) { - defer func() { - if retErr != nil || w.writeErr != nil { - os.Remove(w.f.Name()) - } - }() - if err := w.f.Sync(); err != nil { - w.f.Close() - return err - } - if err := w.f.Close(); err != nil { - return err - } - if err := os.Chmod(w.f.Name(), w.perm); err != nil { - return err - } - if w.writeErr == nil { - return os.Rename(w.f.Name(), w.fn) - } - return nil -} - -// AtomicWriteSet is used to atomically write a set -// of files and ensure they are visible at the same time. -// Must be committed to a new directory. -type AtomicWriteSet struct { - root string -} - -// NewAtomicWriteSet creates a new atomic write set to -// atomically create a set of files. The given directory -// is used as the base directory for storing files before -// commit. If no temporary directory is given the system -// default is used. -func NewAtomicWriteSet(tmpDir string) (*AtomicWriteSet, error) { - td, err := os.MkdirTemp(tmpDir, "write-set-") - if err != nil { - return nil, err - } - - return &AtomicWriteSet{ - root: td, - }, nil -} - -// WriteFile writes a file to the set, guaranteeing the file -// has been synced. -func (ws *AtomicWriteSet) WriteFile(filename string, data []byte, perm os.FileMode) error { - f, err := ws.FileWriter(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm) - if err != nil { - return err - } - n, err := f.Write(data) - if err == nil && n < len(data) { - err = io.ErrShortWrite - } - if err1 := f.Close(); err == nil { - err = err1 - } - return err -} - -type syncFileCloser struct { - *os.File -} - -func (w syncFileCloser) Close() error { - err := w.File.Sync() - if err1 := w.File.Close(); err == nil { - err = err1 - } - return err -} - -// FileWriter opens a file writer inside the set. The file -// should be synced and closed before calling commit. -func (ws *AtomicWriteSet) FileWriter(name string, flag int, perm os.FileMode) (io.WriteCloser, error) { - f, err := os.OpenFile(filepath.Join(ws.root, name), flag, perm) - if err != nil { - return nil, err - } - return syncFileCloser{f}, nil -} - -// Cancel cancels the set and removes all temporary data -// created in the set. -func (ws *AtomicWriteSet) Cancel() error { - return os.RemoveAll(ws.root) -} - -// Commit moves all created files to the target directory. The -// target directory must not exist and the parent of the target -// directory must exist. -func (ws *AtomicWriteSet) Commit(target string) error { - return os.Rename(ws.root, target) -} - -// String returns the location the set is writing to. -func (ws *AtomicWriteSet) String() string { - return ws.root -} diff --git a/vendor/github.com/docker/docker/pkg/ioutils/readers.go b/vendor/github.com/docker/docker/pkg/ioutils/readers.go deleted file mode 100644 index de00b95e3f..0000000000 --- a/vendor/github.com/docker/docker/pkg/ioutils/readers.go +++ /dev/null @@ -1,151 +0,0 @@ -package ioutils // import "github.com/docker/docker/pkg/ioutils" - -import ( - "context" - "io" - - // make sure crypto.SHA256, crypto.sha512 and crypto.SHA384 are registered - // TODO remove once https://github.com/opencontainers/go-digest/pull/64 is merged. - _ "crypto/sha256" - _ "crypto/sha512" -) - -// ReadCloserWrapper wraps an io.Reader, and implements an io.ReadCloser -// It calls the given callback function when closed. It should be constructed -// with NewReadCloserWrapper -type ReadCloserWrapper struct { - io.Reader - closer func() error -} - -// Close calls back the passed closer function -func (r *ReadCloserWrapper) Close() error { - return r.closer() -} - -// NewReadCloserWrapper returns a new io.ReadCloser. -func NewReadCloserWrapper(r io.Reader, closer func() error) io.ReadCloser { - return &ReadCloserWrapper{ - Reader: r, - closer: closer, - } -} - -type readerErrWrapper struct { - reader io.Reader - closer func() -} - -func (r *readerErrWrapper) Read(p []byte) (int, error) { - n, err := r.reader.Read(p) - if err != nil { - r.closer() - } - return n, err -} - -// NewReaderErrWrapper returns a new io.Reader. -func NewReaderErrWrapper(r io.Reader, closer func()) io.Reader { - return &readerErrWrapper{ - reader: r, - closer: closer, - } -} - -// OnEOFReader wraps an io.ReadCloser and a function -// the function will run at the end of file or close the file. -type OnEOFReader struct { - Rc io.ReadCloser - Fn func() -} - -func (r *OnEOFReader) Read(p []byte) (n int, err error) { - n, err = r.Rc.Read(p) - if err == io.EOF { - r.runFunc() - } - return -} - -// Close closes the file and run the function. -func (r *OnEOFReader) Close() error { - err := r.Rc.Close() - r.runFunc() - return err -} - -func (r *OnEOFReader) runFunc() { - if fn := r.Fn; fn != nil { - fn() - r.Fn = nil - } -} - -// cancelReadCloser wraps an io.ReadCloser with a context for cancelling read -// operations. -type cancelReadCloser struct { - cancel func() - pR *io.PipeReader // Stream to read from - pW *io.PipeWriter -} - -// NewCancelReadCloser creates a wrapper that closes the ReadCloser when the -// context is cancelled. The returned io.ReadCloser must be closed when it is -// no longer needed. -func NewCancelReadCloser(ctx context.Context, in io.ReadCloser) io.ReadCloser { - pR, pW := io.Pipe() - - // Create a context used to signal when the pipe is closed - doneCtx, cancel := context.WithCancel(context.Background()) - - p := &cancelReadCloser{ - cancel: cancel, - pR: pR, - pW: pW, - } - - go func() { - _, err := io.Copy(pW, in) - select { - case <-ctx.Done(): - // If the context was closed, p.closeWithError - // was already called. Calling it again would - // change the error that Read returns. - default: - p.closeWithError(err) - } - in.Close() - }() - go func() { - for { - select { - case <-ctx.Done(): - p.closeWithError(ctx.Err()) - case <-doneCtx.Done(): - return - } - } - }() - - return p -} - -// Read wraps the Read method of the pipe that provides data from the wrapped -// ReadCloser. -func (p *cancelReadCloser) Read(buf []byte) (n int, err error) { - return p.pR.Read(buf) -} - -// closeWithError closes the wrapper and its underlying reader. It will -// cause future calls to Read to return err. -func (p *cancelReadCloser) closeWithError(err error) { - p.pW.CloseWithError(err) - p.cancel() -} - -// Close closes the wrapper its underlying reader. It will cause -// future calls to Read to return io.EOF. -func (p *cancelReadCloser) Close() error { - p.closeWithError(io.EOF) - return nil -} diff --git a/vendor/github.com/docker/docker/pkg/ioutils/writeflusher.go b/vendor/github.com/docker/docker/pkg/ioutils/writeflusher.go deleted file mode 100644 index 91b8d18266..0000000000 --- a/vendor/github.com/docker/docker/pkg/ioutils/writeflusher.go +++ /dev/null @@ -1,92 +0,0 @@ -package ioutils // import "github.com/docker/docker/pkg/ioutils" - -import ( - "io" - "sync" -) - -// WriteFlusher wraps the Write and Flush operation ensuring that every write -// is a flush. In addition, the Close method can be called to intercept -// Read/Write calls if the targets lifecycle has already ended. -type WriteFlusher struct { - w io.Writer - flusher flusher - flushed chan struct{} - flushedOnce sync.Once - closed chan struct{} - closeLock sync.Mutex -} - -type flusher interface { - Flush() -} - -var errWriteFlusherClosed = io.EOF - -func (wf *WriteFlusher) Write(b []byte) (n int, err error) { - select { - case <-wf.closed: - return 0, errWriteFlusherClosed - default: - } - - n, err = wf.w.Write(b) - wf.Flush() // every write is a flush. - return n, err -} - -// Flush the stream immediately. -func (wf *WriteFlusher) Flush() { - select { - case <-wf.closed: - return - default: - } - - wf.flushedOnce.Do(func() { - close(wf.flushed) - }) - wf.flusher.Flush() -} - -// Flushed returns the state of flushed. -// If it's flushed, return true, or else it return false. -func (wf *WriteFlusher) Flushed() bool { - // BUG(stevvooe): Remove this method. Its use is inherently racy. Seems to - // be used to detect whether or a response code has been issued or not. - // Another hook should be used instead. - var flushed bool - select { - case <-wf.flushed: - flushed = true - default: - } - return flushed -} - -// Close closes the write flusher, disallowing any further writes to the -// target. After the flusher is closed, all calls to write or flush will -// result in an error. -func (wf *WriteFlusher) Close() error { - wf.closeLock.Lock() - defer wf.closeLock.Unlock() - - select { - case <-wf.closed: - return errWriteFlusherClosed - default: - close(wf.closed) - } - return nil -} - -// NewWriteFlusher returns a new WriteFlusher. -func NewWriteFlusher(w io.Writer) *WriteFlusher { - var fl flusher - if f, ok := w.(flusher); ok { - fl = f - } else { - fl = &NopFlusher{} - } - return &WriteFlusher{w: w, flusher: fl, closed: make(chan struct{}), flushed: make(chan struct{})} -} diff --git a/vendor/github.com/docker/docker/pkg/ioutils/writers.go b/vendor/github.com/docker/docker/pkg/ioutils/writers.go deleted file mode 100644 index 61c679497d..0000000000 --- a/vendor/github.com/docker/docker/pkg/ioutils/writers.go +++ /dev/null @@ -1,66 +0,0 @@ -package ioutils // import "github.com/docker/docker/pkg/ioutils" - -import "io" - -// NopWriter represents a type which write operation is nop. -type NopWriter struct{} - -func (*NopWriter) Write(buf []byte) (int, error) { - return len(buf), nil -} - -type nopWriteCloser struct { - io.Writer -} - -func (w *nopWriteCloser) Close() error { return nil } - -// NopWriteCloser returns a nopWriteCloser. -func NopWriteCloser(w io.Writer) io.WriteCloser { - return &nopWriteCloser{w} -} - -// NopFlusher represents a type which flush operation is nop. -type NopFlusher struct{} - -// Flush is a nop operation. -func (f *NopFlusher) Flush() {} - -type writeCloserWrapper struct { - io.Writer - closer func() error -} - -func (r *writeCloserWrapper) Close() error { - return r.closer() -} - -// NewWriteCloserWrapper returns a new io.WriteCloser. -func NewWriteCloserWrapper(r io.Writer, closer func() error) io.WriteCloser { - return &writeCloserWrapper{ - Writer: r, - closer: closer, - } -} - -// WriteCounter wraps a concrete io.Writer and hold a count of the number -// of bytes written to the writer during a "session". -// This can be convenient when write return is masked -// (e.g., json.Encoder.Encode()) -type WriteCounter struct { - Count int64 - Writer io.Writer -} - -// NewWriteCounter returns a new WriteCounter. -func NewWriteCounter(w io.Writer) *WriteCounter { - return &WriteCounter{ - Writer: w, - } -} - -func (wc *WriteCounter) Write(p []byte) (count int, err error) { - count, err = wc.Writer.Write(p) - wc.Count += int64(count) - return -} diff --git a/vendor/github.com/docker/docker/pkg/plugingetter/getter.go b/vendor/github.com/docker/docker/pkg/plugingetter/getter.go deleted file mode 100644 index 370e0d5b97..0000000000 --- a/vendor/github.com/docker/docker/pkg/plugingetter/getter.go +++ /dev/null @@ -1,52 +0,0 @@ -package plugingetter // import "github.com/docker/docker/pkg/plugingetter" - -import ( - "net" - "time" - - "github.com/docker/docker/pkg/plugins" -) - -const ( - // Lookup doesn't update RefCount - Lookup = 0 - // Acquire increments RefCount - Acquire = 1 - // Release decrements RefCount - Release = -1 -) - -// CompatPlugin is an abstraction to handle both v2(new) and v1(legacy) plugins. -type CompatPlugin interface { - Name() string - ScopedPath(string) string - IsV1() bool - PluginWithV1Client -} - -// PluginWithV1Client is a plugin that directly utilizes the v1/http plugin client -type PluginWithV1Client interface { - Client() *plugins.Client -} - -// PluginAddr is a plugin that exposes the socket address for creating custom clients rather than the built-in `*plugins.Client` -type PluginAddr interface { - Addr() net.Addr - Timeout() time.Duration - Protocol() string -} - -// CountedPlugin is a plugin which is reference counted. -type CountedPlugin interface { - Acquire() - Release() - CompatPlugin -} - -// PluginGetter is the interface implemented by Store -type PluginGetter interface { - Get(name, capability string, mode int) (CompatPlugin, error) - GetAllByCap(capability string) ([]CompatPlugin, error) - GetAllManagedPluginsByCap(capability string) []CompatPlugin - Handle(capability string, callback func(string, *plugins.Client)) -} diff --git a/vendor/github.com/docker/docker/pkg/plugins/client.go b/vendor/github.com/docker/docker/pkg/plugins/client.go deleted file mode 100644 index 4cde40da68..0000000000 --- a/vendor/github.com/docker/docker/pkg/plugins/client.go +++ /dev/null @@ -1,270 +0,0 @@ -package plugins // import "github.com/docker/docker/pkg/plugins" - -import ( - "bytes" - "context" - "encoding/json" - "io" - "net/http" - "net/url" - "time" - - "github.com/containerd/containerd/log" - "github.com/docker/docker/pkg/ioutils" - "github.com/docker/docker/pkg/plugins/transport" - "github.com/docker/go-connections/sockets" - "github.com/docker/go-connections/tlsconfig" -) - -const ( - defaultTimeOut = 30 - - // dummyHost is a hostname used for local communication. - // - // For local communications (npipe://, unix://), the hostname is not used, - // but we need valid and meaningful hostname. - dummyHost = "plugin.moby.localhost" -) - -// VersionMimetype is the Content-Type the engine sends to plugins. -const VersionMimetype = transport.VersionMimetype - -func newTransport(addr string, tlsConfig *tlsconfig.Options) (*transport.HTTPTransport, error) { - tr := &http.Transport{} - - if tlsConfig != nil { - c, err := tlsconfig.Client(*tlsConfig) - if err != nil { - return nil, err - } - tr.TLSClientConfig = c - } - - u, err := url.Parse(addr) - if err != nil { - return nil, err - } - socket := u.Host - if socket == "" { - // valid local socket addresses have the host empty. - socket = u.Path - } - if err := sockets.ConfigureTransport(tr, u.Scheme, socket); err != nil { - return nil, err - } - scheme := httpScheme(u) - hostName := u.Host - if hostName == "" || u.Scheme == "unix" || u.Scheme == "npipe" { - // Override host header for non-tcp connections. - hostName = dummyHost - } - return transport.NewHTTPTransport(tr, scheme, hostName), nil -} - -// NewClient creates a new plugin client (http). -func NewClient(addr string, tlsConfig *tlsconfig.Options) (*Client, error) { - clientTransport, err := newTransport(addr, tlsConfig) - if err != nil { - return nil, err - } - return newClientWithTransport(clientTransport, 0), nil -} - -// NewClientWithTimeout creates a new plugin client (http). -func NewClientWithTimeout(addr string, tlsConfig *tlsconfig.Options, timeout time.Duration) (*Client, error) { - clientTransport, err := newTransport(addr, tlsConfig) - if err != nil { - return nil, err - } - return newClientWithTransport(clientTransport, timeout), nil -} - -// newClientWithTransport creates a new plugin client with a given transport. -func newClientWithTransport(tr *transport.HTTPTransport, timeout time.Duration) *Client { - return &Client{ - http: &http.Client{ - Transport: tr, - Timeout: timeout, - }, - requestFactory: tr, - } -} - -// requestFactory defines an interface that transports can implement to -// create new requests. It's used in testing. -type requestFactory interface { - NewRequest(path string, data io.Reader) (*http.Request, error) -} - -// Client represents a plugin client. -type Client struct { - http *http.Client // http client to use - requestFactory requestFactory -} - -// RequestOpts is the set of options that can be passed into a request -type RequestOpts struct { - Timeout time.Duration - - // testTimeOut is used during tests to limit the max timeout in [abort] - testTimeOut int -} - -// WithRequestTimeout sets a timeout duration for plugin requests -func WithRequestTimeout(t time.Duration) func(*RequestOpts) { - return func(o *RequestOpts) { - o.Timeout = t - } -} - -// Call calls the specified method with the specified arguments for the plugin. -// It will retry for 30 seconds if a failure occurs when calling. -func (c *Client) Call(serviceMethod string, args, ret interface{}) error { - return c.CallWithOptions(serviceMethod, args, ret) -} - -// CallWithOptions is just like call except it takes options -func (c *Client) CallWithOptions(serviceMethod string, args interface{}, ret interface{}, opts ...func(*RequestOpts)) error { - var buf bytes.Buffer - if args != nil { - if err := json.NewEncoder(&buf).Encode(args); err != nil { - return err - } - } - body, err := c.callWithRetry(serviceMethod, &buf, true, opts...) - if err != nil { - return err - } - defer body.Close() - if ret != nil { - if err := json.NewDecoder(body).Decode(&ret); err != nil { - log.G(context.TODO()).Errorf("%s: error reading plugin resp: %v", serviceMethod, err) - return err - } - } - return nil -} - -// Stream calls the specified method with the specified arguments for the plugin and returns the response body -func (c *Client) Stream(serviceMethod string, args interface{}) (io.ReadCloser, error) { - var buf bytes.Buffer - if err := json.NewEncoder(&buf).Encode(args); err != nil { - return nil, err - } - return c.callWithRetry(serviceMethod, &buf, true) -} - -// SendFile calls the specified method, and passes through the IO stream -func (c *Client) SendFile(serviceMethod string, data io.Reader, ret interface{}) error { - body, err := c.callWithRetry(serviceMethod, data, true) - if err != nil { - return err - } - defer body.Close() - if err := json.NewDecoder(body).Decode(&ret); err != nil { - log.G(context.TODO()).Errorf("%s: error reading plugin resp: %v", serviceMethod, err) - return err - } - return nil -} - -func (c *Client) callWithRetry(serviceMethod string, data io.Reader, retry bool, reqOpts ...func(*RequestOpts)) (io.ReadCloser, error) { - var retries int - start := time.Now() - - var opts RequestOpts - for _, o := range reqOpts { - o(&opts) - } - - for { - req, err := c.requestFactory.NewRequest(serviceMethod, data) - if err != nil { - return nil, err - } - - cancelRequest := func() {} - if opts.Timeout > 0 { - var ctx context.Context - ctx, cancelRequest = context.WithTimeout(req.Context(), opts.Timeout) - req = req.WithContext(ctx) - } - - resp, err := c.http.Do(req) - if err != nil { - cancelRequest() - if !retry { - return nil, err - } - - timeOff := backoff(retries) - if abort(start, timeOff, opts.testTimeOut) { - return nil, err - } - retries++ - log.G(context.TODO()).Warnf("Unable to connect to plugin: %s%s: %v, retrying in %v", req.URL.Host, req.URL.Path, err, timeOff) - time.Sleep(timeOff) - continue - } - - if resp.StatusCode != http.StatusOK { - b, err := io.ReadAll(resp.Body) - resp.Body.Close() - cancelRequest() - if err != nil { - return nil, &statusError{resp.StatusCode, serviceMethod, err.Error()} - } - - // Plugins' Response(s) should have an Err field indicating what went - // wrong. Try to unmarshal into ResponseErr. Otherwise fallback to just - // return the string(body) - type responseErr struct { - Err string - } - remoteErr := responseErr{} - if err := json.Unmarshal(b, &remoteErr); err == nil { - if remoteErr.Err != "" { - return nil, &statusError{resp.StatusCode, serviceMethod, remoteErr.Err} - } - } - // old way... - return nil, &statusError{resp.StatusCode, serviceMethod, string(b)} - } - return ioutils.NewReadCloserWrapper(resp.Body, func() error { - err := resp.Body.Close() - cancelRequest() - return err - }), nil - } -} - -func backoff(retries int) time.Duration { - b, maxTimeout := 1, defaultTimeOut - for b < maxTimeout && retries > 0 { - b *= 2 - retries-- - } - if b > maxTimeout { - b = maxTimeout - } - return time.Duration(b) * time.Second -} - -// testNonExistingPlugin is a special plugin-name, which overrides defaultTimeOut in tests. -const testNonExistingPlugin = "this-plugin-does-not-exist" - -func abort(start time.Time, timeOff time.Duration, overrideTimeout int) bool { - to := defaultTimeOut - if overrideTimeout > 0 { - to = overrideTimeout - } - return timeOff+time.Since(start) >= time.Duration(to)*time.Second -} - -func httpScheme(u *url.URL) string { - scheme := u.Scheme - if scheme != "https" { - scheme = "http" - } - return scheme -} diff --git a/vendor/github.com/docker/docker/pkg/plugins/discovery.go b/vendor/github.com/docker/docker/pkg/plugins/discovery.go deleted file mode 100644 index 37316ed482..0000000000 --- a/vendor/github.com/docker/docker/pkg/plugins/discovery.go +++ /dev/null @@ -1,178 +0,0 @@ -package plugins // import "github.com/docker/docker/pkg/plugins" - -import ( - "encoding/json" - "fmt" - "io/fs" - "net/url" - "os" - "path/filepath" - "strings" - "sync" - - "github.com/pkg/errors" -) - -// ErrNotFound plugin not found -var ErrNotFound = errors.New("plugin not found") - -const defaultSocketsPath = "/run/docker/plugins" - -// LocalRegistry defines a registry that is local (using unix socket). -type LocalRegistry struct { - socketsPath string - specsPaths []string -} - -func NewLocalRegistry() LocalRegistry { - return LocalRegistry{ - socketsPath: defaultSocketsPath, - specsPaths: specsPaths(), - } -} - -// Scan scans all the plugin paths and returns all the names it found -func (l *LocalRegistry) Scan() ([]string, error) { - var names []string - dirEntries, err := os.ReadDir(l.socketsPath) - if err != nil && !os.IsNotExist(err) { - return nil, errors.Wrap(err, "error reading dir entries") - } - - for _, entry := range dirEntries { - if entry.IsDir() { - fi, err := os.Stat(filepath.Join(l.socketsPath, entry.Name(), entry.Name()+".sock")) - if err != nil { - continue - } - - entry = fs.FileInfoToDirEntry(fi) - } - - if entry.Type()&os.ModeSocket != 0 { - names = append(names, strings.TrimSuffix(filepath.Base(entry.Name()), filepath.Ext(entry.Name()))) - } - } - - for _, p := range l.specsPaths { - dirEntries, err = os.ReadDir(p) - if err != nil && !os.IsNotExist(err) { - return nil, errors.Wrap(err, "error reading dir entries") - } - - for _, entry := range dirEntries { - if entry.IsDir() { - infos, err := os.ReadDir(filepath.Join(p, entry.Name())) - if err != nil { - continue - } - - for _, info := range infos { - if strings.TrimSuffix(info.Name(), filepath.Ext(info.Name())) == entry.Name() { - entry = info - break - } - } - } - - switch ext := filepath.Ext(entry.Name()); ext { - case ".spec", ".json": - plugin := strings.TrimSuffix(entry.Name(), ext) - names = append(names, plugin) - default: - } - } - } - return names, nil -} - -// Plugin returns the plugin registered with the given name (or returns an error). -func (l *LocalRegistry) Plugin(name string) (*Plugin, error) { - socketPaths := pluginPaths(l.socketsPath, name, ".sock") - for _, p := range socketPaths { - if fi, err := os.Stat(p); err == nil && fi.Mode()&os.ModeSocket != 0 { - return NewLocalPlugin(name, "unix://"+p), nil - } - } - - var txtSpecPaths []string - for _, p := range l.specsPaths { - txtSpecPaths = append(txtSpecPaths, pluginPaths(p, name, ".spec")...) - txtSpecPaths = append(txtSpecPaths, pluginPaths(p, name, ".json")...) - } - - for _, p := range txtSpecPaths { - if _, err := os.Stat(p); err == nil { - if strings.HasSuffix(p, ".json") { - return readPluginJSONInfo(name, p) - } - return readPluginInfo(name, p) - } - } - return nil, errors.Wrapf(ErrNotFound, "could not find plugin %s in v1 plugin registry", name) -} - -// SpecsPaths returns paths in which to look for plugins, in order of priority. -// -// On Windows: -// -// - "%programdata%\docker\plugins" -// -// On Unix in non-rootless mode: -// -// - "/etc/docker/plugins" -// - "/usr/lib/docker/plugins" -// -// On Unix in rootless-mode: -// -// - "$XDG_CONFIG_HOME/docker/plugins" (or "/etc/docker/plugins" if $XDG_CONFIG_HOME is not set) -// - "$HOME/.local/lib/docker/plugins" (pr "/usr/lib/docker/plugins" if $HOME is set) -func SpecsPaths() []string { - return specsPaths() -} - -func readPluginInfo(name, path string) (*Plugin, error) { - content, err := os.ReadFile(path) - if err != nil { - return nil, err - } - addr := strings.TrimSpace(string(content)) - - u, err := url.Parse(addr) - if err != nil { - return nil, err - } - - if len(u.Scheme) == 0 { - return nil, fmt.Errorf("Unknown protocol") - } - - return NewLocalPlugin(name, addr), nil -} - -func readPluginJSONInfo(name, path string) (*Plugin, error) { - f, err := os.Open(path) - if err != nil { - return nil, err - } - defer f.Close() - - var p Plugin - if err := json.NewDecoder(f).Decode(&p); err != nil { - return nil, err - } - p.name = name - if p.TLSConfig != nil && len(p.TLSConfig.CAFile) == 0 { - p.TLSConfig.InsecureSkipVerify = true - } - p.activateWait = sync.NewCond(&sync.Mutex{}) - - return &p, nil -} - -func pluginPaths(base, name, ext string) []string { - return []string{ - filepath.Join(base, name+ext), - filepath.Join(base, name, name+ext), - } -} diff --git a/vendor/github.com/docker/docker/pkg/plugins/discovery_unix.go b/vendor/github.com/docker/docker/pkg/plugins/discovery_unix.go deleted file mode 100644 index 1a05307b74..0000000000 --- a/vendor/github.com/docker/docker/pkg/plugins/discovery_unix.go +++ /dev/null @@ -1,31 +0,0 @@ -//go:build !windows - -package plugins // import "github.com/docker/docker/pkg/plugins" -import ( - "path/filepath" - - "github.com/docker/docker/pkg/homedir" - "github.com/docker/docker/pkg/rootless" -) - -func rootlessConfigPluginsPath() string { - if configHome, err := homedir.GetConfigHome(); err != nil { - return filepath.Join(configHome, "docker/plugins") - } - return "/etc/docker/plugins" -} - -func rootlessLibPluginsPath() string { - if libHome, err := homedir.GetLibHome(); err == nil { - return filepath.Join(libHome, "docker/plugins") - } - return "/usr/lib/docker/plugins" -} - -// specsPaths is the non-Windows implementation of [SpecsPaths]. -func specsPaths() []string { - if rootless.RunningWithRootlessKit() { - return []string{rootlessConfigPluginsPath(), rootlessLibPluginsPath()} - } - return []string{"/etc/docker/plugins", "/usr/lib/docker/plugins"} -} diff --git a/vendor/github.com/docker/docker/pkg/plugins/discovery_windows.go b/vendor/github.com/docker/docker/pkg/plugins/discovery_windows.go deleted file mode 100644 index fe825792ba..0000000000 --- a/vendor/github.com/docker/docker/pkg/plugins/discovery_windows.go +++ /dev/null @@ -1,11 +0,0 @@ -package plugins // import "github.com/docker/docker/pkg/plugins" - -import ( - "os" - "path/filepath" -) - -// specsPaths is the Windows implementation of [SpecsPaths]. -func specsPaths() []string { - return []string{filepath.Join(os.Getenv("programdata"), "docker", "plugins")} -} diff --git a/vendor/github.com/docker/docker/pkg/plugins/errors.go b/vendor/github.com/docker/docker/pkg/plugins/errors.go deleted file mode 100644 index 6735c304bf..0000000000 --- a/vendor/github.com/docker/docker/pkg/plugins/errors.go +++ /dev/null @@ -1,33 +0,0 @@ -package plugins // import "github.com/docker/docker/pkg/plugins" - -import ( - "fmt" - "net/http" -) - -type statusError struct { - status int - method string - err string -} - -// Error returns a formatted string for this error type -func (e *statusError) Error() string { - return fmt.Sprintf("%s: %v", e.method, e.err) -} - -// IsNotFound indicates if the passed in error is from an http.StatusNotFound from the plugin -func IsNotFound(err error) bool { - return isStatusError(err, http.StatusNotFound) -} - -func isStatusError(err error, status int) bool { - if err == nil { - return false - } - e, ok := err.(*statusError) - if !ok { - return false - } - return e.status == status -} diff --git a/vendor/github.com/docker/docker/pkg/plugins/plugins.go b/vendor/github.com/docker/docker/pkg/plugins/plugins.go deleted file mode 100644 index 422434e5df..0000000000 --- a/vendor/github.com/docker/docker/pkg/plugins/plugins.go +++ /dev/null @@ -1,345 +0,0 @@ -// Package plugins provides structures and helper functions to manage Docker -// plugins. -// -// Docker discovers plugins by looking for them in the plugin directory whenever -// a user or container tries to use one by name. UNIX domain socket files must -// be located under /run/docker/plugins, whereas spec files can be located -// either under /etc/docker/plugins or /usr/lib/docker/plugins. This is handled -// by the Registry interface, which lets you list all plugins or get a plugin by -// its name if it exists. -// -// The plugins need to implement an HTTP server and bind this to the UNIX socket -// or the address specified in the spec files. -// A handshake is send at /Plugin.Activate, and plugins are expected to return -// a Manifest with a list of Docker subsystems which this plugin implements. -// -// In order to use a plugins, you can use the `Get` with the name of the -// plugin and the subsystem it implements. -// -// plugin, err := plugins.Get("example", "VolumeDriver") -// if err != nil { -// return fmt.Errorf("Error looking up volume plugin example: %v", err) -// } -package plugins // import "github.com/docker/docker/pkg/plugins" - -import ( - "context" - "errors" - "fmt" - "sync" - "time" - - "github.com/containerd/containerd/log" - "github.com/docker/go-connections/tlsconfig" -) - -// ProtocolSchemeHTTPV1 is the name of the protocol used for interacting with plugins using this package. -const ProtocolSchemeHTTPV1 = "moby.plugins.http/v1" - -// ErrNotImplements is returned if the plugin does not implement the requested driver. -var ErrNotImplements = errors.New("Plugin does not implement the requested driver") - -type plugins struct { - sync.Mutex - plugins map[string]*Plugin -} - -type extpointHandlers struct { - sync.RWMutex - extpointHandlers map[string][]func(string, *Client) -} - -var ( - storage = plugins{plugins: make(map[string]*Plugin)} - handlers = extpointHandlers{extpointHandlers: make(map[string][]func(string, *Client))} -) - -// Manifest lists what a plugin implements. -type Manifest struct { - // List of subsystem the plugin implements. - Implements []string -} - -// Plugin is the definition of a docker plugin. -type Plugin struct { - // Name of the plugin - name string - // Address of the plugin - Addr string - // TLS configuration of the plugin - TLSConfig *tlsconfig.Options - // Client attached to the plugin - client *Client - // Manifest of the plugin (see above) - Manifest *Manifest `json:"-"` - - // wait for activation to finish - activateWait *sync.Cond - // error produced by activation - activateErr error - // keeps track of callback handlers run against this plugin - handlersRun bool -} - -// Name returns the name of the plugin. -func (p *Plugin) Name() string { - return p.name -} - -// Client returns a ready-to-use plugin client that can be used to communicate with the plugin. -func (p *Plugin) Client() *Client { - return p.client -} - -// Protocol returns the protocol name/version used for plugins in this package. -func (p *Plugin) Protocol() string { - return ProtocolSchemeHTTPV1 -} - -// IsV1 returns true for V1 plugins and false otherwise. -func (p *Plugin) IsV1() bool { - return true -} - -// ScopedPath returns the path scoped to the plugin's rootfs. -// For v1 plugins, this always returns the path unchanged as v1 plugins run directly on the host. -func (p *Plugin) ScopedPath(s string) string { - return s -} - -// NewLocalPlugin creates a new local plugin. -func NewLocalPlugin(name, addr string) *Plugin { - return &Plugin{ - name: name, - Addr: addr, - // TODO: change to nil - TLSConfig: &tlsconfig.Options{InsecureSkipVerify: true}, - activateWait: sync.NewCond(&sync.Mutex{}), - } -} - -func (p *Plugin) activate() error { - p.activateWait.L.Lock() - - if p.activated() { - p.runHandlers() - p.activateWait.L.Unlock() - return p.activateErr - } - - p.activateErr = p.activateWithLock() - - p.runHandlers() - p.activateWait.L.Unlock() - p.activateWait.Broadcast() - return p.activateErr -} - -// runHandlers runs the registered handlers for the implemented plugin types -// This should only be run after activation, and while the activation lock is held. -func (p *Plugin) runHandlers() { - if !p.activated() { - return - } - - handlers.RLock() - if !p.handlersRun { - for _, iface := range p.Manifest.Implements { - hdlrs, handled := handlers.extpointHandlers[iface] - if !handled { - continue - } - for _, handler := range hdlrs { - handler(p.name, p.client) - } - } - p.handlersRun = true - } - handlers.RUnlock() -} - -// activated returns if the plugin has already been activated. -// This should only be called with the activation lock held -func (p *Plugin) activated() bool { - return p.Manifest != nil -} - -func (p *Plugin) activateWithLock() error { - c, err := NewClient(p.Addr, p.TLSConfig) - if err != nil { - return err - } - p.client = c - - m := new(Manifest) - if err = p.client.Call("Plugin.Activate", nil, m); err != nil { - return err - } - - p.Manifest = m - return nil -} - -func (p *Plugin) waitActive() error { - p.activateWait.L.Lock() - for !p.activated() && p.activateErr == nil { - p.activateWait.Wait() - } - p.activateWait.L.Unlock() - return p.activateErr -} - -func (p *Plugin) implements(kind string) bool { - if p.Manifest == nil { - return false - } - for _, driver := range p.Manifest.Implements { - if driver == kind { - return true - } - } - return false -} - -func loadWithRetry(name string, retry bool) (*Plugin, error) { - registry := NewLocalRegistry() - start := time.Now() - var testTimeOut int - if name == testNonExistingPlugin { - // override the timeout in tests - testTimeOut = 2 - } - var retries int - for { - pl, err := registry.Plugin(name) - if err != nil { - if !retry { - return nil, err - } - - timeOff := backoff(retries) - if abort(start, timeOff, testTimeOut) { - return nil, err - } - retries++ - log.G(context.TODO()).Warnf("Unable to locate plugin: %s, retrying in %v", name, timeOff) - time.Sleep(timeOff) - continue - } - - storage.Lock() - if pl, exists := storage.plugins[name]; exists { - storage.Unlock() - return pl, pl.activate() - } - storage.plugins[name] = pl - storage.Unlock() - - err = pl.activate() - - if err != nil { - storage.Lock() - delete(storage.plugins, name) - storage.Unlock() - } - - return pl, err - } -} - -func get(name string) (*Plugin, error) { - storage.Lock() - pl, ok := storage.plugins[name] - storage.Unlock() - if ok { - return pl, pl.activate() - } - return loadWithRetry(name, true) -} - -// Get returns the plugin given the specified name and requested implementation. -func Get(name, imp string) (*Plugin, error) { - if name == "" { - return nil, errors.New("Unable to find plugin without name") - } - pl, err := get(name) - if err != nil { - return nil, err - } - if err := pl.waitActive(); err == nil && pl.implements(imp) { - log.G(context.TODO()).Debugf("%s implements: %s", name, imp) - return pl, nil - } - return nil, fmt.Errorf("%w: plugin=%q, requested implementation=%q", ErrNotImplements, name, imp) -} - -// Handle adds the specified function to the extpointHandlers. -func Handle(iface string, fn func(string, *Client)) { - handlers.Lock() - hdlrs, ok := handlers.extpointHandlers[iface] - if !ok { - hdlrs = []func(string, *Client){} - } - - hdlrs = append(hdlrs, fn) - handlers.extpointHandlers[iface] = hdlrs - - storage.Lock() - for _, p := range storage.plugins { - p.activateWait.L.Lock() - if p.activated() && p.implements(iface) { - p.handlersRun = false - } - p.activateWait.L.Unlock() - } - storage.Unlock() - - handlers.Unlock() -} - -// GetAll returns all the plugins for the specified implementation -func (l *LocalRegistry) GetAll(imp string) ([]*Plugin, error) { - pluginNames, err := l.Scan() - if err != nil { - return nil, err - } - - type plLoad struct { - pl *Plugin - err error - } - - chPl := make(chan *plLoad, len(pluginNames)) - var wg sync.WaitGroup - for _, name := range pluginNames { - storage.Lock() - pl, ok := storage.plugins[name] - storage.Unlock() - if ok { - chPl <- &plLoad{pl, nil} - continue - } - - wg.Add(1) - go func(name string) { - defer wg.Done() - pl, err := loadWithRetry(name, false) - chPl <- &plLoad{pl, err} - }(name) - } - - wg.Wait() - close(chPl) - - var out []*Plugin - for pl := range chPl { - if pl.err != nil { - log.G(context.TODO()).Error(pl.err) - continue - } - if err := pl.pl.waitActive(); err == nil && pl.pl.implements(imp) { - out = append(out, pl.pl) - } - } - return out, nil -} diff --git a/vendor/github.com/docker/docker/pkg/plugins/transport/http.go b/vendor/github.com/docker/docker/pkg/plugins/transport/http.go deleted file mode 100644 index e4c1979b8b..0000000000 --- a/vendor/github.com/docker/docker/pkg/plugins/transport/http.go +++ /dev/null @@ -1,41 +0,0 @@ -package transport // import "github.com/docker/docker/pkg/plugins/transport" - -import ( - "io" - "net/http" - "strings" -) - -// HTTPTransport holds an [http.RoundTripper] -// and information about the scheme and address the transport -// sends request to. -type HTTPTransport struct { - http.RoundTripper - scheme string - addr string -} - -// NewHTTPTransport creates a new HTTPTransport. -func NewHTTPTransport(r http.RoundTripper, scheme, addr string) *HTTPTransport { - return &HTTPTransport{ - RoundTripper: r, - scheme: scheme, - addr: addr, - } -} - -// NewRequest creates a new http.Request and sets the URL -// scheme and address with the transport's fields. -func (t HTTPTransport) NewRequest(path string, data io.Reader) (*http.Request, error) { - if !strings.HasPrefix(path, "/") { - path = "/" + path - } - req, err := http.NewRequest(http.MethodPost, path, data) - if err != nil { - return nil, err - } - req.Header.Add("Accept", VersionMimetype) - req.URL.Scheme = t.scheme - req.URL.Host = t.addr - return req, nil -} diff --git a/vendor/github.com/docker/docker/pkg/plugins/transport/mimetype.go b/vendor/github.com/docker/docker/pkg/plugins/transport/mimetype.go deleted file mode 100644 index b5336d515c..0000000000 --- a/vendor/github.com/docker/docker/pkg/plugins/transport/mimetype.go +++ /dev/null @@ -1,6 +0,0 @@ -package transport // import "github.com/docker/docker/pkg/plugins/transport" - -// VersionMimetype is the Content-Type the engine sends to plugins. -// -// For convenience, there is an alias in [github.com/docker/docker/pkg/plugins.VersionMimetype]. -const VersionMimetype = "application/vnd.docker.plugins.v1.2+json" diff --git a/vendor/github.com/docker/docker/pkg/rootless/rootless.go b/vendor/github.com/docker/docker/pkg/rootless/rootless.go deleted file mode 100644 index b52f8eee71..0000000000 --- a/vendor/github.com/docker/docker/pkg/rootless/rootless.go +++ /dev/null @@ -1,11 +0,0 @@ -package rootless // import "github.com/docker/docker/pkg/rootless" - -import "os" - -// RootlessKitDockerProxyBinary is the binary name of rootlesskit-docker-proxy -const RootlessKitDockerProxyBinary = "rootlesskit-docker-proxy" - -// RunningWithRootlessKit returns true if running under RootlessKit namespaces. -func RunningWithRootlessKit() bool { - return os.Getenv("ROOTLESSKIT_STATE_DIR") != "" -} diff --git a/vendor/github.com/docker/go-connections/LICENSE b/vendor/github.com/docker/go-connections/LICENSE deleted file mode 100644 index b55b37bc31..0000000000 --- a/vendor/github.com/docker/go-connections/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ - - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - Copyright 2015 Docker, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/docker/go-connections/sockets/README.md b/vendor/github.com/docker/go-connections/sockets/README.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/vendor/github.com/docker/go-connections/sockets/inmem_socket.go b/vendor/github.com/docker/go-connections/sockets/inmem_socket.go deleted file mode 100644 index 99846ffddb..0000000000 --- a/vendor/github.com/docker/go-connections/sockets/inmem_socket.go +++ /dev/null @@ -1,81 +0,0 @@ -package sockets - -import ( - "errors" - "net" - "sync" -) - -var errClosed = errors.New("use of closed network connection") - -// InmemSocket implements net.Listener using in-memory only connections. -type InmemSocket struct { - chConn chan net.Conn - chClose chan struct{} - addr string - mu sync.Mutex -} - -// dummyAddr is used to satisfy net.Addr for the in-mem socket -// it is just stored as a string and returns the string for all calls -type dummyAddr string - -// NewInmemSocket creates an in-memory only net.Listener -// The addr argument can be any string, but is used to satisfy the `Addr()` part -// of the net.Listener interface -func NewInmemSocket(addr string, bufSize int) *InmemSocket { - return &InmemSocket{ - chConn: make(chan net.Conn, bufSize), - chClose: make(chan struct{}), - addr: addr, - } -} - -// Addr returns the socket's addr string to satisfy net.Listener -func (s *InmemSocket) Addr() net.Addr { - return dummyAddr(s.addr) -} - -// Accept implements the Accept method in the Listener interface; it waits for the next call and returns a generic Conn. -func (s *InmemSocket) Accept() (net.Conn, error) { - select { - case conn := <-s.chConn: - return conn, nil - case <-s.chClose: - return nil, errClosed - } -} - -// Close closes the listener. It will be unavailable for use once closed. -func (s *InmemSocket) Close() error { - s.mu.Lock() - defer s.mu.Unlock() - select { - case <-s.chClose: - default: - close(s.chClose) - } - return nil -} - -// Dial is used to establish a connection with the in-mem server -func (s *InmemSocket) Dial(network, addr string) (net.Conn, error) { - srvConn, clientConn := net.Pipe() - select { - case s.chConn <- srvConn: - case <-s.chClose: - return nil, errClosed - } - - return clientConn, nil -} - -// Network returns the addr string, satisfies net.Addr -func (a dummyAddr) Network() string { - return string(a) -} - -// String returns the string form -func (a dummyAddr) String() string { - return string(a) -} diff --git a/vendor/github.com/docker/go-connections/sockets/proxy.go b/vendor/github.com/docker/go-connections/sockets/proxy.go deleted file mode 100644 index c897cb02ad..0000000000 --- a/vendor/github.com/docker/go-connections/sockets/proxy.go +++ /dev/null @@ -1,28 +0,0 @@ -package sockets - -import ( - "net" - "os" - "strings" -) - -// GetProxyEnv allows access to the uppercase and the lowercase forms of -// proxy-related variables. See the Go specification for details on these -// variables. https://golang.org/pkg/net/http/ -func GetProxyEnv(key string) string { - proxyValue := os.Getenv(strings.ToUpper(key)) - if proxyValue == "" { - return os.Getenv(strings.ToLower(key)) - } - return proxyValue -} - -// DialerFromEnvironment was previously used to configure a net.Dialer to route -// connections through a SOCKS proxy. -// DEPRECATED: SOCKS proxies are now supported by configuring only -// http.Transport.Proxy, and no longer require changing http.Transport.Dial. -// Therefore, only sockets.ConfigureTransport() needs to be called, and any -// sockets.DialerFromEnvironment() calls can be dropped. -func DialerFromEnvironment(direct *net.Dialer) (*net.Dialer, error) { - return direct, nil -} diff --git a/vendor/github.com/docker/go-connections/sockets/sockets.go b/vendor/github.com/docker/go-connections/sockets/sockets.go deleted file mode 100644 index b0eae239d2..0000000000 --- a/vendor/github.com/docker/go-connections/sockets/sockets.go +++ /dev/null @@ -1,37 +0,0 @@ -// Package sockets provides helper functions to create and configure Unix or TCP sockets. -package sockets - -import ( - "errors" - "net" - "net/http" - "time" -) - -const defaultTimeout = 10 * time.Second - -// ErrProtocolNotAvailable is returned when a given transport protocol is not provided by the operating system. -var ErrProtocolNotAvailable = errors.New("protocol not available") - -// ConfigureTransport configures the specified [http.Transport] according to the specified proto -// and addr. -// -// If the proto is unix (using a unix socket to communicate) or npipe the compression is disabled. -// For other protos, compression is enabled. If you want to manually enable/disable compression, -// make sure you do it _after_ any subsequent calls to ConfigureTransport is made against the same -// [http.Transport]. -func ConfigureTransport(tr *http.Transport, proto, addr string) error { - switch proto { - case "unix": - return configureUnixTransport(tr, proto, addr) - case "npipe": - return configureNpipeTransport(tr, proto, addr) - default: - tr.Proxy = http.ProxyFromEnvironment - tr.DisableCompression = false - tr.DialContext = (&net.Dialer{ - Timeout: defaultTimeout, - }).DialContext - } - return nil -} diff --git a/vendor/github.com/docker/go-connections/sockets/sockets_unix.go b/vendor/github.com/docker/go-connections/sockets/sockets_unix.go deleted file mode 100644 index 78a34a980d..0000000000 --- a/vendor/github.com/docker/go-connections/sockets/sockets_unix.go +++ /dev/null @@ -1,39 +0,0 @@ -//go:build !windows - -package sockets - -import ( - "context" - "fmt" - "net" - "net/http" - "syscall" - "time" -) - -const maxUnixSocketPathSize = len(syscall.RawSockaddrUnix{}.Path) - -func configureUnixTransport(tr *http.Transport, proto, addr string) error { - if len(addr) > maxUnixSocketPathSize { - return fmt.Errorf("unix socket path %q is too long", addr) - } - // No need for compression in local communications. - tr.DisableCompression = true - dialer := &net.Dialer{ - Timeout: defaultTimeout, - } - tr.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) { - return dialer.DialContext(ctx, proto, addr) - } - return nil -} - -func configureNpipeTransport(tr *http.Transport, proto, addr string) error { - return ErrProtocolNotAvailable -} - -// DialPipe connects to a Windows named pipe. -// This is not supported on other OSes. -func DialPipe(_ string, _ time.Duration) (net.Conn, error) { - return nil, syscall.EAFNOSUPPORT -} diff --git a/vendor/github.com/docker/go-connections/sockets/sockets_windows.go b/vendor/github.com/docker/go-connections/sockets/sockets_windows.go deleted file mode 100644 index 7acafc5a2a..0000000000 --- a/vendor/github.com/docker/go-connections/sockets/sockets_windows.go +++ /dev/null @@ -1,28 +0,0 @@ -package sockets - -import ( - "context" - "net" - "net/http" - "time" - - "github.com/Microsoft/go-winio" -) - -func configureUnixTransport(tr *http.Transport, proto, addr string) error { - return ErrProtocolNotAvailable -} - -func configureNpipeTransport(tr *http.Transport, proto, addr string) error { - // No need for compression in local communications. - tr.DisableCompression = true - tr.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) { - return winio.DialPipeContext(ctx, addr) - } - return nil -} - -// DialPipe connects to a Windows named pipe. -func DialPipe(addr string, timeout time.Duration) (net.Conn, error) { - return winio.DialPipe(addr, &timeout) -} diff --git a/vendor/github.com/docker/go-connections/sockets/tcp_socket.go b/vendor/github.com/docker/go-connections/sockets/tcp_socket.go deleted file mode 100644 index 53cbb6c79e..0000000000 --- a/vendor/github.com/docker/go-connections/sockets/tcp_socket.go +++ /dev/null @@ -1,22 +0,0 @@ -// Package sockets provides helper functions to create and configure Unix or TCP sockets. -package sockets - -import ( - "crypto/tls" - "net" -) - -// NewTCPSocket creates a TCP socket listener with the specified address and -// the specified tls configuration. If TLSConfig is set, will encapsulate the -// TCP listener inside a TLS one. -func NewTCPSocket(addr string, tlsConfig *tls.Config) (net.Listener, error) { - l, err := net.Listen("tcp", addr) - if err != nil { - return nil, err - } - if tlsConfig != nil { - tlsConfig.NextProtos = []string{"http/1.1"} - l = tls.NewListener(l, tlsConfig) - } - return l, nil -} diff --git a/vendor/github.com/docker/go-connections/sockets/unix_socket.go b/vendor/github.com/docker/go-connections/sockets/unix_socket.go deleted file mode 100644 index b9233521e4..0000000000 --- a/vendor/github.com/docker/go-connections/sockets/unix_socket.go +++ /dev/null @@ -1,126 +0,0 @@ -//go:build !windows - -/* -Package sockets is a simple unix domain socket wrapper. - -# Usage - -For example: - - import( - "fmt" - "net" - "os" - "github.com/docker/go-connections/sockets" - ) - - func main() { - l, err := sockets.NewUnixSocketWithOpts("/path/to/sockets", - sockets.WithChown(0,0),sockets.WithChmod(0660)) - if err != nil { - panic(err) - } - echoStr := "hello" - - go func() { - for { - conn, err := l.Accept() - if err != nil { - return - } - conn.Write([]byte(echoStr)) - conn.Close() - } - }() - - conn, err := net.Dial("unix", path) - if err != nil { - t.Fatal(err) - } - - buf := make([]byte, 5) - if _, err := conn.Read(buf); err != nil { - panic(err) - } else if string(buf) != echoStr { - panic(fmt.Errorf("msg may lost")) - } - } -*/ -package sockets - -import ( - "net" - "os" - "syscall" -) - -// SockOption sets up socket file's creating option -type SockOption func(string) error - -// WithChown modifies the socket file's uid and gid -func WithChown(uid, gid int) SockOption { - return func(path string) error { - if err := os.Chown(path, uid, gid); err != nil { - return err - } - return nil - } -} - -// WithChmod modifies socket file's access mode. -func WithChmod(mask os.FileMode) SockOption { - return func(path string) error { - if err := os.Chmod(path, mask); err != nil { - return err - } - return nil - } -} - -// NewUnixSocketWithOpts creates a unix socket with the specified options. -// By default, socket permissions are 0000 (i.e.: no access for anyone); pass -// WithChmod() and WithChown() to set the desired ownership and permissions. -// -// This function temporarily changes the system's "umask" to 0777 to work around -// a race condition between creating the socket and setting its permissions. While -// this should only be for a short duration, it may affect other processes that -// create files/directories during that period. -func NewUnixSocketWithOpts(path string, opts ...SockOption) (net.Listener, error) { - if err := syscall.Unlink(path); err != nil && !os.IsNotExist(err) { - return nil, err - } - - // net.Listen does not allow for permissions to be set. As a result, when - // specifying custom permissions ("WithChmod()"), there is a short time - // between creating the socket and applying the permissions, during which - // the socket permissions are Less restrictive than desired. - // - // To work around this limitation of net.Listen(), we temporarily set the - // umask to 0777, which forces the socket to be created with 000 permissions - // (i.e.: no access for anyone). After that, WithChmod() must be used to set - // the desired permissions. - // - // We don't use "defer" here, to reset the umask to its original value as soon - // as possible. Ideally we'd be able to detect if WithChmod() was passed as - // an option, and skip changing umask if default permissions are used. - origUmask := syscall.Umask(0o777) - l, err := net.Listen("unix", path) - syscall.Umask(origUmask) - if err != nil { - return nil, err - } - - for _, op := range opts { - if err := op(path); err != nil { - _ = l.Close() - return nil, err - } - } - - return l, nil -} - -// NewUnixSocket creates a unix socket with the specified path and group. -func NewUnixSocket(path string, gid int) (net.Listener, error) { - return NewUnixSocketWithOpts(path, WithChown(0, gid), WithChmod(0o660)) -} diff --git a/vendor/github.com/docker/go-connections/tlsconfig/certpool.go b/vendor/github.com/docker/go-connections/tlsconfig/certpool.go deleted file mode 100644 index f84c624ba0..0000000000 --- a/vendor/github.com/docker/go-connections/tlsconfig/certpool.go +++ /dev/null @@ -1,16 +0,0 @@ -package tlsconfig - -import ( - "crypto/x509" - "runtime" -) - -// SystemCertPool returns a copy of the system cert pool, -// returns an error if failed to load or empty pool on windows. -func SystemCertPool() (*x509.CertPool, error) { - certpool, err := x509.SystemCertPool() - if err != nil && runtime.GOOS == "windows" { - return x509.NewCertPool(), nil - } - return certpool, err -} diff --git a/vendor/github.com/docker/go-connections/tlsconfig/config.go b/vendor/github.com/docker/go-connections/tlsconfig/config.go deleted file mode 100644 index 606c98a38b..0000000000 --- a/vendor/github.com/docker/go-connections/tlsconfig/config.go +++ /dev/null @@ -1,261 +0,0 @@ -// Package tlsconfig provides primitives to retrieve secure-enough TLS configurations for both clients and servers. -// -// As a reminder from https://golang.org/pkg/crypto/tls/#Config: -// -// A Config structure is used to configure a TLS client or server. After one has been passed to a TLS function it must not be modified. -// A Config may be reused; the tls package will also not modify it. -package tlsconfig - -import ( - "crypto/tls" - "crypto/x509" - "encoding/pem" - "errors" - "fmt" - "os" -) - -// Options represents the information needed to create client and server TLS configurations. -type Options struct { - CAFile string - - // If either CertFile or KeyFile is empty, Client() will not load them - // preventing the client from authenticating to the server. - // However, Server() requires them and will error out if they are empty. - CertFile string - KeyFile string - - // client-only option - InsecureSkipVerify bool - // server-only option - ClientAuth tls.ClientAuthType - // If ExclusiveRootPools is set, then if a CA file is provided, the root pool used for TLS - // creds will include exclusively the roots in that CA file. If no CA file is provided, - // the system pool will be used. - ExclusiveRootPools bool - MinVersion uint16 - // If Passphrase is set, it will be used to decrypt a TLS private key - // if the key is encrypted. - // - // Deprecated: Use of encrypted TLS private keys has been deprecated, and - // will be removed in a future release. Golang has deprecated support for - // legacy PEM encryption (as specified in RFC 1423), as it is insecure by - // design (see https://go-review.googlesource.com/c/go/+/264159). - Passphrase string -} - -// Extra (server-side) accepted CBC cipher suites - will phase out in the future -var acceptedCBCCiphers = []uint16{ - tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, -} - -// DefaultServerAcceptedCiphers should be uses by code which already has a crypto/tls -// options struct but wants to use a commonly accepted set of TLS cipher suites, with -// known weak algorithms removed. -var DefaultServerAcceptedCiphers = append(clientCipherSuites, acceptedCBCCiphers...) - -// ServerDefault returns a secure-enough TLS configuration for the server TLS configuration. -func ServerDefault(ops ...func(*tls.Config)) *tls.Config { - tlsConfig := &tls.Config{ - // Avoid fallback by default to SSL protocols < TLS1.2 - MinVersion: tls.VersionTLS12, - PreferServerCipherSuites: true, - CipherSuites: DefaultServerAcceptedCiphers, - } - - for _, op := range ops { - op(tlsConfig) - } - - return tlsConfig -} - -// ClientDefault returns a secure-enough TLS configuration for the client TLS configuration. -func ClientDefault(ops ...func(*tls.Config)) *tls.Config { - tlsConfig := &tls.Config{ - // Prefer TLS1.2 as the client minimum - MinVersion: tls.VersionTLS12, - CipherSuites: clientCipherSuites, - } - - for _, op := range ops { - op(tlsConfig) - } - - return tlsConfig -} - -// certPool returns an X.509 certificate pool from `caFile`, the certificate file. -func certPool(caFile string, exclusivePool bool) (*x509.CertPool, error) { - // If we should verify the server, we need to load a trusted ca - var ( - certPool *x509.CertPool - err error - ) - if exclusivePool { - certPool = x509.NewCertPool() - } else { - certPool, err = SystemCertPool() - if err != nil { - return nil, fmt.Errorf("failed to read system certificates: %v", err) - } - } - pemData, err := os.ReadFile(caFile) - if err != nil { - return nil, fmt.Errorf("could not read CA certificate %q: %v", caFile, err) - } - if !certPool.AppendCertsFromPEM(pemData) { - return nil, fmt.Errorf("failed to append certificates from PEM file: %q", caFile) - } - return certPool, nil -} - -// allTLSVersions lists all the TLS versions and is used by the code that validates -// a uint16 value as a TLS version. -var allTLSVersions = map[uint16]struct{}{ - tls.VersionTLS10: {}, - tls.VersionTLS11: {}, - tls.VersionTLS12: {}, - tls.VersionTLS13: {}, -} - -// isValidMinVersion checks that the input value is a valid tls minimum version -func isValidMinVersion(version uint16) bool { - _, ok := allTLSVersions[version] - return ok -} - -// adjustMinVersion sets the MinVersion on `config`, the input configuration. -// It assumes the current MinVersion on the `config` is the lowest allowed. -func adjustMinVersion(options Options, config *tls.Config) error { - if options.MinVersion > 0 { - if !isValidMinVersion(options.MinVersion) { - return fmt.Errorf("invalid minimum TLS version: %x", options.MinVersion) - } - if options.MinVersion < config.MinVersion { - return fmt.Errorf("requested minimum TLS version is too low. Should be at-least: %x", config.MinVersion) - } - config.MinVersion = options.MinVersion - } - - return nil -} - -// IsErrEncryptedKey returns true if the 'err' is an error of incorrect -// password when trying to decrypt a TLS private key. -// -// Deprecated: Use of encrypted TLS private keys has been deprecated, and -// will be removed in a future release. Golang has deprecated support for -// legacy PEM encryption (as specified in RFC 1423), as it is insecure by -// design (see https://go-review.googlesource.com/c/go/+/264159). -func IsErrEncryptedKey(err error) bool { - return errors.Is(err, x509.IncorrectPasswordError) -} - -// getPrivateKey returns the private key in 'keyBytes', in PEM-encoded format. -// If the private key is encrypted, 'passphrase' is used to decrypted the -// private key. -func getPrivateKey(keyBytes []byte, passphrase string) ([]byte, error) { - // this section makes some small changes to code from notary/tuf/utils/x509.go - pemBlock, _ := pem.Decode(keyBytes) - if pemBlock == nil { - return nil, fmt.Errorf("no valid private key found") - } - - var err error - if x509.IsEncryptedPEMBlock(pemBlock) { //nolint:staticcheck // Ignore SA1019 (IsEncryptedPEMBlock is deprecated) - keyBytes, err = x509.DecryptPEMBlock(pemBlock, []byte(passphrase)) //nolint:staticcheck // Ignore SA1019 (DecryptPEMBlock is deprecated) - if err != nil { - return nil, fmt.Errorf("private key is encrypted, but could not decrypt it: %w", err) - } - keyBytes = pem.EncodeToMemory(&pem.Block{Type: pemBlock.Type, Bytes: keyBytes}) - } - - return keyBytes, nil -} - -// getCert returns a Certificate from the CertFile and KeyFile in 'options', -// if the key is encrypted, the Passphrase in 'options' will be used to -// decrypt it. -func getCert(options Options) ([]tls.Certificate, error) { - if options.CertFile == "" && options.KeyFile == "" { - return nil, nil - } - - cert, err := os.ReadFile(options.CertFile) - if err != nil { - return nil, err - } - - prKeyBytes, err := os.ReadFile(options.KeyFile) - if err != nil { - return nil, err - } - - prKeyBytes, err = getPrivateKey(prKeyBytes, options.Passphrase) - if err != nil { - return nil, err - } - - tlsCert, err := tls.X509KeyPair(cert, prKeyBytes) - if err != nil { - return nil, err - } - - return []tls.Certificate{tlsCert}, nil -} - -// Client returns a TLS configuration meant to be used by a client. -func Client(options Options) (*tls.Config, error) { - tlsConfig := ClientDefault() - tlsConfig.InsecureSkipVerify = options.InsecureSkipVerify - if !options.InsecureSkipVerify && options.CAFile != "" { - CAs, err := certPool(options.CAFile, options.ExclusiveRootPools) - if err != nil { - return nil, err - } - tlsConfig.RootCAs = CAs - } - - tlsCerts, err := getCert(options) - if err != nil { - return nil, fmt.Errorf("could not load X509 key pair: %w", err) - } - tlsConfig.Certificates = tlsCerts - - if err := adjustMinVersion(options, tlsConfig); err != nil { - return nil, err - } - - return tlsConfig, nil -} - -// Server returns a TLS configuration meant to be used by a server. -func Server(options Options) (*tls.Config, error) { - tlsConfig := ServerDefault() - tlsConfig.ClientAuth = options.ClientAuth - tlsCert, err := tls.LoadX509KeyPair(options.CertFile, options.KeyFile) - if err != nil { - if os.IsNotExist(err) { - return nil, fmt.Errorf("could not load X509 key pair (cert: %q, key: %q): %v", options.CertFile, options.KeyFile, err) - } - return nil, fmt.Errorf("error reading X509 key pair - make sure the key is not encrypted (cert: %q, key: %q): %v", options.CertFile, options.KeyFile, err) - } - tlsConfig.Certificates = []tls.Certificate{tlsCert} - if options.ClientAuth >= tls.VerifyClientCertIfGiven && options.CAFile != "" { - CAs, err := certPool(options.CAFile, options.ExclusiveRootPools) - if err != nil { - return nil, err - } - tlsConfig.ClientCAs = CAs - } - - if err := adjustMinVersion(options, tlsConfig); err != nil { - return nil, err - } - - return tlsConfig, nil -} diff --git a/vendor/github.com/docker/go-connections/tlsconfig/config_client_ciphers.go b/vendor/github.com/docker/go-connections/tlsconfig/config_client_ciphers.go deleted file mode 100644 index a82f9fa52e..0000000000 --- a/vendor/github.com/docker/go-connections/tlsconfig/config_client_ciphers.go +++ /dev/null @@ -1,14 +0,0 @@ -// Package tlsconfig provides primitives to retrieve secure-enough TLS configurations for both clients and servers. -package tlsconfig - -import ( - "crypto/tls" -) - -// Client TLS cipher suites (dropping CBC ciphers for client preferred suite set) -var clientCipherSuites = []uint16{ - tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, - tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, - tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, -} diff --git a/vendor/github.com/ishidawataru/sctp/.gitignore b/vendor/github.com/ishidawataru/sctp/.gitignore deleted file mode 100644 index cf2d826c15..0000000000 --- a/vendor/github.com/ishidawataru/sctp/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# Binaries for programs and plugins -*.exe -*.dll -*.so -*.dylib - -# Test binary, build with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 -.glide/ - -example/example diff --git a/vendor/github.com/ishidawataru/sctp/.travis.yml b/vendor/github.com/ishidawataru/sctp/.travis.yml deleted file mode 100644 index a1c693c013..0000000000 --- a/vendor/github.com/ishidawataru/sctp/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: go -arch: - - amd64 - - ppc64le -go: - - 1.9.x - - 1.10.x - - 1.11.x - - 1.12.x - - 1.13.x -# allowing test cases to fail for the versions were not suppotred by ppc64le -matrix: - allow_failures: - - go: 1.9.x - - go: 1.10.x - - go: 1.13.x - - -script: - - go test -v -race ./... - - GOOS=linux GOARCH=amd64 go build . - - GOOS=linux GOARCH=arm go build . - - GOOS=linux GOARCH=arm64 go build . - - GOOS=linux GOARCH=ppc64le go build . - - GOOS=linux GOARCH=mips64le go build . - - (go version | grep go1.6 > /dev/null) || GOOS=linux GOARCH=s390x go build . -# can be compiled but not functional: - - GOOS=linux GOARCH=386 go build . - - GOOS=windows GOARCH=amd64 go build . diff --git a/vendor/github.com/ishidawataru/sctp/GO_LICENSE b/vendor/github.com/ishidawataru/sctp/GO_LICENSE deleted file mode 100644 index 6a66aea5ea..0000000000 --- a/vendor/github.com/ishidawataru/sctp/GO_LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/ishidawataru/sctp/LICENSE b/vendor/github.com/ishidawataru/sctp/LICENSE deleted file mode 100644 index 8dada3edaf..0000000000 --- a/vendor/github.com/ishidawataru/sctp/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/ishidawataru/sctp/NOTICE b/vendor/github.com/ishidawataru/sctp/NOTICE deleted file mode 100644 index cfb675fd4b..0000000000 --- a/vendor/github.com/ishidawataru/sctp/NOTICE +++ /dev/null @@ -1,3 +0,0 @@ -This source code includes following third party code - -- ipsock_linux.go : licensed by the Go authors, see GO_LICENSE file for the license which applies to the code diff --git a/vendor/github.com/ishidawataru/sctp/README.md b/vendor/github.com/ishidawataru/sctp/README.md deleted file mode 100644 index 574ececa86..0000000000 --- a/vendor/github.com/ishidawataru/sctp/README.md +++ /dev/null @@ -1,18 +0,0 @@ -Stream Control Transmission Protocol (SCTP) ----- - -[![Build Status](https://travis-ci.org/ishidawataru/sctp.svg?branch=master)](https://travis-ci.org/ishidawataru/sctp/builds) - -Examples ----- - -See `example/sctp.go` - -```go -$ cd example -$ go build -$ # run example SCTP server -$ ./example -server -port 1000 -ip 10.10.0.1,10.20.0.1 -$ # run example SCTP client -$ ./example -port 1000 -ip 10.10.0.1,10.20.0.1 -``` diff --git a/vendor/github.com/ishidawataru/sctp/ipsock_linux.go b/vendor/github.com/ishidawataru/sctp/ipsock_linux.go deleted file mode 100644 index 3df30fa460..0000000000 --- a/vendor/github.com/ishidawataru/sctp/ipsock_linux.go +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the GO_LICENSE file. - -package sctp - -import ( - "net" - "os" - "sync" - "syscall" -) - -//from https://github.com/golang/go -// Boolean to int. -func boolint(b bool) int { - if b { - return 1 - } - return 0 -} - -//from https://github.com/golang/go -func ipToSockaddr(family int, ip net.IP, port int, zone string) (syscall.Sockaddr, error) { - switch family { - case syscall.AF_INET: - if len(ip) == 0 { - ip = net.IPv4zero - } - ip4 := ip.To4() - if ip4 == nil { - return nil, &net.AddrError{Err: "non-IPv4 address", Addr: ip.String()} - } - sa := &syscall.SockaddrInet4{Port: port} - copy(sa.Addr[:], ip4) - return sa, nil - case syscall.AF_INET6: - // In general, an IP wildcard address, which is either - // "0.0.0.0" or "::", means the entire IP addressing - // space. For some historical reason, it is used to - // specify "any available address" on some operations - // of IP node. - // - // When the IP node supports IPv4-mapped IPv6 address, - // we allow an listener to listen to the wildcard - // address of both IP addressing spaces by specifying - // IPv6 wildcard address. - if len(ip) == 0 || ip.Equal(net.IPv4zero) { - ip = net.IPv6zero - } - // We accept any IPv6 address including IPv4-mapped - // IPv6 address. - ip6 := ip.To16() - if ip6 == nil { - return nil, &net.AddrError{Err: "non-IPv6 address", Addr: ip.String()} - } - //we set ZoneId to 0, as currently we use this functon only to probe the IP capabilities of the host - //if real Zone handling is required, the zone cache implementation in golang/net should be pulled here - sa := &syscall.SockaddrInet6{Port: port, ZoneId: 0} - copy(sa.Addr[:], ip6) - return sa, nil - } - return nil, &net.AddrError{Err: "invalid address family", Addr: ip.String()} -} - -//from https://github.com/golang/go -func sockaddr(a *net.TCPAddr, family int) (syscall.Sockaddr, error) { - if a == nil { - return nil, nil - } - return ipToSockaddr(family, a.IP, a.Port, a.Zone) -} - -//from https://github.com/golang/go -type ipStackCapabilities struct { - sync.Once // guards following - ipv4Enabled bool - ipv6Enabled bool - ipv4MappedIPv6Enabled bool -} - -//from https://github.com/golang/go -var ipStackCaps ipStackCapabilities - -//from https://github.com/golang/go -// supportsIPv4 reports whether the platform supports IPv4 networking -// functionality. -func supportsIPv4() bool { - ipStackCaps.Once.Do(ipStackCaps.probe) - return ipStackCaps.ipv4Enabled -} - -//from https://github.com/golang/go -// supportsIPv6 reports whether the platform supports IPv6 networking -// functionality. -func supportsIPv6() bool { - ipStackCaps.Once.Do(ipStackCaps.probe) - return ipStackCaps.ipv6Enabled -} - -//from https://github.com/golang/go -// supportsIPv4map reports whether the platform supports mapping an -// IPv4 address inside an IPv6 address at transport layer -// protocols. See RFC 4291, RFC 4038 and RFC 3493. -func supportsIPv4map() bool { - ipStackCaps.Once.Do(ipStackCaps.probe) - return ipStackCaps.ipv4MappedIPv6Enabled -} - -//from https://github.com/golang/go -// Probe probes IPv4, IPv6 and IPv4-mapped IPv6 communication -// capabilities which are controlled by the IPV6_V6ONLY socket option -// and kernel configuration. -// -// Should we try to use the IPv4 socket interface if we're only -// dealing with IPv4 sockets? As long as the host system understands -// IPv4-mapped IPv6, it's okay to pass IPv4-mapeed IPv6 addresses to -// the IPv6 interface. That simplifies our code and is most -// general. Unfortunately, we need to run on kernels built without -// IPv6 support too. So probe the kernel to figure it out. -func (p *ipStackCapabilities) probe() { - s, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, syscall.IPPROTO_TCP) - switch err { - case syscall.EAFNOSUPPORT, syscall.EPROTONOSUPPORT: - case nil: - syscall.Close(s) - p.ipv4Enabled = true - } - var probes = []struct { - laddr net.TCPAddr - value int - }{ - // IPv6 communication capability - {laddr: net.TCPAddr{IP: net.IPv6loopback}, value: 1}, - // IPv4-mapped IPv6 address communication capability - {laddr: net.TCPAddr{IP: net.IPv4(127, 0, 0, 1)}, value: 0}, - } - - for i := range probes { - s, err := syscall.Socket(syscall.AF_INET6, syscall.SOCK_STREAM, syscall.IPPROTO_TCP) - if err != nil { - continue - } - defer syscall.Close(s) - syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, probes[i].value) - sa, err := sockaddr(&(probes[i].laddr), syscall.AF_INET6) - if err != nil { - continue - } - if err := syscall.Bind(s, sa); err != nil { - continue - } - if i == 0 { - p.ipv6Enabled = true - } else { - p.ipv4MappedIPv6Enabled = true - } - } -} - -//from https://github.com/golang/go -//Change: we check the first IP address in the list of candidate SCTP IP addresses -func (a *SCTPAddr) isWildcard() bool { - if a == nil { - return true - } - if 0 == len(a.IPAddrs) { - return true - } - - return a.IPAddrs[0].IP.IsUnspecified() -} - -func (a *SCTPAddr) family() int { - if a != nil { - for _, ip := range a.IPAddrs { - if ip.IP.To4() == nil { - return syscall.AF_INET6 - } - } - } - return syscall.AF_INET -} - -//from https://github.com/golang/go -func favoriteAddrFamily(network string, laddr *SCTPAddr, raddr *SCTPAddr, mode string) (family int, ipv6only bool) { - switch network[len(network)-1] { - case '4': - return syscall.AF_INET, false - case '6': - return syscall.AF_INET6, true - } - - if mode == "listen" && (laddr == nil || laddr.isWildcard()) { - if supportsIPv4map() || !supportsIPv4() { - return syscall.AF_INET6, false - } - if laddr == nil { - return syscall.AF_INET, false - } - return laddr.family(), false - } - - if (laddr == nil || laddr.family() == syscall.AF_INET) && - (raddr == nil || raddr.family() == syscall.AF_INET) { - return syscall.AF_INET, false - } - return syscall.AF_INET6, false -} - -//from https://github.com/golang/go -//Changes: it is for SCTP only -func setDefaultSockopts(s int, family int, ipv6only bool) error { - if family == syscall.AF_INET6 { - // Allow both IP versions even if the OS default - // is otherwise. Note that some operating systems - // never admit this option. - syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, boolint(ipv6only)) - } - // Allow broadcast. - return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)) -} diff --git a/vendor/github.com/ishidawataru/sctp/sctp.go b/vendor/github.com/ishidawataru/sctp/sctp.go deleted file mode 100644 index add951a2de..0000000000 --- a/vendor/github.com/ishidawataru/sctp/sctp.go +++ /dev/null @@ -1,737 +0,0 @@ -// Copyright 2019 Wataru Ishida. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -// implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package sctp - -import ( - "bytes" - "encoding/binary" - "fmt" - "net" - "strconv" - "strings" - "sync" - "sync/atomic" - "syscall" - "time" - "unsafe" -) - -const ( - SOL_SCTP = 132 - - SCTP_BINDX_ADD_ADDR = 0x01 - SCTP_BINDX_REM_ADDR = 0x02 - - MSG_NOTIFICATION = 0x8000 -) - -const ( - SCTP_RTOINFO = iota - SCTP_ASSOCINFO - SCTP_INITMSG - SCTP_NODELAY - SCTP_AUTOCLOSE - SCTP_SET_PEER_PRIMARY_ADDR - SCTP_PRIMARY_ADDR - SCTP_ADAPTATION_LAYER - SCTP_DISABLE_FRAGMENTS - SCTP_PEER_ADDR_PARAMS - SCTP_DEFAULT_SENT_PARAM - SCTP_EVENTS - SCTP_I_WANT_MAPPED_V4_ADDR - SCTP_MAXSEG - SCTP_STATUS - SCTP_GET_PEER_ADDR_INFO - SCTP_DELAYED_ACK_TIME - SCTP_DELAYED_ACK = SCTP_DELAYED_ACK_TIME - SCTP_DELAYED_SACK = SCTP_DELAYED_ACK_TIME - - SCTP_SOCKOPT_BINDX_ADD = 100 - SCTP_SOCKOPT_BINDX_REM = 101 - SCTP_SOCKOPT_PEELOFF = 102 - SCTP_GET_PEER_ADDRS = 108 - SCTP_GET_LOCAL_ADDRS = 109 - SCTP_SOCKOPT_CONNECTX = 110 - SCTP_SOCKOPT_CONNECTX3 = 111 -) - -const ( - SCTP_EVENT_DATA_IO = 1 << iota - SCTP_EVENT_ASSOCIATION - SCTP_EVENT_ADDRESS - SCTP_EVENT_SEND_FAILURE - SCTP_EVENT_PEER_ERROR - SCTP_EVENT_SHUTDOWN - SCTP_EVENT_PARTIAL_DELIVERY - SCTP_EVENT_ADAPTATION_LAYER - SCTP_EVENT_AUTHENTICATION - SCTP_EVENT_SENDER_DRY - - SCTP_EVENT_ALL = SCTP_EVENT_DATA_IO | SCTP_EVENT_ASSOCIATION | SCTP_EVENT_ADDRESS | SCTP_EVENT_SEND_FAILURE | SCTP_EVENT_PEER_ERROR | SCTP_EVENT_SHUTDOWN | SCTP_EVENT_PARTIAL_DELIVERY | SCTP_EVENT_ADAPTATION_LAYER | SCTP_EVENT_AUTHENTICATION | SCTP_EVENT_SENDER_DRY -) - -type SCTPNotificationType int - -const ( - SCTP_SN_TYPE_BASE = SCTPNotificationType(iota + (1 << 15)) - SCTP_ASSOC_CHANGE - SCTP_PEER_ADDR_CHANGE - SCTP_SEND_FAILED - SCTP_REMOTE_ERROR - SCTP_SHUTDOWN_EVENT - SCTP_PARTIAL_DELIVERY_EVENT - SCTP_ADAPTATION_INDICATION - SCTP_AUTHENTICATION_INDICATION - SCTP_SENDER_DRY_EVENT -) - -type NotificationHandler func([]byte) error - -type EventSubscribe struct { - DataIO uint8 - Association uint8 - Address uint8 - SendFailure uint8 - PeerError uint8 - Shutdown uint8 - PartialDelivery uint8 - AdaptationLayer uint8 - Authentication uint8 - SenderDry uint8 -} - -const ( - SCTP_CMSG_INIT = iota - SCTP_CMSG_SNDRCV - SCTP_CMSG_SNDINFO - SCTP_CMSG_RCVINFO - SCTP_CMSG_NXTINFO -) - -const ( - SCTP_UNORDERED = 1 << iota - SCTP_ADDR_OVER - SCTP_ABORT - SCTP_SACK_IMMEDIATELY - SCTP_EOF -) - -const ( - SCTP_MAX_STREAM = 0xffff -) - -type InitMsg struct { - NumOstreams uint16 - MaxInstreams uint16 - MaxAttempts uint16 - MaxInitTimeout uint16 -} - -type SndRcvInfo struct { - Stream uint16 - SSN uint16 - Flags uint16 - _ uint16 - PPID uint32 - Context uint32 - TTL uint32 - TSN uint32 - CumTSN uint32 - AssocID int32 -} - -type SndInfo struct { - SID uint16 - Flags uint16 - PPID uint32 - Context uint32 - AssocID int32 -} - -type GetAddrsOld struct { - AssocID int32 - AddrNum int32 - Addrs uintptr -} - -type NotificationHeader struct { - Type uint16 - Flags uint16 - Length uint32 -} - -type SCTPState uint16 - -const ( - SCTP_COMM_UP = SCTPState(iota) - SCTP_COMM_LOST - SCTP_RESTART - SCTP_SHUTDOWN_COMP - SCTP_CANT_STR_ASSOC -) - -var nativeEndian binary.ByteOrder -var sndRcvInfoSize uintptr - -func init() { - i := uint16(1) - if *(*byte)(unsafe.Pointer(&i)) == 0 { - nativeEndian = binary.BigEndian - } else { - nativeEndian = binary.LittleEndian - } - info := SndRcvInfo{} - sndRcvInfoSize = unsafe.Sizeof(info) -} - -func toBuf(v interface{}) []byte { - var buf bytes.Buffer - binary.Write(&buf, nativeEndian, v) - return buf.Bytes() -} - -func htons(h uint16) uint16 { - if nativeEndian == binary.LittleEndian { - return (h << 8 & 0xff00) | (h >> 8 & 0xff) - } - return h -} - -var ntohs = htons - -// setInitOpts sets options for an SCTP association initialization -// see https://tools.ietf.org/html/rfc4960#page-25 -func setInitOpts(fd int, options InitMsg) error { - optlen := unsafe.Sizeof(options) - _, _, err := setsockopt(fd, SCTP_INITMSG, uintptr(unsafe.Pointer(&options)), uintptr(optlen)) - return err -} - -func setNumOstreams(fd, num int) error { - return setInitOpts(fd, InitMsg{NumOstreams: uint16(num)}) -} - -type SCTPAddr struct { - IPAddrs []net.IPAddr - Port int -} - -func (a *SCTPAddr) ToRawSockAddrBuf() []byte { - p := htons(uint16(a.Port)) - if len(a.IPAddrs) == 0 { // if a.IPAddrs list is empty - fall back to IPv4 zero addr - s := syscall.RawSockaddrInet4{ - Family: syscall.AF_INET, - Port: p, - } - copy(s.Addr[:], net.IPv4zero) - return toBuf(s) - } - buf := []byte{} - for _, ip := range a.IPAddrs { - ipBytes := ip.IP - if len(ipBytes) == 0 { - ipBytes = net.IPv4zero - } - if ip4 := ipBytes.To4(); ip4 != nil { - s := syscall.RawSockaddrInet4{ - Family: syscall.AF_INET, - Port: p, - } - copy(s.Addr[:], ip4) - buf = append(buf, toBuf(s)...) - } else { - var scopeid uint32 - ifi, err := net.InterfaceByName(ip.Zone) - if err == nil { - scopeid = uint32(ifi.Index) - } - s := syscall.RawSockaddrInet6{ - Family: syscall.AF_INET6, - Port: p, - Scope_id: scopeid, - } - copy(s.Addr[:], ipBytes) - buf = append(buf, toBuf(s)...) - } - } - return buf -} - -func (a *SCTPAddr) String() string { - var b bytes.Buffer - - for n, i := range a.IPAddrs { - if i.IP.To4() != nil { - b.WriteString(i.String()) - } else if i.IP.To16() != nil { - b.WriteRune('[') - b.WriteString(i.String()) - b.WriteRune(']') - } - if n < len(a.IPAddrs)-1 { - b.WriteRune('/') - } - } - b.WriteRune(':') - b.WriteString(strconv.Itoa(a.Port)) - return b.String() -} - -func (a *SCTPAddr) Network() string { return "sctp" } - -func ResolveSCTPAddr(network, addrs string) (*SCTPAddr, error) { - tcpnet := "" - switch network { - case "", "sctp": - tcpnet = "tcp" - case "sctp4": - tcpnet = "tcp4" - case "sctp6": - tcpnet = "tcp6" - default: - return nil, fmt.Errorf("invalid net: %s", network) - } - elems := strings.Split(addrs, "/") - if len(elems) == 0 { - return nil, fmt.Errorf("invalid input: %s", addrs) - } - ipaddrs := make([]net.IPAddr, 0, len(elems)) - for _, e := range elems[:len(elems)-1] { - tcpa, err := net.ResolveTCPAddr(tcpnet, e+":") - if err != nil { - return nil, err - } - ipaddrs = append(ipaddrs, net.IPAddr{IP: tcpa.IP, Zone: tcpa.Zone}) - } - tcpa, err := net.ResolveTCPAddr(tcpnet, elems[len(elems)-1]) - if err != nil { - return nil, err - } - if tcpa.IP != nil { - ipaddrs = append(ipaddrs, net.IPAddr{IP: tcpa.IP, Zone: tcpa.Zone}) - } else { - ipaddrs = nil - } - return &SCTPAddr{ - IPAddrs: ipaddrs, - Port: tcpa.Port, - }, nil -} - -func SCTPConnect(fd int, addr *SCTPAddr) (int, error) { - buf := addr.ToRawSockAddrBuf() - param := GetAddrsOld{ - AddrNum: int32(len(buf)), - Addrs: uintptr(uintptr(unsafe.Pointer(&buf[0]))), - } - optlen := unsafe.Sizeof(param) - _, _, err := getsockopt(fd, SCTP_SOCKOPT_CONNECTX3, uintptr(unsafe.Pointer(¶m)), uintptr(unsafe.Pointer(&optlen))) - if err == nil { - return int(param.AssocID), nil - } else if err != syscall.ENOPROTOOPT { - return 0, err - } - r0, _, err := setsockopt(fd, SCTP_SOCKOPT_CONNECTX, uintptr(unsafe.Pointer(&buf[0])), uintptr(len(buf))) - return int(r0), err -} - -func SCTPBind(fd int, addr *SCTPAddr, flags int) error { - var option uintptr - switch flags { - case SCTP_BINDX_ADD_ADDR: - option = SCTP_SOCKOPT_BINDX_ADD - case SCTP_BINDX_REM_ADDR: - option = SCTP_SOCKOPT_BINDX_REM - default: - return syscall.EINVAL - } - - buf := addr.ToRawSockAddrBuf() - _, _, err := setsockopt(fd, option, uintptr(unsafe.Pointer(&buf[0])), uintptr(len(buf))) - return err -} - -type SCTPConn struct { - _fd int32 - notificationHandler NotificationHandler -} - -func (c *SCTPConn) fd() int { - return int(atomic.LoadInt32(&c._fd)) -} - -func NewSCTPConn(fd int, handler NotificationHandler) *SCTPConn { - conn := &SCTPConn{ - _fd: int32(fd), - notificationHandler: handler, - } - return conn -} - -func (c *SCTPConn) Write(b []byte) (int, error) { - return c.SCTPWrite(b, nil) -} - -func (c *SCTPConn) Read(b []byte) (int, error) { - n, _, err := c.SCTPRead(b) - if n < 0 { - n = 0 - } - return n, err -} - -func (c *SCTPConn) SetInitMsg(numOstreams, maxInstreams, maxAttempts, maxInitTimeout int) error { - return setInitOpts(c.fd(), InitMsg{ - NumOstreams: uint16(numOstreams), - MaxInstreams: uint16(maxInstreams), - MaxAttempts: uint16(maxAttempts), - MaxInitTimeout: uint16(maxInitTimeout), - }) -} - -func (c *SCTPConn) SubscribeEvents(flags int) error { - var d, a, ad, sf, p, sh, pa, ada, au, se uint8 - if flags&SCTP_EVENT_DATA_IO > 0 { - d = 1 - } - if flags&SCTP_EVENT_ASSOCIATION > 0 { - a = 1 - } - if flags&SCTP_EVENT_ADDRESS > 0 { - ad = 1 - } - if flags&SCTP_EVENT_SEND_FAILURE > 0 { - sf = 1 - } - if flags&SCTP_EVENT_PEER_ERROR > 0 { - p = 1 - } - if flags&SCTP_EVENT_SHUTDOWN > 0 { - sh = 1 - } - if flags&SCTP_EVENT_PARTIAL_DELIVERY > 0 { - pa = 1 - } - if flags&SCTP_EVENT_ADAPTATION_LAYER > 0 { - ada = 1 - } - if flags&SCTP_EVENT_AUTHENTICATION > 0 { - au = 1 - } - if flags&SCTP_EVENT_SENDER_DRY > 0 { - se = 1 - } - param := EventSubscribe{ - DataIO: d, - Association: a, - Address: ad, - SendFailure: sf, - PeerError: p, - Shutdown: sh, - PartialDelivery: pa, - AdaptationLayer: ada, - Authentication: au, - SenderDry: se, - } - optlen := unsafe.Sizeof(param) - _, _, err := setsockopt(c.fd(), SCTP_EVENTS, uintptr(unsafe.Pointer(¶m)), uintptr(optlen)) - return err -} - -func (c *SCTPConn) SubscribedEvents() (int, error) { - param := EventSubscribe{} - optlen := unsafe.Sizeof(param) - _, _, err := getsockopt(c.fd(), SCTP_EVENTS, uintptr(unsafe.Pointer(¶m)), uintptr(unsafe.Pointer(&optlen))) - if err != nil { - return 0, err - } - var flags int - if param.DataIO > 0 { - flags |= SCTP_EVENT_DATA_IO - } - if param.Association > 0 { - flags |= SCTP_EVENT_ASSOCIATION - } - if param.Address > 0 { - flags |= SCTP_EVENT_ADDRESS - } - if param.SendFailure > 0 { - flags |= SCTP_EVENT_SEND_FAILURE - } - if param.PeerError > 0 { - flags |= SCTP_EVENT_PEER_ERROR - } - if param.Shutdown > 0 { - flags |= SCTP_EVENT_SHUTDOWN - } - if param.PartialDelivery > 0 { - flags |= SCTP_EVENT_PARTIAL_DELIVERY - } - if param.AdaptationLayer > 0 { - flags |= SCTP_EVENT_ADAPTATION_LAYER - } - if param.Authentication > 0 { - flags |= SCTP_EVENT_AUTHENTICATION - } - if param.SenderDry > 0 { - flags |= SCTP_EVENT_SENDER_DRY - } - return flags, nil -} - -func (c *SCTPConn) SetDefaultSentParam(info *SndRcvInfo) error { - optlen := unsafe.Sizeof(*info) - _, _, err := setsockopt(c.fd(), SCTP_DEFAULT_SENT_PARAM, uintptr(unsafe.Pointer(info)), uintptr(optlen)) - return err -} - -func (c *SCTPConn) GetDefaultSentParam() (*SndRcvInfo, error) { - info := &SndRcvInfo{} - optlen := unsafe.Sizeof(*info) - _, _, err := getsockopt(c.fd(), SCTP_DEFAULT_SENT_PARAM, uintptr(unsafe.Pointer(info)), uintptr(unsafe.Pointer(&optlen))) - return info, err -} - -func (c *SCTPConn) Getsockopt(optname, optval, optlen uintptr) (uintptr, uintptr, error) { - return getsockopt(c.fd(), optname, optval, optlen) -} - -func (c *SCTPConn) Setsockopt(optname, optval, optlen uintptr) (uintptr, uintptr, error) { - return setsockopt(c.fd(), optname, optval, optlen) -} - -func resolveFromRawAddr(ptr unsafe.Pointer, n int) (*SCTPAddr, error) { - addr := &SCTPAddr{ - IPAddrs: make([]net.IPAddr, n), - } - - switch family := (*(*syscall.RawSockaddrAny)(ptr)).Addr.Family; family { - case syscall.AF_INET: - addr.Port = int(ntohs(uint16((*(*syscall.RawSockaddrInet4)(ptr)).Port))) - tmp := syscall.RawSockaddrInet4{} - size := unsafe.Sizeof(tmp) - for i := 0; i < n; i++ { - a := *(*syscall.RawSockaddrInet4)(unsafe.Pointer( - uintptr(ptr) + size*uintptr(i))) - addr.IPAddrs[i] = net.IPAddr{IP: a.Addr[:]} - } - case syscall.AF_INET6: - addr.Port = int(ntohs(uint16((*(*syscall.RawSockaddrInet4)(ptr)).Port))) - tmp := syscall.RawSockaddrInet6{} - size := unsafe.Sizeof(tmp) - for i := 0; i < n; i++ { - a := *(*syscall.RawSockaddrInet6)(unsafe.Pointer( - uintptr(ptr) + size*uintptr(i))) - var zone string - ifi, err := net.InterfaceByIndex(int(a.Scope_id)) - if err == nil { - zone = ifi.Name - } - addr.IPAddrs[i] = net.IPAddr{IP: a.Addr[:], Zone: zone} - } - default: - return nil, fmt.Errorf("unknown address family: %d", family) - } - return addr, nil -} - -func sctpGetAddrs(fd, id, optname int) (*SCTPAddr, error) { - - type getaddrs struct { - assocId int32 - addrNum uint32 - addrs [4096]byte - } - param := getaddrs{ - assocId: int32(id), - } - optlen := unsafe.Sizeof(param) - _, _, err := getsockopt(fd, uintptr(optname), uintptr(unsafe.Pointer(¶m)), uintptr(unsafe.Pointer(&optlen))) - if err != nil { - return nil, err - } - return resolveFromRawAddr(unsafe.Pointer(¶m.addrs), int(param.addrNum)) -} - -func (c *SCTPConn) SCTPGetPrimaryPeerAddr() (*SCTPAddr, error) { - - type sctpGetSetPrim struct { - assocId int32 - addrs [128]byte - } - param := sctpGetSetPrim{ - assocId: int32(0), - } - optlen := unsafe.Sizeof(param) - _, _, err := getsockopt(c.fd(), SCTP_PRIMARY_ADDR, uintptr(unsafe.Pointer(¶m)), uintptr(unsafe.Pointer(&optlen))) - if err != nil { - return nil, err - } - return resolveFromRawAddr(unsafe.Pointer(¶m.addrs), 1) -} - -func (c *SCTPConn) SCTPLocalAddr(id int) (*SCTPAddr, error) { - return sctpGetAddrs(c.fd(), id, SCTP_GET_LOCAL_ADDRS) -} - -func (c *SCTPConn) SCTPRemoteAddr(id int) (*SCTPAddr, error) { - return sctpGetAddrs(c.fd(), id, SCTP_GET_PEER_ADDRS) -} - -func (c *SCTPConn) LocalAddr() net.Addr { - addr, err := sctpGetAddrs(c.fd(), 0, SCTP_GET_LOCAL_ADDRS) - if err != nil { - return nil - } - return addr -} - -func (c *SCTPConn) RemoteAddr() net.Addr { - addr, err := sctpGetAddrs(c.fd(), 0, SCTP_GET_PEER_ADDRS) - if err != nil { - return nil - } - return addr -} - -func (c *SCTPConn) PeelOff(id int) (*SCTPConn, error) { - type peeloffArg struct { - assocId int32 - sd int - } - param := peeloffArg{ - assocId: int32(id), - } - optlen := unsafe.Sizeof(param) - _, _, err := getsockopt(c.fd(), SCTP_SOCKOPT_PEELOFF, uintptr(unsafe.Pointer(¶m)), uintptr(unsafe.Pointer(&optlen))) - if err != nil { - return nil, err - } - return &SCTPConn{_fd: int32(param.sd)}, nil -} - -func (c *SCTPConn) SetDeadline(t time.Time) error { - return syscall.EOPNOTSUPP -} - -func (c *SCTPConn) SetReadDeadline(t time.Time) error { - return syscall.EOPNOTSUPP -} - -func (c *SCTPConn) SetWriteDeadline(t time.Time) error { - return syscall.EOPNOTSUPP -} - -type SCTPListener struct { - fd int - m sync.Mutex -} - -func (ln *SCTPListener) Addr() net.Addr { - laddr, err := sctpGetAddrs(ln.fd, 0, SCTP_GET_LOCAL_ADDRS) - if err != nil { - return nil - } - return laddr -} - -type SCTPSndRcvInfoWrappedConn struct { - conn *SCTPConn -} - -func NewSCTPSndRcvInfoWrappedConn(conn *SCTPConn) *SCTPSndRcvInfoWrappedConn { - conn.SubscribeEvents(SCTP_EVENT_DATA_IO) - return &SCTPSndRcvInfoWrappedConn{conn} -} - -func (c *SCTPSndRcvInfoWrappedConn) Write(b []byte) (int, error) { - if len(b) < int(sndRcvInfoSize) { - return 0, syscall.EINVAL - } - info := (*SndRcvInfo)(unsafe.Pointer(&b[0])) - n, err := c.conn.SCTPWrite(b[sndRcvInfoSize:], info) - return n + int(sndRcvInfoSize), err -} - -func (c *SCTPSndRcvInfoWrappedConn) Read(b []byte) (int, error) { - if len(b) < int(sndRcvInfoSize) { - return 0, syscall.EINVAL - } - n, info, err := c.conn.SCTPRead(b[sndRcvInfoSize:]) - if err != nil { - return n, err - } - copy(b, toBuf(info)) - return n + int(sndRcvInfoSize), err -} - -func (c *SCTPSndRcvInfoWrappedConn) Close() error { - return c.conn.Close() -} - -func (c *SCTPSndRcvInfoWrappedConn) LocalAddr() net.Addr { - return c.conn.LocalAddr() -} - -func (c *SCTPSndRcvInfoWrappedConn) RemoteAddr() net.Addr { - return c.conn.RemoteAddr() -} - -func (c *SCTPSndRcvInfoWrappedConn) SetDeadline(t time.Time) error { - return c.conn.SetDeadline(t) -} - -func (c *SCTPSndRcvInfoWrappedConn) SetReadDeadline(t time.Time) error { - return c.conn.SetReadDeadline(t) -} - -func (c *SCTPSndRcvInfoWrappedConn) SetWriteDeadline(t time.Time) error { - return c.conn.SetWriteDeadline(t) -} - -func (c *SCTPSndRcvInfoWrappedConn) SetWriteBuffer(bytes int) error { - return c.conn.SetWriteBuffer(bytes) -} - -func (c *SCTPSndRcvInfoWrappedConn) GetWriteBuffer() (int, error) { - return c.conn.GetWriteBuffer() -} - -func (c *SCTPSndRcvInfoWrappedConn) SetReadBuffer(bytes int) error { - return c.conn.SetReadBuffer(bytes) -} - -func (c *SCTPSndRcvInfoWrappedConn) GetReadBuffer() (int, error) { - return c.conn.GetReadBuffer() -} - -// SocketConfig contains options for the SCTP socket. -type SocketConfig struct { - // If Control is not nil it is called after the socket is created but before - // it is bound or connected. - Control func(network, address string, c syscall.RawConn) error - - // InitMsg is the options to send in the initial SCTP message - InitMsg InitMsg -} - -func (cfg *SocketConfig) Listen(net string, laddr *SCTPAddr) (*SCTPListener, error) { - return listenSCTPExtConfig(net, laddr, cfg.InitMsg, cfg.Control) -} - -func (cfg *SocketConfig) Dial(net string, laddr, raddr *SCTPAddr) (*SCTPConn, error) { - return dialSCTPExtConfig(net, laddr, raddr, cfg.InitMsg, cfg.Control) -} diff --git a/vendor/github.com/ishidawataru/sctp/sctp_linux.go b/vendor/github.com/ishidawataru/sctp/sctp_linux.go deleted file mode 100644 index e11d012cff..0000000000 --- a/vendor/github.com/ishidawataru/sctp/sctp_linux.go +++ /dev/null @@ -1,309 +0,0 @@ -// +build linux,!386 -// Copyright 2019 Wataru Ishida. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -// implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package sctp - -import ( - "io" - "net" - "sync/atomic" - "syscall" - "unsafe" - "runtime" -) - -func setsockopt(fd int, optname, optval, optlen uintptr) (uintptr, uintptr, error) { - // FIXME: syscall.SYS_SETSOCKOPT is undefined on 386 - r0, r1, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, - uintptr(fd), - SOL_SCTP, - optname, - optval, - optlen, - 0) - if errno != 0 { - return r0, r1, errno - } - return r0, r1, nil -} - -func getsockopt(fd int, optname, optval, optlen uintptr) (uintptr, uintptr, error) { - if runtime.GOARCH == "s390x" { - optlen = uintptr(unsafe.Pointer(&optlen)) - } - // FIXME: syscall.SYS_GETSOCKOPT is undefined on 386 - r0, r1, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, - uintptr(fd), - SOL_SCTP, - optname, - optval, - optlen, - 0) - if errno != 0 { - return r0, r1, errno - } - return r0, r1, nil -} - -type rawConn struct { - sockfd int -} - -func (r rawConn) Control(f func(fd uintptr)) error { - f(uintptr(r.sockfd)) - return nil -} - -func (r rawConn) Read(f func(fd uintptr) (done bool)) error { - panic("not implemented") -} - -func (r rawConn) Write(f func(fd uintptr) (done bool)) error { - panic("not implemented") -} - -func (c *SCTPConn) SCTPWrite(b []byte, info *SndRcvInfo) (int, error) { - var cbuf []byte - if info != nil { - cmsgBuf := toBuf(info) - hdr := &syscall.Cmsghdr{ - Level: syscall.IPPROTO_SCTP, - Type: SCTP_CMSG_SNDRCV, - } - - // bitwidth of hdr.Len is platform-specific, - // so we use hdr.SetLen() rather than directly setting hdr.Len - hdr.SetLen(syscall.CmsgSpace(len(cmsgBuf))) - cbuf = append(toBuf(hdr), cmsgBuf...) - } - return syscall.SendmsgN(c.fd(), b, cbuf, nil, 0) -} - -func parseSndRcvInfo(b []byte) (*SndRcvInfo, error) { - msgs, err := syscall.ParseSocketControlMessage(b) - if err != nil { - return nil, err - } - for _, m := range msgs { - if m.Header.Level == syscall.IPPROTO_SCTP { - switch m.Header.Type { - case SCTP_CMSG_SNDRCV: - return (*SndRcvInfo)(unsafe.Pointer(&m.Data[0])), nil - } - } - } - return nil, nil -} - -func (c *SCTPConn) SCTPRead(b []byte) (int, *SndRcvInfo, error) { - oob := make([]byte, 254) - for { - n, oobn, recvflags, _, err := syscall.Recvmsg(c.fd(), b, oob, 0) - if err != nil { - return n, nil, err - } - - if n == 0 && oobn == 0 { - return 0, nil, io.EOF - } - - if recvflags&MSG_NOTIFICATION > 0 && c.notificationHandler != nil { - if err := c.notificationHandler(b[:n]); err != nil { - return 0, nil, err - } - } else { - var info *SndRcvInfo - if oobn > 0 { - info, err = parseSndRcvInfo(oob[:oobn]) - } - return n, info, err - } - } -} - -func (c *SCTPConn) Close() error { - if c != nil { - fd := atomic.SwapInt32(&c._fd, -1) - if fd > 0 { - info := &SndRcvInfo{ - Flags: SCTP_EOF, - } - c.SCTPWrite(nil, info) - syscall.Shutdown(int(fd), syscall.SHUT_RDWR) - return syscall.Close(int(fd)) - } - } - return syscall.EBADF -} - -func (c *SCTPConn) SetWriteBuffer(bytes int) error { - return syscall.SetsockoptInt(c.fd(), syscall.SOL_SOCKET, syscall.SO_SNDBUF, bytes) -} - -func (c *SCTPConn) GetWriteBuffer() (int, error) { - return syscall.GetsockoptInt(c.fd(), syscall.SOL_SOCKET, syscall.SO_SNDBUF) -} - -func (c *SCTPConn) SetReadBuffer(bytes int) error { - return syscall.SetsockoptInt(c.fd(), syscall.SOL_SOCKET, syscall.SO_RCVBUF, bytes) -} - -func (c *SCTPConn) GetReadBuffer() (int, error) { - return syscall.GetsockoptInt(c.fd(), syscall.SOL_SOCKET, syscall.SO_RCVBUF) -} - -// ListenSCTP - start listener on specified address/port -func ListenSCTP(net string, laddr *SCTPAddr) (*SCTPListener, error) { - return ListenSCTPExt(net, laddr, InitMsg{NumOstreams: SCTP_MAX_STREAM}) -} - -// ListenSCTPExt - start listener on specified address/port with given SCTP options -func ListenSCTPExt(network string, laddr *SCTPAddr, options InitMsg) (*SCTPListener, error) { - return listenSCTPExtConfig(network, laddr, options, nil) -} - -// listenSCTPExtConfig - start listener on specified address/port with given SCTP options and socket configuration -func listenSCTPExtConfig(network string, laddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error) (*SCTPListener, error) { - af, ipv6only := favoriteAddrFamily(network, laddr, nil, "listen") - sock, err := syscall.Socket( - af, - syscall.SOCK_STREAM, - syscall.IPPROTO_SCTP, - ) - if err != nil { - return nil, err - } - - // close socket on error - defer func() { - if err != nil { - syscall.Close(sock) - } - }() - if err = setDefaultSockopts(sock, af, ipv6only); err != nil { - return nil, err - } - if control != nil { - rc := rawConn{sockfd: sock} - if err = control(network, laddr.String(), rc); err != nil { - return nil, err - } - } - err = setInitOpts(sock, options) - if err != nil { - return nil, err - } - - if laddr != nil { - // If IP address and/or port was not provided so far, let's use the unspecified IPv4 or IPv6 address - if len(laddr.IPAddrs) == 0 { - if af == syscall.AF_INET { - laddr.IPAddrs = append(laddr.IPAddrs, net.IPAddr{IP: net.IPv4zero}) - } else if af == syscall.AF_INET6 { - laddr.IPAddrs = append(laddr.IPAddrs, net.IPAddr{IP: net.IPv6zero}) - } - } - err = SCTPBind(sock, laddr, SCTP_BINDX_ADD_ADDR) - if err != nil { - return nil, err - } - } - err = syscall.Listen(sock, syscall.SOMAXCONN) - if err != nil { - return nil, err - } - return &SCTPListener{ - fd: sock, - }, nil -} - -// AcceptSCTP waits for and returns the next SCTP connection to the listener. -func (ln *SCTPListener) AcceptSCTP() (*SCTPConn, error) { - fd, _, err := syscall.Accept4(ln.fd, 0) - return NewSCTPConn(fd, nil), err -} - -// Accept waits for and returns the next connection connection to the listener. -func (ln *SCTPListener) Accept() (net.Conn, error) { - return ln.AcceptSCTP() -} - -func (ln *SCTPListener) Close() error { - syscall.Shutdown(ln.fd, syscall.SHUT_RDWR) - return syscall.Close(ln.fd) -} - -// DialSCTP - bind socket to laddr (if given) and connect to raddr -func DialSCTP(net string, laddr, raddr *SCTPAddr) (*SCTPConn, error) { - return DialSCTPExt(net, laddr, raddr, InitMsg{NumOstreams: SCTP_MAX_STREAM}) -} - -// DialSCTPExt - same as DialSCTP but with given SCTP options -func DialSCTPExt(network string, laddr, raddr *SCTPAddr, options InitMsg) (*SCTPConn, error) { - return dialSCTPExtConfig(network, laddr, raddr, options, nil) -} - -// dialSCTPExtConfig - same as DialSCTP but with given SCTP options and socket configuration -func dialSCTPExtConfig(network string, laddr, raddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error) (*SCTPConn, error) { - af, ipv6only := favoriteAddrFamily(network, laddr, raddr, "dial") - sock, err := syscall.Socket( - af, - syscall.SOCK_STREAM, - syscall.IPPROTO_SCTP, - ) - if err != nil { - return nil, err - } - - // close socket on error - defer func() { - if err != nil { - syscall.Close(sock) - } - }() - if err = setDefaultSockopts(sock, af, ipv6only); err != nil { - return nil, err - } - if control != nil { - rc := rawConn{sockfd: sock} - if err = control(network, laddr.String(), rc); err != nil { - return nil, err - } - } - err = setInitOpts(sock, options) - if err != nil { - return nil, err - } - if laddr != nil { - // If IP address and/or port was not provided so far, let's use the unspecified IPv4 or IPv6 address - if len(laddr.IPAddrs) == 0 { - if af == syscall.AF_INET { - laddr.IPAddrs = append(laddr.IPAddrs, net.IPAddr{IP: net.IPv4zero}) - } else if af == syscall.AF_INET6 { - laddr.IPAddrs = append(laddr.IPAddrs, net.IPAddr{IP: net.IPv6zero}) - } - } - err = SCTPBind(sock, laddr, SCTP_BINDX_ADD_ADDR) - if err != nil { - return nil, err - } - } - _, err = SCTPConnect(sock, raddr) - if err != nil { - return nil, err - } - return NewSCTPConn(sock, nil), nil -} diff --git a/vendor/github.com/ishidawataru/sctp/sctp_unsupported.go b/vendor/github.com/ishidawataru/sctp/sctp_unsupported.go deleted file mode 100644 index 118fe159e9..0000000000 --- a/vendor/github.com/ishidawataru/sctp/sctp_unsupported.go +++ /dev/null @@ -1,98 +0,0 @@ -// +build !linux linux,386 -// Copyright 2019 Wataru Ishida. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -// implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package sctp - -import ( - "errors" - "net" - "runtime" - "syscall" -) - -var ErrUnsupported = errors.New("SCTP is unsupported on " + runtime.GOOS + "/" + runtime.GOARCH) - -func setsockopt(fd int, optname, optval, optlen uintptr) (uintptr, uintptr, error) { - return 0, 0, ErrUnsupported -} - -func getsockopt(fd int, optname, optval, optlen uintptr) (uintptr, uintptr, error) { - return 0, 0, ErrUnsupported -} - -func (c *SCTPConn) SCTPWrite(b []byte, info *SndRcvInfo) (int, error) { - return 0, ErrUnsupported -} - -func (c *SCTPConn) SCTPRead(b []byte) (int, *SndRcvInfo, error) { - return 0, nil, ErrUnsupported -} - -func (c *SCTPConn) Close() error { - return ErrUnsupported -} - -func (c *SCTPConn) SetWriteBuffer(bytes int) error { - return ErrUnsupported -} - -func (c *SCTPConn) GetWriteBuffer() (int, error) { - return 0, ErrUnsupported -} - -func (c *SCTPConn) SetReadBuffer(bytes int) error { - return ErrUnsupported -} - -func (c *SCTPConn) GetReadBuffer() (int, error) { - return 0, ErrUnsupported -} - -func ListenSCTP(net string, laddr *SCTPAddr) (*SCTPListener, error) { - return nil, ErrUnsupported -} - -func ListenSCTPExt(net string, laddr *SCTPAddr, options InitMsg) (*SCTPListener, error) { - return nil, ErrUnsupported -} - -func listenSCTPExtConfig(network string, laddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error) (*SCTPListener, error) { - return nil, ErrUnsupported -} - -func (ln *SCTPListener) Accept() (net.Conn, error) { - return nil, ErrUnsupported -} - -func (ln *SCTPListener) AcceptSCTP() (*SCTPConn, error) { - return nil, ErrUnsupported -} - -func (ln *SCTPListener) Close() error { - return ErrUnsupported -} - -func DialSCTP(net string, laddr, raddr *SCTPAddr) (*SCTPConn, error) { - return nil, ErrUnsupported -} - -func DialSCTPExt(network string, laddr, raddr *SCTPAddr, options InitMsg) (*SCTPConn, error) { - return nil, ErrUnsupported -} - -func dialSCTPExtConfig(network string, laddr, raddr *SCTPAddr, options InitMsg, control func(network, address string, c syscall.RawConn) error) (*SCTPConn, error) { - return nil, ErrUnsupported -} diff --git a/vendor/modules.txt b/vendor/modules.txt index cfd734e59e..eb9ddf5721 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -44,52 +44,12 @@ github.com/cloudflare/cfssl/signer/local # github.com/container-storage-interface/spec v1.2.0 ## explicit github.com/container-storage-interface/spec/lib/go/csi -# github.com/containerd/containerd v1.6.22 -## explicit; go 1.18 -github.com/containerd/containerd/log # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew # github.com/distribution/reference v0.5.0 ## explicit; go 1.20 github.com/distribution/reference -# github.com/docker/docker v24.0.0-rc.2.0.20230908212318-6ce5aa1cd5a4+incompatible -## explicit -github.com/docker/docker/errdefs -github.com/docker/docker/libnetwork/bitmap -github.com/docker/docker/libnetwork/discoverapi -github.com/docker/docker/libnetwork/driverapi -github.com/docker/docker/libnetwork/drivers/bridge/brmanager -github.com/docker/docker/libnetwork/drivers/host -github.com/docker/docker/libnetwork/drivers/ipvlan/ivmanager -github.com/docker/docker/libnetwork/drivers/macvlan/mvmanager -github.com/docker/docker/libnetwork/drivers/overlay/overlayutils -github.com/docker/docker/libnetwork/drivers/overlay/ovmanager -github.com/docker/docker/libnetwork/drivers/remote -github.com/docker/docker/libnetwork/drivers/remote/api -github.com/docker/docker/libnetwork/drvregistry -github.com/docker/docker/libnetwork/ipam -github.com/docker/docker/libnetwork/ipamapi -github.com/docker/docker/libnetwork/ipams/builtin -github.com/docker/docker/libnetwork/ipams/null -github.com/docker/docker/libnetwork/ipams/remote -github.com/docker/docker/libnetwork/ipams/remote/api -github.com/docker/docker/libnetwork/ipams/windowsipam -github.com/docker/docker/libnetwork/ipamutils -github.com/docker/docker/libnetwork/ipbits -github.com/docker/docker/libnetwork/netlabel -github.com/docker/docker/libnetwork/scope -github.com/docker/docker/libnetwork/types -github.com/docker/docker/pkg/homedir -github.com/docker/docker/pkg/ioutils -github.com/docker/docker/pkg/plugingetter -github.com/docker/docker/pkg/plugins -github.com/docker/docker/pkg/plugins/transport -github.com/docker/docker/pkg/rootless -# github.com/docker/go-connections v0.4.1-0.20231110212414-fa09c952e3ea -## explicit; go 1.18 -github.com/docker/go-connections/sockets -github.com/docker/go-connections/tlsconfig # github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c ## explicit github.com/docker/go-events @@ -180,9 +140,6 @@ github.com/hashicorp/golang-lru/simplelru # github.com/inconshreveable/mousetrap v1.1.0 ## explicit; go 1.18 github.com/inconshreveable/mousetrap -# github.com/ishidawataru/sctp v0.0.0-20230406120618-7ff4192f6ff2 -## explicit; go 1.12 -github.com/ishidawataru/sctp # github.com/jmoiron/sqlx v1.3.3 ## explicit; go 1.10 github.com/jmoiron/sqlx/types