diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index cedf11a93..e26bf8350 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -62,14 +62,14 @@ jobs: with: time: 30s - - name: Set logs result as environment variable - run: cd plugins/tyk && echo "TYK_DC_RESULT=$(docker-compose logs tyk-gateway | grep -i '\[INFO\] Olric bindAddr')" >> $GITHUB_ENV + name: Set Tyk logs configuration result as environment variable + run: cd plugins/tyk && echo "TYK_MIDDLEWARE_RESULT=$(docker-compose logs tyk-gateway | grep SouinResponseHandler)" >> $GITHUB_ENV - - name: Check Olric is loaded to define if Souin is loaded too + name: Check if the configuration is loaded to define if Souin is loaded too uses: nick-invision/assert-action@v1 with: - expected: '[INFO] Olric bindAddr' - actual: ${{ env.TYK_DC_RESULT }} + expected: 'level=info msg="Loaded Go response plugin: SouinResponseHandler" mwPath="/opt/tyk-gateway/middleware/souin-plugin.so" mwSymbolName=SouinResponseHandler' + actual: ${{ env.TYK_MIDDLEWARE_RESULT }} comparison: contains - name: Run Tyk E2E tests diff --git a/.gitignore b/.gitignore index 695b580de..89ad1a818 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ traefik.json *.iml plugins/caddy/caddy plugins/caddy/.github/* -vendor/ +/vendor/ diff --git a/README.md b/README.md index 31ee67dbd..12f823086 100644 --- a/README.md +++ b/README.md @@ -354,7 +354,7 @@ experimental: plugins: souin: moduleName: github.com/darkweak/souin - version: v1.5.11-beta2 + version: v1.5.11-beta5 ``` After that you can declare either the whole configuration at once in the middleware block or by service. See the examples below. ```yaml diff --git a/docs/e2e/Souin E2E.postman_collection.json b/docs/e2e/Souin E2E.postman_collection.json index 590be2d13..9d120d64a 100644 --- a/docs/e2e/Souin E2E.postman_collection.json +++ b/docs/e2e/Souin E2E.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "701efdfd-3e8c-4786-8ba3-bfd5871d6293", + "_postman_id": "6d3b2b13-1b7f-493b-aba5-2a479033f357", "name": "Souin E2E", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, @@ -234,46 +234,6 @@ }, "response": [] }, - { - "name": "Souin api", - "event": [ - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "test", - "script": { - "exec": [ - "utils.souinAPI.listKeys(pm, 'GET-domain.com-/', utils.getVar(pm, 'traefik_url'), '/')" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Cache-Control", - "value": "", - "type": "text" - } - ], - "url": { - "raw": "{{traefik_url}}{{souin_base_api}}{{souin_api}}", - "host": [ - "{{traefik_url}}{{souin_base_api}}{{souin_api}}" - ] - } - }, - "response": [] - }, { "name": "Default no cache", "event": [ @@ -331,7 +291,7 @@ "listen": "test", "script": { "exec": [ - "utils.baseEndpoint(pm, `${utils.getVar(pm, 'traefik_url')}/test_exclude_another`, '', false, true)" + "utils.baseEndpoint(pm, `${utils.getVar(pm, 'traefik_url')}/test_exclude_another`, 'cache', false, true)" ], "type": "text/javascript" } @@ -416,6 +376,62 @@ } }, "response": [] + }, + { + "name": "Default no cache", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "utils.baseEndpoint(pm, `${utils.getVar(pm, 'tyk_url')}/`, 'no-cache')" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{tyk_url}}/", + "host": [ + "{{tyk_url}}" + ], + "path": [ + "" + ] + } + }, + "response": [] + }, + { + "name": "Default no store", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "utils.baseEndpoint(pm, `${utils.getVar(pm, 'tyk_url')}/`, 'no-store')" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{tyk_url}}/", + "host": [ + "{{tyk_url}}" + ], + "path": [ + "" + ] + } + }, + "response": [] } ], "event": [ @@ -564,7 +580,7 @@ }, { "key": "tyk_url", - "value": "http://localhost:8080/httpbin" + "value": "http://localhost:4443/httpbin" } ] } diff --git a/go.mod b/go.mod index 0e935766c..1db79efd8 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,15 @@ module github.com/darkweak/souin go 1.16 require ( - github.com/buraksezer/olric v0.4.1-0.20211125194525-6be543336717 - github.com/dgraph-io/badger/v3 v3.2103.1 + github.com/buraksezer/olric v0.4.1-0.20211130141003-a889ee19dcd9 + github.com/dgraph-io/badger/v3 v3.2103.2 github.com/dgraph-io/ristretto v0.1.0 - github.com/fsnotify/fsnotify v1.4.9 - github.com/go-chi/stampede v0.4.5 + github.com/fsnotify/fsnotify v1.5.1 + github.com/go-chi/stampede v0.5.0 github.com/golang-jwt/jwt v3.2.2+incompatible github.com/google/uuid v1.3.0 github.com/imdario/mergo v0.3.12 github.com/pquerna/cachecontrol v0.1.0 - go.uber.org/zap v1.19.0 + go.uber.org/zap v1.19.1 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ) diff --git a/go.sum b/go.sum index 3fa9ab4c9..6c462a07e 100644 --- a/go.sum +++ b/go.sum @@ -15,6 +15,8 @@ github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72 h1:fUmDBbSvv github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72/go.mod h1:OEE5igu/CDjGegM1Jn6ZMo7R6LlV/JChAkjfQQIRLpg= github.com/buraksezer/olric v0.4.1-0.20211125194525-6be543336717 h1:uyCe3KrznXq2YGMrB4wxGf9UyZOzBHmsylPgkUzf8xo= github.com/buraksezer/olric v0.4.1-0.20211125194525-6be543336717/go.mod h1:jSgaKtv7MphQyVPqS2qGoecZKGqiL2YYmyQx9LUJk6Y= +github.com/buraksezer/olric v0.4.1-0.20211130141003-a889ee19dcd9 h1:oyFU+vboRDFCfHjecXS6GleoBwNoxG6Bk2tAAHl+kBA= +github.com/buraksezer/olric v0.4.1-0.20211130141003-a889ee19dcd9/go.mod h1:jSgaKtv7MphQyVPqS2qGoecZKGqiL2YYmyQx9LUJk6Y= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= @@ -30,6 +32,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgraph-io/badger/v3 v3.2103.1 h1:zaX53IRg7ycxVlkd5pYdCeFp1FynD6qBGQoQql3R3Hk= github.com/dgraph-io/badger/v3 v3.2103.1/go.mod h1:dULbq6ehJ5K0cGW/1TQ9iSfUk0gbSiToDWmWmTsJ53E= +github.com/dgraph-io/badger/v3 v3.2103.2 h1:dpyM5eCJAtQCBcMCZcT4UBZchuTJgCywerHHgmxfxM8= +github.com/dgraph-io/badger/v3 v3.2103.2/go.mod h1:RHo4/GmYcKKh5Lxu63wLEMHJ70Pac2JqZRYGhlyAo2M= github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= @@ -40,8 +44,13 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/go-chi/cors v1.2.0/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= github.com/go-chi/stampede v0.4.5 h1:/qEiOLkpBstcdVnlYfg7TEWfL4It3ruXYDKpJkmkZMQ= github.com/go-chi/stampede v0.4.5/go.mod h1:26lupLoxsX2qfPW6QCOEj8Gb1/KWpbH5XysNAoNojsU= +github.com/go-chi/stampede v0.5.0 h1:pby7lUVANhFHbjcorWiYhm/NVPyYnnLcBlpxbDpJrAI= +github.com/go-chi/stampede v0.5.0/go.mod h1:UFRS0DzmgIqq/LevhSX67qtc0hkykVdLHRc5MJxfgBQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= @@ -60,6 +69,8 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCy github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/flatbuffers v1.12.0 h1:/PtAHvnBY4Kqnx/xCQ3OIV9uYcSFGScBsWI3Oogeh6w= github.com/google/flatbuffers v1.12.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= +github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= @@ -145,16 +156,20 @@ github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6Ac github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.22.5 h1:dntmOdLpSpHlVqbW5Eay97DelsZHe+55D+xC6i0dDS0= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.19.0 h1:mZQZefskPPCMIBCSEH0v2/iUqqLrYtaeqwD6FUGUnFE= go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -171,6 +186,7 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -183,6 +199,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200930145003-4acb6c075d10/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -193,6 +211,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200930132711-30421366ff76/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -204,8 +224,14 @@ golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -218,6 +244,7 @@ golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/plugins/caddy/go.mod b/plugins/caddy/go.mod index 6f146a0ce..e05ecdb85 100644 --- a/plugins/caddy/go.mod +++ b/plugins/caddy/go.mod @@ -5,7 +5,7 @@ go 1.16 require ( github.com/caddyserver/caddy/v2 v2.4.5 github.com/darkweak/souin v1.5.11 - go.uber.org/zap v1.19.0 + go.uber.org/zap v1.19.1 ) replace github.com/darkweak/souin v1.5.11 => ../.. diff --git a/plugins/caddy/go.sum b/plugins/caddy/go.sum index 962e0f711..bdf77d9de 100644 --- a/plugins/caddy/go.sum +++ b/plugins/caddy/go.sum @@ -177,8 +177,8 @@ github.com/buraksezer/connpool v0.4.0 h1:fNLvWu0FOtJxL7Sqetm6+040mhZWVs8c6vrke14 github.com/buraksezer/connpool v0.4.0/go.mod h1:qPiG7gKXo+EjrwG/yqn2StZM4ek6gcYnnGgFIVKN6b0= github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72 h1:fUmDBbSvv1uOzo/t8WaxZMVb7BxJ8JECo5lGoR9c5bA= github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72/go.mod h1:OEE5igu/CDjGegM1Jn6ZMo7R6LlV/JChAkjfQQIRLpg= -github.com/buraksezer/olric v0.4.1-0.20211125194525-6be543336717 h1:uyCe3KrznXq2YGMrB4wxGf9UyZOzBHmsylPgkUzf8xo= -github.com/buraksezer/olric v0.4.1-0.20211125194525-6be543336717/go.mod h1:jSgaKtv7MphQyVPqS2qGoecZKGqiL2YYmyQx9LUJk6Y= +github.com/buraksezer/olric v0.4.1-0.20211130141003-a889ee19dcd9 h1:oyFU+vboRDFCfHjecXS6GleoBwNoxG6Bk2tAAHl+kBA= +github.com/buraksezer/olric v0.4.1-0.20211130141003-a889ee19dcd9/go.mod h1:jSgaKtv7MphQyVPqS2qGoecZKGqiL2YYmyQx9LUJk6Y= github.com/caarlos0/ctrlc v1.0.0/go.mod h1:CdXpj4rmq0q/1Eb44M9zi2nKB0QraNKuRGYGrrHhcQw= github.com/caddyserver/caddy/v2 v2.4.5 h1:P1mRs6V2cMcagSPn+NWpD+OEYUYLIf6ecOa48cFGeUg= github.com/caddyserver/caddy/v2 v2.4.5/go.mod h1:YhfZAAh3jWSbG6rEEOM49FwxmcbLY2fZQVlo59Sc/80= @@ -250,8 +250,8 @@ github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrV github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20201003150343-5d1bab4fc658/go.mod h1:2uGEvGm+JSDLd5UAaKIFSbXDcYyeH0fWJP4N2HMMYMI= github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= -github.com/dgraph-io/badger/v3 v3.2103.1 h1:zaX53IRg7ycxVlkd5pYdCeFp1FynD6qBGQoQql3R3Hk= -github.com/dgraph-io/badger/v3 v3.2103.1/go.mod h1:dULbq6ehJ5K0cGW/1TQ9iSfUk0gbSiToDWmWmTsJ53E= +github.com/dgraph-io/badger/v3 v3.2103.2 h1:dpyM5eCJAtQCBcMCZcT4UBZchuTJgCywerHHgmxfxM8= +github.com/dgraph-io/badger/v3 v3.2103.2/go.mod h1:RHo4/GmYcKKh5Lxu63wLEMHJ70Pac2JqZRYGhlyAo2M= github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgraph-io/ristretto v0.0.4-0.20200906165740-41ebdbffecfd/go.mod h1:YylP9MpCYGVZQrly/j/diqcdUetCRRePeBB0c2VGXsA= @@ -297,8 +297,9 @@ github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiD github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/fullstorydev/grpcurl v1.8.0/go.mod h1:Mn2jWbdMrQGJQ8UD62uNyMumT2acsZUCkZIqFxsQf1o= github.com/fullstorydev/grpcurl v1.8.1/go.mod h1:3BWhvHZwNO7iLXaQlojdg5NA6SxUDePli4ecpK1N7gw= github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= @@ -308,8 +309,10 @@ github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aev github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec= github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= -github.com/go-chi/stampede v0.4.5 h1:/qEiOLkpBstcdVnlYfg7TEWfL4It3ruXYDKpJkmkZMQ= -github.com/go-chi/stampede v0.4.5/go.mod h1:26lupLoxsX2qfPW6QCOEj8Gb1/KWpbH5XysNAoNojsU= +github.com/go-chi/cors v1.2.0 h1:tV1g1XENQ8ku4Bq3K9ub2AtgG+p16SmzeMSGTwrOKdE= +github.com/go-chi/cors v1.2.0/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= +github.com/go-chi/stampede v0.5.0 h1:pby7lUVANhFHbjcorWiYhm/NVPyYnnLcBlpxbDpJrAI= +github.com/go-chi/stampede v0.5.0/go.mod h1:UFRS0DzmgIqq/LevhSX67qtc0hkykVdLHRc5MJxfgBQ= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -403,8 +406,8 @@ github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB github.com/google/certificate-transparency-go v1.1.2-0.20210422104406-9f33727a7a18/go.mod h1:6CKh9dscIRoqc2kC6YUFICHZMT9NrClyPrRVFrdw1QQ= github.com/google/certificate-transparency-go v1.1.2-0.20210512142713-bed466244fa6/go.mod h1:aF2dp7Dh81mY8Y/zpzyXps4fQW5zQbDu2CxfpJB6NkI= github.com/google/certificate-transparency-go v1.1.2-0.20210623111010-a50f74f4ce95/go.mod h1:Qj+RD7dL44/KQVYkRk4wDVszkPOzxNcHmuX4HCMEqKg= -github.com/google/flatbuffers v1.12.0 h1:/PtAHvnBY4Kqnx/xCQ3OIV9uYcSFGScBsWI3Oogeh6w= -github.com/google/flatbuffers v1.12.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= +github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -1036,8 +1039,9 @@ go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= @@ -1049,8 +1053,9 @@ go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= -go.uber.org/zap v1.19.0 h1:mZQZefskPPCMIBCSEH0v2/iUqqLrYtaeqwD6FUGUnFE= go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= gocloud.dev v0.19.0/go.mod h1:SmKwiR8YwIMMJvQBKLsC3fHNyMwXLw3PMDO+VVteJMI= golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= @@ -1104,7 +1109,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -1391,8 +1395,9 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3 h1:L69ShwSZEyCsLKoAxDKeMvLDZkumEe8gXUZAjab0tX8= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/plugins/traefik/go.mod b/plugins/traefik/go.mod index ab0f6de77..41a538514 100644 --- a/plugins/traefik/go.mod +++ b/plugins/traefik/go.mod @@ -6,7 +6,7 @@ require ( github.com/darkweak/souin v1.5.10 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pquerna/cachecontrol v0.1.0 - go.uber.org/zap v1.19.0 + go.uber.org/zap v1.19.1 golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e // indirect ) diff --git a/plugins/traefik/go.sum b/plugins/traefik/go.sum index 84ee35b51..6cc5199a7 100644 --- a/plugins/traefik/go.sum +++ b/plugins/traefik/go.sum @@ -13,8 +13,8 @@ github.com/buraksezer/connpool v0.4.0 h1:fNLvWu0FOtJxL7Sqetm6+040mhZWVs8c6vrke14 github.com/buraksezer/connpool v0.4.0/go.mod h1:qPiG7gKXo+EjrwG/yqn2StZM4ek6gcYnnGgFIVKN6b0= github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72 h1:fUmDBbSvv1uOzo/t8WaxZMVb7BxJ8JECo5lGoR9c5bA= github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72/go.mod h1:OEE5igu/CDjGegM1Jn6ZMo7R6LlV/JChAkjfQQIRLpg= -github.com/buraksezer/olric v0.4.1-0.20211125194525-6be543336717 h1:uyCe3KrznXq2YGMrB4wxGf9UyZOzBHmsylPgkUzf8xo= -github.com/buraksezer/olric v0.4.1-0.20211125194525-6be543336717/go.mod h1:jSgaKtv7MphQyVPqS2qGoecZKGqiL2YYmyQx9LUJk6Y= +github.com/buraksezer/olric v0.4.1-0.20211130141003-a889ee19dcd9 h1:oyFU+vboRDFCfHjecXS6GleoBwNoxG6Bk2tAAHl+kBA= +github.com/buraksezer/olric v0.4.1-0.20211130141003-a889ee19dcd9/go.mod h1:jSgaKtv7MphQyVPqS2qGoecZKGqiL2YYmyQx9LUJk6Y= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= @@ -28,8 +28,8 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgraph-io/badger/v3 v3.2103.1 h1:zaX53IRg7ycxVlkd5pYdCeFp1FynD6qBGQoQql3R3Hk= -github.com/dgraph-io/badger/v3 v3.2103.1/go.mod h1:dULbq6ehJ5K0cGW/1TQ9iSfUk0gbSiToDWmWmTsJ53E= +github.com/dgraph-io/badger/v3 v3.2103.2 h1:dpyM5eCJAtQCBcMCZcT4UBZchuTJgCywerHHgmxfxM8= +github.com/dgraph-io/badger/v3 v3.2103.2/go.mod h1:RHo4/GmYcKKh5Lxu63wLEMHJ70Pac2JqZRYGhlyAo2M= github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= @@ -38,9 +38,11 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4 github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/go-chi/stampede v0.4.5 h1:/qEiOLkpBstcdVnlYfg7TEWfL4It3ruXYDKpJkmkZMQ= -github.com/go-chi/stampede v0.4.5/go.mod h1:26lupLoxsX2qfPW6QCOEj8Gb1/KWpbH5XysNAoNojsU= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/go-chi/cors v1.2.0 h1:tV1g1XENQ8ku4Bq3K9ub2AtgG+p16SmzeMSGTwrOKdE= +github.com/go-chi/cors v1.2.0/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= +github.com/go-chi/stampede v0.5.0 h1:pby7lUVANhFHbjcorWiYhm/NVPyYnnLcBlpxbDpJrAI= +github.com/go-chi/stampede v0.5.0/go.mod h1:UFRS0DzmgIqq/LevhSX67qtc0hkykVdLHRc5MJxfgBQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= @@ -57,8 +59,8 @@ github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/flatbuffers v1.12.0 h1:/PtAHvnBY4Kqnx/xCQ3OIV9uYcSFGScBsWI3Oogeh6w= -github.com/google/flatbuffers v1.12.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= +github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= @@ -146,16 +148,17 @@ github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6Ac github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.22.5 h1:dntmOdLpSpHlVqbW5Eay97DelsZHe+55D+xC6i0dDS0= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= -go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/zap v1.19.0 h1:mZQZefskPPCMIBCSEH0v2/iUqqLrYtaeqwD6FUGUnFE= -go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -167,11 +170,11 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -182,8 +185,9 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200930145003-4acb6c075d10/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -192,8 +196,9 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200930132711-30421366ff76/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -202,24 +207,27 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/client/dmap.go b/plugins/traefik/vendor/github.com/buraksezer/olric/client/dmap.go index 1c144bf24..dc165a77e 100644 --- a/plugins/traefik/vendor/github.com/buraksezer/olric/client/dmap.go +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/client/dmap.go @@ -217,6 +217,23 @@ func (l *LockContext) Unlock() error { return checkStatusCode(resp) } +// Lease update the expiry of an acquired lock for the given key. +// It returns olric.ErrNoSuchLock if there is no lock or already expired for the given key. +func (l *LockContext) Lease(timeout time.Duration) error { + req := protocol.NewDMapMessage(protocol.OpLockLease) + req.SetDMap(l.name) + req.SetKey(l.key) + req.SetValue(l.token) + req.SetExtra(protocol.LockLeaseExtra{ + Timeout: int64(timeout), + }) + resp, err := l.dmap.request(req) + if err != nil { + return err + } + return checkStatusCode(resp) +} + // Destroy flushes the given dmap on the cluster. You should know that there is no global lock on DMaps. // So if you call Put/PutEx/PutIf/PutIfEx and Destroy methods concurrently on the cluster, // those calls may set new values to the dmap. diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/config/dmap.go b/plugins/traefik/vendor/github.com/buraksezer/olric/config/dmap.go new file mode 100644 index 000000000..2a7e263df --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/config/dmap.go @@ -0,0 +1,105 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 config + +import ( + "fmt" + "time" +) + +// EvictionPolicy denotes eviction policy. Currently: LRU or NONE. +type EvictionPolicy string + +// Important note on DMap and DMaps structs: +// Golang does not provide the typical notion of inheritance. +// because of that I preferred to define the types explicitly. + +// DMap denotes configuration for a particular distributed map. Most of the +// fields are related with distributed cache implementation. +type DMap struct { + Engine *Engine + + // MaxIdleDuration denotes maximum time for each entry to stay idle in the + // DMap. It limits the lifetime of the entries relative to the time of the + // last read or write access performed on them. The entries whose idle period + // exceeds this limit are expired and evicted automatically. An entry is idle + // if no Get, GetEntry, Put, PutEx, Expire, PutIf, PutIfEx on it. Configuration + // of MaxIdleDuration feature varies by preferred deployment method. + MaxIdleDuration time.Duration + + // TTLDuration is useful to set a default TTL for every key/value pair a DMap + // instance. + TTLDuration time.Duration + + // MaxKeys denotes maximum key count on a particular node. So if you have 10 + // nodes with MaxKeys=100000, your key count in the cluster should be around + // MaxKeys*10=1000000 + MaxKeys int + + // MaxInuse denotes maximum amount of in-use memory on a particular node. So + // if you have 10 nodes with MaxInuse=100M (it has to be in bytes), amount of + // in-use memory should be around MaxInuse*10=1G + MaxInuse int + + // LRUSamples denotes amount of randomly selected key count by the approximate + // LRU implementation. Lower values are better for high performance. It's 5 + // by default. + LRUSamples int + + // EvictionPolicy determines the eviction policy in use. It's NONE by default. + // Set as LRU to enable LRU eviction policy. + EvictionPolicy EvictionPolicy +} + +// Sanitize sets default values to empty configuration variables, if it's possible. +func (dm *DMap) Sanitize() error { + if dm.EvictionPolicy == "" { + dm.EvictionPolicy = "NONE" + } + if dm.LRUSamples <= 0 { + dm.LRUSamples = DefaultLRUSamples + } + if dm.MaxInuse < 0 { + dm.MaxInuse = 0 + } + if dm.MaxKeys < 0 { + dm.MaxKeys = 0 + } + + if dm.Engine == nil { + dm.Engine = NewEngine() + } + + if err := dm.Engine.LoadPlugin(); err != nil { + return fmt.Errorf("failed to load storage engine plugin: %w", err) + } + + if err := dm.Engine.Sanitize(); err != nil { + return fmt.Errorf("failed to sanitize storage engine configuration: %w", err) + } + + return nil +} + +// Validate finds errors in the current configuration. +func (dm *DMap) Validate() error { + if err := dm.Engine.Validate(); err != nil { + return fmt.Errorf("failed to validate storage engine configuration: %w", err) + } + + return nil +} + +var _ IConfig = (*DMap)(nil) diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/config/dmaps.go b/plugins/traefik/vendor/github.com/buraksezer/olric/config/dmaps.go new file mode 100644 index 000000000..eaa1a1612 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/config/dmaps.go @@ -0,0 +1,139 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 config + +import ( + "fmt" + "runtime" + "time" +) + +// DMaps denotes a global configuration for DMaps. You can still overwrite it by +// setting a DMap for a particular distributed map via Custom field. Most of the +// fields are related with distributed cache implementation. +type DMaps struct { + // Engine contains configuration for a storage engine implementation. It may contain the implementation. + // See Engine itself. + Engine *Engine + + // NumEvictionWorkers denotes the number of goroutines that's used to find + // keys for eviction. + NumEvictionWorkers int64 + + // MaxIdleDuration denotes maximum time for each entry to stay idle in the DMap. + // It limits the lifetime of the entries relative to the time of the last + // read or write access performed on them. The entries whose idle period exceeds + // this limit are expired and evicted automatically. An entry is idle if no Get, + // GetEntry, Put, PutEx, Expire, PutIf, PutIfEx on it. Configuration of + // MaxIdleDuration feature varies by preferred deployment method. + MaxIdleDuration time.Duration + + // TTLDuration is useful to set a default TTL for every key/value pair a + // distributed map instance. + TTLDuration time.Duration + + // MaxKeys denotes maximum key count on a particular node. So if you have 10 + // nodes with MaxKeys=100000, your key count in the cluster should be around + // MaxKeys*10=1000000 + MaxKeys int + + // MaxInuse denotes maximum amount of in-use memory on a particular node. + // So if you have 10 nodes with MaxInuse=100M (it has to be in bytes), amount + // of in-use memory should be around MaxInuse*10=1G + MaxInuse int + + // LRUSamples denotes amount of randomly selected key count by the approximate + // LRU implementation. Lower values are better for high performance. It's + // 5 by default. + LRUSamples int + + // EvictionPolicy determines the eviction policy in use. It's NONE by default. + // Set as LRU to enable LRU eviction policy. + EvictionPolicy EvictionPolicy + + // CheckEmptyFragmentsInterval is interval between two sequential call of empty + // fragment cleaner. + CheckEmptyFragmentsInterval time.Duration + + // TriggerCompactionInterval is interval between two sequential call of compaction worker. + TriggerCompactionInterval time.Duration + + // Custom is useful to set custom cache config per DMap instance. + Custom map[string]DMap +} + +// Sanitize sets default values to empty configuration variables, if it's possible. +func (dm *DMaps) Sanitize() error { + if dm.Engine == nil { + dm.Engine = NewEngine() + } + + if dm.Custom == nil { + dm.Custom = make(map[string]DMap) + } + + if dm.EvictionPolicy == "" { + dm.EvictionPolicy = "NONE" + } + + if dm.LRUSamples <= 0 { + dm.LRUSamples = DefaultLRUSamples + } + + if dm.MaxInuse < 0 { + dm.MaxInuse = 0 + } + + if dm.MaxKeys < 0 { + dm.MaxKeys = 0 + } + + if dm.NumEvictionWorkers <= 0 { + dm.NumEvictionWorkers = int64(runtime.NumCPU()) + } + + if dm.CheckEmptyFragmentsInterval.Microseconds() == 0 { + dm.CheckEmptyFragmentsInterval = DefaultCheckEmptyFragmentsInterval + } + + if dm.TriggerCompactionInterval.Microseconds() == 0 { + dm.TriggerCompactionInterval = DefaultTriggerCompactionInterval + } + + for _, d := range dm.Custom { + if err := d.Sanitize(); err != nil { + return err + } + } + + if err := dm.Engine.LoadPlugin(); err != nil { + return fmt.Errorf("failed to load storage engine plugin: %w", err) + } + + if err := dm.Engine.Sanitize(); err != nil { + return fmt.Errorf("failed to sanitize storage engine configuration: %w", err) + } + + return nil +} + +func (dm *DMaps) Validate() error { + if err := dm.Engine.Validate(); err != nil { + return fmt.Errorf("failed to validate storage engine configuration: %w", err) + } + return nil +} + +var _ IConfig = (*DMaps)(nil) diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/config/engine.go b/plugins/traefik/vendor/github.com/buraksezer/olric/config/engine.go new file mode 100644 index 000000000..9e8076b0b --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/config/engine.go @@ -0,0 +1,103 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 config + +import ( + "fmt" + "os" + + "github.com/buraksezer/olric/internal/kvstore" + "github.com/buraksezer/olric/pkg/storage" +) + +// Engine contains storage engine configuration and their implementations. +// If you don't have a custom storage engine implementation or configuration for +// the default one, just call NewStorageEngine() function to use it with sane defaults. +type Engine struct { + // Plugins is an array that contains the paths of storage engine plugins. + // These plugins have to implement storage.Engine interface. + Plugin string + + Name string + + Implementation storage.Engine + + // Config is a map that contains configuration of the storage engines, for + // both plugins and imported ones. If you want to use a storage engine other + // than the default one, you must set configuration for it. + Config map[string]interface{} +} + +// NewEngine initializes Engine with sane defaults. +// Olric will set its own storage engine implementation and related configuration, +// if there is no other engine. +func NewEngine() *Engine { + return &Engine{ + Config: make(map[string]interface{}), + } +} + +// Validate finds errors in the current configuration. +func (s *Engine) Validate() error { + if s.Config == nil { + s.Config = make(map[string]interface{}) + } + return nil +} + +func (s *Engine) LoadPlugin() error { + if s.Plugin == "" { + return nil + } + + _, err := os.Stat(s.Plugin) + if os.IsNotExist(err) { + return fmt.Errorf("storage engine plugin could not be found on disk: %s", s.Plugin) + } + if err != nil { + return err + } + + engine, err := storage.LoadAsPlugin(s.Plugin) + if err != nil { + return err + } + s.Implementation = engine + s.Name = engine.Name() + return nil +} + +// Sanitize sets default values to empty configuration variables, if it's possible. +func (s *Engine) Sanitize() error { + if s.Name == "" { + s.Name = DefaultStorageEngine + } + + if s.Implementation == nil { + switch s.Name { + case DefaultStorageEngine: + s.Implementation = &kvstore.KVStore{} + s.Config = kvstore.DefaultConfig().ToMap() + default: + return fmt.Errorf("unknown storage engine: %s", s.Name) + } + } else { + s.Name = s.Implementation.Name() + } + return nil +} + +// Interface guard +var _ IConfig = (*Engine)(nil) diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/checkpoint/checkpoint.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/checkpoint/checkpoint.go new file mode 100644 index 000000000..9bb6f6a7a --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/checkpoint/checkpoint.go @@ -0,0 +1,34 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 checkpoint + +import "sync/atomic" + +var ( + required int32 + passed int32 +) + +func Add() { + atomic.AddInt32(&required, 1) +} + +func Pass() { + atomic.AddInt32(&passed, 1) +} + +func AllPassed() bool { + return atomic.LoadInt32(&passed) == required +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/balancer/balancer.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/balancer/balancer.go new file mode 100644 index 000000000..444dcc1f2 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/balancer/balancer.go @@ -0,0 +1,258 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 balancer + +import ( + "context" + "strings" + "sync" + "time" + + "github.com/buraksezer/olric/config" + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/cluster/routingtable" + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/internal/environment" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/internal/service" + "github.com/buraksezer/olric/pkg/flog" +) + +type Balancer struct { + sync.Mutex + + log *flog.Logger + config *config.Config + primary *partitions.Partitions + backup *partitions.Partitions + rt *routingtable.RoutingTable + wg sync.WaitGroup + ctx context.Context + cancel context.CancelFunc +} + +func New(e *environment.Environment) *Balancer { + c := e.Get("config").(*config.Config) + log := e.Get("logger").(*flog.Logger) + ctx, cancel := context.WithCancel(context.Background()) + return &Balancer{ + config: c, + primary: e.Get("primary").(*partitions.Partitions), + backup: e.Get("backup").(*partitions.Partitions), + rt: e.Get("routingtable").(*routingtable.RoutingTable), + log: log, + ctx: ctx, + cancel: cancel, + } +} + +func (b *Balancer) isAlive() bool { + select { + case <-b.ctx.Done(): + // The node is gone. + return false + default: + } + return true +} + +func (b *Balancer) scanPartition(sign uint64, part *partitions.Partition, owners ...discovery.Member) { + ownersStr := func() string { + var names []string + for _, owner := range owners { + names = append(names, owner.String()) + } + return strings.Join(names, ",") + }() + + part.Map().Range(func(name, tmp interface{}) bool { + f := tmp.(partitions.Fragment) + if f.Length() == 0 { + return false + } + + b.log.V(2).Printf("[INFO] Moving %s fragment: %s (kind: %s) on PartID: %d to %s", + f.Name(), name, part.Kind(), part.ID(), ownersStr) + + err := f.Move(part, name.(string), owners) + if err != nil { + b.log.V(2).Printf("[ERROR] Failed to move %s fragment: %s on PartID: %d to %s: %v", + f.Name(), name, part.ID(), ownersStr, err) + } + + // if this returns true, the iteration continues + return !b.breakLoop(sign) + }) +} + +func (b *Balancer) primaryCopies() { + sign := b.rt.Signature() + for partID := uint64(0); partID < b.config.PartitionCount; partID++ { + if b.breakLoop(sign) { + break + } + + part := b.primary.PartitionByID(partID) + if part.Length() == 0 { + // Empty partition. Skip it. + continue + } + + owner := part.Owner() + // Here we don't use CompareByID function because the routing table is an + // eventually consistent data structure and a node can try to move data + // to previous instance(the same name but a different birthdate) + // of itself. So just check the name. + if owner.CompareByName(b.rt.This()) { + // Already belongs to me. + continue + } + + // This is a previous owner. Move the keys. + b.scanPartition(sign, part, owner) + } +} + +func (b *Balancer) breakLoop(sign uint64) bool { + if !b.isAlive() { + return true + } + + if sign != b.rt.Signature() { + // Routing table is updated. Just quit. Another balancer goroutine + // will work on the new table immediately. + return true + } + + return false +} + +func (b *Balancer) backupCopies() { + sign := b.rt.Signature() +LOOP: + for partID := uint64(0); partID < b.config.PartitionCount; partID++ { + if b.breakLoop(sign) { + break + } + + part := b.backup.PartitionByID(partID) + if part.Length() == 0 || part.OwnerCount() == 0 { + continue + } + + var ( + counter = 1 + currentOwners []discovery.Member + ) + + owners := part.Owners() + for i := len(owners) - 1; i >= 0; i-- { + if counter > b.config.ReplicaCount-1 { + break + } + + counter++ + owner := owners[i] + // Here we don't use CompareById function because the routing table + // is an eventually consistent data structure and a node can try to + // move data to previous instance(the same name but a different birthdate) + // of itself. So just check the name. + if b.rt.This().CompareByName(owner) { + // Already belongs to me. + continue LOOP + } + currentOwners = append(currentOwners, owner) + } + + if len(currentOwners) == 0 { + continue LOOP + } + + b.scanPartition(sign, part, currentOwners...) + } +} + +func (b *Balancer) triggerBalancer() { + b.Lock() + defer b.Unlock() + + if err := b.rt.CheckBootstrap(); err != nil { + b.log.V(2).Printf("[WARN] Balancer awaits for bootstrapping") + return + } + + b.primaryCopies() + + if b.config.ReplicaCount > config.MinimumReplicaCount { + b.backupCopies() + } +} + +func (b *Balancer) BalanceEagerly() { + b.triggerBalancer() +} + +func (b *Balancer) balance() { + defer b.wg.Done() + + timer := time.NewTimer(b.config.TriggerBalancerInterval) + defer timer.Stop() + + for { + timer.Reset(b.config.TriggerBalancerInterval) + select { + case <-timer.C: + b.triggerBalancer() + case <-b.ctx.Done(): + return + } + } +} + +func (b *Balancer) Start() error { + b.wg.Add(1) + go b.balance() + return nil +} + +func (b *Balancer) RegisterOperations(_ map[protocol.OpCode]func(w, r protocol.EncodeDecoder)) {} + +func (b *Balancer) Shutdown(ctx context.Context) error { + select { + case <-b.ctx.Done(): + // already closed + return nil + default: + } + + b.cancel() + done := make(chan struct{}) + go func() { + b.wg.Wait() + close(done) + }() + select { + case <-ctx.Done(): + err := ctx.Err() + if err != nil { + return err + } + case <-done: + } + + return nil +} + +var _ service.Service = (*Balancer)(nil) diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/partitions/fragment.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/partitions/fragment.go new file mode 100644 index 000000000..c00bb7a11 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/partitions/fragment.go @@ -0,0 +1,30 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 partitions + +import ( + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/pkg/storage" +) + +type Fragment interface { + Name() string + Stats() storage.Stats + Length() int + Move(*Partition, string, []discovery.Member) error + Compaction() (bool, error) + Destroy() error + Close() error +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/partitions/hkey.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/partitions/hkey.go new file mode 100644 index 000000000..84c655c2b --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/partitions/hkey.go @@ -0,0 +1,38 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 partitions + +import ( + "sync" + "unsafe" + + "github.com/buraksezer/olric/hasher" +) + +var ( + hashFunc hasher.Hasher + once sync.Once +) + +func SetHashFunc(h hasher.Hasher) { + once.Do(func() { + hashFunc = h + }) +} + +func HKey(name, key string) uint64 { + tmp := name + key + return hashFunc.Sum64(*(*[]byte)(unsafe.Pointer(&tmp))) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/partitions/partition.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/partitions/partition.go new file mode 100644 index 000000000..58a4fd48c --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/partitions/partition.go @@ -0,0 +1,90 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 partitions + +import ( + "sync" + "sync/atomic" + + "github.com/buraksezer/olric/internal/discovery" +) + +// Partition is a basic, logical storage unit in Olric and stores DMaps in a sync.Map. +type Partition struct { + sync.RWMutex + + id uint64 + kind Kind + m *sync.Map + owners atomic.Value +} + +func (p *Partition) Kind() Kind { + return p.kind +} + +func (p *Partition) ID() uint64 { + return p.id +} + +func (p *Partition) Map() *sync.Map { + return p.m +} + +// Owner returns partition Owner. It's not thread-safe. +func (p *Partition) Owner() discovery.Member { + if p.Kind() == BACKUP { + // programming error. it cannot occur at production! + panic("cannot call this if backup is true") + } + owners := p.owners.Load().([]discovery.Member) + if len(owners) == 0 { + panic("owners list cannot be empty") + } + return owners[len(owners)-1] +} + +// OwnerCount returns the current Owner count of a partition. +func (p *Partition) OwnerCount() int { + owners := p.owners.Load() + if owners == nil { + return 0 + } + return len(owners.([]discovery.Member)) +} + +// Owners loads the partition owners from atomic.Value and returns. +func (p *Partition) Owners() []discovery.Member { + owners := p.owners.Load() + if owners == nil { + return []discovery.Member{} + } + return owners.([]discovery.Member) +} + +func (p *Partition) SetOwners(owners []discovery.Member) { + p.owners.Store(owners) +} + +func (p *Partition) Length() int { + var length int + p.Map().Range(func(_, tmp interface{}) bool { + u := tmp.(Fragment) + length += u.Length() + // Continue scanning. + return true + }) + return length +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/partitions/partitions.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/partitions/partitions.go new file mode 100644 index 000000000..2069a29ad --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/partitions/partitions.go @@ -0,0 +1,89 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 partitions + +import ( + "sync" + + "github.com/buraksezer/olric/internal/discovery" +) + +type Kind int + +func (k Kind) String() string { + switch { + case k == PRIMARY: + return "Primary" + case k == BACKUP: + return "Backup" + default: + return "Unknown" + } +} + +const ( + PRIMARY = Kind(iota + 1) + BACKUP +) + +type Partitions struct { + count uint64 + kind Kind + m map[uint64]*Partition +} + +func New(count uint64, kind Kind) *Partitions { + ps := &Partitions{ + kind: kind, + count: count, + m: make(map[uint64]*Partition), + } + for i := uint64(0); i < count; i++ { + ps.m[i] = &Partition{ + id: i, + kind: kind, + m: &sync.Map{}, + } + } + return ps +} + +// PartitionByID returns the partition for the given HKey +func (ps *Partitions) PartitionByID(partID uint64) *Partition { + return ps.m[partID] +} + +// PartitionIDByHKey returns partition ID for a given HKey. +func (ps *Partitions) PartitionIDByHKey(hkey uint64) uint64 { + return hkey % ps.count +} + +// PartitionByHKey returns the partition for the given HKey +func (ps *Partitions) PartitionByHKey(hkey uint64) *Partition { + partID := ps.PartitionIDByHKey(hkey) + return ps.m[partID] +} + +// PartitionOwnersByHKey loads the partition owners list for a given hkey. +func (ps *Partitions) PartitionOwnersByHKey(hkey uint64) []discovery.Member { + part := ps.PartitionByHKey(hkey) + return part.owners.Load().([]discovery.Member) +} + +// PartitionOwnersByID loads the partition owners list for a given hkey. +func (ps *Partitions) PartitionOwnersByID(partID uint64) []discovery.Member { + part := ps.PartitionByID(partID) + return part.owners.Load().([]discovery.Member) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/callback.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/callback.go new file mode 100644 index 000000000..a42be69e1 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/callback.go @@ -0,0 +1,38 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 routingtable + +func (r *RoutingTable) AddCallback(f func()) { + r.callbackMtx.Lock() + defer r.callbackMtx.Unlock() + + r.callbacks = append(r.callbacks, f) +} + +func (r *RoutingTable) runCallbacks() { + defer r.wg.Done() + + r.callbackMtx.Lock() + defer r.callbackMtx.Unlock() + + for _, f := range r.callbacks { + select { + case <-r.ctx.Done(): + return + default: + } + f() + } +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/discovery.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/discovery.go new file mode 100644 index 000000000..a14e16020 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/discovery.go @@ -0,0 +1,109 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 routingtable + +import ( + "context" + "errors" + "time" +) + +var ( + ErrServerGone = errors.New("server is gone") + ErrClusterJoin = errors.New("cannot join the cluster") + // ErrOperationTimeout is returned when an operation times out. + ErrOperationTimeout = errors.New("operation timeout") +) + +// bootstrapCoordinator prepares the very first routing table and bootstraps the coordinator node. +func (r *RoutingTable) bootstrapCoordinator() error { + r.Lock() + defer r.Unlock() + + r.fillRoutingTable() + _, err := r.updateRoutingTableOnCluster() + if err != nil { + return err + } + // The coordinator bootstraps itself. + r.markBootstrapped() + r.log.V(2).Printf("[INFO] The cluster coordinator has been bootstrapped") + return nil +} + +func (r *RoutingTable) attemptToJoin() error { + attempts := 0 + for attempts < r.config.MaxJoinAttempts { + select { + case <-r.ctx.Done(): + // The node is gone. + return ErrServerGone + default: + } + + attempts++ + n, err := r.discovery.Join() + if err == nil { + r.log.V(2).Printf("[INFO] Join completed. Synced with %d initial nodes", n) + return nil + } + + r.log.V(2).Printf("[ERROR] Join attempt returned error: %s", err) + if r.IsBootstrapped() { + r.log.V(2).Printf("[INFO] Bootstrapped by the cluster coordinator") + return nil + } + + r.log.V(2).Printf("[INFO] Awaits for %s to join again (%d/%d)", + r.config.JoinRetryInterval, attempts, r.config.MaxJoinAttempts) + <-time.After(r.config.JoinRetryInterval) + } + return ErrClusterJoin +} + +func (r *RoutingTable) tryWithInterval(ctx context.Context, interval time.Duration, f func() error) error { + ticker := time.NewTicker(interval) + defer ticker.Stop() + + var funcErr error + + funcErr = f() + if funcErr == nil { + // Done. No need to try with interval + return nil + } + +loop: + for { + select { + case <-ctx.Done(): + // context is done + err := ctx.Err() + if errors.Is(err, context.DeadlineExceeded) { + break loop + } + if errors.Is(err, context.Canceled) { + return ErrServerGone + } + return err + case <-ticker.C: + funcErr = f() + if funcErr == nil { + break loop + } + } + } + return funcErr +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/distribute.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/distribute.go new file mode 100644 index 000000000..abf981132 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/distribute.go @@ -0,0 +1,228 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 routingtable + +import ( + "errors" + "github.com/buraksezer/consistent" + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/internal/protocol" + "github.com/vmihailenco/msgpack" +) + +func (r *RoutingTable) distributePrimaryCopies(partID uint64) []discovery.Member { + // First you need to create a copy of the owners list. Don't modify the current list. + part := r.primary.PartitionByID(partID) + owners := make([]discovery.Member, part.OwnerCount()) + copy(owners, part.Owners()) + + // Find the new partition owner. + newOwner := r.consistent.GetPartitionOwner(int(partID)) + + // First run. + if len(owners) == 0 { + owners = append(owners, newOwner.(discovery.Member)) + return owners + } + + // Prune dead nodes + for i := 0; i < len(owners); i++ { + owner := owners[i] + current, err := r.discovery.FindMemberByName(owner.Name) + if err != nil { + r.log.V(6).Printf("[DEBUG] Failed to find %s in the cluster: %v", owner, err) + owners = append(owners[:i], owners[i+1:]...) + i-- + continue + } + if !owner.CompareByID(current) { + r.log.V(4).Printf("[WARN] One of the partitions owners is probably re-joined: %s", current) + owners = append(owners[:i], owners[i+1:]...) + i-- + continue + } + } + + // Prune empty nodes + for i := 0; i < len(owners); i++ { + owner := owners[i] + req := protocol.NewSystemMessage(protocol.OpLengthOfPart) + req.SetExtra(protocol.LengthOfPartExtra{PartID: partID}) + res, err := r.requestTo(owner.String(), req) + if err != nil { + r.log.V(3).Printf("[ERROR] Failed to check key count on partition: %d: %v", partID, err) + // Pass it. If the node is gone, memberlist package will notify us. + continue + } + + var count int32 + err = msgpack.Unmarshal(res.Value(), &count) + if err != nil { + // This may be a temporary issue. + // Pass it. If the node is gone, memberlist package will notify us. + continue + } + if count == 0 { + // Empty partition. Delete it from ownership list. + owners = append(owners[:i], owners[i+1:]...) + i-- + } + } + + // Here add the new partition newOwner. + for i, owner := range owners { + if owner.CompareByID(newOwner.(discovery.Member)) { + // Remove it from the current position + owners = append(owners[:i], owners[i+1:]...) + // Append it again to head + return append(owners, newOwner.(discovery.Member)) + } + } + return append(owners, newOwner.(discovery.Member)) +} + +func (r *RoutingTable) getReplicaOwners(partID uint64) ([]consistent.Member, error) { + for i := r.config.ReplicaCount; i > 0; i-- { + newOwners, err := r.consistent.GetClosestNForPartition(int(partID), i) + if errors.Is(err, consistent.ErrInsufficientMemberCount) { + continue + } + if err != nil { + // Fail early + return nil, err + } + return newOwners, nil + } + return nil, consistent.ErrInsufficientMemberCount +} + +func isOwner(member discovery.Member, owners []consistent.Member) bool { + for _, owner := range owners { + if member.Name == owner.String() { + return true + } + } + return false +} + +func (r *RoutingTable) distributeBackups(partID uint64) []discovery.Member { + part := r.backup.PartitionByID(partID) + owners := make([]discovery.Member, part.OwnerCount()) + copy(owners, part.Owners()) + + newOwners, err := r.getReplicaOwners(partID) + if err != nil { + r.log.V(3).Printf("[ERROR] Failed to get replica owners for PartID: %d: %v", + partID, err) + return nil + } + + // Remove the primary owner + newOwners = newOwners[1:] + + // First run + if len(owners) == 0 { + for _, owner := range newOwners { + owners = append(owners, owner.(discovery.Member)) + } + return owners + } + + // Prune dead nodes + for i := 0; i < len(owners); i++ { + backup := owners[i] + cur, err := r.discovery.FindMemberByName(backup.Name) + if err != nil { + r.log.V(6).Printf("[DEBUG] Failed to find %s in the cluster: %v", backup, err) + // Delete it. + owners = append(owners[:i], owners[i+1:]...) + i-- + continue + } + if !backup.CompareByID(cur) { + r.log.V(3).Printf("[WARN] One of the backup owners is probably re-joined: %s", cur) + // Delete it. + owners = append(owners[:i], owners[i+1:]...) + i-- + continue + } + } + + // Prune empty nodes + for i := 0; i < len(owners); i++ { + backup := owners[i] + req := protocol.NewSystemMessage(protocol.OpLengthOfPart) + req.SetExtra(protocol.LengthOfPartExtra{ + PartID: partID, + Backup: true, + }) + res, err := r.requestTo(backup.String(), req) + if err != nil { + r.log.V(3).Printf("[ERROR] Failed to check key count on backup "+ + "partition: %d: %v", partID, err) + // Pass it. If the node is down, memberlist package will send a leave event. + continue + } + + var count int32 + err = msgpack.Unmarshal(res.Value(), &count) + if err != nil { + r.log.V(3).Printf("[ERROR] Failed to unmarshal key count "+ + "while checking replica partition: %d: %v", partID, err) + // This may be a temporary event. Pass it. + continue + } + + if count != 0 { + // About this scenario: + // + // * ReplicaCount = 3 + // * Create three nodes and insert some keys + // * Kill one of the nodes + // * Now we have replicas that it's impossible to transfer its ownership + // * Since we cannot drop a healthy replica, we prefer to keep it until + // a new node joined. Then, we transfer the ownership safely. + // * During this incident, a node owns a primary and backup replicas at the same time. + if !isOwner(backup, newOwners) { + r.log.V(3).Printf("[WARN] %s still hosts backup replica "+ + "for PartID: %d", backup, partID) + } + continue + } + + // Empty node, delete it. + owners = append(owners[:i], owners[i+1:]...) + i-- + } + + // Here add the new backup owners. + for _, newOwner := range newOwners { + var exists bool + for i, owner := range owners { + if owner.CompareByID(newOwner.(discovery.Member)) { + exists = true + // Remove it from the current position + owners = append(owners[:i], owners[i+1:]...) + // Append it again to head + owners = append(owners, newOwner.(discovery.Member)) + break + } + } + if !exists { + owners = append(owners, newOwner.(discovery.Member)) + } + } + return owners +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/left_over_data.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/left_over_data.go new file mode 100644 index 000000000..2ebd4c086 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/left_over_data.go @@ -0,0 +1,60 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 routingtable + +import ( + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/discovery" +) + +func (r *RoutingTable) processLeftOverDataReports(reports map[discovery.Member]*leftOverDataReport) { + check := func(member discovery.Member, owners []discovery.Member) bool { + for _, owner := range owners { + if member.CompareByID(owner) { + return true + } + } + return false + } + + ensureOwnership := func(member discovery.Member, partID uint64, part *partitions.Partition) { + owners := part.Owners() + if check(member, owners) { + return + } + // This section is protected by routingMtx against parallel writers. + // + // Copy owners and append the member to head + newOwners := make([]discovery.Member, len(owners)) + copy(newOwners, owners) + // Prepend + newOwners = append([]discovery.Member{member}, newOwners...) + part.SetOwners(newOwners) + r.log.V(2).Printf("[INFO] %s still have some data for PartID (kind: %s): %d", member, part.Kind(), partID) + } + + // data structures in this function is guarded by routingMtx + for member, report := range reports { + for _, partID := range report.Partitions { + part := r.primary.PartitionByID(partID) + ensureOwnership(member, partID, part) + } + + for _, partID := range report.Backups { + part := r.backup.PartitionByID(partID) + ensureOwnership(member, partID, part) + } + } +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/members.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/members.go new file mode 100644 index 000000000..4a9b53650 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/members.go @@ -0,0 +1,69 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 routingtable + +import ( + "fmt" + "sync" + + "github.com/buraksezer/olric/internal/discovery" +) + +type Members struct { + sync.RWMutex + m map[uint64]discovery.Member +} + +func newMembers() *Members { + return &Members{ + m: map[uint64]discovery.Member{}, + } +} + +func (m *Members) Add(member discovery.Member) { + m.m[member.ID] = member +} + +func (m *Members) Get(id uint64) (discovery.Member, error) { + member, ok := m.m[id] + if !ok { + return discovery.Member{}, fmt.Errorf("member not found with id: %d", id) + } + return member, nil +} + +func (m *Members) Delete(id uint64) { + delete(m.m, id) +} + +func (m *Members) DeleteByName(other discovery.Member) { + for id, member := range m.m { + if member.CompareByName(other) { + delete(m.m, id) + } + } +} + +func (m *Members) Length() int { + return len(m.m) +} + +func (m *Members) Range(f func(id uint64, member discovery.Member) bool) { + for id, member := range m.m { + if !f(id, member) { + break + } + } +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/operations.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/operations.go new file mode 100644 index 000000000..945df10cb --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/operations.go @@ -0,0 +1,125 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 routingtable + +import ( + "fmt" + + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/cespare/xxhash" + "github.com/vmihailenco/msgpack" +) + +func (r *RoutingTable) lengthOfPartOperation(w, rq protocol.EncodeDecoder) { + req := rq.(*protocol.SystemMessage) + partID := req.Extra().(protocol.LengthOfPartExtra).PartID + isBackup := req.Extra().(protocol.LengthOfPartExtra).Backup + + var part *partitions.Partition + if isBackup { + part = r.backup.PartitionByID(partID) + } else { + part = r.primary.PartitionByID(partID) + } + + value, err := msgpack.Marshal(part.Length()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetValue(value) + w.SetStatus(protocol.StatusOK) +} + +func (r *RoutingTable) verifyRoutingTable(id uint64, table map[uint64]*route) error { + // Check the coordinator + coordinator, err := r.discovery.FindMemberByID(id) + if err != nil { + return err + } + + myCoordinator := r.discovery.GetCoordinator() + if !coordinator.CompareByID(myCoordinator) { + return fmt.Errorf("unrecognized cluster coordinator: %s: %s", coordinator, myCoordinator) + } + + // Compare partition counts to catch a possible inconsistencies in configuration + if r.config.PartitionCount != uint64(len(table)) { + return fmt.Errorf("invalid partition count: %d", len(table)) + } + return nil +} + +func (r *RoutingTable) updateRoutingOperation(w, rq protocol.EncodeDecoder) { + r.updateRoutingMtx.Lock() + defer r.updateRoutingMtx.Unlock() + + req := rq.(*protocol.SystemMessage) + table := make(map[uint64]*route) + err := msgpack.Unmarshal(req.Value(), &table) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + coordinatorID := req.Extra().(protocol.UpdateRoutingExtra).CoordinatorID + + // Log this event + coordinator, err := r.discovery.FindMemberByID(coordinatorID) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + r.log.V(3).Printf("[INFO] Routing table has been pushed by %s", coordinator) + + if err = r.verifyRoutingTable(coordinatorID, table); err != nil { + neterrors.ErrorResponse(w, err) + return + } + + // owners(atomic.value) is guarded by routingUpdateMtx against parallel writers. + // Calculate routing signature. This is useful to control balancing tasks. + r.setSignature(xxhash.Sum64(req.Value())) + for partID, data := range table { + // Set partition(primary copies) owners + part := r.primary.PartitionByID(partID) + part.SetOwners(data.Owners) + + // Set backup owners + bpart := r.backup.PartitionByID(partID) + bpart.SetOwners(data.Backups) + } + + // Used by the LRU implementation. + r.setOwnedPartitionCount() + + // Bootstrapped by the coordinator. + r.markBootstrapped() + + // Collect report + value, err := r.prepareLeftOverDataReport() + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + // Call balancer to distribute load evenly + r.wg.Add(1) + go r.runCallbacks() + w.SetValue(value) + w.SetStatus(protocol.StatusOK) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/routingtable.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/routingtable.go new file mode 100644 index 000000000..32556b5c0 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/routingtable.go @@ -0,0 +1,435 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 routingtable + +import ( + "context" + "errors" + "sync" + "sync/atomic" + "time" + + "github.com/buraksezer/consistent" + "github.com/buraksezer/olric/config" + "github.com/buraksezer/olric/internal/checkpoint" + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/internal/environment" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/internal/service" + "github.com/buraksezer/olric/internal/transport" + "github.com/buraksezer/olric/pkg/flog" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/hashicorp/memberlist" +) + +// ErrClusterQuorum means that the cluster could not reach a healthy numbers of members to operate. +var ErrClusterQuorum = neterrors.New(protocol.StatusErrClusterQuorum, + "cannot be reached cluster quorum to operate") + +type route struct { + Owners []discovery.Member + Backups []discovery.Member +} + +type RoutingTable struct { + sync.RWMutex // routingMtx + + // Currently owned partition count. Approximate LRU implementation + // uses that. + ownedPartitionCount uint64 + signature uint64 + // numMembers is used to check cluster quorum. + numMembers int32 + + // These values is useful to control operation status. + bootstrapped int32 + + updateRoutingMtx sync.Mutex + table map[uint64]*route + consistent *consistent.Consistent + this discovery.Member + members *Members + config *config.Config + log *flog.Logger + primary *partitions.Partitions + backup *partitions.Partitions + client *transport.Client + discovery *discovery.Discovery + callbacks []func() + callbackMtx sync.Mutex + pushPeriod time.Duration + ctx context.Context + cancel context.CancelFunc + wg sync.WaitGroup +} + +func New(e *environment.Environment) *RoutingTable { + checkpoint.Add() + c := e.Get("config").(*config.Config) + log := e.Get("logger").(*flog.Logger) + + ctx, cancel := context.WithCancel(context.Background()) + cc := consistent.Config{ + Hasher: c.Hasher, + PartitionCount: int(c.PartitionCount), + ReplicationFactor: 20, // TODO: This also may be a configuration param. + Load: c.LoadFactor, + } + return &RoutingTable{ + members: newMembers(), + discovery: discovery.New(log, c), + config: c, + log: log, + consistent: consistent.New(nil, cc), + primary: e.Get("primary").(*partitions.Partitions), + backup: e.Get("backup").(*partitions.Partitions), + client: e.Get("client").(*transport.Client), + pushPeriod: c.RoutingTablePushInterval, + ctx: ctx, + cancel: cancel, + } +} + +func (r *RoutingTable) Discovery() *discovery.Discovery { + return r.discovery +} + +func (r *RoutingTable) This() discovery.Member { + return r.this +} + +// setNumMembers assigns the current number of members in the cluster to a variable. +func (r *RoutingTable) setNumMembers() { + // Calling NumMembers in every request is quite expensive. + // It's rarely updated. Just call this when the membership info changed. + nr := int32(r.discovery.NumMembers()) + atomic.StoreInt32(&r.numMembers, nr) +} + +func (r *RoutingTable) SetNumMembersEagerly(nr int32) { + atomic.StoreInt32(&r.numMembers, nr) +} + +func (r *RoutingTable) NumMembers() int32 { + return atomic.LoadInt32(&r.numMembers) +} + +func (r *RoutingTable) Members() *Members { + return r.members +} + +func (r *RoutingTable) setSignature(s uint64) { + atomic.StoreUint64(&r.signature, s) +} + +func (r *RoutingTable) Signature() uint64 { + return atomic.LoadUint64(&r.signature) +} + +func (r *RoutingTable) setOwnedPartitionCount() { + var count uint64 + for partID := uint64(0); partID < r.config.PartitionCount; partID++ { + part := r.primary.PartitionByID(partID) + if part.Owner().CompareByID(r.this) { + count++ + } + } + atomic.StoreUint64(&r.ownedPartitionCount, count) +} + +func (r *RoutingTable) OwnedPartitionCount() uint64 { + return atomic.LoadUint64(&r.ownedPartitionCount) +} + +func (r *RoutingTable) CheckMemberCountQuorum() error { + // This type of quorum function determines the presence of quorum based on the count of members in the cluster, + // as observed by the local member’s cluster membership manager + if r.config.MemberCountQuorum > r.NumMembers() { + return ErrClusterQuorum + } + return nil +} + +func (r *RoutingTable) markBootstrapped() { + // Bootstrapped by the coordinator. + atomic.StoreInt32(&r.bootstrapped, 1) +} + +func (r *RoutingTable) IsBootstrapped() bool { + // Bootstrapped by the coordinator. + return atomic.LoadInt32(&r.bootstrapped) == 1 +} + +// CheckBootstrap is called for every request and checks whether the node is bootstrapped. +// It has to be very fast for a smooth operation. +func (r *RoutingTable) CheckBootstrap() error { + ctx, cancel := context.WithTimeout(context.Background(), r.config.BootstrapTimeout) + defer cancel() + return r.tryWithInterval(ctx, 100*time.Millisecond, func() error { + if r.IsBootstrapped() { + return nil + } + // Final error + return ErrOperationTimeout + }) +} + +func (r *RoutingTable) fillRoutingTable() { + if r.config.ReplicaCount > int(r.NumMembers()) { + r.log.V(1).Printf("[WARN] Desired replica count is %d and "+ + "the cluster has %d members currently", + r.config.ReplicaCount, r.NumMembers()) + } + table := make(map[uint64]*route) + for partID := uint64(0); partID < r.config.PartitionCount; partID++ { + rt := &route{ + Owners: r.distributePrimaryCopies(partID), + } + if r.config.ReplicaCount > config.MinimumReplicaCount { + rt.Backups = r.distributeBackups(partID) + } + table[partID] = rt + } + r.table = table +} + +func (r *RoutingTable) UpdateEagerly() { + r.updateRouting() +} + +func (r *RoutingTable) RegisterOperations(operations map[protocol.OpCode]func(w, r protocol.EncodeDecoder)) { + operations[protocol.OpUpdateRouting] = r.updateRoutingOperation + operations[protocol.OpLengthOfPart] = r.lengthOfPartOperation +} + +func (r *RoutingTable) updateRouting() { + // This function is called by listenMemberlistEvents and updateRoutingPeriodically + // So this lock prevents parallel execution. + r.Lock() + defer r.Unlock() + + // This function is only run by the cluster coordinator. + if !r.discovery.IsCoordinator() { + return + } + + // This type of quorum function determines the presence of quorum based on the count of members in the cluster, + // as observed by the local member’s cluster membership manager + if err := r.CheckMemberCountQuorum(); err != nil { + r.log.V(2).Printf("[ERROR] Impossible to calculate and update routing table: %v", err) + return + } + + r.fillRoutingTable() + reports, err := r.updateRoutingTableOnCluster() + if err != nil { + r.log.V(2).Printf("[ERROR] Failed to update routing table on cluster: %v", err) + return + } + r.processLeftOverDataReports(reports) +} + +func (r *RoutingTable) processClusterEvent(event *discovery.ClusterEvent) { + r.Members().Lock() + defer r.Members().Unlock() + + member, _ := discovery.NewMemberFromMetadata(event.NodeMeta) + + switch event.Event { + case memberlist.NodeJoin: + r.Members().Add(member) + r.consistent.Add(member) + r.log.V(2).Printf("[INFO] Node joined: %s", member) + case memberlist.NodeLeave: + if _, err := r.Members().Get(member.ID); err != nil { + r.log.V(2).Printf("[ERROR] Unknown node left: %s: %d", event.NodeName, member.ID) + return + } + r.Members().Delete(member.ID) + r.consistent.Remove(event.NodeName) + // Don't try to used closed sockets again. + r.client.ClosePool(event.NodeName) + r.log.V(2).Printf("[INFO] Node left: %s", event.NodeName) + case memberlist.NodeUpdate: + // Node's birthdate may be changed. Close the pool and re-add to the hash ring. + // This takes linear time, but member count should be too small for a decent computer! + r.Members().Range(func(id uint64, item discovery.Member) bool { + if member.CompareByName(item) { + r.Members().Delete(id) + r.consistent.Remove(event.NodeName) + r.client.ClosePool(event.NodeName) + } + return true + }) + r.Members().Add(member) + r.consistent.Add(member) + r.log.V(2).Printf("[INFO] Node updated: %s", member) + default: + r.log.V(2).Printf("[ERROR] Unknown event received: %v", event) + return + } + + // Store the current number of members in the member list. + // We need this to implement a simple split-brain protection algorithm. + r.setNumMembers() +} + +func (r *RoutingTable) listenClusterEvents(eventCh chan *discovery.ClusterEvent) { + defer r.wg.Done() + for { + select { + case <-r.ctx.Done(): + return + case e := <-eventCh: + r.processClusterEvent(e) + r.updateRouting() + } + } +} + +func (r *RoutingTable) pushPeriodically() { + defer r.wg.Done() + + ticker := time.NewTicker(r.pushPeriod) + defer ticker.Stop() + for { + select { + case <-r.ctx.Done(): + return + case <-ticker.C: + r.updateRouting() + } + } +} + +func (r *RoutingTable) requestTo(addr string, req protocol.EncodeDecoder) (protocol.EncodeDecoder, error) { + resp, err := r.client.RequestTo(addr, req) + if err != nil { + return nil, err + } + status := resp.Status() + if status == protocol.StatusOK { + return resp, nil + } + if status == protocol.StatusErrInternalFailure { + return nil, neterrors.Wrap(neterrors.ErrInternalFailure, string(resp.Value())) + } + return nil, neterrors.GetByCode(status) +} + +func (r *RoutingTable) Start() error { + err := r.discovery.Start() + if err != nil { + return err + } + + err = r.attemptToJoin() + if errors.Is(err, ErrClusterJoin) { + r.log.V(1).Printf("[INFO] Forming a new Olric cluster") + err = nil + } + if err != nil { + return err + } + + this, err := r.discovery.FindMemberByName(r.config.MemberlistConfig.Name) + if err != nil { + r.log.V(2).Printf("[ERROR] Failed to get this node in cluster: %v", err) + serr := r.discovery.Shutdown() + if serr != nil { + return serr + } + return err + } + r.this = this + + // Store the current number of members in the member list. + // We need this to implement a simple split-brain protection algorithm. + r.setNumMembers() + + r.wg.Add(1) + go r.listenClusterEvents(r.discovery.ClusterEvents) + + // 1 Hour + ctx, cancel := context.WithTimeout(r.ctx, time.Hour) + defer cancel() + err = r.tryWithInterval(ctx, time.Second, func() error { + // Check member count quorum now. If there is no enough peers to work, wait forever. + err := r.CheckMemberCountQuorum() + if err != nil { + r.log.V(2).Printf("[ERROR] Inoperable node: %v", err) + } + return err + }) + if err != nil { + return err + } + + r.Members().Lock() + r.Members().Add(r.this) + r.Members().Unlock() + + r.consistent.Add(r.this) + + if r.discovery.IsCoordinator() { + err = r.bootstrapCoordinator() + if err != nil { + return err + } + } + + r.wg.Add(1) + go r.pushPeriodically() + + if r.config.MemberlistInterface != "" { + r.log.V(2).Printf("[INFO] Memberlist uses interface: %s", r.config.MemberlistInterface) + } + r.log.V(2).Printf("[INFO] Memberlist bindAddr: %s, bindPort: %d", r.config.MemberlistConfig.BindAddr, r.config.MemberlistConfig.BindPort) + r.log.V(2).Printf("[INFO] Cluster coordinator: %s", r.discovery.GetCoordinator()) + checkpoint.Pass() + return nil +} + +func (r *RoutingTable) Shutdown(ctx context.Context) error { + select { + case <-r.ctx.Done(): + // already closed + return nil + default: + } + + if err := r.discovery.Shutdown(); err != nil { + return err + } + + r.cancel() + done := make(chan struct{}) + go func() { + r.wg.Wait() + close(done) + }() + select { + case <-ctx.Done(): + err := ctx.Err() + if err != nil { + return err + } + case <-done: + } + return nil +} + +var _ service.Service = (*RoutingTable)(nil) diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/update.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/update.go new file mode 100644 index 000000000..e70729438 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/cluster/routingtable/update.go @@ -0,0 +1,111 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 routingtable + +import ( + "runtime" + "sync" + + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/internal/protocol" + "github.com/vmihailenco/msgpack" + "golang.org/x/sync/errgroup" + "golang.org/x/sync/semaphore" +) + +type leftOverDataReport struct { + Partitions []uint64 + Backups []uint64 +} + +func (r *RoutingTable) prepareLeftOverDataReport() ([]byte, error) { + res := leftOverDataReport{} + for partID := uint64(0); partID < r.config.PartitionCount; partID++ { + part := r.primary.PartitionByID(partID) + if part.Length() != 0 { + res.Partitions = append(res.Partitions, partID) + } + + backup := r.backup.PartitionByID(partID) + if backup.Length() != 0 { + res.Backups = append(res.Backups, partID) + } + } + return msgpack.Marshal(res) +} + +func (r *RoutingTable) updateRoutingTableOnMember(data []byte, member discovery.Member) (*leftOverDataReport, error) { + req := protocol.NewSystemMessage(protocol.OpUpdateRouting) + req.SetValue(data) + req.SetExtra(protocol.UpdateRoutingExtra{ + CoordinatorID: r.this.ID, + }) + // TODO: This blocks whole flow. Use timeout for smooth operation. + resp, err := r.requestTo(member.String(), req) + if err != nil { + r.log.V(3).Printf("[ERROR] Failed to update routing table on %s: %v", member, err) + return nil, err + } + + report := leftOverDataReport{} + err = msgpack.Unmarshal(resp.Value(), &report) + if err != nil { + r.log.V(3).Printf("[ERROR] Failed to call decode ownership report from %s: %v", member, err) + return nil, err + } + return &report, nil +} + +func (r *RoutingTable) updateRoutingTableOnCluster() (map[discovery.Member]*leftOverDataReport, error) { + data, err := msgpack.Marshal(r.table) + if err != nil { + return nil, err + } + + var mtx sync.Mutex + var g errgroup.Group + reports := make(map[discovery.Member]*leftOverDataReport) + num := int64(runtime.NumCPU()) + sem := semaphore.NewWeighted(num) + + r.Members().RLock() + r.Members().Range(func(id uint64, tmp discovery.Member) bool { + member := tmp + g.Go(func() error { + if err := sem.Acquire(r.ctx, 1); err != nil { + r.log.V(3).Printf("[ERROR] Failed to acquire semaphore to update routing table on %s: %v", member, err) + return err + } + defer sem.Release(1) + + report, err := r.updateRoutingTableOnMember(data, member) + if err != nil { + return err + } + + mtx.Lock() + defer mtx.Unlock() + reports[member] = report + return nil + }) + return true + }) + r.Members().RUnlock() + + if err := g.Wait(); err != nil { + return nil, err + } + return reports, nil +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/discovery/delegate.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/discovery/delegate.go new file mode 100644 index 000000000..a0bd6f3ee --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/discovery/delegate.go @@ -0,0 +1,50 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 discovery + +// delegate is a struct which implements memberlist.Delegate interface. +type delegate struct { + meta []byte +} + +// newDelegate returns a new delegate instance. +func (d *Discovery) newDelegate() (delegate, error) { + data, err := d.member.Encode() + if err != nil { + return delegate{}, err + } + return delegate{ + meta: data, + }, nil +} + +// NodeMeta is used to retrieve meta-data about the current node +// when broadcasting an alive message. It's length is limited to +// the given byte size. This metadata is available in the Node structure. +func (d delegate) NodeMeta(limit int) []byte { + return d.meta +} + +// NotifyMsg is called when a user-data message is received. +func (d delegate) NotifyMsg(data []byte) {} + +// GetBroadcasts is called when user data messages can be broadcast. +func (d delegate) GetBroadcasts(overhead, limit int) [][]byte { return nil } + +// LocalState is used for a TCP Push/Pull. +func (d delegate) LocalState(join bool) []byte { return nil } + +// MergeRemoteState is invoked after a TCP Push/Pull. +func (d delegate) MergeRemoteState(buf []byte, join bool) {} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/discovery/events.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/discovery/events.go new file mode 100644 index 000000000..45672a999 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/discovery/events.go @@ -0,0 +1,62 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 discovery + +import "github.com/hashicorp/memberlist" + +func ToClusterEvent(e memberlist.NodeEvent) *ClusterEvent { + return &ClusterEvent{ + Event: e.Event, + NodeName: e.Node.Name, + NodeAddr: e.Node.Addr, + NodePort: e.Node.Port, + NodeMeta: e.Node.Meta, + } +} + +func (d *Discovery) handleEvent(event memberlist.NodeEvent) { + d.clusterEventsMtx.RLock() + defer d.clusterEventsMtx.RUnlock() + + for _, ch := range d.eventSubscribers { + if event.Node.Name == d.member.Name { + continue + } + ch <- ToClusterEvent(event) + } +} + +// eventLoop awaits for messages from memberlist and broadcasts them to event listeners. +func (d *Discovery) eventLoop(eventsCh chan memberlist.NodeEvent) { + defer d.wg.Done() + + for { + select { + case e := <-eventsCh: + d.handleEvent(e) + case <-d.ctx.Done(): + return + } + } +} + +func (d *Discovery) SubscribeNodeEvents() chan *ClusterEvent { + d.clusterEventsMtx.Lock() + defer d.clusterEventsMtx.Unlock() + + ch := make(chan *ClusterEvent, eventChanCapacity) + d.eventSubscribers = append(d.eventSubscribers, ch) + return ch +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/discovery/member.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/discovery/member.go new file mode 100644 index 000000000..ff303ef78 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/discovery/member.go @@ -0,0 +1,73 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 discovery + +import ( + "encoding/binary" + "time" + + "github.com/buraksezer/olric/config" + "github.com/vmihailenco/msgpack" +) + +// Member represents a node in the cluster. +type Member struct { + Name string + NameHash uint64 + ID uint64 + Birthdate int64 +} + +// CompareByID returns true if two members denote the same member in the cluster. +func (m Member) CompareByID(other Member) bool { + // ID variable is calculated by combining member's name and birthdate + return m.ID == other.ID +} + +// CompareByName returns true if the two members has the same name in the cluster. +// This function is intended to redirect the requests to the partition owner. +func (m Member) CompareByName(other Member) bool { + return m.NameHash == other.NameHash +} + +func (m Member) String() string { + return m.Name +} + +func (m Member) Encode() ([]byte, error) { + return msgpack.Marshal(m) +} + +func NewMemberFromMetadata(metadata []byte) (Member, error) { + res := &Member{} + err := msgpack.Unmarshal(metadata, res) + return *res, err +} + +func NewMember(c *config.Config) Member { + // Calculate member's identity. It's useful to compare hosts. + birthdate := time.Now().UnixNano() + + buf := make([]byte, 8+len(c.MemberlistConfig.Name)) + binary.BigEndian.PutUint64(buf, uint64(birthdate)) + buf = append(buf, []byte(c.MemberlistConfig.Name)...) + nameHash := c.Hasher.Sum64([]byte(c.MemberlistConfig.Name)) + return Member{ + Name: c.MemberlistConfig.Name, + NameHash: nameHash, + ID: c.Hasher.Sum64(buf), + Birthdate: birthdate, + } +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/atomic.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/atomic.go new file mode 100644 index 000000000..9bf8bb900 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/atomic.go @@ -0,0 +1,168 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "errors" + "fmt" + "time" + + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/protocol" +) + +func (dm *DMap) loadCurrentAtomicInt(e *env) (int, error) { + entry, err := dm.get(e.key) + if errors.Is(err, ErrKeyNotFound) { + err = nil + } + if err != nil { + return 0, err + } + + var current int + if entry != nil { + var value interface{} + if err := dm.s.serializer.Unmarshal(entry.Value(), &value); err != nil { + return 0, err + } + return valueToInt(value) + } + return current, nil +} + +func (dm *DMap) atomicIncrDecr(opcode protocol.OpCode, e *env, delta int) (int, error) { + atomicKey := e.dmap + e.key + dm.s.locker.Lock(atomicKey) + defer func() { + err := dm.s.locker.Unlock(atomicKey) + if err != nil { + dm.s.log.V(3).Printf("[ERROR] Failed to release the fine grained lock for key: %s on DMap: %s: %v", e.key, e.dmap, err) + } + }() + + current, err := dm.loadCurrentAtomicInt(e) + if err != nil { + return 0, err + } + + var updated int + switch { + case opcode == protocol.OpIncr: + updated = current + delta + case opcode == protocol.OpDecr: + updated = current - delta + default: + return 0, fmt.Errorf("invalid operation") + } + + val, err := dm.s.serializer.Marshal(updated) + if err != nil { + return 0, err + } + + e.value = val + err = dm.put(e) + if err != nil { + return 0, err + } + + return updated, nil +} + +// Incr atomically increments key by delta. The return value is the new value after being incremented or an error. +func (dm *DMap) Incr(key string, delta int) (int, error) { + e := &env{ + opcode: protocol.OpPut, + replicaOpcode: protocol.OpPutReplica, + dmap: dm.name, + key: key, + timestamp: time.Now().UnixNano(), + kind: partitions.PRIMARY, + } + return dm.atomicIncrDecr(protocol.OpIncr, e, delta) +} + +// Decr atomically decrements key by delta. The return value is the new value after being decremented or an error. +func (dm *DMap) Decr(key string, delta int) (int, error) { + e := &env{ + opcode: protocol.OpPut, + replicaOpcode: protocol.OpPutReplica, + dmap: dm.name, + key: key, + timestamp: time.Now().UnixNano(), + kind: partitions.PRIMARY, + } + return dm.atomicIncrDecr(protocol.OpDecr, e, delta) +} + +func (dm *DMap) getPut(e *env) ([]byte, error) { + atomicKey := e.dmap + e.key + dm.s.locker.Lock(atomicKey) + defer func() { + err := dm.s.locker.Unlock(atomicKey) + if err != nil { + dm.s.log.V(3).Printf("[ERROR] Failed to release the lock for key: %s on DMap: %s: %v", e.key, e.dmap, err) + } + }() + + entry, err := dm.get(e.key) + if errors.Is(err, ErrKeyNotFound) { + err = nil + } + if err != nil { + return nil, err + } + err = dm.put(e) + if err != nil { + return nil, err + } + if entry == nil { + // The value is nil. + return nil, nil + } + return entry.Value(), nil +} + +// GetPut atomically sets key to value and returns the old value stored at key. +func (dm *DMap) GetPut(key string, value interface{}) (interface{}, error) { + if value == nil { + value = struct{}{} + } + val, err := dm.s.serializer.Marshal(value) + if err != nil { + return nil, err + } + e := &env{ + opcode: protocol.OpPut, + replicaOpcode: protocol.OpPutReplica, + dmap: dm.name, + key: key, + value: val, + timestamp: time.Now().UnixNano(), + } + raw, err := dm.getPut(e) + if err != nil { + return nil, err + } + + var old interface{} + if raw != nil { + if err = dm.s.serializer.Unmarshal(raw, &old); err != nil { + return nil, err + } + } + return old, nil +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/atomic_operations.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/atomic_operations.go new file mode 100644 index 000000000..7b20e6ace --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/atomic_operations.go @@ -0,0 +1,113 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "fmt" + "reflect" + "time" + + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" +) + +func valueToInt(delta interface{}) (int, error) { + switch value := delta.(type) { + case int: + return value, nil + case int8: + return int(value), nil + case int16: + return int(value), nil + case int32: + return int(value), nil + case int64: + return int(value), nil + default: + return 0, fmt.Errorf("mismatched type: %v", reflect.TypeOf(delta)) + } +} + +func (s *Service) incrDecrOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.DMapMessage) + dm, err := s.getOrCreateDMap(req.DMap()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + e := &env{ + opcode: protocol.OpPut, + replicaOpcode: protocol.OpPutReplica, + dmap: req.DMap(), + key: req.Key(), + timestamp: time.Now().UnixNano(), + kind: partitions.PRIMARY, + } + var delta interface{} + err = s.serializer.Unmarshal(req.Value(), &delta) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + v, err := valueToInt(delta) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + latest, err := dm.atomicIncrDecr(req.Op, e, v) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + value, err := s.serializer.Marshal(latest) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) + w.SetValue(value) +} + +func (s *Service) getPutOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.DMapMessage) + dm, err := s.getOrCreateDMap(req.DMap()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + e := &env{ + opcode: protocol.OpPut, + replicaOpcode: protocol.OpPutReplica, + dmap: req.DMap(), + key: req.Key(), + value: req.Value(), + timestamp: time.Now().UnixNano(), + kind: partitions.PRIMARY, + } + old, err := dm.getPut(e) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + if old != nil { + w.SetValue(old) + } + w.SetStatus(protocol.StatusOK) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/balance.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/balance.go new file mode 100644 index 000000000..9e7e3e75b --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/balance.go @@ -0,0 +1,141 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "errors" + "fmt" + + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/buraksezer/olric/pkg/storage" + "github.com/vmihailenco/msgpack" +) + +type fragmentPack struct { + PartID uint64 + Kind partitions.Kind + Name string + Payload []byte +} + +func (dm *DMap) fragmentMergeFunction(f *fragment, hkey uint64, entry storage.Entry) error { + current, err := f.storage.Get(hkey) + if errors.Is(err, storage.ErrKeyNotFound) { + return f.storage.Put(hkey, entry) + } + if err != nil { + return err + } + + versions := []*version{{entry: current}, {entry: entry}} + versions = dm.sortVersions(versions) + winner := versions[0].entry + if winner == current { + // No need to insert the winner + return nil + } + return f.storage.Put(hkey, versions[0].entry) +} + +func (dm *DMap) mergeFragments(part *partitions.Partition, fp *fragmentPack) error { + f, err := dm.loadOrCreateFragment(part) + if err != nil { + return err + } + + // Acquire fragment's lock. No one should work on it. + f.Lock() + defer f.Unlock() + + return f.storage.Import(fp.Payload, func(hkey uint64, entry storage.Entry) error { + return dm.fragmentMergeFunction(f, hkey, entry) + }) +} + +func (s *Service) checkOwnership(part *partitions.Partition) bool { + owners := part.Owners() + for _, owner := range owners { + if owner.CompareByID(s.rt.This()) { + return true + } + } + return false +} + +func (s *Service) validateFragmentPack(fp *fragmentPack) error { + if fp.PartID >= s.config.PartitionCount { + return fmt.Errorf("invalid partition id: %d", fp.PartID) + } + + var part *partitions.Partition + if fp.Kind == partitions.PRIMARY { + part = s.primary.PartitionByID(fp.PartID) + } else { + part = s.backup.PartitionByID(fp.PartID) + } + + // Check ownership before merging. This is useful to prevent data corruption in network partitioning case. + if !s.checkOwnership(part) { + return neterrors.Wrap(neterrors.ErrInvalidArgument, + fmt.Sprintf("partID: %d (kind: %s) doesn't belong to %s", fp.PartID, fp.Kind, s.rt.This())) + } + return nil +} + +func (s *Service) extractFragmentPack(r protocol.EncodeDecoder) (*fragmentPack, error) { + req := r.(*protocol.SystemMessage) + fp := &fragmentPack{} + err := msgpack.Unmarshal(req.Value(), fp) + return fp, err +} + +func (s *Service) moveFragmentOperation(w, r protocol.EncodeDecoder) { + fp, err := s.extractFragmentPack(r) + if err != nil { + s.log.V(2).Printf("[ERROR] Failed to unmarshal DMap: %v", err) + neterrors.ErrorResponse(w, err) + return + } + + if err = s.validateFragmentPack(fp); err != nil { + neterrors.ErrorResponse(w, err) + return + } + + var part *partitions.Partition + if fp.Kind == partitions.PRIMARY { + part = s.primary.PartitionByID(fp.PartID) + } else { + part = s.backup.PartitionByID(fp.PartID) + } + s.log.V(2).Printf("[INFO] Received DMap (kind: %s): %s on PartID: %d", fp.Kind, fp.Name, fp.PartID) + + dm, err := s.NewDMap(fp.Name) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + err = dm.mergeFragments(part, fp) + if err != nil { + s.log.V(2).Printf("[ERROR] Failed to merge Received DMap (kind: %s): %s on PartID: %d: %v", + fp.Kind, fp.Name, fp.PartID, err) + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/compaction.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/compaction.go new file mode 100644 index 000000000..71ce832ba --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/compaction.go @@ -0,0 +1,112 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "strings" + "sync" + "time" + + "github.com/buraksezer/olric/internal/cluster/partitions" + "golang.org/x/sync/semaphore" +) + +func (s *Service) callCompactionOnFragment(f *fragment) bool { + for { + f.Lock() + done, err := f.Compaction() + if err != nil { + f.Unlock() + // Continue + return true + } + f.Unlock() + + if done { + return true + } + + select { + case <-s.ctx.Done(): + // Break + return false + case <-time.After(time.Millisecond): + } + } +} + +func (s *Service) doCompaction(partID uint64) { + compaction := func(part *partitions.Partition) { + part.Map().Range(func(name, tmp interface{}) bool { + if !strings.HasPrefix(name.(string), "dmap.") { + // Continue. This fragment belongs to a different data structure. + return true + } + + f := tmp.(*fragment) + return s.callCompactionOnFragment(f) + }) + } + + part := s.primary.PartitionByID(partID) + compaction(part) + + backup := s.backup.PartitionByID(partID) + compaction(backup) +} + +func (s *Service) triggerCompaction() { + var wg sync.WaitGroup + + sem := semaphore.NewWeighted(10) + for partID := uint64(0); partID < s.config.PartitionCount; partID++ { + select { + case <-s.ctx.Done(): + break + default: + } + + if err := sem.Acquire(s.ctx, 1); err != nil { + s.log.V(3).Printf("[ERROR] Failed to acquire semaphore: %v", err) + continue + } + + wg.Add(1) + go func(id uint64) { + defer wg.Done() + defer sem.Release(1) + s.doCompaction(id) + }(partID) + } + + wg.Wait() +} + +func (s *Service) compactionWorker() { + defer s.wg.Done() + + timer := time.NewTimer(s.config.DMaps.TriggerCompactionInterval) + defer timer.Stop() + + for { + timer.Reset(s.config.DMaps.TriggerCompactionInterval) + select { + case <-timer.C: + s.triggerCompaction() + case <-s.ctx.Done(): + return + } + } +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/config.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/config.go new file mode 100644 index 000000000..57685e3c9 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/config.go @@ -0,0 +1,73 @@ +package dmap + +import ( + "fmt" + "time" + + "github.com/buraksezer/olric/config" +) + +// dmapConfig keeps DMap config control parameters and access-log for keys in a dmap. +type dmapConfig struct { + engine *config.Engine + maxIdleDuration time.Duration + ttlDuration time.Duration + maxKeys int + maxInuse int + lruSamples int + evictionPolicy config.EvictionPolicy +} + +func (c *dmapConfig) load(dc *config.DMaps, name string) error { + // Try to set config configuration for this dmap. + c.maxIdleDuration = dc.MaxIdleDuration + c.ttlDuration = dc.TTLDuration + c.maxKeys = dc.MaxKeys + c.maxInuse = dc.MaxInuse + c.lruSamples = dc.LRUSamples + c.evictionPolicy = dc.EvictionPolicy + c.engine = dc.Engine + + if dc.Custom != nil { + // config.DMap struct can be used for fine-grained control. + cs, ok := dc.Custom[name] + if ok { + if c.maxIdleDuration != cs.MaxIdleDuration { + c.maxIdleDuration = cs.MaxIdleDuration + } + if c.ttlDuration != cs.TTLDuration { + c.ttlDuration = cs.TTLDuration + } + if c.evictionPolicy != cs.EvictionPolicy { + c.evictionPolicy = cs.EvictionPolicy + } + if c.maxKeys != cs.MaxKeys { + c.maxKeys = cs.MaxKeys + } + if c.maxInuse != cs.MaxInuse { + c.maxInuse = cs.MaxInuse + } + if c.lruSamples != cs.LRUSamples { + c.lruSamples = cs.LRUSamples + } + if c.evictionPolicy != cs.EvictionPolicy { + c.evictionPolicy = cs.EvictionPolicy + } + if c.engine == nil { + c.engine = cs.Engine + } + } + } + + // TODO: Create a new function to verify config config. + if c.evictionPolicy == config.LRUEviction { + if c.maxInuse <= 0 && c.maxKeys <= 0 { + return fmt.Errorf("maxInuse or maxKeys have to be greater than zero") + } + // set the default value. + if c.lruSamples == 0 { + c.lruSamples = config.DefaultLRUSamples + } + } + return nil +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/delete.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/delete.go new file mode 100644 index 000000000..ca93f2371 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/delete.go @@ -0,0 +1,152 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "errors" + + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/internal/stats" + "golang.org/x/sync/errgroup" +) + +var ( + // DeleteHits is the number of deletion reqs resulting in an item being removed. + DeleteHits = stats.NewInt64Counter() + + // DeleteMisses is the number of deletions reqs for missing keys + DeleteMisses = stats.NewInt64Counter() +) + +func (dm *DMap) deleteBackupFromFragment(key string, kind partitions.Kind) error { + hkey := partitions.HKey(dm.name, key) + part := dm.getPartitionByHKey(hkey, kind) + f, err := dm.loadFragment(part) + if errors.Is(err, errFragmentNotFound) { + // key doesn't exist + return nil + } + if err != nil { + return err + } + + f.Lock() + defer f.Unlock() + + return f.storage.Delete(hkey) +} + +func (dm *DMap) deleteFromPreviousOwners(key string, owners []discovery.Member) error { + // Traverse in reverse order. Except from the latest host, this one. + for i := len(owners) - 2; i >= 0; i-- { + owner := owners[i] + req := protocol.NewDMapMessage(protocol.OpDeletePrev) + req.SetDMap(dm.name) + req.SetKey(key) + _, err := dm.s.requestTo(owner.String(), req) + if err != nil { + return err + } + } + return nil +} + +func (dm *DMap) deleteBackupOnCluster(hkey uint64, key string) error { + owners := dm.s.backup.PartitionOwnersByHKey(hkey) + var g errgroup.Group + for _, owner := range owners { + mem := owner + g.Go(func() error { + // TODO: Add retry with backoff + req := protocol.NewDMapMessage(protocol.OpDeleteReplica) + req.SetDMap(dm.name) + req.SetKey(key) + _, err := dm.s.requestTo(mem.String(), req) + if err != nil { + dm.s.log.V(3).Printf("[ERROR] Failed to delete replica key/value on %s: %s", dm.name, err) + } + return err + }) + } + return g.Wait() +} + +// deleteOnCluster is not a thread-safe function +func (dm *DMap) deleteOnCluster(hkey uint64, key string, f *fragment) error { + owners := dm.s.primary.PartitionOwnersByHKey(hkey) + if len(owners) == 0 { + panic("partition owners list cannot be empty") + } + + err := dm.deleteFromPreviousOwners(key, owners) + if err != nil { + return err + } + + if dm.s.config.ReplicaCount != 0 { + err := dm.deleteBackupOnCluster(hkey, key) + if err != nil { + return err + } + } + + err = f.storage.Delete(hkey) + if err != nil { + return err + } + + // DeleteHits is the number of deletion reqs resulting in an item being removed. + DeleteHits.Increase(1) + + return nil +} + +func (dm *DMap) deleteKey(key string) error { + hkey := partitions.HKey(dm.name, key) + member := dm.s.primary.PartitionByHKey(hkey).Owner() + if !member.CompareByName(dm.s.rt.This()) { + req := protocol.NewDMapMessage(protocol.OpDelete) + req.SetDMap(dm.name) + req.SetKey(key) + _, err := dm.s.requestTo(member.String(), req) + return err + } + + part := dm.getPartitionByHKey(hkey, partitions.PRIMARY) + f, err := dm.loadOrCreateFragment(part) + if err != nil { + return err + } + + f.Lock() + defer f.Unlock() + + // Check the HKey before trying to delete it. + if !f.storage.Check(hkey) { + // DeleteMisses is the number of deletions reqs for missing keys + DeleteMisses.Increase(1) + return nil + } + + return dm.deleteOnCluster(hkey, key, f) +} + +// Delete deletes the value for the given key. Delete will not return error if key doesn't exist. It's thread-safe. +// It is safe to modify the contents of the argument after Delete returns. +func (dm *DMap) Delete(key string) error { + return dm.deleteKey(key) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/delete_operations.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/delete_operations.go new file mode 100644 index 000000000..7a638e42f --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/delete_operations.go @@ -0,0 +1,57 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" +) + +func (s *Service) deleteOperationCommon(w, r protocol.EncodeDecoder, f func(dm *DMap, r protocol.EncodeDecoder) error) { + req := r.(*protocol.DMapMessage) + dm, err := s.getOrCreateDMap(req.DMap()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + err = f(dm, r) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) +} + +func (s *Service) deleteOperation(w, r protocol.EncodeDecoder) { + s.deleteOperationCommon(w, r, func(dm *DMap, r protocol.EncodeDecoder) error { + req := r.(*protocol.DMapMessage) + return dm.deleteKey(req.Key()) + }) +} + +func (s *Service) deletePrevOperation(w, r protocol.EncodeDecoder) { + s.deleteOperationCommon(w, r, func(dm *DMap, r protocol.EncodeDecoder) error { + req := r.(*protocol.DMapMessage) + return dm.deleteBackupFromFragment(req.Key(), partitions.PRIMARY) + }) +} + +func (s *Service) deleteReplicaOperation(w, r protocol.EncodeDecoder) { + s.deleteOperationCommon(w, r, func(dm *DMap, r protocol.EncodeDecoder) error { + req := r.(*protocol.DMapMessage) + return dm.deleteBackupFromFragment(req.Key(), partitions.BACKUP) + }) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/destroy.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/destroy.go new file mode 100644 index 000000000..231b59618 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/destroy.go @@ -0,0 +1,72 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "runtime" + + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/internal/protocol" + "golang.org/x/sync/errgroup" + "golang.org/x/sync/semaphore" +) + +func (dm *DMap) destroyOnCluster() error { + num := int64(runtime.NumCPU()) + sem := semaphore.NewWeighted(num) + + var g errgroup.Group + + // Don't block routing table to destroy a DMap on the cluster. + // Just get a copy of members and run Destroy. + var members []discovery.Member + m := dm.s.rt.Members() + m.RLock() + m.Range(func(_ uint64, member discovery.Member) bool { + members = append(members, member) + return true + }) + m.RUnlock() + + for _, item := range members { + addr := item.String() + g.Go(func() error { + if err := sem.Acquire(dm.s.ctx, 1); err != nil { + dm.s.log.V(3). + Printf("[ERROR] Failed to acquire semaphore to call Destroy command on %s for %s: %v", + addr, dm.name, err) + return err + } + defer sem.Release(1) + + req := protocol.NewDMapMessage(protocol.OpDestroyDMapInternal) + req.SetDMap(dm.name) + dm.s.log.V(6).Printf("[DEBUG] Calling Destroy command on %s for %s", addr, dm.name) + _, err := dm.s.requestTo(addr, req) + if err != nil { + dm.s.log.V(3).Printf("[ERROR] Failed to destroy DMap: %s on %s", dm.name, addr) + } + return err + }) + } + return g.Wait() +} + +// Destroy flushes the given DMap on the cluster. You should know that there +// is no global lock on DMaps. So if you call Put, PutEx and Destroy methods +// concurrently on the cluster, Put and PutEx calls may set new values to the DMap. +func (dm *DMap) Destroy() error { + return dm.destroyOnCluster() +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/destroy_operations.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/destroy_operations.go new file mode 100644 index 000000000..d782a0bb1 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/destroy_operations.go @@ -0,0 +1,88 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "errors" + + "github.com/buraksezer/olric/config" + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" +) + +func (s *Service) destroyOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.DMapMessage) + dm, err := s.getOrCreateDMap(req.DMap()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + err = dm.destroyOnCluster() + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) +} + +func (dm *DMap) destroyFragmentOnPartition(part *partitions.Partition) error { + f, err := dm.loadFragment(part) + if errors.Is(err, errFragmentNotFound) { + // not exists + return nil + } + if err != nil { + return err + } + return wipeOutFragment(part, dm.fragmentName, f) +} + +func (s *Service) destroyDMapOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.DMapMessage) + // This is very similar with rm -rf. Destroys given dmap on the cluster + for partID := uint64(0); partID < s.config.PartitionCount; partID++ { + dm, err := s.getDMap(req.DMap()) + if errors.Is(err, ErrDMapNotFound) { + continue + } + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + part := dm.s.primary.PartitionByID(partID) + err = dm.destroyFragmentOnPartition(part) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + // Destroy on replicas + if s.config.ReplicaCount > config.MinimumReplicaCount { + backup := dm.s.backup.PartitionByID(partID) + err = dm.destroyFragmentOnPartition(backup) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + } + } + + s.Lock() + delete(s.dmaps, req.DMap()) + s.Unlock() + w.SetStatus(protocol.StatusOK) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/dmap.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/dmap.go new file mode 100644 index 000000000..7fed66aef --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/dmap.go @@ -0,0 +1,154 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "errors" + "fmt" + "time" + + "github.com/buraksezer/olric/internal/bufpool" + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/buraksezer/olric/pkg/storage" +) + +// pool is good for recycling memory while reading messages from the socket. +var bufferPool = bufpool.New() + +const nilTimeout = 0 * time.Second + +var ( + // ErrKeyNotFound is returned when a key could not be found. + ErrKeyNotFound = neterrors.New(protocol.StatusErrKeyNotFound, "key not found") + ErrDMapNotFound = errors.New("dmap not found") + ErrServerGone = errors.New("server is gone") +) + +// DMap implements a single-hop distributed hash table. +type DMap struct { + name string + fragmentName string + s *Service + engine storage.Engine + config *dmapConfig +} + +// Name exposes name of the DMap. +func (dm *DMap) Name() string { + return dm.name +} + +// getDMap returns an initialized DMap instance, otherwise it returns ErrDMapNotFound. +func (s *Service) getDMap(name string) (*DMap, error) { + s.RLock() + defer s.RUnlock() + + dm, ok := s.dmaps[name] + if !ok { + return nil, ErrDMapNotFound + } + return dm, nil +} + +func (s *Service) fragmentName(name string) string { + return fmt.Sprintf("dmap.%s", name) +} + +// NewDMap creates and returns a new DMap instance. It checks member count quorum +// and bootstrapping status before creating a new DMap. +func (s *Service) NewDMap(name string) (*DMap, error) { + // Check operation status first: + // + // * Checks member count in the cluster, returns ErrClusterQuorum if + // the quorum value cannot be satisfied, + // * Checks bootstrapping status and awaits for a short period before + // returning ErrRequest timeout. + if err := s.rt.CheckMemberCountQuorum(); err != nil { + return nil, err + } + // An Olric node has to be bootstrapped to function properly. + if err := s.rt.CheckBootstrap(); err != nil { + return nil, err + } + + s.Lock() + defer s.Unlock() + + dm, ok := s.dmaps[name] + if ok { + return dm, nil + } + + dm = &DMap{ + config: &dmapConfig{}, + name: name, + fragmentName: s.fragmentName(name), + s: s, + } + if err := dm.config.load(s.config.DMaps, name); err != nil { + return nil, err + } + + // It's a shortcut. + dm.engine = dm.config.engine.Implementation + s.dmaps[name] = dm + return dm, nil +} + +// getOrCreate is a shortcut function to create a new DMap or get an already initialized DMap instance. +func (s *Service) getOrCreateDMap(name string) (*DMap, error) { + dm, err := s.getDMap(name) + if errors.Is(err, ErrDMapNotFound) { + return s.NewDMap(name) + } + return dm, err +} + +func (dm *DMap) getPartitionByHKey(hkey uint64, kind partitions.Kind) *partitions.Partition { + var part *partitions.Partition + switch { + case kind == partitions.PRIMARY: + part = dm.s.primary.PartitionByHKey(hkey) + case kind == partitions.BACKUP: + part = dm.s.backup.PartitionByHKey(hkey) + default: + panic("unknown partition kind") + } + return part +} + +func timeoutToTTL(timeout time.Duration) int64 { + if timeout.Seconds() == 0 { + return 0 + } + // convert nanoseconds to milliseconds + return (timeout.Nanoseconds() + time.Now().UnixNano()) / 1000000 +} + +func isKeyExpired(ttl int64) bool { + if ttl == 0 { + return false + } + + // convert nanoseconds to milliseconds + res := (time.Now().UnixNano() / 1000000) >= ttl + if res { + // number of valid items removed from cache to free memory for new items. + EvictedTotal.Increase(1) + } + return res +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/env.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/env.go new file mode 100644 index 000000000..8e5bbf055 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/env.go @@ -0,0 +1,142 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "time" + + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/protocol" +) + +type env struct { + hkey uint64 + timestamp int64 + flags int16 + opcode protocol.OpCode + replicaOpcode protocol.OpCode + dmap string + key string + value []byte + timeout time.Duration + kind partitions.Kind + fragment *fragment +} + +func newEnv(opcode protocol.OpCode, name, key string, value []byte, timeout time.Duration, flags int16, kind partitions.Kind) *env { + e := &env{ + opcode: opcode, + dmap: name, + key: key, + value: value, + timestamp: time.Now().UnixNano(), + timeout: timeout, + flags: flags, + kind: kind, + } + switch { + case opcode == protocol.OpPut: + e.replicaOpcode = protocol.OpPutReplica + case opcode == protocol.OpPutEx: + e.replicaOpcode = protocol.OpPutExReplica + case opcode == protocol.OpPutIf: + e.replicaOpcode = protocol.OpPutIfReplica + case opcode == protocol.OpPutIfEx: + e.replicaOpcode = protocol.OpPutIfExReplica + } + return e +} + +// newEnvFromReq generates a new protocol message from writeop instance. +func newEnvFromReq(r protocol.EncodeDecoder, kind partitions.Kind) *env { + e := &env{} + req := r.(*protocol.DMapMessage) + e.dmap = req.DMap() + e.key = req.Key() + e.value = req.Value() + e.opcode = req.Op + e.kind = kind + e.hkey = partitions.HKey(req.DMap(), req.Key()) + + // Set opcode for a possible replica operation + switch e.opcode { + case protocol.OpPut: + e.replicaOpcode = protocol.OpPutReplica + case protocol.OpPutEx: + e.replicaOpcode = protocol.OpPutExReplica + case protocol.OpPutIf: + e.replicaOpcode = protocol.OpPutIfReplica + case protocol.OpPutIfEx: + e.replicaOpcode = protocol.OpPutIfExReplica + } + + // Extract extras + switch req.Op { + case protocol.OpPut, protocol.OpPutReplica: + e.timestamp = req.Extra().(protocol.PutExtra).Timestamp + case protocol.OpPutEx, protocol.OpPutExReplica: + e.timestamp = req.Extra().(protocol.PutExExtra).Timestamp + e.timeout = time.Duration(req.Extra().(protocol.PutExExtra).TTL) + case protocol.OpPutIf, protocol.OpPutIfReplica: + e.flags = req.Extra().(protocol.PutIfExtra).Flags + e.timestamp = req.Extra().(protocol.PutIfExtra).Timestamp + case protocol.OpPutIfEx, protocol.OpPutIfExReplica: + e.flags = req.Extra().(protocol.PutIfExExtra).Flags + e.timestamp = req.Extra().(protocol.PutIfExExtra).Timestamp + e.timeout = time.Duration(req.Extra().(protocol.PutIfExExtra).TTL) + case protocol.OpExpire: + e.timestamp = req.Extra().(protocol.ExpireExtra).Timestamp + e.timeout = time.Duration(req.Extra().(protocol.ExpireExtra).TTL) + } + return e +} + +// toReq generates a new protocol message from a writeop. +func (e *env) toReq(opcode protocol.OpCode) *protocol.DMapMessage { + req := protocol.NewDMapMessage(opcode) + req.SetDMap(e.dmap) + req.SetKey(e.key) + req.SetValue(e.value) + + // Prepare extras + switch opcode { + case protocol.OpPut, protocol.OpPutReplica: + req.SetExtra(protocol.PutExtra{ + Timestamp: e.timestamp, + }) + case protocol.OpPutEx, protocol.OpPutExReplica: + req.SetExtra(protocol.PutExExtra{ + TTL: e.timeout.Nanoseconds(), + Timestamp: e.timestamp, + }) + case protocol.OpPutIf, protocol.OpPutIfReplica: + req.SetExtra(protocol.PutIfExtra{ + Flags: e.flags, + Timestamp: e.timestamp, + }) + case protocol.OpPutIfEx, protocol.OpPutIfExReplica: + req.SetExtra(protocol.PutIfExExtra{ + Flags: e.flags, + Timestamp: e.timestamp, + TTL: e.timeout.Nanoseconds(), + }) + case protocol.OpExpire: + req.SetExtra(protocol.ExpireExtra{ + Timestamp: e.timestamp, + TTL: e.timeout.Nanoseconds(), + }) + } + return req +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/eviction.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/eviction.go new file mode 100644 index 000000000..95b683801 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/eviction.go @@ -0,0 +1,241 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "errors" + "fmt" + "math/rand" + "runtime" + "sort" + "time" + + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/pkg/storage" + "golang.org/x/sync/semaphore" +) + +// isKeyIdleOnFragment is not a thread-safe function. It accesses underlying fragment for the given hkey. +func (dm *DMap) isKeyIdleOnFragment(hkey uint64, f *fragment) bool { + if dm.config == nil { + return false + } + + if dm.config.maxIdleDuration.Nanoseconds() == 0 { + return false + } + // Maximum time in seconds for each entry to stay idle in the map. + // It limits the lifetime of the entries relative to the time of the last + // read or write access performed on them. The entries whose idle period + // exceeds this limit are expired and evicted automatically. + lastAccess, err := f.storage.GetLastAccess(hkey) + if errors.Is(err, storage.ErrKeyNotFound) { + return false + } + // TODO: Handle other errors. + ttl := (dm.config.maxIdleDuration.Nanoseconds() + lastAccess) / 1000000 + return isKeyExpired(ttl) +} + +func (dm *DMap) isKeyIdle(hkey uint64) bool { + part := dm.getPartitionByHKey(hkey, partitions.PRIMARY) + f, err := dm.loadFragment(part) + if errors.Is(err, errFragmentNotFound) { + // it's no possible to know whether the key is idle or not. + return false + } + if err != nil { + // This could be a programming error and should never be happened on production systems. + panic(fmt.Sprintf("failed to get primary partition for: %d: %v", hkey, err)) + } + f.Lock() + defer f.Unlock() + return dm.isKeyIdleOnFragment(hkey, f) +} + +func (s *Service) evictKeysAtBackground() { + defer s.wg.Done() + + num := int64(runtime.NumCPU()) + if s.config.DMaps != nil && s.config.DMaps.NumEvictionWorkers != 0 { + num = s.config.DMaps.NumEvictionWorkers + } + sem := semaphore.NewWeighted(num) + for { + if !s.isAlive() { + return + } + + if err := sem.Acquire(s.ctx, 1); err != nil { + s.log.V(3).Printf("[ERROR] Failed to acquire semaphore: %v", err) + return + } + + s.wg.Add(1) + go func() { + defer s.wg.Done() + defer sem.Release(1) + // Good for developing tests. + s.evictKeys() + select { + case <-time.After(100 * time.Millisecond): + case <-s.ctx.Done(): + return + } + }() + } +} + +func (s *Service) evictKeys() { + partID := uint64(rand.Intn(int(s.config.PartitionCount))) + part := s.primary.PartitionByID(partID) + part.Map().Range(func(name, tmp interface{}) bool { + f := tmp.(*fragment) + s.scanFragmentForEviction(partID, name.(string), f) + // this breaks the loop, we only scan one dmap instance per call + return false + }) +} + +func (s *Service) scanFragmentForEviction(partID uint64, name string, f *fragment) { + /* + From Redis Docs: + 1- Test 20 random keys from the set of keys with an associated expire. + 2- Delete all the keys found expired. + 3- If more than 25% of keys were expired, start again from step 1. + */ + + // We need limits to prevent CPU starvation. deleteOnCluster does some network operation + // to delete keys from the backup nodes and the previous owners. + var maxKeyCount = 20 + var maxTotalCount = 100 + var totalCount = 0 + + dm, err := s.getOrCreateDMap(name) + if err != nil { + s.log.V(3).Printf("[ERROR] Failed to load DMap: %s: %v", name, err) + return + } + + janitor := func() bool { + if totalCount > maxTotalCount { + // Release the lock. Eviction will be triggered again. + return false + } + f.Lock() + defer f.Unlock() + count, keyCount := 0, 0 + f.storage.Range(func(hkey uint64, entry storage.Entry) bool { + keyCount++ + if keyCount >= maxKeyCount { + // this means 'break'. + return false + } + if isKeyExpired(entry.TTL()) || dm.isKeyIdleOnFragment(hkey, f) { + err = dm.deleteOnCluster(hkey, entry.Key(), f) + if err != nil { + // It will be tried again. + dm.s.log.V(3).Printf("[ERROR] Failed to delete expired key: %s on DMap: %s: %v", + entry.Key(), dm.name, err) + return true + } + + // number of valid items removed from cache to free memory for new items. + EvictedTotal.Increase(1) + } + return true + }) + + totalCount += count + return count >= maxKeyCount/4 + } + + defer func() { + if totalCount > 0 { + if s.log.V(6).Ok() { + s.log.V(6).Printf("[DEBUG] Evicted key count is %d on PartID: %d", totalCount, partID) + } + } + }() + for { + select { + case <-f.ctx.Done(): + // the fragment is closed. + return + case <-s.ctx.Done(): + // The server has gone. + return + default: + } + // Call janitorWorker again until it returns false. + if !janitor() { + return + } + } +} + +type lruItem struct { + HKey uint64 + LastAccess int64 +} + +func (dm *DMap) evictKeyWithLRU(e *env) error { + var idx = 1 + var items []lruItem + + // Warning: fragment is already locked by DMap.Put. Be sure about that before editing this function. + + // Pick random items from the distributed map and sort them by accessedAt. + e.fragment.storage.Range(func(hkey uint64, e storage.Entry) bool { + if idx >= dm.config.lruSamples { + return false + } + idx++ + i := lruItem{ + HKey: hkey, + LastAccess: e.LastAccess(), + } + items = append(items, i) + return true + }) + + if len(items) == 0 { + return fmt.Errorf("nothing found to expire with LRU") + } + + sort.Slice(items, func(i, j int) bool { return items[i].LastAccess < items[j].LastAccess }) + // Pick the first item to delete. It's the least recently used item in the sample. + item := items[0] + key, err := e.fragment.storage.GetKey(item.HKey) + if err != nil { + if errors.Is(err, storage.ErrKeyNotFound) { + err = ErrKeyNotFound + GetMisses.Increase(1) + } + return err + } + // Here we have a key/value pair to evict for making room for a new pair. + if dm.s.log.V(6).Ok() { + dm.s.log.V(6).Printf("[DEBUG] Evicted item on DMap: %s, key: %s with LRU", e.dmap, key) + } + err = dm.deleteOnCluster(item.HKey, key, e.fragment) + if err != nil { + return err + } + + // number of valid items removed from cache to free memory for new items. + EvictedTotal.Increase(1) + return nil +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/expire.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/expire.go new file mode 100644 index 000000000..13e9d120a --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/expire.go @@ -0,0 +1,161 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "errors" + "fmt" + "time" + + "github.com/buraksezer/olric/config" + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/storage" +) + +func (dm *DMap) localExpireOnReplica(e *env) error { + part := dm.getPartitionByHKey(e.hkey, partitions.BACKUP) + f, err := dm.loadFragment(part) + if errors.Is(err, errFragmentNotFound) { + return ErrKeyNotFound + } + if err != nil { + return err + } + + e.fragment = f + f.Lock() + defer f.Unlock() + + return dm.localExpire(e) +} + +func (dm *DMap) localExpire(e *env) error { + ttl := timeoutToTTL(e.timeout) + entry := e.fragment.storage.NewEntry() + entry.SetTimestamp(e.timestamp) + entry.SetTTL(ttl) + err := e.fragment.storage.UpdateTTL(e.hkey, entry) + if err != nil { + if errors.Is(err, storage.ErrKeyNotFound) { + err = ErrKeyNotFound + } + return err + } + return nil +} + +func (dm *DMap) asyncExpireOnCluster(e *env) error { + req := e.toReq(protocol.OpExpireReplica) + // Fire and forget mode. + owners := dm.s.backup.PartitionOwnersByHKey(e.hkey) + for _, owner := range owners { + dm.s.wg.Add(1) + go func(host discovery.Member) { + defer dm.s.wg.Done() + _, err := dm.s.requestTo(host.String(), req) + if err != nil { + if dm.s.log.V(3).Ok() { + dm.s.log.V(3).Printf("[ERROR] Failed to set expire in async mode: %v", err) + } + } + }(owner) + } + return dm.putOnFragment(e) +} + +func (dm *DMap) syncExpireOnCluster(e *env) error { + req := e.toReq(protocol.OpExpireReplica) + + // Quorum based replication. + var successful int + owners := dm.s.backup.PartitionOwnersByHKey(e.hkey) + for _, owner := range owners { + _, err := dm.s.requestTo(owner.String(), req) + if err != nil { + if dm.s.log.V(3).Ok() { + dm.s.log.V(3).Printf("[ERROR] Failed to call expire command on %s for DMap: %s: %v", + owner, e.dmap, err) + } + continue + } + successful++ + } + err := dm.localExpire(e) + if err != nil { + if dm.s.log.V(3).Ok() { + dm.s.log.V(3).Printf("[ERROR] Failed to call expire command on %s for DMap: %s: %v", + dm.s.rt.This(), e.dmap, err) + } + } else { + successful++ + } + if successful >= dm.s.config.WriteQuorum { + return nil + } + return ErrWriteQuorum +} + +func (dm *DMap) callExpireOnCluster(e *env) error { + part := dm.getPartitionByHKey(e.hkey, partitions.PRIMARY) + f, err := dm.loadOrCreateFragment(part) + if err != nil { + return err + } + e.fragment = f + f.Lock() + defer f.Unlock() + + if dm.s.config.ReplicaCount == config.MinimumReplicaCount { + // MinimumReplicaCount is 1. So it's enough to put the key locally. There is no + // other replica host. + return dm.localExpire(e) + } + + switch dm.s.config.ReplicationMode { + case config.AsyncReplicationMode: + return dm.asyncExpireOnCluster(e) + case config.SyncReplicationMode: + return dm.syncExpireOnCluster(e) + default: + return fmt.Errorf("invalid replication mode: %v", dm.s.config.ReplicationMode) + } +} + +func (dm *DMap) expire(e *env) error { + e.hkey = partitions.HKey(e.dmap, e.key) + member := dm.s.primary.PartitionByHKey(e.hkey).Owner() + if member.CompareByName(dm.s.rt.This()) { + // We are on the partition owner. + return dm.callExpireOnCluster(e) + } + // Redirect to the partition owner + req := e.toReq(protocol.OpExpire) + _, err := dm.s.requestTo(member.String(), req) + return err +} + +// Expire updates the expiry for the given key. It returns ErrKeyNotFound if the +// DB does not contain the key. It's thread-safe. +func (dm *DMap) Expire(key string, timeout time.Duration) error { + e := &env{ + dmap: dm.name, + key: key, + timestamp: time.Now().UnixNano(), + timeout: timeout, + } + return dm.expire(e) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/expire_operations.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/expire_operations.go new file mode 100644 index 000000000..3351e0824 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/expire_operations.go @@ -0,0 +1,50 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" +) + +func (s *Service) expireOperationCommon(w, r protocol.EncodeDecoder, f func(dm *DMap, r protocol.EncodeDecoder) error) { + req := r.(*protocol.DMapMessage) + dm, err := s.getOrCreateDMap(req.DMap()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + err = f(dm, r) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) +} + +func (s *Service) expireReplicaOperation(w, r protocol.EncodeDecoder) { + s.expireOperationCommon(w, r, func(dm *DMap, r protocol.EncodeDecoder) error { + e := newEnvFromReq(r, partitions.BACKUP) + return dm.localExpireOnReplica(e) + }) +} + +func (s *Service) expireOperation(w, r protocol.EncodeDecoder) { + s.expireOperationCommon(w, r, func(dm *DMap, r protocol.EncodeDecoder) error { + e := newEnvFromReq(r, partitions.PRIMARY) + return dm.expire(e) + }) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/fragment.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/fragment.go new file mode 100644 index 000000000..b536049f1 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/fragment.go @@ -0,0 +1,165 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "context" + "errors" + "strings" + "sync" + + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/storage" + "github.com/vmihailenco/msgpack" +) + +type fragment struct { + sync.RWMutex + + service *Service + storage storage.Engine + ctx context.Context + cancel context.CancelFunc +} + +func (f *fragment) Stats() storage.Stats { + return f.storage.Stats() +} + +func (f *fragment) Compaction() (bool, error) { + select { + case <-f.ctx.Done(): + // fragment is closed or destroyed + return false, nil + default: + } + return f.storage.Compaction() +} + +func (f *fragment) Destroy() error { + select { + case <-f.ctx.Done(): + return f.storage.Destroy() + default: + } + return errors.New("fragment is not closed") +} + +func (f *fragment) Close() error { + defer f.cancel() + return f.storage.Close() +} + +func (f *fragment) Name() string { + return "DMap" +} + +func (f *fragment) Length() int { + f.RLock() + defer f.RUnlock() + + return f.storage.Stats().Length +} + +func (f *fragment) Move(part *partitions.Partition, name string, owners []discovery.Member) error { + f.Lock() + defer f.Unlock() + + i := f.storage.TransferIterator() + if !i.Next() { + return nil + } + + payload, err := i.Export() + if err != nil { + return err + } + fp := &fragmentPack{ + PartID: part.ID(), + Kind: part.Kind(), + Name: strings.TrimPrefix(name, "dmap."), + Payload: payload, + } + value, err := msgpack.Marshal(fp) + if err != nil { + return err + } + + req := protocol.NewSystemMessage(protocol.OpMoveFragment) + req.SetValue(value) + for _, owner := range owners { + _, err = f.service.requestTo(owner.String(), req) + if err != nil { + return err + } + } + + return i.Pop() +} + +func (dm *DMap) newFragment() (*fragment, error) { + c := storage.NewConfig(dm.config.engine.Config) + engine, err := dm.engine.Fork(c) + if err != nil { + return nil, err + } + + engine.SetLogger(dm.s.config.Logger) + err = engine.Start() + if err != nil { + return nil, err + } + + ctx, cancel := context.WithCancel(context.Background()) + return &fragment{ + service: dm.s, + storage: engine, + ctx: ctx, + cancel: cancel, + }, nil +} + +func (dm *DMap) loadOrCreateFragment(part *partitions.Partition) (*fragment, error) { + part.Lock() + defer part.Unlock() + + // Creating a new fragment is our critical section here. + // It should be protected by a lock. + + fg, ok := part.Map().Load(dm.fragmentName) + if ok { + return fg.(*fragment), nil + } + + f, err := dm.newFragment() + if err != nil { + return nil, err + } + + part.Map().Store(dm.fragmentName, f) + return f, nil +} + +func (dm *DMap) loadFragment(part *partitions.Partition) (*fragment, error) { + f, ok := part.Map().Load(dm.fragmentName) + if !ok { + return nil, errFragmentNotFound + } + return f.(*fragment), nil +} + +var _ partitions.Fragment = (*fragment)(nil) diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/get.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/get.go new file mode 100644 index 000000000..81990da7f --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/get.go @@ -0,0 +1,389 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "errors" + "sort" + "time" + + "github.com/buraksezer/olric/config" + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/internal/stats" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/buraksezer/olric/pkg/storage" +) + +// Entry is a DMap entry with its metadata. +type Entry struct { + Key string + Value interface{} + TTL int64 + Timestamp int64 +} + +var ( + // GetMisses is the number of entries that have been requested and not found + GetMisses = stats.NewInt64Counter() + + // GetHits is the number of entries that have been requested and found present + GetHits = stats.NewInt64Counter() + + // EvictedTotal is the number of entries removed from cache to free memory for new entries. + EvictedTotal = stats.NewInt64Counter() +) + +var ErrReadQuorum = neterrors.New(protocol.StatusErrReadQuorum, "read quorum cannot be reached") + +type version struct { + host *discovery.Member + entry storage.Entry +} + +func (dm *DMap) unmarshalValue(raw []byte) (interface{}, error) { + var value interface{} + err := dm.s.serializer.Unmarshal(raw, &value) + if err != nil { + return nil, err + } + if _, ok := value.(struct{}); ok { + return nil, nil + } + return value, nil +} + +func (dm *DMap) getOnFragment(e *env) (storage.Entry, error) { + part := dm.getPartitionByHKey(e.hkey, e.kind) + f, err := dm.loadFragment(part) + if err != nil { + return nil, err + } + + f.RLock() + defer f.RUnlock() + + entry, err := f.storage.Get(e.hkey) + if err != nil { + return nil, err + } + + if isKeyExpired(entry.TTL()) { + return nil, ErrKeyNotFound + } + return entry, nil +} + +func (dm *DMap) lookupOnPreviousOwner(owner *discovery.Member, key string) (*version, error) { + req := protocol.NewDMapMessage(protocol.OpGetPrev) + req.SetDMap(dm.name) + req.SetKey(key) + + v := &version{host: owner} + resp, err := dm.s.requestTo(owner.String(), req) + if err != nil { + return nil, err + } + data := dm.engine.NewEntry() + data.Decode(resp.Value()) + v.entry = data + return v, nil +} + +func (dm *DMap) valueToVersion(value storage.Entry) *version { + this := dm.s.rt.This() + return &version{ + host: &this, + entry: value, + } +} + +func (dm *DMap) lookupOnThisNode(hkey uint64, key string) *version { + // Check on localhost, the partition owner. + part := dm.getPartitionByHKey(hkey, partitions.PRIMARY) + f, err := dm.loadFragment(part) + if err != nil { + if !errors.Is(err, errFragmentNotFound) { + dm.s.log.V(3).Printf("[ERROR] Failed to get DMap fragment: %v", err) + } + return dm.valueToVersion(nil) + } + f.RLock() + defer f.RUnlock() + + value, err := f.storage.Get(hkey) + if err != nil { + if !errors.Is(err, storage.ErrKeyNotFound) { + // still need to use "ver". just log this error. + dm.s.log.V(3).Printf("[ERROR] Failed to get key: %s on %s: %s", key, dm.name, err) + } + return dm.valueToVersion(nil) + } + // We found the key + // + // LRU and MaxIdleDuration eviction policies are only valid on + // the partition owner. Normally, we shouldn't need to retrieve the keys + // from the backup or the previous owners. When the fsck merge + // a fragmented partition or recover keys from a backup, Olric + // continue maintaining a reliable access log. + return dm.valueToVersion(value) +} + +// lookupOnOwners collects versions of a key/value pair on the partition owner +// by including previous partition owners. +func (dm *DMap) lookupOnOwners(hkey uint64, key string) []*version { + owners := dm.s.primary.PartitionOwnersByHKey(hkey) + if len(owners) == 0 { + panic("partition owners list cannot be empty") + } + + var versions []*version + versions = append(versions, dm.lookupOnThisNode(hkey, key)) + + // Run a query on the previous owners. + // Traverse in reverse order. Except from the latest host, this one. + for i := len(owners) - 2; i >= 0; i-- { + owner := owners[i] + v, err := dm.lookupOnPreviousOwner(&owner, key) + if err != nil { + if dm.s.log.V(3).Ok() { + dm.s.log.V(3).Printf("[ERROR] Failed to call get on a previous "+ + "primary owner: %s: %v", owner, err) + } + continue + } + // Ignore failed owners. The data on those hosts will be wiped out + // by the balancer. + versions = append(versions, v) + } + return versions +} + +func (dm *DMap) sortVersions(versions []*version) []*version { + sort.Slice(versions, + func(i, j int) bool { + return versions[i].entry.Timestamp() >= versions[j].entry.Timestamp() + }, + ) + // Explicit is better than implicit. + return versions +} + +func (dm *DMap) sanitizeAndSortVersions(versions []*version) []*version { + var sanitized []*version + // We use versions slice for read-repair. Clear nil values first. + for _, ver := range versions { + if ver.entry != nil { + sanitized = append(sanitized, ver) + } + } + if len(sanitized) <= 1 { + return sanitized + } + return dm.sortVersions(sanitized) +} + +func (dm *DMap) lookupOnReplicas(hkey uint64, key string) []*version { + // Check backup. + backups := dm.s.backup.PartitionOwnersByHKey(hkey) + versions := make([]*version, 0, len(backups)) + for _, replica := range backups { + req := protocol.NewDMapMessage(protocol.OpGetReplica) + req.SetDMap(dm.name) + req.SetKey(key) + host := replica + v := &version{host: &host} + resp, err := dm.s.requestTo(replica.String(), req) + if err != nil { + if dm.s.log.V(6).Ok() { + dm.s.log.V(6).Printf("[ERROR] Failed to call get on"+ + " a replica owner: %s: %v", replica, err) + } + } else { + data := dm.engine.NewEntry() + data.Decode(resp.Value()) + v.entry = data + } + versions = append(versions, v) + } + return versions +} + +func (dm *DMap) readRepair(winner *version, versions []*version) { + for _, version := range versions { + if version.entry != nil && winner.entry.Timestamp() == version.entry.Timestamp() { + continue + } + + // Sync + tmp := *version.host + if tmp.CompareByID(dm.s.rt.This()) { + hkey := partitions.HKey(dm.name, winner.entry.Key()) + part := dm.getPartitionByHKey(hkey, partitions.PRIMARY) + f, err := dm.loadOrCreateFragment(part) + if err != nil { + dm.s.log.V(3).Printf("[ERROR] Failed to get or create the fragment for: %s on %s: %v", + winner.entry.Key(), dm.name, err) + return + } + + f.Lock() + e := &env{ + dmap: dm.name, + key: winner.entry.Key(), + value: winner.entry.Value(), + timestamp: winner.entry.Timestamp(), + timeout: time.Duration(winner.entry.TTL()), + hkey: hkey, + fragment: f, + } + err = dm.putOnFragment(e) + if err != nil { + dm.s.log.V(3).Printf("[ERROR] Failed to synchronize with replica: %v", err) + } + f.Unlock() + } else { + // If readRepair is enabled, this function is called by every GET request. + var req *protocol.DMapMessage + if winner.entry.TTL() == 0 { + req = protocol.NewDMapMessage(protocol.OpPutReplica) + req.SetDMap(dm.name) + req.SetKey(winner.entry.Key()) + req.SetValue(winner.entry.Value()) + req.SetExtra(protocol.PutExtra{Timestamp: winner.entry.Timestamp()}) + } else { + req = protocol.NewDMapMessage(protocol.OpPutExReplica) + req.SetDMap(dm.name) + req.SetKey(winner.entry.Key()) + req.SetValue(winner.entry.Value()) + req.SetExtra(protocol.PutExExtra{ + Timestamp: winner.entry.Timestamp(), + TTL: winner.entry.TTL(), + }) + } + _, err := dm.s.requestTo(version.host.String(), req) + if err != nil { + dm.s.log.V(3).Printf("[ERROR] Failed to synchronize replica %s: %v", version.host, err) + } + } + } +} + +func (dm *DMap) getOnCluster(hkey uint64, key string) (storage.Entry, error) { + // RUnlock should not be called with defer statement here because + // readRepair function may call putOnFragment function which needs a write + // lock. Please don't forget calling RUnlock before returning here. + versions := dm.lookupOnOwners(hkey, key) + if dm.s.config.ReadQuorum >= config.MinimumReplicaCount { + v := dm.lookupOnReplicas(hkey, key) + versions = append(versions, v...) + } + if len(versions) < dm.s.config.ReadQuorum { + return nil, ErrReadQuorum + } + sorted := dm.sanitizeAndSortVersions(versions) + if len(sorted) == 0 { + // We checked everywhere, it's not here. + return nil, ErrKeyNotFound + } + if len(sorted) < dm.s.config.ReadQuorum { + return nil, ErrReadQuorum + } + + // The most up-to-date version of the values. + winner := sorted[0] + if isKeyExpired(winner.entry.TTL()) || dm.isKeyIdle(hkey) { + return nil, ErrKeyNotFound + } + + if dm.s.config.ReadRepair { + // Parallel read operations may propagate different versions of + // the same key/value pair. The rule is simple: last write wins. + dm.readRepair(winner, versions) + } + return winner.entry, nil +} + +func (dm *DMap) get(key string) (storage.Entry, error) { + hkey := partitions.HKey(dm.name, key) + member := dm.s.primary.PartitionByHKey(hkey).Owner() + // We are on the partition owner + if member.CompareByName(dm.s.rt.This()) { + entry, err := dm.getOnCluster(hkey, key) + if errors.Is(err, ErrKeyNotFound) { + GetMisses.Increase(1) + } + if err != nil { + return nil, err + } + + // number of keys that have been requested and found present + GetHits.Increase(1) + + return entry, nil + } + + // Redirect to the partition owner + req := protocol.NewDMapMessage(protocol.OpGet) + req.SetDMap(dm.name) + req.SetKey(key) + + resp, err := dm.s.requestTo(member.String(), req) + if errors.Is(err, ErrKeyNotFound) { + GetMisses.Increase(1) + } + if err != nil { + return nil, err + } + + // number of keys that have been requested and found present + GetHits.Increase(1) + + entry := dm.engine.NewEntry() + entry.Decode(resp.Value()) + return entry, nil +} + +// Get gets the value for the given key. It returns ErrKeyNotFound if the DB +// does not contains the key. It's thread-safe. It is safe to modify the contents +// of the returned value. +func (dm *DMap) Get(key string) (interface{}, error) { + raw, err := dm.get(key) + if err != nil { + return nil, err + } + return dm.unmarshalValue(raw.Value()) +} + +// GetEntry gets the value for the given key with its metadata. It returns ErrKeyNotFound if the DB +// does not contain the key. It's thread-safe. It is safe to modify the contents +// of the returned value. +func (dm *DMap) GetEntry(key string) (*Entry, error) { + entry, err := dm.get(key) + if err != nil { + return nil, err + } + value, err := dm.unmarshalValue(entry.Value()) + if err != nil { + return nil, err + } + return &Entry{ + Key: entry.Key(), + Value: value, + TTL: entry.TTL(), + Timestamp: entry.Timestamp(), + }, nil +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/get_operations.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/get_operations.go new file mode 100644 index 000000000..d43614b2e --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/get_operations.go @@ -0,0 +1,60 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/buraksezer/olric/pkg/storage" +) + +func (s *Service) getOperationCommon(w, r protocol.EncodeDecoder, f func(dm *DMap, r protocol.EncodeDecoder) (storage.Entry, error)) { + req := r.(*protocol.DMapMessage) + dm, err := s.getOrCreateDMap(req.DMap()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + entry, err := f(dm, r) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) + w.SetValue(entry.Encode()) +} + +func (s *Service) getOperation(w, r protocol.EncodeDecoder) { + s.getOperationCommon(w, r, func(dm *DMap, r protocol.EncodeDecoder) (storage.Entry, error) { + req := r.(*protocol.DMapMessage) + return dm.get(req.Key()) + }) +} + +func (s *Service) getReplicaOperation(w, r protocol.EncodeDecoder) { + s.getOperationCommon(w, r, func(dm *DMap, r protocol.EncodeDecoder) (storage.Entry, error) { + e := newEnvFromReq(r, partitions.BACKUP) + return dm.getOnFragment(e) + }) +} + +func (s *Service) getPrevOperation(w, r protocol.EncodeDecoder) { + s.getOperationCommon(w, r, func(dm *DMap, r protocol.EncodeDecoder) (storage.Entry, error) { + e := newEnvFromReq(r, partitions.PRIMARY) + return dm.getOnFragment(e) + }) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/janitor.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/janitor.go new file mode 100644 index 000000000..64beee46b --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/janitor.go @@ -0,0 +1,94 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "strings" + "time" + + "github.com/buraksezer/olric/internal/cluster/partitions" +) + +func wipeOutFragment(part *partitions.Partition, name string, f *fragment) error { + // Stop background services if there is any. + err := f.Close() + if err != nil { + return err + } + // Destroy data on-disk or in-memory. + err = f.Destroy() + if err != nil { + return err + } + // Delete the fragment from partition. + part.Map().Delete(name) + return nil +} + +func (s *Service) deleteEmptyFragments() { + janitor := func(part *partitions.Partition) { + part.Map().Range(func(name, tmp interface{}) bool { + if !strings.HasPrefix(name.(string), "dmap.") { + // This fragment belongs to a different data structure. + return true + } + + f := tmp.(*fragment) + f.Lock() + defer f.Unlock() + + if f.storage.Stats().Length != 0 { + // It's not empty. Continue scanning. + return true + } + + err := wipeOutFragment(part, name.(string), f) + if err != nil { + s.log.V(3).Printf("[ERROR] Failed to delete empty DMap fragment (kind: %s): %s on PartID: %d", + part.Kind(), name, part.ID()) + // continue scanning + return true + } + + s.log.V(4).Printf("[INFO] Empty DMap fragment (kind: %s) has been deleted: %s on PartID: %d", + part.Kind(), name, part.ID()) + return true + }) + } + for partID := uint64(0); partID < s.config.PartitionCount; partID++ { + // Clean stale DMap fragments on partition table + part := s.primary.PartitionByID(partID) + janitor(part) + // Clean stale DMap fragments on backup partition table + backup := s.backup.PartitionByID(partID) + janitor(backup) + } +} + +func (s *Service) janitorWorker() { + defer s.wg.Done() + timer := time.NewTimer(s.config.DMaps.CheckEmptyFragmentsInterval) + defer timer.Stop() + + for { + timer.Reset(s.config.DMaps.CheckEmptyFragmentsInterval) + select { + case <-timer.C: + s.deleteEmptyFragments() + case <-s.ctx.Done(): + return + } + } +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/lock.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/lock.go new file mode 100644 index 000000000..146a30a20 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/lock.go @@ -0,0 +1,250 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "bytes" + "context" + "crypto/rand" + "errors" + "fmt" + "time" + + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" +) + +var ( + // ErrLockNotAcquired is returned when the requested lock could not be acquired + ErrLockNotAcquired = neterrors.New(protocol.StatusErrLockNotAcquired, "lock not acquired") + + // ErrNoSuchLock is returned when the requested lock does not exist + ErrNoSuchLock = neterrors.New(protocol.StatusErrNoSuchLock, "no such lock") +) + +// LockContext is returned by Lock and LockWithTimeout methods. +// It should be stored in a proper way to release the lock. +type LockContext struct { + key string + token []byte + dm *DMap +} + +// unlockKey tries to unlock the lock by verifying the lock with token. +func (dm *DMap) unlockKey(key string, token []byte) error { + lkey := dm.name + key + // Only one unlockKey should work for a given key. + dm.s.locker.Lock(lkey) + defer func() { + err := dm.s.locker.Unlock(lkey) + if err != nil { + dm.s.log.V(3).Printf("[ERROR] Failed to release the fine grained lock for key: %s on DMap: %s: %v", key, dm.name, err) + } + }() + + // get the key to check its value + entry, err := dm.get(key) + if errors.Is(err, ErrKeyNotFound) { + return ErrNoSuchLock + } + if err != nil { + return err + } + val, err := dm.unmarshalValue(entry.Value()) + if err != nil { + return err + } + + // the locks is released by the node(timeout) or the user + if !bytes.Equal(val.([]byte), token) { + return ErrNoSuchLock + } + + // release it. + err = dm.deleteKey(key) + if err != nil { + return fmt.Errorf("unlock failed because of delete: %w", err) + } + return nil +} + +// unlock takes key and token and tries to unlock the key. +// It redirects the request to the partition owner, if required. +func (dm *DMap) unlock(key string, token []byte) error { + hkey := partitions.HKey(dm.name, key) + member := dm.s.primary.PartitionByHKey(hkey).Owner() + if member.CompareByName(dm.s.rt.This()) { + return dm.unlockKey(key, token) + } + + req := protocol.NewDMapMessage(protocol.OpUnlock) + req.SetDMap(dm.name) + req.SetKey(key) + req.SetValue(token) + _, err := dm.s.requestTo(member.String(), req) + return err +} + +// Unlock releases the lock. +func (l *LockContext) Unlock() error { + return l.dm.unlock(l.key, l.token) +} + +// tryLock takes a deadline and env and sets a key-value pair by using +// PutIf or PutIfEx commands. It tries to acquire the lock 100 times per second +// if the lock is already acquired. It returns ErrLockNotAcquired if the deadline exceeds. +func (dm *DMap) tryLock(e *env, deadline time.Duration) error { + err := dm.put(e) + if err == nil { + return nil + } + // If it returns ErrKeyFound, the lock is already acquired. + if !errors.Is(err, ErrKeyFound) { + // something went wrong + return err + } + + ctx, cancel := context.WithTimeout(context.Background(), deadline) + defer cancel() + + timer := time.NewTimer(10 * time.Millisecond) + defer timer.Stop() + + // Try to acquire lock. +LOOP: + for { + timer.Reset(10 * time.Millisecond) + select { + case <-timer.C: + err = dm.put(e) + if errors.Is(err, ErrKeyFound) { + // not released by the other process/goroutine. try again. + continue + } + if err != nil { + // something went wrong. + return err + } + // Acquired! Quit without error. + break LOOP + case <-ctx.Done(): + // Deadline exceeded. Quit with an error. + return ErrLockNotAcquired + case <-dm.s.ctx.Done(): + return fmt.Errorf("server is gone") + } + } + return nil +} + +// lockKey prepares a token and env calls tryLock +func (dm *DMap) lockKey(opcode protocol.OpCode, key string, timeout, deadline time.Duration) (*LockContext, error) { + token := make([]byte, 16) + _, err := rand.Read(token) + if err != nil { + return nil, err + } + e, err := dm.prepareAndSerialize(opcode, key, token, timeout, IfNotFound) + if err != nil { + return nil, err + } + err = dm.tryLock(e, deadline) + if err != nil { + return nil, err + } + return &LockContext{ + key: key, + token: token, + dm: dm, + }, nil +} + +// LockWithTimeout sets a lock for the given key. If the lock is still unreleased the end of given period of time, +// it automatically releases the lock. Acquired lock is only for the key in this dmap. +// +// It returns immediately if it acquires the lock for the given key. Otherwise, it waits until deadline. +// +// You should know that the locks are approximate, and only to be used for non-critical purposes. +func (dm *DMap) LockWithTimeout(key string, timeout, deadline time.Duration) (*LockContext, error) { + return dm.lockKey(protocol.OpPutIfEx, key, timeout, deadline) +} + +// Lock sets a lock for the given key. Acquired lock is only for the key in this dmap. +// +// It returns immediately if it acquires the lock for the given key. Otherwise, it waits until deadline. +// +// You should know that the locks are approximate, and only to be used for non-critical purposes. +func (dm *DMap) Lock(key string, deadline time.Duration) (*LockContext, error) { + return dm.lockKey(protocol.OpPutIf, key, nilTimeout, deadline) +} + +// leaseKey tries to update the expiry of the key by verifying token. +func (dm *DMap) leaseKey(key string, token []byte, timeout time.Duration) error { + // get the key to check its value + entry, err := dm.get(key) + if errors.Is(err, ErrKeyNotFound) { + return ErrNoSuchLock + } + if err != nil { + return err + } + + val, err := dm.unmarshalValue(entry.Value()) + if err != nil { + return err + } + // the locks is released by the node(timeout) or the user + if !bytes.Equal(val.([]byte), token) { + return ErrNoSuchLock + } + + // already expired + if (time.Now().UnixNano() / 1000000) >= entry.TTL() { + return ErrNoSuchLock + } + + // update + err = dm.Expire(key, timeout) + if err != nil { + return fmt.Errorf("lease failed: %w", err) + } + return nil +} + +// lease takes key and token and tries to update the expiry with duration. +// It redirects the request to the partition owner, if required. +func (dm *DMap) Lease(key string, token []byte, duration time.Duration) error { + hkey := partitions.HKey(dm.name, key) + member := dm.s.primary.PartitionByHKey(hkey).Owner() + if member.CompareByName(dm.s.rt.This()) { + return dm.leaseKey(key, token, duration) + } + + req := protocol.NewDMapMessage(protocol.OpLockLease) + req.SetDMap(dm.name) + req.SetKey(key) + req.SetValue(token) + req.SetExtra(protocol.LockLeaseExtra{ + Timeout: int64(duration), + }) + _, err := dm.s.requestTo(member.String(), req) + return err +} + +// Lease takes the duration to update the expiry for the given Lock. +func (l *LockContext) Lease(duration time.Duration) error { + return l.dm.Lease(l.key, l.token, duration) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/lock_operations.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/lock_operations.go new file mode 100644 index 000000000..64fd3f3ad --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/lock_operations.go @@ -0,0 +1,87 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "time" + + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" +) + +func (s *Service) lockOperationCommon(w, r protocol.EncodeDecoder, + f func(dm *DMap, r protocol.EncodeDecoder) (*LockContext, error)) { + req := r.(*protocol.DMapMessage) + dm, err := s.getOrCreateDMap(req.DMap()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + ctx, err := f(dm, r) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) + w.SetValue(ctx.token) +} + +func (s *Service) lockWithTimeoutOperation(w, r protocol.EncodeDecoder) { + s.lockOperationCommon(w, r, func(dm *DMap, r protocol.EncodeDecoder) (*LockContext, error) { + req := r.(*protocol.DMapMessage) + timeout := req.Extra().(protocol.LockWithTimeoutExtra).Timeout + deadline := req.Extra().(protocol.LockWithTimeoutExtra).Deadline + return dm.lockKey(protocol.OpPutIfEx, req.Key(), time.Duration(timeout), time.Duration(deadline)) + }) +} + +func (s *Service) lockOperation(w, r protocol.EncodeDecoder) { + s.lockOperationCommon(w, r, func(dm *DMap, r protocol.EncodeDecoder) (*LockContext, error) { + req := r.(*protocol.DMapMessage) + deadline := req.Extra().(protocol.LockExtra).Deadline + return dm.lockKey(protocol.OpPutIf, req.Key(), nilTimeout, time.Duration(deadline)) + }) +} + +func (s *Service) unlockOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.DMapMessage) + dm, err := s.getOrCreateDMap(req.DMap()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + err = dm.unlock(req.Key(), req.Value()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) +} + +func (s *Service) leaseLockOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.DMapMessage) + dm, err := s.getOrCreateDMap(req.DMap()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + timeout := req.Extra().(protocol.LockLeaseExtra).Timeout + err = dm.Lease(req.Key(), req.Value(), time.Duration(timeout)) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/operations.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/operations.go new file mode 100644 index 000000000..0cc95186b --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/operations.go @@ -0,0 +1,84 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import "github.com/buraksezer/olric/internal/protocol" + +func (s *Service) RegisterOperations(operations map[protocol.OpCode]func(w, r protocol.EncodeDecoder)) { + // Operations on DMap data structure + // + // DMap.Put + s.operations[protocol.OpPut] = s.putOperation + s.operations[protocol.OpPutEx] = s.putOperation + s.operations[protocol.OpPutReplica] = s.putReplicaOperation + s.operations[protocol.OpPutExReplica] = s.putReplicaOperation + s.operations[protocol.OpPutIf] = s.putOperation + s.operations[protocol.OpPutIfEx] = s.putOperation + s.operations[protocol.OpPutIfReplica] = s.putReplicaOperation + s.operations[protocol.OpPutIfExReplica] = s.putReplicaOperation + + // DMap.Get + s.operations[protocol.OpGet] = s.getOperation + s.operations[protocol.OpGetPrev] = s.getPrevOperation + s.operations[protocol.OpGetReplica] = s.getReplicaOperation + + // DMap.Delete + s.operations[protocol.OpDelete] = s.deleteOperation + s.operations[protocol.OpDeleteReplica] = s.deleteReplicaOperation + s.operations[protocol.OpDeletePrev] = s.deletePrevOperation + + // DMap.Atomic + s.operations[protocol.OpIncr] = s.incrDecrOperation + s.operations[protocol.OpDecr] = s.incrDecrOperation + s.operations[protocol.OpGetPut] = s.getPutOperation + + // DMap.Destroy + s.operations[protocol.OpDestroy] = s.destroyOperation + s.operations[protocol.OpDestroyDMapInternal] = s.destroyDMapOperation + + // DMap.Pipeline + s.operations[protocol.OpPipeline] = s.pipelineOperation + + // DMap.Lock + s.operations[protocol.OpLockWithTimeout] = s.lockWithTimeoutOperation + s.operations[protocol.OpLock] = s.lockOperation + + // DMap.Unlock + s.operations[protocol.OpUnlock] = s.unlockOperation + + // DMap.Lease + s.operations[protocol.OpLockLease] = s.leaseLockOperation + + // DMap.Atomic + s.operations[protocol.OpIncr] = s.incrDecrOperation + s.operations[protocol.OpDecr] = s.incrDecrOperation + s.operations[protocol.OpGetPut] = s.getPutOperation + + // DMap.Expire + s.operations[protocol.OpExpire] = s.expireOperation + s.operations[protocol.OpExpireReplica] = s.expireReplicaOperation + + // DMap.Query (distributed query) + s.operations[protocol.OpLocalQuery] = s.localQueryOperation + s.operations[protocol.OpQuery] = s.queryOperation + + // Internals + s.operations[protocol.OpMoveFragment] = s.moveFragmentOperation + + // Import + for code, f := range s.operations { + operations[code] = f + } +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/pipeline.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/pipeline.go new file mode 100644 index 000000000..d290f56ac --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/pipeline.go @@ -0,0 +1,77 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "bytes" + "errors" + "io" + + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" +) + +func (s *Service) extractPipelineMessage(conn io.ReadWriteCloser, response *bytes.Buffer) error { + buf := bufferPool.Get() + defer bufferPool.Put(buf) + + _, err := protocol.ReadMessage(conn, buf) + if err != nil { + return err + } + preq := protocol.NewDMapMessageFromRequest(buf) + err = preq.Decode() + // Return an error message in pipelined response. + if err != nil { + preq.SetStatus(protocol.StatusErrInternalFailure) + preq.SetValue([]byte(err.Error())) + return nil + } + f, ok := s.operations[preq.Op] + if !ok { + preq.SetStatus(protocol.StatusErrInternalFailure) + preq.SetValue([]byte(neterrors.ErrUnknownOperation.Error())) + return nil + } + + presp := preq.Response(response) + // Call its function to prepare a response. + f(presp, preq) + return presp.Encode() +} + +func (s *Service) pipelineOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.PipelineMessage) + conn := protocol.NewBytesToConn(req.Value()) + response := bufferPool.Get() + defer bufferPool.Put(response) + + // Decode the pipelined messages into an in-memory buffer. + for { + err := s.extractPipelineMessage(conn, response) + if errors.Is(err, io.EOF) { + // It's done. The last message has been read. + break + } + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + } + + // Create a success response and assign pipelined responses as value. + w.SetStatus(protocol.StatusOK) + w.SetValue(response.Bytes()) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/put.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/put.go new file mode 100644 index 000000000..e27e2cdcb --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/put.go @@ -0,0 +1,346 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "errors" + "fmt" + "time" + + "github.com/buraksezer/olric/config" + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/internal/stats" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/buraksezer/olric/pkg/storage" +) + +const ( + IfNotFound = int16(1) << iota + IfFound +) + +// EntriesTotal is the total number of entries(including replicas) +// stored during the life of this instance. +var EntriesTotal = stats.NewInt64Counter() + +var ( + ErrKeyFound = neterrors.New(protocol.StatusErrKeyFound, "key found") + ErrWriteQuorum = neterrors.New(protocol.StatusErrWriteQuorum, "write quorum cannot be reached") + ErrKeyTooLarge = neterrors.New(protocol.StatusErrKeyTooLarge, "key too large") +) + +// putOnFragment calls underlying storage engine's Put method to store the key/value pair. It's not thread-safe. +func (dm *DMap) putOnFragment(e *env) error { + entry := e.fragment.storage.NewEntry() + entry.SetKey(e.key) + entry.SetValue(e.value) + entry.SetTTL(timeoutToTTL(e.timeout)) + entry.SetTimestamp(e.timestamp) + + err := e.fragment.storage.Put(e.hkey, entry) + if errors.Is(err, storage.ErrKeyTooLarge) { + err = ErrKeyTooLarge + } + if err != nil { + return err + } + + // total number of entries stored during the life of this instance. + EntriesTotal.Increase(1) + + return nil +} + +func (dm *DMap) putOnReplicaFragment(e *env) error { + part := dm.getPartitionByHKey(e.hkey, partitions.BACKUP) + f, err := dm.loadOrCreateFragment(part) + if err != nil { + return err + } + + e.fragment = f + f.Lock() + defer f.Unlock() + + return dm.putOnFragment(e) +} + +func (dm *DMap) asyncPutOnBackup(e *env, owner discovery.Member) { + defer dm.s.wg.Done() + + req := e.toReq(e.replicaOpcode) + _, err := dm.s.requestTo(owner.String(), req) + if err != nil { + if dm.s.log.V(3).Ok() { + dm.s.log.V(3).Printf("[ERROR] Failed to create replica in async mode: %v", err) + } + } +} + +func (dm *DMap) asyncPutOnCluster(e *env) error { + err := dm.putOnFragment(e) + if err != nil { + return err + } + + // Fire and forget mode. + owners := dm.s.backup.PartitionOwnersByHKey(e.hkey) + for _, owner := range owners { + if !dm.s.isAlive() { + return ErrServerGone + } + + dm.s.wg.Add(1) + go dm.asyncPutOnBackup(e, owner) + } + + return nil +} + +func (dm *DMap) syncPutOnCluster(e *env) error { + // Quorum based replication. + var successful int + owners := dm.s.backup.PartitionOwnersByHKey(e.hkey) + for _, owner := range owners { + req := e.toReq(e.replicaOpcode) + _, err := dm.s.requestTo(owner.String(), req) + if err != nil { + if dm.s.log.V(3).Ok() { + dm.s.log.V(3).Printf("[ERROR] Failed to call put command on %s for DMap: %s: %v", owner, e.dmap, err) + } + continue + } + successful++ + } + err := dm.putOnFragment(e) + if err != nil { + if dm.s.log.V(3).Ok() { + dm.s.log.V(3).Printf("[ERROR] Failed to call put command on %s for DMap: %s: %v", dm.s.rt.This(), e.dmap, err) + } + } else { + successful++ + } + if successful >= dm.s.config.WriteQuorum { + return nil + } + return ErrWriteQuorum +} + +func (dm *DMap) setLRUEvictionStats(e *env) error { + // Try to make room for the new item, if it's required. + // MaxKeys and MaxInuse properties of LRU can be used in the same time. + // But I think that it's good to use only one of time in a production system. + // Because it should be easy to understand and debug. + st := e.fragment.storage.Stats() + // This works for every request if you enabled LRU. + // But loading a number from memory should be very cheap. + // ownedPartitionCount changes in the case of node join or leave. + ownedPartitionCount := dm.s.rt.OwnedPartitionCount() + if dm.config.maxKeys > 0 { + // MaxKeys controls maximum key count owned by this node. + // We need ownedPartitionCount property because every partition + // manages itself independently. So if you set MaxKeys=70 and + // your partition count is 7, every partition 10 keys at maximum. + if st.Length >= dm.config.maxKeys/int(ownedPartitionCount) { + err := dm.evictKeyWithLRU(e) + if err != nil { + return err + } + } + } + + if dm.config.maxInuse > 0 { + // MaxInuse controls maximum in-use memory of partitions on this node. + // We need ownedPartitionCount property because every partition + // manages itself independently. So if you set MaxInuse=70M(in bytes) and + // your partition count is 7, every partition consumes 10M in-use space at maximum. + // WARNING: Actual allocated memory can be different. + if st.Inuse >= dm.config.maxInuse/int(ownedPartitionCount) { + err := dm.evictKeyWithLRU(e) + if err != nil { + return err + } + } + } + return nil +} + +func (dm *DMap) checkPutConditions(e *env) error { + // Only set the key if it does not already exist. + if e.flags&IfNotFound != 0 { + ttl, err := e.fragment.storage.GetTTL(e.hkey) + if err == nil { + if !isKeyExpired(ttl) { + return ErrKeyFound + } + } + if errors.Is(err, storage.ErrKeyNotFound) { + err = nil + } + if err != nil { + return err + } + } + + // Only set the key if it already exists. + if e.flags&IfFound != 0 && !e.fragment.storage.Check(e.hkey) { + ttl, err := e.fragment.storage.GetTTL(e.hkey) + if err == nil { + if isKeyExpired(ttl) { + return ErrKeyNotFound + } + } + if errors.Is(err, storage.ErrKeyNotFound) { + err = ErrKeyNotFound + } + if err != nil { + return err + } + } + return nil +} + +func (dm *DMap) putOnCluster(e *env) error { + part := dm.getPartitionByHKey(e.hkey, partitions.PRIMARY) + f, err := dm.loadOrCreateFragment(part) + if err != nil { + return err + } + + e.fragment = f + f.Lock() + defer f.Unlock() + + if err = dm.checkPutConditions(e); err != nil { + return err + } + + if dm.config != nil { + if dm.config.ttlDuration.Seconds() != 0 && e.timeout.Seconds() == 0 { + e.timeout = dm.config.ttlDuration + } + if dm.config.evictionPolicy == config.LRUEviction { + if err = dm.setLRUEvictionStats(e); err != nil { + return err + } + } + } + + if dm.s.config.ReplicaCount > config.MinimumReplicaCount { + switch dm.s.config.ReplicationMode { + case config.AsyncReplicationMode: + // Fire and forget mode. Calls PutBackup command in different goroutines + // and stores the key/value pair on local storage instance. + return dm.asyncPutOnCluster(e) + case config.SyncReplicationMode: + // Quorum based replication. + return dm.syncPutOnCluster(e) + default: + return fmt.Errorf("invalid replication mode: %v", dm.s.config.ReplicationMode) + } + } + + // single replica + return dm.putOnFragment(e) +} + +// put controls every write operation in Olric. It redirects the requests to its owner, +// if the key belongs to another host. +func (dm *DMap) put(e *env) error { + e.hkey = partitions.HKey(e.dmap, e.key) + member := dm.s.primary.PartitionByHKey(e.hkey).Owner() + if member.CompareByName(dm.s.rt.This()) { + // We are on the partition owner. + return dm.putOnCluster(e) + } + + // Redirect to the partition owner. + req := e.toReq(e.opcode) + _, err := dm.s.requestTo(member.String(), req) + return err +} + +func (dm *DMap) prepareAndSerialize(opcode protocol.OpCode, key string, value interface{}, + timeout time.Duration, flags int16) (*env, error) { + val, err := dm.s.serializer.Marshal(value) + if err != nil { + return nil, err + } + return newEnv(opcode, dm.name, key, val, timeout, flags, partitions.PRIMARY), nil +} + +// PutEx sets the value for the given key with TTL. It overwrites any previous +// value for that key. It's thread-safe. The key has to be string. value type +// is arbitrary. It is safe to modify the contents of the arguments after +// Put returns but not before. +func (dm *DMap) PutEx(key string, value interface{}, timeout time.Duration) error { + e, err := dm.prepareAndSerialize(protocol.OpPutEx, key, value, timeout, 0) + if err != nil { + return err + } + return dm.put(e) +} + +// Put sets the value for the given key. It overwrites any previous value +// for that key and it's thread-safe. The key has to be string. value type +// is arbitrary. It is safe to modify the contents of the arguments after +// Put returns but not before. +func (dm *DMap) Put(key string, value interface{}) error { + e, err := dm.prepareAndSerialize(protocol.OpPut, key, value, nilTimeout, 0) + if err != nil { + return err + } + return dm.put(e) +} + +// PutIf Put sets the value for the given key. It overwrites any previous value +// for that key, and it's thread-safe. The key has to be string. value type +// is arbitrary. It is safe to modify the contents of the arguments after +// Put returns but not before. +// Flag argument currently has two different options: +// +// IfNotFound: Only set the key if it does not already exist. +// It returns ErrFound if the key already exist. +// +// IfFound: Only set the key if it already exist. +// It returns ErrKeyNotFound if the key does not exist. +func (dm *DMap) PutIf(key string, value interface{}, flags int16) error { + e, err := dm.prepareAndSerialize(protocol.OpPutIf, key, value, nilTimeout, flags) + if err != nil { + return err + } + return dm.put(e) +} + +// PutIfEx sets the value for the given key with TTL. It overwrites any previous +// value for that key. It's thread-safe. The key has to be string. value type +// is arbitrary. It is safe to modify the contents of the arguments after +// Put returns but not before. +// Flag argument currently has two different options: +// +// IfNotFound: Only set the key if it does not already exist. +// It returns ErrFound if the key already exist. +// +// IfFound: Only set the key if it already exist. +// It returns ErrKeyNotFound if the key does not exist. +func (dm *DMap) PutIfEx(key string, value interface{}, timeout time.Duration, flags int16) error { + e, err := dm.prepareAndSerialize(protocol.OpPutIfEx, key, value, timeout, flags) + if err != nil { + return err + } + return dm.put(e) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/put_operations.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/put_operations.go new file mode 100644 index 000000000..356c8b140 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/put_operations.go @@ -0,0 +1,51 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" +) + +func (s *Service) putOperationCommon(w, r protocol.EncodeDecoder, f func(dm *DMap, r protocol.EncodeDecoder) error) { + req := r.(*protocol.DMapMessage) + dm, err := s.getOrCreateDMap(req.DMap()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + err = f(dm, r) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) +} + +func (s *Service) putOperation(w, r protocol.EncodeDecoder) { + s.putOperationCommon(w, r, func(dm *DMap, r protocol.EncodeDecoder) error { + e := newEnvFromReq(r, partitions.PRIMARY) + return dm.put(e) + }) +} + +func (s *Service) putReplicaOperation(w, r protocol.EncodeDecoder) { + s.putOperationCommon(w, r, func(dm *DMap, r protocol.EncodeDecoder) error { + e := newEnvFromReq(r, partitions.BACKUP) + return dm.putOnReplicaFragment(e) + }) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/query.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/query.go new file mode 100644 index 000000000..30af4c5ce --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/query.go @@ -0,0 +1,262 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "context" + "errors" + "fmt" + "sync" + + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/buraksezer/olric/pkg/storage" + "github.com/buraksezer/olric/query" + "github.com/hashicorp/go-multierror" + "github.com/vmihailenco/msgpack" + "golang.org/x/sync/semaphore" +) + +// NumConcurrentWorkers is the number of concurrent workers to run a query on the cluster. +const NumConcurrentWorkers = 2 + +// ErrEndOfQuery is the error returned by Range when no more data is available. +// Functions should return ErrEndOfQuery only to signal a graceful end of input. +var ErrEndOfQuery = neterrors.New(protocol.StatusErrEndOfQuery, "end of query") + +// QueryResponse denotes returned data by a node for query. +type QueryResponse map[string]interface{} + +// internal representation of query response +type queryResponse map[uint64][]byte + +// Cursor implements distributed query on DMaps. +type Cursor struct { + dm *DMap + query query.M + ctx context.Context + cancel context.CancelFunc +} + +// Query runs a distributed query on a dmap instance. +// Olric supports a very simple query DSL and now, it only scans keys. The query DSL has very +// few keywords: +// +// $onKey: Runs the given query on keys or manages options on keys for a given query. +// +// $onValue: Runs the given query on values or manages options on values for a given query. +// +// $options: Useful to modify data returned from a query +// +// Keywords for $options: +// +// $ignore: Ignores a value. +// +// A distributed query looks like the following: +// +// query.M{ +// "$onKey": query.M{ +// "$regexMatch": "^even:", +// "$options": query.M{ +// "$onValue": query.M{ +// "$ignore": true, +// }, +// }, +// }, +// } +// +// This query finds the keys starts with "even:", drops the values and returns only keys. +// If you also want to retrieve the values, just remove the $options directive: +// +// query.M{ +// "$onKey": query.M{ +// "$regexMatch": "^even:", +// }, +// } +// +// In order to iterate over all the keys: +// +// query.M{ +// "$onKey": query.M{ +// "$regexMatch": "", +// }, +// } +// +// Query function returns a cursor which has Range and Close methods. Please take look at the Range +// function for further info. +func (dm *DMap) Query(q query.M) (*Cursor, error) { + err := query.Validate(q) + if err != nil { + return nil, err + } + ctx, cancel := context.WithCancel(context.Background()) + return &Cursor{ + dm: dm, + query: q, + ctx: ctx, + cancel: cancel, + }, nil +} + +func (dm *DMap) runLocalQuery(partID uint64, q query.M) (queryResponse, error) { + p := newQueryPipeline(dm, partID) + return p.execute(q) +} + +func (c *Cursor) reconcileResponses(responses []queryResponse) map[uint64]storage.Entry { + result := make(map[uint64]storage.Entry) + for _, response := range responses { + for hkey, tmp1 := range response { + val1 := c.dm.engine.NewEntry() + val1.Decode(tmp1) + + if val2, ok := result[hkey]; ok { + if val1.Timestamp() > val2.Timestamp() { + result[hkey] = val1 + } + } else { + result[hkey] = val1 + } + } + } + return result +} + +func (c *Cursor) runQueryOnOwners(partID uint64) ([]storage.Entry, error) { + value, err := msgpack.Marshal(c.query) + if err != nil { + return nil, err + } + + owners := c.dm.s.primary.PartitionOwnersByID(partID) + var responses []queryResponse + for _, owner := range owners { + if owner.CompareByID(c.dm.s.rt.This()) { + response, err := c.dm.runLocalQuery(partID, c.query) + if err != nil { + return nil, err + } + responses = append(responses, response) + continue + } + req := protocol.NewDMapMessage(protocol.OpLocalQuery) + req.SetDMap(c.dm.name) + req.SetValue(value) + req.SetExtra(protocol.LocalQueryExtra{ + PartID: partID, + }) + response, err := c.dm.s.requestTo(owner.String(), req) + if err != nil { + return nil, fmt.Errorf("query call is failed: %w", err) + } + + tmp := make(queryResponse) + err = msgpack.Unmarshal(response.Value(), &tmp) + if err != nil { + return nil, err + } + responses = append(responses, tmp) + } + + var result []storage.Entry + for _, entry := range c.reconcileResponses(responses) { + result = append(result, entry) + } + return result, nil +} + +func (c *Cursor) runQueryOnCluster(results chan []storage.Entry, errCh chan error) { + defer c.dm.s.wg.Done() + defer close(results) + + var mu sync.Mutex + var wg sync.WaitGroup + + var errs error + appendError := func(e error) error { + mu.Lock() + defer mu.Unlock() + return multierror.Append(e, errs) + } + + sem := semaphore.NewWeighted(NumConcurrentWorkers) + for partID := uint64(0); partID < c.dm.s.config.PartitionCount; partID++ { + err := sem.Acquire(c.ctx, 1) + if errors.Is(err, context.Canceled) { + break + } + if err != nil { + errs = appendError(err) + break + } + + wg.Add(1) + go func(id uint64) { + defer sem.Release(1) + defer wg.Done() + + responses, err := c.runQueryOnOwners(id) + if err != nil { + errs = appendError(err) + c.Close() // Breaks the loop + return + } + select { + case <-c.ctx.Done(): + // cursor is gone: + return + case <-c.dm.s.ctx.Done(): + // Server is gone. + return + default: + results <- responses + } + }(partID) + } + wg.Wait() + errCh <- errs +} + +// Range calls f sequentially for each key and value yielded from the cursor. If f returns false, +// range stops the iteration. +func (c *Cursor) Range(f func(key string, value interface{}) bool) error { + defer c.Close() + + // Currently we have only 2 parallel query on the cluster. It's good enough for a smooth operation. + results := make(chan []storage.Entry, NumConcurrentWorkers) + errCh := make(chan error, 1) + + c.dm.s.wg.Add(1) + go c.runQueryOnCluster(results, errCh) + + for res := range results { + for _, entry := range res { + value, err := c.dm.unmarshalValue(entry.Value()) + if err != nil { + return err + } + if !f(entry.Key(), value) { + // User called "break" in this loop (Range) + return nil + } + } + } + return <-errCh +} + +// Close cancels the underlying context and background goroutines stops running. +func (c *Cursor) Close() { + c.cancel() +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/query_operations.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/query_operations.go new file mode 100644 index 000000000..43302e50f --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/query_operations.go @@ -0,0 +1,92 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/buraksezer/olric/query" + "github.com/vmihailenco/msgpack" +) + +func (s *Service) queryOperationCommon(w, r protocol.EncodeDecoder, + f func(dm *DMap, q query.M, r protocol.EncodeDecoder) (interface{}, error)) { + req := r.(*protocol.DMapMessage) + dm, err := s.getOrCreateDMap(req.DMap()) + if err == ErrDMapNotFound { + // No need to create a new DMap here. + w.SetStatus(protocol.StatusOK) + return + } + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + q, err := query.FromByte(req.Value()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + result, err := f(dm, q, r) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + value, err := msgpack.Marshal(&result) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) + w.SetValue(value) +} + +func (s *Service) localQueryOperation(w, r protocol.EncodeDecoder) { + s.queryOperationCommon(w, r, + func(dm *DMap, q query.M, r protocol.EncodeDecoder) (interface{}, error) { + req := r.(*protocol.DMapMessage) + partID := req.Extra().(protocol.LocalQueryExtra).PartID + return dm.runLocalQuery(partID, q) + }) +} + +func (s *Service) queryOperation(w, r protocol.EncodeDecoder) { + s.queryOperationCommon(w, r, + func(dm *DMap, q query.M, r protocol.EncodeDecoder) (interface{}, error) { + req := r.(*protocol.DMapMessage) + c, err := dm.Query(q) + if err != nil { + return nil, err + } + defer c.Close() + + partID := req.Extra().(protocol.QueryExtra).PartID + if partID >= s.config.PartitionCount { + return nil, ErrEndOfQuery + } + responses, err := c.runQueryOnOwners(partID) + if err != nil { + return nil, ErrEndOfQuery + } + + data := make(QueryResponse) + for _, response := range responses { + data[response.Key()] = response.Value() + } + return data, nil + }) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/query_pipeline.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/query_pipeline.go new file mode 100644 index 000000000..40c457f2d --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/query_pipeline.go @@ -0,0 +1,84 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "errors" + "fmt" + + "github.com/buraksezer/olric/pkg/storage" + "github.com/buraksezer/olric/query" +) + +type queryPipeline struct { + dm *DMap + partID uint64 + result queryResponse +} + +func newQueryPipeline(dm *DMap, partID uint64) *queryPipeline { + return &queryPipeline{ + dm: dm, + partID: partID, + result: make(queryResponse), + } +} + +func (p *queryPipeline) doOnKey(q query.M) error { + part := p.dm.s.primary.PartitionByID(p.partID) + f, err := p.dm.loadFragment(part) + if errors.Is(err, errFragmentNotFound) { + // there is nothing to do + return nil + } + if err != nil { + return err + } + f.RLock() + defer f.RUnlock() + + expr, ok := q["$regexMatch"].(string) + if !ok { + return fmt.Errorf("missing $regexMatch on $onKey") + } + nilValue, _ := p.dm.s.serializer.Marshal(nil) + + return f.storage.RegexMatchOnKeys(expr, func(hkey uint64, entry storage.Entry) bool { + // Eliminate already expired k/v pairs + if !isKeyExpired(entry.TTL()) { + options, ok := q["$options"].(query.M) + if ok { + onValue, ok := options["$onValue"].(query.M) + if ok { + ignore, ok := onValue["$ignore"].(bool) + if ok && ignore { + entry.SetValue(nilValue) + } + } + } + p.result[hkey] = entry.Encode() + } + return true + }) +} + +func (p *queryPipeline) execute(q query.M) (queryResponse, error) { + if onKey, ok := q["$onKey"]; ok { + if err := p.doOnKey(onKey.(query.M)); err != nil { + return nil, err + } + } + return p.result, nil +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/service.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/service.go new file mode 100644 index 000000000..699dadfbc --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dmap/service.go @@ -0,0 +1,174 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dmap + +import ( + "context" + "errors" + "sync" + "time" + + "github.com/buraksezer/olric/config" + "github.com/buraksezer/olric/internal/cluster/partitions" + "github.com/buraksezer/olric/internal/cluster/routingtable" + "github.com/buraksezer/olric/internal/environment" + "github.com/buraksezer/olric/internal/locker" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/internal/service" + "github.com/buraksezer/olric/internal/transport" + "github.com/buraksezer/olric/pkg/flog" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/buraksezer/olric/pkg/storage" + "github.com/buraksezer/olric/serializer" +) + +var errFragmentNotFound = errors.New("fragment not found") + +type storageMap struct { + engines map[string]storage.Engine + configs map[string]map[string]interface{} +} + +type Service struct { + sync.RWMutex // protects dmaps map + + log *flog.Logger + config *config.Config + client *transport.Client + rt *routingtable.RoutingTable + serializer serializer.Serializer + primary *partitions.Partitions + backup *partitions.Partitions + locker *locker.Locker + dmaps map[string]*DMap + operations map[protocol.OpCode]func(w, r protocol.EncodeDecoder) + storage *storageMap + wg sync.WaitGroup + ctx context.Context + cancel context.CancelFunc +} + +func NewService(e *environment.Environment) (service.Service, error) { + ctx, cancel := context.WithCancel(context.Background()) + return &Service{ + config: e.Get("config").(*config.Config), + serializer: e.Get("config").(*config.Config).Serializer, + client: e.Get("client").(*transport.Client), + log: e.Get("logger").(*flog.Logger), + rt: e.Get("routingtable").(*routingtable.RoutingTable), + primary: e.Get("primary").(*partitions.Partitions), + backup: e.Get("backup").(*partitions.Partitions), + locker: e.Get("locker").(*locker.Locker), + storage: &storageMap{ + engines: make(map[string]storage.Engine), + configs: make(map[string]map[string]interface{}), + }, + dmaps: make(map[string]*DMap), + operations: make(map[protocol.OpCode]func(w, r protocol.EncodeDecoder)), + ctx: ctx, + cancel: cancel, + }, nil +} + +func (s *Service) isAlive() bool { + select { + case <-s.ctx.Done(): + // The node is gone. + return false + default: + } + return true +} + +func (s *Service) callCompactionOnStorage(f *fragment) { + defer s.wg.Done() + timer := time.NewTimer(50 * time.Millisecond) + defer timer.Stop() + + for { + timer.Reset(50 * time.Millisecond) + select { + case <-timer.C: + f.Lock() + // Compaction returns false if the fragment is closed. + done, err := f.Compaction() + if err != nil { + s.log.V(3).Printf("[ERROR] Failed to run compaction on fragment: %v", err) + } + if done { + // Fragmented tables are merged. Quit. + f.Unlock() + return + } + f.Unlock() + case <-s.ctx.Done(): + return + } + } +} + +func (s *Service) requestTo(addr string, req protocol.EncodeDecoder) (protocol.EncodeDecoder, error) { + resp, err := s.client.RequestTo(addr, req) + if err != nil { + return nil, err + } + status := resp.Status() + if status == protocol.StatusOK { + return resp, nil + } + switch resp.Status() { + case protocol.StatusErrInternalFailure: + return nil, neterrors.Wrap(neterrors.ErrInternalFailure, string(resp.Value())) + case protocol.StatusErrInvalidArgument: + return nil, neterrors.Wrap(neterrors.ErrInvalidArgument, string(resp.Value())) + } + return nil, neterrors.GetByCode(status) +} + +// Start starts the distributed map service. +func (s *Service) Start() error { + s.wg.Add(1) + go s.janitorWorker() + + s.wg.Add(1) + go s.compactionWorker() + + s.wg.Add(1) + go s.evictKeysAtBackground() + + return nil +} + +func (s *Service) Shutdown(ctx context.Context) error { + s.cancel() + done := make(chan struct{}) + + go func() { + s.wg.Wait() + close(done) + }() + + select { + case <-ctx.Done(): + err := ctx.Err() + if err != nil { + return err + } + case <-done: + } + return nil +} + +var _ service.Service = (*Service)(nil) diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/destroy.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/destroy.go new file mode 100644 index 000000000..a58fb50e7 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/destroy.go @@ -0,0 +1,64 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dtopic + +import ( + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" + "golang.org/x/sync/errgroup" +) + +func (s *Service) destroyDTopicInternalOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.DTopicMessage) + s.dispatcher.destroy(req.DTopic()) + w.SetStatus(protocol.StatusOK) +} + +func (s *Service) destroyDTopicOnCluster(topic string) error { + s.rt.Members().RLock() + defer s.rt.Members().RUnlock() + + var g errgroup.Group + s.rt.Members().Range(func(_ uint64, m discovery.Member) bool { + member := m // https://golang.org/doc/faq#closures_and_goroutines + g.Go(func() error { + if !s.isAlive() { + return ErrServerGone + } + req := protocol.NewDTopicMessage(protocol.OpDestroyDTopicInternal) + req.SetDTopic(topic) + _, err := s.requestTo(member.String(), req) + if err != nil { + s.log.V(2).Printf("[ERROR] Failed to call Destroy on %s, topic: %s : %v", member, topic, err) + return err + } + return nil + }) + return true + }) + + return g.Wait() +} + +func (s *Service) dtopicDestroyOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.DTopicMessage) + err := s.destroyDTopicOnCluster(req.DTopic()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/dispatcher.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/dispatcher.go new file mode 100644 index 000000000..4db351470 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/dispatcher.go @@ -0,0 +1,146 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dtopic + +import ( + "context" + "fmt" + "github.com/buraksezer/olric/pkg/neterrors" + "math/rand" + "runtime" + "sync" + + "golang.org/x/sync/semaphore" +) + +type listener struct { + f func(message Message) +} + +// Listeners with id. +type listeners struct { + m map[uint64]*listener + concurrency int +} + +type Dispatcher struct { + sync.RWMutex + + m map[string]*listeners + ctx context.Context +} + +func NewDispatcher(ctx context.Context) *Dispatcher { + return &Dispatcher{ + m: make(map[string]*listeners), + ctx: ctx, + } +} + +func (d *Dispatcher) _addListener(listenerID uint64, topic string, concurrency int, f func(Message)) error { + d.Lock() + defer d.Unlock() + + l, ok := d.m[topic] + if ok { + if _, ok = l.m[listenerID]; ok { + return errListenerIDCollision + } + l.m[listenerID] = &listener{f: f} + } else { + d.m[topic] = &listeners{ + m: make(map[uint64]*listener), + concurrency: concurrency, + } + d.m[topic].m[listenerID] = &listener{f: f} + } + return nil +} + +func (d *Dispatcher) addListener(topic string, concurrency int, f func(Message)) (uint64, error) { + listenerID := rand.Uint64() + err := d._addListener(listenerID, topic, concurrency, f) + if err != nil { + return 0, err + } + return listenerID, nil +} + +// addRemoveListener registers clients listeners. +func (d *Dispatcher) addRemoteListener(listenerID uint64, topic string, concurrency int, f func(Message)) error { + return d._addListener(listenerID, topic, concurrency, f) +} + +func (d *Dispatcher) removeListener(topic string, listenerID uint64) error { + d.Lock() + defer d.Unlock() + + l, ok := d.m[topic] + if !ok { + return neterrors.Wrap(neterrors.ErrInvalidArgument, fmt.Sprintf("topic not found: %s", topic)) + } + + _, ok = l.m[listenerID] + if !ok { + return neterrors.Wrap(neterrors.ErrInvalidArgument, fmt.Sprintf("listener not found: %d", listenerID)) + } + + delete(l.m, listenerID) + if len(l.m) == 0 { + delete(d.m, topic) + } + return nil +} + +// dispatch sends a received message to all registered listeners. It doesn't store +// any message. It just dispatch the message. +func (d *Dispatcher) dispatch(topic string, msg *Message) error { + d.RLock() + defer d.RUnlock() + + l, ok := d.m[topic] + if !ok { + // there is no listener for this topic on this node. + return fmt.Errorf("%w: topic not found: %s", neterrors.ErrInvalidArgument, topic) + } + + var wg sync.WaitGroup + if l.concurrency == 0 { + // the number of logical CPUs usable by the current process. + l.concurrency = runtime.NumCPU() + } + sem := semaphore.NewWeighted(int64(l.concurrency)) + for _, ll := range l.m { + if err := sem.Acquire(d.ctx, 1); err != nil { + return err + } + + wg.Add(1) + // Dereference the pointer and make a copy of DTopicMessage for every listener. + go func(f func(message Message)) { + defer wg.Done() + defer sem.Release(1) + f(*msg) + }(ll.f) + } + wg.Wait() + return nil +} + +func (d *Dispatcher) destroy(topic string) { + d.Lock() + defer d.Unlock() + delete(d.m, topic) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/dtopic.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/dtopic.go new file mode 100644 index 000000000..ee31a172e --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/dtopic.go @@ -0,0 +1,145 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dtopic + +import ( + "errors" + "fmt" + "time" + + "github.com/buraksezer/olric/internal/stats" + "github.com/buraksezer/olric/pkg/neterrors" +) + +var ( + // PublishedTotal is the total number of published messages during the life of this instance. + PublishedTotal = stats.NewInt64Counter() + + // CurrentListeners is the current number of listeners of DTopics. + CurrentListeners = stats.NewInt64Gauge() + + // ListenersTotal is the total number of registered listeners during the life of this instance. + ListenersTotal = stats.NewInt64Counter() +) + +const ( + // UnorderedDelivery means that messages are delivered in random order. It's good to distribute independent events in a distributed system. + UnorderedDelivery = int16(1) << iota + + // OrderedDelivery means that messages are delivered in some order. Not implemented yet. + OrderedDelivery +) + +var errListenerIDCollision = errors.New("given listenerID already exists") + +// Message is a message type for DTopic data structure. +type Message struct { + Message interface{} + PublisherAddr string + PublishedAt int64 +} + +// DTopic implements a distributed topic to deliver messages between clients and Olric nodes. You should know that: +// +// * Communication between parties is one-to-many (fan-out). +// * All data is in-memory, and the published messages are not stored in the cluster. +// * Fire&Forget: message delivery is not guaranteed. +type DTopic struct { + name string + flag int16 + concurrency int + s *Service +} + +// NewDTopic returns a new distributed topic instance. +// Parameters: +// * name: DTopic name. +// * concurrency: Maximum number of concurrently processing DTopic messages. +// * flag: Any flag to control DTopic behaviour. +// Flags for delivery options: +// * UnorderedDelivery: Messages are delivered in random order. It's good to distribute independent events in a distributed system. +// * OrderedDelivery: Messages are delivered in order. Not implemented yet. +func (s *Service) NewDTopic(name string, concurrency int, flag int16) (*DTopic, error) { + s.Lock() + defer s.Unlock() + + if dt, ok := s.m[name]; ok { + return dt, nil + } + + if flag&UnorderedDelivery == 0 && flag&OrderedDelivery == 0 { + return nil, fmt.Errorf("%w: invalid delivery mode", neterrors.ErrInvalidArgument) + } + if flag&OrderedDelivery != 0 { + return nil, neterrors.ErrNotImplemented + } + // Check operation status first: + // + // * Checks member count in the cluster, returns ErrClusterQuorum if + // the quorum value cannot be satisfied, + // * Checks bootstrapping status and awaits for a short period before + // returning ErrRequestTimeout. + if err := s.rt.CheckMemberCountQuorum(); err != nil { + return nil, err + } + // An Olric node has to be bootstrapped to function properly. + if err := s.rt.CheckBootstrap(); err != nil { + return nil, err + } + + dt := &DTopic{ + name: name, + flag: flag, + concurrency: concurrency, + s: s, + } + + s.m[name] = dt + return dt, nil +} + +// Publish publishes the given message to listeners of the topic. Message order and delivery are not guaranteed. +func (d *DTopic) Publish(msg interface{}) error { + tm := &Message{ + Message: msg, + PublisherAddr: d.s.rt.This().String(), + PublishedAt: time.Now().UnixNano(), + } + return d.s.publishDTopicMessage(d.name, tm) +} + +// AddListener adds a new listener for the topic. Returns a registration ID or a non-nil error. +// Registered functions are run by parallel. +func (d *DTopic) AddListener(f func(Message)) (uint64, error) { + // CurrentListeners is the current number of listeners of DTopics. + CurrentListeners.Increase(1) + + // ListenersTotal is the total number of registered listeners during the life of this instance. + ListenersTotal.Increase(1) + + return d.s.dispatcher.addListener(d.name, d.concurrency, f) +} + +// RemoveListener removes a listener with the given listenerID. +func (d *DTopic) RemoveListener(listenerID uint64) error { + CurrentListeners.Decrease(1) + return d.s.dispatcher.removeListener(d.name, listenerID) +} + +// Destroy removes all listeners for this topic on the cluster. If Publish function is called again after Destroy, the topic will be +// recreated. +func (d *DTopic) Destroy() error { + return d.s.destroyDTopicOnCluster(d.name) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/operations.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/operations.go new file mode 100644 index 000000000..bec1941e1 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/operations.go @@ -0,0 +1,112 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dtopic + +import ( + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/internal/streams" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/vmihailenco/msgpack" +) + +func (s *Service) processDTopicMessage(msg Message, name string, streamID, listenerID uint64) { + ss, err := s.streams.GetStreamByID(streamID) + if err != nil { + s.log.V(4).Printf("[ERROR] Stream could not be found with the given StreamID: %d", streamID) + err := s.dispatcher.removeListener(name, listenerID) + if err != nil { + s.log.V(4).Printf("[ERROR] Listener could not be removed with ListenerID: %d: %v", listenerID, err) + } + return + } + + value, err := msgpack.Marshal(msg) + if err != nil { + s.log.V(4).Printf("[ERROR] Failed to serialize DTopicMessage: %v", err) + return + } + + m := protocol.NewDTopicMessage(protocol.OpStreamMessage) + m.SetDTopic(name) + m.SetValue(value) + m.SetExtra(protocol.StreamMessageExtra{ + ListenerID: listenerID, + }) + ss.Write(m) +} + +func (s *Service) waitAndTeardownListener(ss *streams.Stream, name string, listenerID uint64) { + defer s.wg.Done() + + select { + case <-ss.Done(): + case <-s.ctx.Done(): + } + + err := s.dispatcher.removeListener(name, listenerID) + if err != nil { + s.log.V(4).Printf("[ERROR] ListenerID: %d could not be removed: %v", listenerID, err) + } + s.log.V(4).Printf("[INFO] ListenerID: %d has been removed", listenerID) +} + +func (s *Service) addListenerOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.DTopicMessage) + name := req.DTopic() + streamID := req.Extra().(protocol.DTopicAddListenerExtra).StreamID + ss, err := s.streams.GetStreamByID(streamID) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + // Local listener + listenerID := req.Extra().(protocol.DTopicAddListenerExtra).ListenerID + + s.wg.Add(1) + go s.waitAndTeardownListener(ss, name, listenerID) + + f := func(msg Message) { s.processDTopicMessage(msg, name, streamID, listenerID) } + // set concurrency parameter as 0. the registered listener will only make network i/o. NumCPU is good for this. + err = s.dispatcher.addRemoteListener(listenerID, name, 0, f) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + // CurrentListeners is the current number of listeners of DTopics. + CurrentListeners.Increase(1) + + // ListenersTotal is the total number of registered listeners during the life of this instance. + ListenersTotal.Increase(1) + + w.SetStatus(protocol.StatusOK) +} + +func (s *Service) removeListenerOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.DTopicMessage) + extra, ok := req.Extra().(protocol.DTopicRemoveListenerExtra) + if !ok { + neterrors.ErrorResponse(w, neterrors.Wrap(neterrors.ErrInvalidArgument, "wrong extra type")) + return + } + err := s.dispatcher.removeListener(req.DTopic(), extra.ListenerID) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + CurrentListeners.Decrease(1) + w.SetStatus(protocol.StatusOK) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/publish.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/publish.go new file mode 100644 index 000000000..e455c4692 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/publish.go @@ -0,0 +1,134 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dtopic + +import ( + "errors" + "runtime" + "time" + + "github.com/buraksezer/olric/internal/discovery" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/vmihailenco/msgpack" + "golang.org/x/sync/errgroup" + "golang.org/x/sync/semaphore" +) + +func (s *Service) publishMessageOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.DTopicMessage) + var msg Message + err := msgpack.Unmarshal(req.Value(), &msg) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + + err = s.dispatcher.dispatch(req.DTopic(), &msg) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) +} + +func (s *Service) publishDTopicMessageToAddr(member discovery.Member, topic string, msg *Message, sem *semaphore.Weighted) error { + defer sem.Release(1) + + if member.CompareByID(s.rt.This()) { + // Dispatch messages in this process. + err := s.dispatcher.dispatch(topic, msg) + if err != nil { + if s.log.V(6).Ok() { + s.log.V(6).Printf("[ERROR] Failed to dispatch message on this node: %v", err) + } + if !errors.Is(err, neterrors.ErrInvalidArgument) { + return err + } + return nil + } + return nil + } + data, err := msgpack.Marshal(*msg) + if err != nil { + return err + } + req := protocol.NewDTopicMessage(protocol.OpPublishDTopicMessage) + req.SetDTopic(topic) + req.SetValue(data) + _, err = s.requestTo(member.String(), req) + if err != nil { + s.log.V(2).Printf("[ERROR] Failed to publish message to %s: %v", member, err) + return err + } + return nil +} + +func (s *Service) publishDTopicMessage(topic string, msg *Message) error { + s.rt.Members().RLock() + defer s.rt.Members().RUnlock() + + // Propagate the message to the cluster in a parallel manner but + // control concurrency. In order to prevent overloaded servers + // because of network I/O, we use a semaphore. + num := int64(runtime.NumCPU()) + sem := semaphore.NewWeighted(num) + var g errgroup.Group + + s.rt.Members().Range(func(_ uint64, m discovery.Member) bool { + member := m // https://golang.org/doc/faq#closures_and_goroutines + s.wg.Add(1) + g.Go(func() error { + defer s.wg.Done() + if !s.isAlive() { + return ErrServerGone + } + + if err := sem.Acquire(s.ctx, 1); err != nil { + s.log.V(3).Printf("[ERROR] Failed to acquire semaphore: %v", err) + return err + } + return s.publishDTopicMessageToAddr(member, topic, msg, sem) + }) + return true + }) + + // PublishedTotal is the total number of published messages during the life of this instance. + PublishedTotal.Increase(1) + + // Wait blocks until all function calls from the Go method have returned, + // then returns the first non-nil error (if any) from them. + return g.Wait() +} + +func (s *Service) exPublishOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.DTopicMessage) + msg, err := s.unmarshalValue(req.Value()) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + tm := &Message{ + Message: msg, + PublisherAddr: "", + PublishedAt: time.Now().UnixNano(), + } + err = s.publishDTopicMessage(req.DTopic(), tm) + if err != nil { + neterrors.ErrorResponse(w, err) + return + } + w.SetStatus(protocol.StatusOK) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/service.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/service.go new file mode 100644 index 000000000..65190e177 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/dtopic/service.go @@ -0,0 +1,150 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 dtopic + +import ( + "context" + "errors" + "sync" + + "github.com/buraksezer/olric/config" + "github.com/buraksezer/olric/internal/cluster/routingtable" + "github.com/buraksezer/olric/internal/environment" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/internal/service" + "github.com/buraksezer/olric/internal/streams" + "github.com/buraksezer/olric/internal/transport" + "github.com/buraksezer/olric/pkg/flog" + "github.com/buraksezer/olric/pkg/neterrors" + "github.com/buraksezer/olric/serializer" +) + +var ErrServerGone = errors.New("server is gone") + +type Service struct { + sync.RWMutex + + log *flog.Logger + serializer serializer.Serializer + client *transport.Client + rt *routingtable.RoutingTable + streams *streams.Streams + dispatcher *Dispatcher + m map[string]*DTopic + wg sync.WaitGroup + ctx context.Context + cancel context.CancelFunc +} + +func NewService(e *environment.Environment) (service.Service, error) { + ctx, cancel := context.WithCancel(context.Background()) + return &Service{ + streams: e.Get("streams").(*streams.Streams), + serializer: e.Get("config").(*config.Config).Serializer, + client: e.Get("client").(*transport.Client), + log: e.Get("logger").(*flog.Logger), + rt: e.Get("routingtable").(*routingtable.RoutingTable), + dispatcher: NewDispatcher(context.Background()), + m: make(map[string]*DTopic), + ctx: ctx, + cancel: cancel, + }, nil +} + +func (s *Service) Start() error { + // dummy implementation + return nil +} + +func (s *Service) isAlive() bool { + select { + case <-s.ctx.Done(): + // The node is gone. + return false + default: + } + return true +} + +func (s *Service) unmarshalValue(raw []byte) (interface{}, error) { + var value interface{} + err := s.serializer.Unmarshal(raw, &value) + if err != nil { + return nil, err + } + if _, ok := value.(struct{}); ok { + return nil, nil + } + return value, nil +} + +func (s *Service) requestTo(addr string, req protocol.EncodeDecoder) (protocol.EncodeDecoder, error) { + resp, err := s.client.RequestTo(addr, req) + if err != nil { + return nil, err + } + status := resp.Status() + if status == protocol.StatusOK { + return resp, nil + } + + switch status { + case protocol.StatusErrInternalFailure: + return nil, neterrors.Wrap(neterrors.ErrInternalFailure, string(resp.Value())) + case protocol.StatusErrInvalidArgument: + return nil, neterrors.Wrap(neterrors.ErrInvalidArgument, string(resp.Value())) + } + return nil, neterrors.GetByCode(status) +} + +func (s *Service) RegisterOperations(operations map[protocol.OpCode]func(w, r protocol.EncodeDecoder)) { + // Operations on DTopic data structure + // + // DTopic.Publish + operations[protocol.OpPublishDTopicMessage] = s.publishMessageOperation + operations[protocol.OpDTopicPublish] = s.exPublishOperation + + // DTopic.Destroy + operations[protocol.OpDestroyDTopicInternal] = s.destroyDTopicInternalOperation + operations[protocol.OpDTopicDestroy] = s.dtopicDestroyOperation + + // DTopic.AddListener + operations[protocol.OpDTopicAddListener] = s.addListenerOperation + + // DTopic.RemoveListener + operations[protocol.OpDTopicRemoveListener] = s.removeListenerOperation +} + +func (s *Service) Shutdown(ctx context.Context) error { + s.cancel() + done := make(chan struct{}) + + go func() { + s.wg.Wait() + close(done) + }() + + select { + case <-ctx.Done(): + err := ctx.Err() + if err != nil { + return err + } + case <-done: + } + return nil +} + +var _ service.Service = (*Service)(nil) diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/environment/environment.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/environment/environment.go new file mode 100644 index 000000000..f2c3e6c60 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/environment/environment.go @@ -0,0 +1,58 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 environment + +import "sync" + +type Environment struct { + sync.RWMutex + + m map[string]interface{} +} + +func New() *Environment { + return &Environment{ + m: make(map[string]interface{}), + } +} + +func (e *Environment) Get(key string) interface{} { + e.RLock() + defer e.RUnlock() + + value, ok := e.m[key] + if ok { + return value + } + return nil +} + +func (e *Environment) Set(key string, value interface{}) { + e.Lock() + defer e.Unlock() + + e.m[key] = value +} + +func (e *Environment) Clone() *Environment { + e.RLock() + defer e.RUnlock() + + f := New() + for key, value := range e.m { + f.Set(key, value) + } + return f +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/compaction.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/compaction.go new file mode 100644 index 000000000..afb3e9c0a --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/compaction.go @@ -0,0 +1,110 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 kvstore + +import ( + "errors" + "fmt" + "time" + + "github.com/buraksezer/olric/internal/kvstore/table" + "github.com/buraksezer/olric/pkg/storage" +) + +func (k *KVStore) evictTable(t *table.Table) error { + var total int + var evictErr error + t.Range(func(hkey uint64, e storage.Entry) bool { + entry, _ := t.GetRaw(hkey) + err := k.PutRaw(hkey, entry) + if errors.Is(err, table.ErrNotEnoughSpace) { + err := k.makeTable() + if err != nil { + evictErr = err + return false + } + // try again + return false + } + if err != nil { + // log this error and continue + evictErr = fmt.Errorf("put command failed: HKey: %d: %w", hkey, err) + return false + } + + err = t.Delete(hkey) + if errors.Is(err, table.ErrHKeyNotFound) { + err = nil + } + if err != nil { + evictErr = err + return false + } + total++ + + return total <= 1000 + }) + + stats := t.Stats() + if stats.Inuse == 0 { + t.Reset() + } + + return evictErr +} + +func (k *KVStore) isTableExpired(recycledAt int64) bool { + timeout, err := k.config.Get("maxIdleTableTimeout") + if err != nil { + // That would be impossible + panic(err) + } + limit := (timeout.(time.Duration).Nanoseconds() + recycledAt) / 1000000 + return (time.Now().UnixNano() / 1000000) >= limit +} + +func (k *KVStore) isCompactionOK(t *table.Table) bool { + s := t.Stats() + return float64(s.Garbage) >= float64(s.Allocated)*maxGarbageRatio +} + +func (k *KVStore) Compaction() (bool, error) { + for _, t := range k.tables { + if k.isCompactionOK(t) { + err := k.evictTable(t) + if err != nil { + return false, err + } + // Continue scanning + return false, nil + } + } + + for i := 0; i < len(k.tables); i++ { + t := k.tables[i] + s := t.Stats() + if t.State() == table.RecycledState { + if k.isTableExpired(s.RecycledAt) { + if len(k.tables) == 1 { + break + } + k.tables = append(k.tables[:i], k.tables[i+1:]...) + i-- + } + } + } + + return true, nil +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/entry/entry.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/entry/entry.go new file mode 100644 index 000000000..521a44871 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/entry/entry.go @@ -0,0 +1,141 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 entry + +import ( + "encoding/binary" + + "github.com/buraksezer/olric/pkg/storage" +) + +// In-memory layout for an entry: +// +// KEY-LENGTH(uint8) | KEY(bytes) | TTL(uint64) | | Timestamp(uint64) | VALUE-LENGTH(uint32) | VALUE(bytes) + +// Entry represents a value with its metadata. +type Entry struct { + key string + ttl int64 + timestamp int64 + lastAccess int64 + value []byte +} + +var _ storage.Entry = (*Entry)(nil) + +func New() *Entry { + return &Entry{} +} + +func (e *Entry) SetKey(key string) { + e.key = key +} + +func (e *Entry) Key() string { + return e.key +} + +func (e *Entry) SetValue(value []byte) { + e.value = value +} + +func (e *Entry) Value() []byte { + return e.value +} + +func (e *Entry) SetTTL(ttl int64) { + e.ttl = ttl +} + +func (e *Entry) TTL() int64 { + return e.ttl +} + +func (e *Entry) SetTimestamp(timestamp int64) { + e.timestamp = timestamp +} + +func (e *Entry) Timestamp() int64 { + return e.timestamp +} + +func (e *Entry) SetLastAccess(lastAccess int64) { + e.lastAccess = lastAccess +} + +func (e *Entry) LastAccess() int64 { + return e.lastAccess +} + +func (e *Entry) Encode() []byte { + var offset int + + klen := uint8(len(e.Key())) + vlen := len(e.Value()) + length := 29 + len(e.Key()) + vlen + + buf := make([]byte, length) + + // Set key length. It's 1 byte. + copy(buf[offset:], []byte{klen}) + offset++ + + // Set the key. + copy(buf[offset:], e.Key()) + offset += len(e.Key()) + + // Set the TTL. It's 8 bytes. + binary.BigEndian.PutUint64(buf[offset:], uint64(e.TTL())) + offset += 8 + + // Set the Timestamp. It's 8 bytes. + binary.BigEndian.PutUint64(buf[offset:], uint64(e.Timestamp())) + offset += 8 + + // Set the LastAccess. It's 8 bytes. + binary.BigEndian.PutUint64(buf[offset:], uint64(e.LastAccess())) + offset += 8 + + // Set the value length. It's 4 bytes. + binary.BigEndian.PutUint32(buf[offset:], uint32(len(e.Value()))) + offset += 4 + + // Set the value. + copy(buf[offset:], e.Value()) + return buf +} + +func (e *Entry) Decode(buf []byte) { + var offset int + + keyLength := int(buf[offset]) + offset++ + + e.key = string(buf[offset : offset+keyLength]) + offset += keyLength + + e.ttl = int64(binary.BigEndian.Uint64(buf[offset : offset+8])) + offset += 8 + + e.timestamp = int64(binary.BigEndian.Uint64(buf[offset : offset+8])) + offset += 8 + + e.lastAccess = int64(binary.BigEndian.Uint64(buf[offset : offset+8])) + offset += 8 + + vlen := binary.BigEndian.Uint32(buf[offset : offset+4]) + offset += 4 + e.value = buf[offset : offset+int(vlen)] +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/kvstore.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/kvstore.go new file mode 100644 index 000000000..d7172c4b3 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/kvstore.go @@ -0,0 +1,403 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 kvstore implements a GC friendly in-memory storage engine by using +built-in maps and byte slices. It also supports compaction.*/ +package kvstore + +import ( + "errors" + "log" + "regexp" + "time" + + "github.com/buraksezer/olric/internal/kvstore/entry" + "github.com/buraksezer/olric/internal/kvstore/table" + "github.com/buraksezer/olric/pkg/storage" +) + +const ( + maxGarbageRatio = 0.40 + // 1MB + defaultTableSize = uint32(1 << 20) + + defaultMaxIdleTableTimeout = 15 * time.Minute +) + +// KVStore implements an in-memory storage engine. +type KVStore struct { + tables []*table.Table + config *storage.Config +} + +var _ storage.Engine = (*KVStore)(nil) + +func DefaultConfig() *storage.Config { + options := storage.NewConfig(nil) + options.Add("tableSize", defaultTableSize) + options.Add("maxIdleTableTimeout", defaultMaxIdleTableTimeout) + return options +} + +func (k *KVStore) SetConfig(c *storage.Config) { + k.config = c +} + +func (k *KVStore) makeTable() error { + size, err := k.config.Get("tableSize") + if err != nil { + return err + } + + head := k.tables[len(k.tables)-1] + head.SetState(table.ReadOnlyState) + + for i, t := range k.tables { + if t.State() == table.RecycledState { + k.tables = append(k.tables, t) + k.tables = append(k.tables[:i], k.tables[i+1:]...) + t.SetState(table.ReadWriteState) + return nil + } + } + + current := table.New(size.(uint32)) + k.tables = append(k.tables, current) + return nil +} + +func (k *KVStore) SetLogger(_ *log.Logger) {} + +func (k *KVStore) Start() error { + if k.config == nil { + return errors.New("config cannot be nil") + } + return nil +} + +// Fork creates a new KVStore instance. +func (k *KVStore) Fork(c *storage.Config) (storage.Engine, error) { + if c == nil { + c = k.config.Copy() + } + size, err := c.Get("tableSize") + if err != nil { + return nil, err + } + child := &KVStore{ + config: c, + } + t := table.New(size.(uint32)) + child.tables = append(child.tables, t) + return child, nil +} + +func (k *KVStore) AppendTable(t *table.Table) { + k.tables = append(k.tables, t) +} + +func (k *KVStore) Name() string { + return "kvstore" +} + +func (k *KVStore) NewEntry() storage.Entry { + return entry.New() +} + +// PutRaw sets the raw value for the given key. +func (k *KVStore) PutRaw(hkey uint64, value []byte) error { + if len(k.tables) == 0 { + if err := k.makeTable(); err != nil { + return err + } + } + + for { + // Get the last value, storage only calls Put on the last created table. + t := k.tables[len(k.tables)-1] + err := t.PutRaw(hkey, value) + if errors.Is(err, table.ErrNotEnoughSpace) { + err := k.makeTable() + if err != nil { + return err + } + // try again + continue + } + if err != nil { + return err + } + // everything is ok + break + } + + return nil +} + +// Put sets the value for the given key. It overwrites any previous value for that key +func (k *KVStore) Put(hkey uint64, value storage.Entry) error { + if len(k.tables) == 0 { + if err := k.makeTable(); err != nil { + return err + } + } + + for { + // Get the last value, storage only calls Put on the last created table. + t := k.tables[len(k.tables)-1] + err := t.Put(hkey, value) + if errors.Is(err, table.ErrNotEnoughSpace) { + err := k.makeTable() + if err != nil { + return err + } + // try again + continue + } + if err != nil { + return err + } + + // everything is ok + break + } + + return nil +} + +// GetRaw extracts encoded value for the given hkey. This is useful for merging tables. +func (k *KVStore) GetRaw(hkey uint64) ([]byte, error) { + // Scan available tables by starting the last added table. + for i := len(k.tables) - 1; i >= 0; i-- { + t := k.tables[i] + raw, err := t.GetRaw(hkey) + if errors.Is(err, table.ErrHKeyNotFound) { + // Try out the other tables. + continue + } + if err != nil { + return nil, err + } + // Found the key, return the stored value with its metadata. + return raw, nil + } + + // Nothing here. + return nil, storage.ErrKeyNotFound +} + +// Get gets the value for the given key. It returns storage.ErrKeyNotFound if the DB +// does not contain the key. The returned Entry is its own copy, +// it is safe to modify the contents of the returned slice. +func (k *KVStore) Get(hkey uint64) (storage.Entry, error) { + // Scan available tables by starting the last added table. + for i := len(k.tables) - 1; i >= 0; i-- { + t := k.tables[i] + res, err := t.Get(hkey) + if errors.Is(err, table.ErrHKeyNotFound) { + // Try out the other tables. + continue + } + if err != nil { + return nil, err + } + // Found the key, return the stored value with its metadata. + return res, nil + } + // Nothing here. + return nil, storage.ErrKeyNotFound +} + +// GetTTL gets the timeout for the given key. It returns storage.ErrKeyNotFound if the DB +// does not contain the key. +func (k *KVStore) GetTTL(hkey uint64) (int64, error) { + // Scan available tables by starting the last added table. + for i := len(k.tables) - 1; i >= 0; i-- { + t := k.tables[i] + ttl, err := t.GetTTL(hkey) + if errors.Is(err, table.ErrHKeyNotFound) { + // Try out the other tables. + continue + } + if err != nil { + return 0, err + } + // Found the key, return its ttl + return ttl, nil + } + + // Nothing here. + return 0, storage.ErrKeyNotFound +} + +func (k *KVStore) GetLastAccess(hkey uint64) (int64, error) { + // Scan available tables by starting the last added table. + for i := len(k.tables) - 1; i >= 0; i-- { + t := k.tables[i] + lastAccess, err := t.GetLastAccess(hkey) + if errors.Is(err, table.ErrHKeyNotFound) { + // Try out the other tables. + continue + } + if err != nil { + return 0, err + } + // Found the key, return its ttl + return lastAccess, nil + } + + // Nothing here. + return 0, storage.ErrKeyNotFound +} + +// GetKey gets the key for the given hkey. It returns storage.ErrKeyNotFound if the DB +// does not contain the key. +func (k *KVStore) GetKey(hkey uint64) (string, error) { + // Scan available tables by starting the last added table. + for i := len(k.tables) - 1; i >= 0; i-- { + t := k.tables[i] + key, err := t.GetKey(hkey) + if errors.Is(err, table.ErrHKeyNotFound) { + // Try out the other tables. + continue + } + if err != nil { + return "", err + } + // Found the key, return its ttl + return key, nil + } + + // Nothing here. + return "", storage.ErrKeyNotFound +} + +// Delete deletes the value for the given key. Delete will not returns error if key doesn't exist. +func (k *KVStore) Delete(hkey uint64) error { + // Scan available tables by starting the last added table. + for i := len(k.tables) - 1; i >= 0; i-- { + t := k.tables[i] + err := t.Delete(hkey) + if errors.Is(err, table.ErrHKeyNotFound) { + // Try out the other tables. + continue + } + if err != nil { + return err + } + break + } + + return nil +} + +// UpdateTTL updates the expiry for the given key. +func (k *KVStore) UpdateTTL(hkey uint64, data storage.Entry) error { + // Scan available tables by starting the last added table. + for i := len(k.tables) - 1; i >= 0; i-- { + t := k.tables[i] + err := t.UpdateTTL(hkey, data) + if errors.Is(err, table.ErrHKeyNotFound) { + // Try out the other tables. + continue + } + if err != nil { + return err + } + // Found the key, return the stored value with its metadata. + return nil + } + // Nothing here. + return storage.ErrKeyNotFound +} + +// Stats is a function which provides memory allocation and garbage ratio of a storage instance. +func (k *KVStore) Stats() storage.Stats { + stats := storage.Stats{ + NumTables: len(k.tables), + } + for _, t := range k.tables { + s := t.Stats() + stats.Allocated += int(s.Allocated) + stats.Inuse += int(s.Inuse) + stats.Garbage += int(s.Garbage) + stats.Length += s.Length + } + return stats +} + +// Check checks the key existence. +func (k *KVStore) Check(hkey uint64) bool { + // Scan available tables by starting the last added table. + for i := len(k.tables) - 1; i >= 0; i-- { + t := k.tables[i] + ok := t.Check(hkey) + if ok { + return true + } + } + + // Nothing there. + return false +} + +// Range calls f sequentially for each key and value present in the map. +// If f returns false, range stops the iteration. Range may be O(N) with +// the number of elements in the map even if f returns false after a constant +// number of calls. +func (k *KVStore) Range(f func(hkey uint64, e storage.Entry) bool) { + // Scan available tables by starting the last added table. + for i := len(k.tables) - 1; i >= 0; i-- { + t := k.tables[i] + t.Range(func(hkey uint64, e storage.Entry) bool { + return f(hkey, e) + }) + } +} + +// RegexMatchOnKeys calls a regular expression on keys and provides an iterator. +func (k *KVStore) RegexMatchOnKeys(expr string, f func(hkey uint64, e storage.Entry) bool) error { + if len(k.tables) == 0 { + // There is nothing to do + return nil + } + + r, err := regexp.Compile(expr) + if err != nil { + return err + } + + // Scan available tables by starting the last added table. + for i := len(k.tables) - 1; i >= 0; i-- { + t := k.tables[i] + t.Range(func(hkey uint64, e storage.Entry) bool { + key, _ := t.GetRawKey(hkey) + if !r.Match(key) { + return true + } + data, _ := t.Get(hkey) + return f(hkey, data) + }) + } + + return nil +} + +func (k *KVStore) Close() error { + return nil +} + +func (k *KVStore) Destroy() error { + return nil +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/table/pack.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/table/pack.go new file mode 100644 index 000000000..6ce52a9b9 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/table/pack.go @@ -0,0 +1,65 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 table + +import "github.com/vmihailenco/msgpack" + +type Pack struct { + Offset uint32 + Allocated uint32 + Inuse uint32 + Garbage uint32 + RecycledAt int64 + State State + HKeys map[uint64]uint32 + Memory []byte +} + +func Encode(t *Table) ([]byte, error) { + p := Pack{ + Offset: t.offset, + Allocated: t.allocated, + Inuse: t.inuse, + Garbage: t.garbage, + RecycledAt: t.recycledAt, + State: t.state, + HKeys: t.hkeys, + } + p.Memory = make([]byte, t.offset) + copy(p.Memory, t.memory[:t.offset]) + + return msgpack.Marshal(p) +} + +func Decode(data []byte) (*Table, error) { + p := &Pack{} + + err := msgpack.Unmarshal(data, p) + if err != nil { + return nil, err + } + + t := New(p.Allocated) + t.offset = p.Offset + t.inuse = p.Inuse + t.garbage = p.Garbage + t.recycledAt = p.RecycledAt + t.state = p.State + t.hkeys = p.HKeys + + copy(t.memory[:t.offset], p.Memory) + + return t, nil +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/table/table.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/table/table.go new file mode 100644 index 000000000..1f8c02899 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/table/table.go @@ -0,0 +1,366 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 table + +import ( + "encoding/binary" + "fmt" + "time" + + "github.com/buraksezer/olric/internal/kvstore/entry" + "github.com/buraksezer/olric/pkg/storage" + "github.com/pkg/errors" +) + +const maxKeyLen = 256 + +type State uint8 + +const ( + ReadWriteState = State(iota + 1) + ReadOnlyState + RecycledState +) + +var ( + ErrNotEnoughSpace = errors.New("not enough space") + ErrHKeyNotFound = errors.New("hkey not found") +) + +type Stats struct { + Allocated uint32 + Inuse uint32 + Garbage uint32 + Length int + RecycledAt int64 +} + +type Table struct { + offset uint32 + allocated uint32 + inuse uint32 + garbage uint32 + recycledAt int64 + state State + hkeys map[uint64]uint32 + memory []byte +} + +func New(size uint32) *Table { + t := &Table{ + hkeys: make(map[uint64]uint32), + allocated: size, + state: ReadWriteState, + } + // From builtin.go: + // + // The size specifies the length. The capacity of the slice is + // equal to its length. A second integer argument may be provided to + // specify a different capacity; it must be no smaller than the + // length. For example, make([]int, 0, 10) allocates an underlying array + // of size 10 and returns a slice of length 0 and capacity 10 that is + // backed by this underlying array. + t.memory = make([]byte, size) + return t +} + +func (t *Table) SetState(s State) { + t.state = s +} + +func (t *Table) State() State { + return t.state +} + +func (t *Table) PutRaw(hkey uint64, value []byte) error { + // Check empty space on allocated memory area. + inuse := uint32(len(value)) + if inuse+t.offset >= t.allocated { + return ErrNotEnoughSpace + } + t.hkeys[hkey] = t.offset + copy(t.memory[t.offset:], value) + t.inuse += inuse + t.offset += inuse + return nil +} + +// In-memory layout for entry: +// +// KEY-LENGTH(uint8) | KEY(bytes) | TTL(uint64) | TIMESTAMP(uint64) | LASTACCESS(uint64) | VALUE-LENGTH(uint32) | VALUE(bytes) +func (t *Table) Put(hkey uint64, value storage.Entry) error { + if len(value.Key()) >= maxKeyLen { + return storage.ErrKeyTooLarge + } + + // Check empty space on allocated memory area. + + // TTL + Timestamp + LastAccess + + value-Length + key-Length + inuse := uint32(len(value.Key()) + len(value.Value()) + 29) + if inuse+t.offset >= t.allocated { + return ErrNotEnoughSpace + } + + // If we already have the key, delete it. + err := t.Delete(hkey) + if errors.Is(err, ErrHKeyNotFound) { + err = nil + } + if err != nil { + return err + } + + t.hkeys[hkey] = t.offset + t.inuse += inuse + + // Set key length. It's 1 byte. + klen := uint8(len(value.Key())) + copy(t.memory[t.offset:], []byte{klen}) + t.offset++ + + // Set the key. + copy(t.memory[t.offset:], value.Key()) + t.offset += uint32(len(value.Key())) + + // Set the TTL. It's 8 bytes. + binary.BigEndian.PutUint64(t.memory[t.offset:], uint64(value.TTL())) + t.offset += 8 + + // Set the Timestamp. It's 8 bytes. + binary.BigEndian.PutUint64(t.memory[t.offset:], uint64(value.Timestamp())) + t.offset += 8 + + // Set the last access. It's 8 bytes. + binary.BigEndian.PutUint64(t.memory[t.offset:], uint64(time.Now().UnixNano())) + t.offset += 8 + + // Set the value length. It's 4 bytes. + binary.BigEndian.PutUint32(t.memory[t.offset:], uint32(len(value.Value()))) + t.offset += 4 + + // Set the value. + copy(t.memory[t.offset:], value.Value()) + t.offset += uint32(len(value.Value())) + return nil +} + +func (t *Table) GetRaw(hkey uint64) ([]byte, error) { + offset, ok := t.hkeys[hkey] + if !ok { + return nil, ErrHKeyNotFound + } + start, end := offset, offset + + // In-memory structure: + // 1 | klen | 8 | 8 | 8 | 4 | vlen + // KEY-LENGTH(uint8) | KEY(bytes) | TTL(uint64) | TIMESTAMP(uint64) | LASTACCESS(uint64) | VALUE-LENGTH(uint32) | VALUE(bytes) + klen := uint32(t.memory[end]) + end++ // One byte to keep key length + end += klen // key length + end += 8 // TTL + end += 8 // Timestamp + end += 8 // LastAccess + + vlen := binary.BigEndian.Uint32(t.memory[end : end+4]) + end += 4 // 4 bytes to keep value length + end += vlen // value length + + // Create a copy of the requested data. + rawval := make([]byte, end-start) + copy(rawval, t.memory[start:end]) + return rawval, nil +} + +func (t *Table) GetRawKey(hkey uint64) ([]byte, error) { + offset, ok := t.hkeys[hkey] + if !ok { + return nil, ErrHKeyNotFound + } + + klen := uint32(t.memory[offset]) + offset++ + return t.memory[offset : offset+klen], nil +} + +func (t *Table) GetKey(hkey uint64) (string, error) { + raw, err := t.GetRawKey(hkey) + if raw == nil { + return "", err + } + return string(raw), err +} + +func (t *Table) GetTTL(hkey uint64) (int64, error) { + offset, ok := t.hkeys[hkey] + if !ok { + return 0, ErrHKeyNotFound + } + + klen := uint32(t.memory[offset]) + offset++ + offset += klen + + return int64(binary.BigEndian.Uint64(t.memory[offset : offset+8])), nil +} + +func (t *Table) GetLastAccess(hkey uint64) (int64, error) { + offset, ok := t.hkeys[hkey] + if !ok { + return 0, ErrHKeyNotFound + } + + klen := uint32(t.memory[offset]) + offset++ // Key length + offset += klen // Key's itself + offset += 8 // TTL + offset += 8 // Timestamp + + return int64(binary.BigEndian.Uint64(t.memory[offset : offset+8])), nil +} + +func (t *Table) Get(hkey uint64) (storage.Entry, error) { + offset, ok := t.hkeys[hkey] + if !ok { + return nil, ErrHKeyNotFound + } + + e := &entry.Entry{} + // In-memory structure: + // + // KEY-LENGTH(uint8) | KEY(bytes) | TTL(uint64) | TIMESTAMP(uint64) | LASTACCESS(uint64) | VALUE-LENGTH(uint32) | VALUE(bytes) + klen := uint32(t.memory[offset]) + offset++ + + e.SetKey(string(t.memory[offset : offset+klen])) + offset += klen + + e.SetTTL(int64(binary.BigEndian.Uint64(t.memory[offset : offset+8]))) + offset += 8 + + e.SetTimestamp(int64(binary.BigEndian.Uint64(t.memory[offset : offset+8]))) + offset += 8 + + e.SetLastAccess(int64(binary.BigEndian.Uint64(t.memory[offset : offset+8]))) + // Update the last access field + binary.BigEndian.PutUint64(t.memory[offset:], uint64(time.Now().UnixNano())) + offset += 8 + + vlen := binary.BigEndian.Uint32(t.memory[offset : offset+4]) + offset += 4 + e.SetValue(t.memory[offset : offset+vlen]) + + return e, nil +} + +func (t *Table) Delete(hkey uint64) error { + offset, ok := t.hkeys[hkey] + if !ok { + // Try the previous tables. + return ErrHKeyNotFound + } + var garbage uint32 + + // key, 1 byte for key size, klen for key's actual length. + klen := uint32(t.memory[offset]) + offset += 1 + klen + garbage += 1 + klen + + // TTL, skip it. + offset += 8 + garbage += 8 + + // Timestamp, skip it. + offset += 8 + garbage += 8 + + // LastAccess, skip it. + offset += 8 + garbage += 8 + + // value len and its header. + vlen := binary.BigEndian.Uint32(t.memory[offset : offset+4]) + garbage += 4 + vlen + + // Delete it from metadata + delete(t.hkeys, hkey) + + t.garbage += garbage + t.inuse -= garbage + return nil +} + +func (t *Table) UpdateTTL(hkey uint64, value storage.Entry) error { + offset, ok := t.hkeys[hkey] + if !ok { + return ErrHKeyNotFound + } + + // key, 1 byte for key size, klen for key's actual length. + klen := uint32(t.memory[offset]) + offset += 1 + klen + + // Set the new TTL. It's 8 bytes. + binary.BigEndian.PutUint64(t.memory[offset:], uint64(value.TTL())) + offset += 8 + + // Set the new Timestamp. It's 8 bytes. + binary.BigEndian.PutUint64(t.memory[offset:], uint64(value.Timestamp())) + + offset += 8 + + // Update the last access field + binary.BigEndian.PutUint64(t.memory[offset:], uint64(time.Now().UnixNano())) + + return nil +} + +func (t *Table) Check(hkey uint64) bool { + _, ok := t.hkeys[hkey] + return ok +} + +func (t *Table) Stats() Stats { + return Stats{ + Allocated: t.allocated, + Inuse: t.inuse, + Garbage: t.garbage, + Length: len(t.hkeys), + RecycledAt: t.recycledAt, + } +} + +func (t *Table) Range(f func(hkey uint64, e storage.Entry) bool) { + for hkey := range t.hkeys { + e, err := t.Get(hkey) + if errors.Is(err, ErrHKeyNotFound) { + panic(fmt.Errorf("hkey: %d found in index, but Get could not find it", hkey)) + } + + if !f(hkey, e) { + break + } + } +} + +func (t *Table) Reset() { + if len(t.hkeys) != 0 { + t.hkeys = make(map[uint64]uint32) + } + t.SetState(RecycledState) + t.inuse = 0 + t.garbage = 0 + t.offset = 0 + t.recycledAt = time.Now().UnixNano() +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/transport.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/transport.go new file mode 100644 index 000000000..33b289999 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/kvstore/transport.go @@ -0,0 +1,83 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 kvstore + +import ( + "fmt" + "io" + + "github.com/buraksezer/olric/internal/kvstore/table" + "github.com/buraksezer/olric/pkg/storage" +) + +type transferIterator struct { + storage *KVStore +} + +func (t *transferIterator) Next() bool { + return len(t.storage.tables) != 0 +} + +func (t *transferIterator) Pop() error { + if len(t.storage.tables) == 0 { + return fmt.Errorf("there is no table to pop") + } + + t.storage.tables = append(t.storage.tables[:0], t.storage.tables[1:]...) + + return nil +} + +func (t *transferIterator) Export() ([]byte, error) { + for _, t := range t.storage.tables { + if t.State() == table.RecycledState { + continue + } + + return table.Encode(t) + } + return nil, io.EOF +} + +func (k *KVStore) Import(data []byte, f func(uint64, storage.Entry) error) error { + tb, err := table.Decode(data) + if err != nil { + return err + } + + if k.Stats().Length == 0 { + // DMap has no keys. Set the imported storage instance. + // The old one will be garbage collected. + k.AppendTable(tb) + tb.Range(func(hkey uint64, e storage.Entry) bool { + data, err := k.Get(hkey) + fmt.Println(data, err) + return true + }) + return nil + } + + tb.Range(func(hkey uint64, e storage.Entry) bool { + return f(hkey, e) == nil // return false to break the loop + }) + + return err +} + +func (k *KVStore) TransferIterator() storage.TransferIterator { + return &transferIterator{ + storage: k, + } +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/protocol/extras.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/protocol/extras.go index 6dcdb337a..d3411b011 100644 --- a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/protocol/extras.go +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/protocol/extras.go @@ -106,6 +106,10 @@ type StatsExtra struct { CollectRuntime bool } +type LockLeaseExtra struct { + Timeout int64 +} + func loadExtras(raw []byte, op OpCode) (interface{}, error) { switch op { case OpPutEx, OpPutExReplica: @@ -124,6 +128,10 @@ func loadExtras(raw []byte, op OpCode) (interface{}, error) { extra := LockExtra{} err := binary.Read(bytes.NewReader(raw), binary.BigEndian, &extra) return extra, err + case OpLockLease: + extra := LockLeaseExtra{} + err := binary.Read(bytes.NewReader(raw), binary.BigEndian, &extra) + return extra, err case OpLengthOfPart: extra := LengthOfPartExtra{} err := binary.Read(bytes.NewReader(raw), binary.BigEndian, &extra) diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/protocol/operations.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/protocol/operations.go index 1633d4b8f..70245de9c 100644 --- a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/protocol/operations.go +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/protocol/operations.go @@ -61,6 +61,7 @@ const ( OpStreamMessage // 41 OpStreamPing // 42 OpStreamPong // 43 + OpLockLease // 44 ) type StatusCode uint8 diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/service/service.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/service/service.go new file mode 100644 index 000000000..d548c8e36 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/service/service.go @@ -0,0 +1,26 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 service + +import ( + "context" + "github.com/buraksezer/olric/internal/protocol" +) + +type Service interface { + Start() error + RegisterOperations(map[protocol.OpCode]func(w, r protocol.EncodeDecoder)) + Shutdown(ctx context.Context) error +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/stats/stats.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/stats/stats.go new file mode 100644 index 000000000..b0ca4f128 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/stats/stats.go @@ -0,0 +1,64 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 stats + +import "sync/atomic" + +// Int64Counter is a cumulative metric that represents a single monotonically +// increasing counter whose value can only increase or be reset to zero on restart. +type Int64Counter struct { + counter int64 +} + +// NewInt64Counter returns a new Int64Counter +func NewInt64Counter() *Int64Counter { + return &Int64Counter{} +} + +// Increase increases the counter by delta. +func (c *Int64Counter) Increase(delta int64) { + atomic.AddInt64(&c.counter, delta) +} + +// Read returns the current value of counter. +func (c *Int64Counter) Read() int64 { + return atomic.LoadInt64(&c.counter) +} + +// Int64Gauge is a metric that represents a single numerical value that can +// arbitrarily go up and down. +type Int64Gauge struct { + gauge int64 +} + +// NewInt64Gauge returns a new Int64Gauge +func NewInt64Gauge() *Int64Gauge { + return &Int64Gauge{} +} + +// Increase increases the gauge by delta. +func (c *Int64Gauge) Increase(delta int64) { + atomic.AddInt64(&c.gauge, delta) +} + +// Decrease decreases the counter by delta. +func (c *Int64Gauge) Decrease(delta int64) { + atomic.AddInt64(&c.gauge, -1*delta) +} + +// Read returns the current value of gauge. +func (c *Int64Gauge) Read() int64 { + return atomic.LoadInt64(&c.gauge) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/streams/stream.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/streams/stream.go new file mode 100644 index 000000000..f50b80747 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/streams/stream.go @@ -0,0 +1,152 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 streams + +import ( + "context" + "fmt" + "io" + "sync" + "time" + + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/flog" + "golang.org/x/sync/errgroup" +) + +// Stream provides a bidirectional communication channel between Olric nodes and clients. It can also be used +// for node-to-node communication. +type Stream struct { + mu sync.RWMutex + + pingReceivedAt int64 + log *flog.Logger + conn io.ReadWriteCloser + read chan protocol.EncodeDecoder + write chan protocol.EncodeDecoder + ctx context.Context + cancel context.CancelFunc + errGr errgroup.Group +} + +// Close calls s.cancel and stops all background goroutines. +func (s *Stream) Close() { + s.cancel() +} + +func (s *Stream) Done() <-chan struct{} { + return s.ctx.Done() +} + +func (s *Stream) Write(m protocol.EncodeDecoder) { + s.write <- m +} + +func (s *Stream) readFromStream(bufCh chan<- protocol.EncodeDecoder) error { + defer s.cancel() + + f := func() error { + buf := bufferPool.Get() + defer bufferPool.Put(buf) + + header, err := protocol.ReadMessage(s.conn, buf) + if err != nil { + return err + } + + var msg protocol.EncodeDecoder + if header.Magic == protocol.MagicStreamReq { + msg = protocol.NewStreamMessageFromRequest(buf) + msg.(*protocol.StreamMessage).SetConn(s.conn) + } else if header.Magic == protocol.MagicDMapReq { + msg = protocol.NewDMapMessageFromRequest(buf) + } else if header.Magic == protocol.MagicPipelineReq { + msg = protocol.NewPipelineMessageFromRequest(buf) + } else { + return fmt.Errorf("invalid magic") + } + err = msg.Decode() + if err != nil { + return err + } + bufCh <- msg + return nil + } + + for { + // this is good to manage bufferPool with defer statement + if err := f(); err != nil { + return err + } + } +} + +func (s *Stream) readLoop() error { + defer s.cancel() + + bufCh := make(chan protocol.EncodeDecoder, 1) + s.errGr.Go(func() error { + return s.readFromStream(bufCh) + }) + + for { + select { + case <-s.ctx.Done(): + return nil + case buf := <-bufCh: + if buf.OpCode() == protocol.OpStreamPing { + s.setPingReceivedAt() + s.write <- protocol.NewStreamMessage(protocol.OpStreamPong) + } else { + s.read <- buf + } + } + } +} + +func (s *Stream) writeToStream(msg protocol.EncodeDecoder) error { + buf := bufferPool.Get() + defer bufferPool.Put(buf) + + msg.SetBuffer(buf) + err := msg.Encode() + if err != nil { + return err + } + _, err = msg.Buffer().WriteTo(s.conn) + return err +} + +func (s *Stream) writeLoop() error { + defer s.cancel() + + for { + select { + case <-s.ctx.Done(): + return nil + case msg := <-s.write: + if err := s.writeToStream(msg); err != nil { + return err + } + } + } +} + +func (s *Stream) setPingReceivedAt() { + s.mu.Lock() + defer s.mu.Unlock() + + s.pingReceivedAt = time.Now().UnixNano() +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/internal/streams/streams.go b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/streams/streams.go new file mode 100644 index 000000000..556a86502 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/internal/streams/streams.go @@ -0,0 +1,194 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 streams + +import ( + "context" + "errors" + "math/rand" + "sync" + "time" + + "github.com/buraksezer/olric/internal/bufpool" + "github.com/buraksezer/olric/internal/environment" + "github.com/buraksezer/olric/internal/protocol" + "github.com/buraksezer/olric/pkg/flog" +) + +var ErrStreamNotFound = errors.New("stream could not be found") + +// pool is good for recycling memory while reading messages from the socket. +var bufferPool = bufpool.New() + +// Streams maps StreamIDs to Stream +type Streams struct { + sync.RWMutex + + log *flog.Logger + m map[uint64]*Stream + wg sync.WaitGroup + ctx context.Context + cancel context.CancelFunc +} + +func New(e *environment.Environment) *Streams { + log := e.Get("logger").(*flog.Logger) + ctx, cancel := context.WithCancel(context.Background()) + return &Streams{ + log: log, + m: make(map[uint64]*Stream), + ctx: ctx, + cancel: cancel, + } +} + +func (ss *Streams) RegisterOperations(operations map[protocol.OpCode]func(w, r protocol.EncodeDecoder)) { + operations[protocol.OpCreateStream] = ss.createStreamOperation +} + +func (ss *Streams) Shutdown(ctx context.Context) error { + ss.RLock() + defer ss.RUnlock() + + for _, stream := range ss.m { + stream.Close() + } + + done := make(chan struct{}) + go func() { + ss.wg.Wait() + close(done) + }() + select { + case <-ctx.Done(): + err := ctx.Err() + if err != nil { + return err + } + case <-done: + } + return nil +} + +func (ss *Streams) GetStreamByID(id uint64) (*Stream, error) { + ss.RLock() + defer ss.RUnlock() + + s, ok := ss.m[id] + if !ok { + return nil, ErrStreamNotFound + } + return s, nil +} + +func (ss *Streams) DeleteStreamByID(id uint64) { + ss.Lock() + defer ss.Unlock() + + delete(ss.m, id) +} + +func (ss *Streams) checkStreamAliveness(s *Stream, streamID uint64) { + defer ss.wg.Done() + +loop: + for { + select { + case <-s.ctx.Done(): + return + case <-ss.ctx.Done(): + return + case <-time.After(time.Second): + s.mu.RLock() + if s.pingReceivedAt == 0 { + s.mu.RUnlock() + continue loop + } + if s.pingReceivedAt+(5*time.Second).Nanoseconds() <= time.Now().UnixNano() { + // There is no need to call Stream.Close method here. The underlying socket is already gone. + s.cancel() + ss.log.V(4).Printf("[INFO] StreamID: %d is dead", streamID) + } + s.mu.RUnlock() + } + } +} + +func (ss *Streams) createStreamOperation(w, r protocol.EncodeDecoder) { + req := r.(*protocol.StreamMessage) + + streamID := rand.Uint64() + ctx, cancel := context.WithCancel(context.Background()) + ss.Lock() + s := &Stream{ + conn: req.Conn(), + read: make(chan protocol.EncodeDecoder, 1), + write: make(chan protocol.EncodeDecoder, 1), + ctx: ctx, + cancel: cancel, + } + // this cancel function will be called by the server when the underlying socket is gone. + req.SetCancelFunc(s.cancel) + ss.m[streamID] = s + ss.Unlock() + + ss.wg.Add(1) + go ss.checkStreamAliveness(s, streamID) + + defer func() { + ss.DeleteStreamByID(streamID) + ss.log.V(4).Printf("[INFO] StreamID: %d is gone", streamID) + }() + + rq := protocol.NewStreamMessage(protocol.OpStreamCreated) + rq.SetExtra(protocol.StreamCreatedExtra{ + StreamID: streamID, + }) + rq.SetStatus(protocol.StatusOK) + s.write <- rq + + s.errGr.Go(func() error { + return s.writeLoop() + }) + + s.errGr.Go(func() error { + return s.readLoop() + }) + +loop: + for { + select { + case <-s.ctx.Done(): + // Stream.Close method is called + break loop + case <-ss.ctx.Done(): + // server is gone + break loop + } + } + + // this closes the Stream goroutines + s.cancel() + if err := s.conn.Close(); err != nil { + ss.log.V(4).Printf("Failed to Close underlying TCP socket of StreamID: %d", streamID) + } + + if err := s.errGr.Wait(); err != nil { + w.SetStatus(protocol.StatusErrInternalFailure) + w.SetValue([]byte(err.Error())) + return + } + w.SetStatus(protocol.StatusOK) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/neterrors/errors.go b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/neterrors/errors.go new file mode 100644 index 000000000..7f21745f9 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/neterrors/errors.go @@ -0,0 +1,25 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 neterrors + +import "github.com/buraksezer/olric/internal/protocol" + +var ( + ErrInvalidArgument = New(protocol.StatusErrInvalidArgument, "invalid argument") + ErrUnknownOperation = New(protocol.StatusErrUnknownOperation, "unknown operation") + ErrInternalFailure = New(protocol.StatusErrInternalFailure, "internal failure") + ErrNotImplemented = New(protocol.StatusErrNotImplemented, "not implemented") + ErrOperationTimeout = New(protocol.StatusErrOperationTimeout, "operation timeout") +) diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/neterrors/neterrors.go b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/neterrors/neterrors.go new file mode 100644 index 000000000..983a97c40 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/neterrors/neterrors.go @@ -0,0 +1,130 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 neterrors + +import ( + "errors" + "fmt" + "sync" + "unsafe" + + "github.com/buraksezer/olric/internal/protocol" +) + +var ( + mtx sync.Mutex + registryOnce sync.Once + registry map[protocol.StatusCode]error +) + +// NetError defines a custom error type. +type NetError struct { + message string + statusCode protocol.StatusCode +} + +func New(code protocol.StatusCode, message string) *NetError { + e := &NetError{ + statusCode: code, + message: message, + } + registryOnce.Do(func() { + registry = make(map[protocol.StatusCode]error) + }) + mtx.Lock() + defer mtx.Unlock() + _, ok := registry[code] + if ok { + panic(fmt.Sprintf("an error has already been registered with StatusCode: %d", code)) + } + registry[code] = e + return e +} + +func (e *NetError) Error() string { + return e.message +} + +func (e *NetError) Bytes() []byte { + return *(*[]byte)(unsafe.Pointer(&e.message)) +} + +func (e *NetError) StatusCode() protocol.StatusCode { + return e.statusCode +} + +// Wrap extends this error with an additional information. +func Wrap(err error, message interface{}) error { + return fmt.Errorf("%w: %v", err, message) +} + +func Unwrap(err error) error { + return errors.Unwrap(err) +} + +func GetByCode(code protocol.StatusCode) error { + if code == protocol.StatusOK { + return nil + } + err, ok := registry[code] + if !ok { + return fmt.Errorf("no error found with StatusCode: %d", code) + } + return err +} + +func toByte(err interface{}) []byte { + switch val := err.(type) { + case string: + return []byte(val) + case error: + return []byte(val.Error()) + default: + return nil + } +} + +func ErrorResponse(w protocol.EncodeDecoder, msg interface{}) { + netErr, ok := msg.(*NetError) + if ok { + w.SetValue(netErr.Bytes()) + w.SetStatus(netErr.StatusCode()) + return + } + + err, ok := msg.(error) + if !ok { + w.SetValue(toByte(msg)) + w.SetStatus(protocol.StatusErrInternalFailure) + return + } + + var tmp error + for { + tmp = Unwrap(err) + if tmp == nil { + break + } + err = tmp + } + netErr, ok = err.(*NetError) + if !ok { + w.SetValue(toByte(msg)) + w.SetStatus(protocol.StatusErrInternalFailure) + return + } + w.SetValue(toByte(msg)) + w.SetStatus(netErr.StatusCode()) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/config.go b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/config.go new file mode 100644 index 000000000..3754dc9f9 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/config.go @@ -0,0 +1,79 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 storage + +import ( + "fmt" + "sync" +) + +// Config defines a new storage engine configuration +type Config struct { + m map[string]interface{} + sync.RWMutex +} + +// NewConfig returns a new Config +func NewConfig(cfg map[string]interface{}) *Config { + if cfg == nil { + cfg = make(map[string]interface{}) + } + return &Config{ + m: cfg, + } +} + +// Add adds a new key/value pair to Config +func (c *Config) Add(key string, value interface{}) { + c.Lock() + defer c.Unlock() + c.m[key] = value +} + +// Get loads a configuration variable with its key, otherwise it returns an error. +func (c *Config) Get(key string) (interface{}, error) { + c.Lock() + defer c.Unlock() + value, ok := c.m[key] + if !ok { + return nil, fmt.Errorf("not found: %s", key) + } + return value, nil +} + +// Delete deletes a configuration variable with its key. +func (c *Config) Delete(key string) { + c.Lock() + defer c.Unlock() + delete(c.m, key) +} + +// Copy creates a thread-safe copy of the existing Config struct. +func (c *Config) Copy() *Config { + c.Lock() + defer c.Unlock() + n := &Config{ + m: make(map[string]interface{}), + } + for key, value := range c.m { + n.m[key] = value + } + return n +} + +// ToMap casts Config to map[string]interface{} type. +func (c *Config) ToMap() map[string]interface{} { + return c.Copy().m +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/engine.go b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/engine.go new file mode 100644 index 000000000..b3eaaa437 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/engine.go @@ -0,0 +1,107 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 storage + +import ( + "log" +) + +type TransferIterator interface { + Next() bool + + Export() ([]byte, error) + + Pop() error +} + +// Engine defines methods for a storage engine implementation. +type Engine interface { + // SetConfig sets a storage engine configuration. nil can be accepted, but + // it depends on the implementation. + SetConfig(*Config) + + // SetLogger sets a logger. nil can be accepted, but it depends on the implementation. + SetLogger(*log.Logger) + + // Start can be used to run background services before starting operation. + Start() error + + // NewEntry returns a new Entry interface implemented by the current storage + // engine implementation. + NewEntry() Entry + + // Name returns name of the current storage engine implementation. + Name() string + + // Fork creates an empty instance of an online engine by using the current + // configuration. + Fork(*Config) (Engine, error) + + // PutRaw inserts an encoded entry into the storage engine. + PutRaw(uint64, []byte) error + + // Put inserts a new Entry into the storage engine. + Put(uint64, Entry) error + + // GetRaw reads an encoded entry from the storage engine. + GetRaw(uint64) ([]byte, error) + + // Get reads an entry from the storage engine. + Get(uint64) (Entry, error) + + // GetTTL extracts TTL of an entry. + GetTTL(uint64) (int64, error) + + // GetLastAccess extracts LastAccess of an entry. + GetLastAccess(uint64) (int64, error) + + // GetKey extracts key of an entry. + GetKey(uint64) (string, error) + + // Delete deletes an entry from the storage engine. + Delete(uint64) error + + // UpdateTTL updates TTL of an entry. It returns ErrKeyNotFound, + // if the key doesn't exist. + UpdateTTL(uint64, Entry) error + + TransferIterator() TransferIterator + + Import([]byte, func(uint64, Entry) error) error + + // Stats returns metrics for an online storage engine. + Stats() Stats + + // Check returns true, if the key exists. + Check(uint64) bool + + // Range implements a loop over the storage engine + Range(func(uint64, Entry) bool) + + // RegexMatchOnKeys runs a regular expression over keys and loops over the result. + RegexMatchOnKeys(string, func(uint64, Entry) bool) error + + // Compaction reorganizes storage tables and reclaims wasted resources. + Compaction() (bool, error) + + // Close stops an online storage engine instance. It may free some of allocated + // resources. A storage engine implementation should be started again, but it + // depends on the implementation. + Close() error + + // Destroy stops an online storage engine instance and frees allocated resources. + // It should not be possible to reuse a destroyed storage engine. + Destroy() error +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/entry.go b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/entry.go new file mode 100644 index 000000000..290e53f4a --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/entry.go @@ -0,0 +1,54 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 storage + +// Entry interface defines methods for a storage entry. +type Entry interface { + // SetKey accepts strings as a key and inserts the key into the underlying + // data structure. + SetKey(string) + + // Key returns the key as string + Key() string + + // SetValue accepts a byte slice as a value and inserts the value into the + // underlying data structure. + SetValue([]byte) + + // Value returns the value as a byte slice. + Value() []byte + + // SetTTL sets TTL to an entry. + SetTTL(int64) + + // TTL returns the current TTL for an entry. + TTL() int64 + + // SetTimestamp sets the current timestamp to an entry. + SetTimestamp(int64) + + // Timestamp returns the current timestamp for an entry. + Timestamp() int64 + + SetLastAccess(int64) + + LastAccess() int64 + + // Encode encodes an entry into a binary form and returns the result. + Encode() []byte + + // Decode decodes a byte slice into an Entry. + Decode([]byte) +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/stats.go b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/stats.go new file mode 100644 index 000000000..2f5546277 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/stats.go @@ -0,0 +1,36 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 storage + +// Stats defines metrics exposed by a storage engine implementation. +type Stats struct { + // Currently allocated memory by the engine. + Allocated int + + // Used portion of allocated memory + Inuse int + + // Deleted portions of allocated memory. + Garbage int + + // Total number of keys hosted by the engine instance. + Length int + + // Number of tables hosted by the engine instance. + NumTables int + + // Any other metrics that's specific to an engine implementation. + Extras map[string]interface{} +} diff --git a/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/storage.go b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/storage.go new file mode 100644 index 000000000..7885f8464 --- /dev/null +++ b/plugins/traefik/vendor/github.com/buraksezer/olric/pkg/storage/storage.go @@ -0,0 +1,48 @@ +// Copyright 2018-2021 Burak Sezer +// +// 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 storage // import "github.com/buraksezer/olric/pkg/storage" + +import ( + "errors" + "fmt" + "plugin" +) + +// ErrKeyTooLarge is an error that indicates the given key is large than the determined key size. +// The current maximum key length is 256. +var ErrKeyTooLarge = errors.New("key too large") + +// ErrKeyNotFound is an error that indicates that the requested key could not be found in the DB. +var ErrKeyNotFound = errors.New("key not found") + +// ErrNotImplemented means that the interface implementation does not support +// the functionality required to fulfill the request. +var ErrNotImplemented = errors.New("not implemented yet") + +func LoadAsPlugin(pluginPath string) (Engine, error) { + plug, err := plugin.Open(pluginPath) + if err != nil { + return nil, fmt.Errorf("failed to open plugin: %w", err) + } + tmp, err := plug.Lookup("StorageEngines") + if err != nil { + return nil, fmt.Errorf("failed to lookup StorageEngines symbol: %w", err) + } + impl, ok := tmp.(Engine) + if !ok { + return nil, fmt.Errorf("unable to assert type to StorageEngines") + } + return impl, nil +} diff --git a/plugins/traefik/vendor/github.com/darkweak/souin/cache/surrogate/providers/clouflare.go b/plugins/traefik/vendor/github.com/darkweak/souin/cache/surrogate/providers/clouflare.go new file mode 100644 index 000000000..dfd9fd07e --- /dev/null +++ b/plugins/traefik/vendor/github.com/darkweak/souin/cache/surrogate/providers/clouflare.go @@ -0,0 +1,92 @@ +package providers + +import ( + "bytes" + "encoding/json" + "io/ioutil" + "net/http" + "strings" + + "github.com/darkweak/souin/configurationtypes" +) + +// CloudflareSurrogateStorage is the layer for Surrogate-key support storage +type CloudflareSurrogateStorage struct { + *baseStorage + providerAPIKey string + email string + zoneID string +} + +func generateCloudflareInstance(config configurationtypes.AbstractConfigurationInterface) *CloudflareSurrogateStorage { + cdn := config.GetDefaultCache().GetCDN() + f := &CloudflareSurrogateStorage{ + baseStorage: &baseStorage{}, + providerAPIKey: cdn.APIKey, + zoneID: cdn.ZoneID, + email: cdn.Email, + } + + f.init(config) + f.parent = f + + return f +} + +func (*CloudflareSurrogateStorage) getHeaderSeparator() string { + return "," +} + +// Store stores the response tags located in the first non empty supported header +func (c *CloudflareSurrogateStorage) Store(response *http.Response, cacheKey string) error { + defer func() { + response.Header.Del(surrogateKey) + response.Header.Del(surrogateControl) + }() + e := c.baseStorage.Store(response, cacheKey) + response.Header.Set(cacheTag, strings.Join(c.ParseHeaders(response.Header.Get(surrogateKey)), c.getHeaderSeparator())) + + return e +} + +func (*CloudflareSurrogateStorage) getOrderedSurrogateKeyHeadersCandidate() []string { + return []string{ + cacheTag, + surrogateKey, + } +} + +func processBatches(arr []string, req *http.Request) { + const maxPerBatch = 30 + for i := 0; i < len(arr); i += maxPerBatch { + j := i + maxPerBatch + if j > len(arr) { + j = len(arr) + } + + body, _ := json.Marshal(map[string]interface{}{"tags": arr[i:j]}) + req.Body = ioutil.NopCloser(bytes.NewBuffer(body)) + _, _ = new(http.Client).Do(req) + } +} + +// Purge purges the urls associated to the tags +func (c *CloudflareSurrogateStorage) Purge(header http.Header) (cacheKeys []string, surrogateKeys []string) { + keys, headers := c.baseStorage.Purge(header) + req, err := http.NewRequest( + http.MethodPost, + "https://api.cloudflare.com/client/v4/zones/"+c.zoneID+"/purge", + nil, + ) + if err == nil { + req.Header.Set("X-Auth-Email", c.email) + req.Header.Set("X-Auth-Key", c.providerAPIKey) + req.Header.Set("Content-Type", "application/json") + + go func() { + processBatches(headers, req) + }() + } + + return keys, headers +} diff --git a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/CHANGELOG.md b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/CHANGELOG.md index 9dc49bac2..aae5f0f9b 100644 --- a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/CHANGELOG.md +++ b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). +## [3.2103.2] - 2021-10-07 + +### Fixed + + - fix(compact): close vlog after the compaction at L0 has completed (#1752) + - fix(builder): put the upper limit on reallocation (#1748) + - deps: Bump github.com/google/flatbuffers to v1.12.1 (#1746) + - fix(levels): Avoid a deadlock when acquiring read locks in levels (#1744) + - fix(pubsub): avoid deadlock in publisher and subscriber (#1749) (#1751) + ## [3.2103.1] - 2021-07-08 ### Fixed diff --git a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/db.go b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/db.go index 7bedd1dec..3ac6a2d95 100644 --- a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/db.go +++ b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/db.go @@ -559,11 +559,6 @@ func (db *DB) close() (err error) { db.closers.pub.SignalAndWait() db.closers.cacheHealth.Signal() - // Now close the value log. - if vlogErr := db.vlog.Close(); vlogErr != nil { - err = y.Wrap(vlogErr, "DB.Close") - } - // Make sure that block writer is done pushing stuff into memtable! // Otherwise, you will have a race condition: we are trying to flush memtables // and remove them completely, while the block / memtable writer is still @@ -619,6 +614,11 @@ func (db *DB) close() (err error) { } } + // Now close the value log. + if vlogErr := db.vlog.Close(); vlogErr != nil { + err = y.Wrap(vlogErr, "DB.Close") + } + db.opt.Infof(db.LevelsToString()) if lcErr := db.lc.close(); err == nil { err = y.Wrap(lcErr, "DB.Close") @@ -1869,11 +1869,11 @@ func (db *DB) Subscribe(ctx context.Context, cb func(kv *KVList) error, matches } c := z.NewCloser(1) - recvCh, id := db.pub.newSubscriber(c, matches) + s := db.pub.newSubscriber(c, matches) slurp := func(batch *pb.KVList) error { for { select { - case kvs := <-recvCh: + case kvs := <-s.sendCh: batch.Kv = append(batch.Kv, kvs.Kv...) default: if len(batch.GetKv()) > 0 { @@ -1883,6 +1883,16 @@ func (db *DB) Subscribe(ctx context.Context, cb func(kv *KVList) error, matches } } } + + drain := func() { + for { + select { + case <-s.sendCh: + default: + return + } + } + } for { select { case <-c.HasBeenClosed(): @@ -1894,15 +1904,19 @@ func (db *DB) Subscribe(ctx context.Context, cb func(kv *KVList) error, matches return err case <-ctx.Done(): c.Done() - db.pub.deleteSubscriber(id) + atomic.StoreUint64(s.active, 0) + drain() + db.pub.deleteSubscriber(s.id) // Delete the subscriber to avoid further updates. return ctx.Err() - case batch := <-recvCh: + case batch := <-s.sendCh: err := slurp(batch) if err != nil { c.Done() + atomic.StoreUint64(s.active, 0) + drain() // Delete the subscriber if there is an error by the callback. - db.pub.deleteSubscriber(id) + db.pub.deleteSubscriber(s.id) return err } } diff --git a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/go.mod b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/go.mod index 997b9d536..28da3cc36 100644 --- a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/go.mod +++ b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/go.mod @@ -11,7 +11,7 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/golang/protobuf v1.3.1 github.com/golang/snappy v0.0.3 - github.com/google/flatbuffers v1.12.0 + github.com/google/flatbuffers v1.12.1 github.com/google/go-cmp v0.5.4 // indirect github.com/klauspost/compress v1.12.3 github.com/kr/pretty v0.1.0 // indirect diff --git a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/go.sum b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/go.sum index 258863751..cdeb960ea 100644 --- a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/go.sum +++ b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/go.sum @@ -34,8 +34,8 @@ github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/flatbuffers v1.12.0 h1:/PtAHvnBY4Kqnx/xCQ3OIV9uYcSFGScBsWI3Oogeh6w= -github.com/google/flatbuffers v1.12.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= +github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= diff --git a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/levels.go b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/levels.go index 637a3565d..1c625d1b3 100644 --- a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/levels.go +++ b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/levels.go @@ -1119,8 +1119,22 @@ func (s *levelsController) fillTablesL0ToL0(cd *compactDef) bool { cd.nextRange = keyRange{} cd.bot = nil - cd.lockLevels() - defer cd.unlockLevels() + // Because this level and next level are both level 0, we should NOT acquire + // the read lock twice, because it can result in a deadlock. So, we don't + // call compactDef.lockLevels, instead locking the level only once and + // directly here. + // + // As per godocs on RWMutex: + // If a goroutine holds a RWMutex for reading and another goroutine might + // call Lock, no goroutine should expect to be able to acquire a read lock + // until the initial read lock is released. In particular, this prohibits + // recursive read locking. This is to ensure that the lock eventually + // becomes available; a blocked Lock call excludes new readers from + // acquiring the lock. + y.AssertTrue(cd.thisLevel.level == 0) + y.AssertTrue(cd.nextLevel.level == 0) + s.levels[0].RLock() + defer s.levels[0].RUnlock() s.cstatus.Lock() defer s.cstatus.Unlock() diff --git a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/publisher.go b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/publisher.go index 6694433f2..f4c31b2ea 100644 --- a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/publisher.go +++ b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/publisher.go @@ -18,6 +18,7 @@ package badger import ( "sync" + "sync/atomic" "github.com/dgraph-io/badger/v3/pb" "github.com/dgraph-io/badger/v3/trie" @@ -26,9 +27,13 @@ import ( ) type subscriber struct { + id uint64 matches []pb.Match - sendCh chan<- *pb.KVList + sendCh chan *pb.KVList subCloser *z.Closer + // this will be atomic pointer which will be used to + // track whether the subscriber is active or not + active *uint64 } type publisher struct { @@ -106,26 +111,32 @@ func (p *publisher) publishUpdates(reqs requests) { } for id, kvs := range batchedUpdates { - p.subscribers[id].sendCh <- kvs + if atomic.LoadUint64(p.subscribers[id].active) == 1 { + p.subscribers[id].sendCh <- kvs + } } } -func (p *publisher) newSubscriber(c *z.Closer, matches []pb.Match) (<-chan *pb.KVList, uint64) { +func (p *publisher) newSubscriber(c *z.Closer, matches []pb.Match) subscriber { p.Lock() defer p.Unlock() ch := make(chan *pb.KVList, 1000) id := p.nextID // Increment next ID. p.nextID++ - p.subscribers[id] = subscriber{ + active := uint64(1) + s := subscriber{ + active: &active, + id: id, matches: matches, sendCh: ch, subCloser: c, } + p.subscribers[id] = s for _, m := range matches { p.indexer.AddMatch(m, id) } - return ch, id + return s } // cleanSubscribers stops all the subscribers. Ideally, It should be called while closing DB. diff --git a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/table/builder.go b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/table/builder.go index 8322bb86f..5bab48a72 100644 --- a/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/table/builder.go +++ b/plugins/traefik/vendor/github.com/dgraph-io/badger/v3/table/builder.go @@ -100,8 +100,12 @@ type Builder struct { func (b *Builder) allocate(need int) []byte { bb := b.curBlock if len(bb.data[bb.end:]) < need { - // We need to reallocate. + // We need to reallocate. 1GB is the max size that the allocator can allocate. + // While reallocating, if doubling exceeds that limit, then put the upper bound on it. sz := 2 * len(bb.data) + if sz > (1 << 30) { + sz = 1 << 30 + } if bb.end+need > sz { sz = bb.end + need } diff --git a/plugins/traefik/vendor/github.com/go-chi/stampede/LICENSE b/plugins/traefik/vendor/github.com/go-chi/stampede/LICENSE index d99f02ffa..767cb9dc2 100644 --- a/plugins/traefik/vendor/github.com/go-chi/stampede/LICENSE +++ b/plugins/traefik/vendor/github.com/go-chi/stampede/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015-present Peter Kieltyka (https://github.com/pkieltyka), Google Inc. +Copyright (c) 2015-Present https://github.com/go-chi authors MIT License diff --git a/plugins/traefik/vendor/github.com/go-chi/stampede/go.mod b/plugins/traefik/vendor/github.com/go-chi/stampede/go.mod index 15741a394..837212b9b 100644 --- a/plugins/traefik/vendor/github.com/go-chi/stampede/go.mod +++ b/plugins/traefik/vendor/github.com/go-chi/stampede/go.mod @@ -4,6 +4,7 @@ go 1.14 require ( github.com/cespare/xxhash/v2 v2.1.1 + github.com/go-chi/cors v1.2.0 // indirect github.com/hashicorp/golang-lru v0.5.5-0.20200511160909-eb529947af53 github.com/stretchr/testify v1.5.1 ) diff --git a/plugins/traefik/vendor/github.com/go-chi/stampede/go.sum b/plugins/traefik/vendor/github.com/go-chi/stampede/go.sum index 5e6f91f15..72847624a 100644 --- a/plugins/traefik/vendor/github.com/go-chi/stampede/go.sum +++ b/plugins/traefik/vendor/github.com/go-chi/stampede/go.sum @@ -2,6 +2,8 @@ github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-chi/cors v1.2.0 h1:tV1g1XENQ8ku4Bq3K9ub2AtgG+p16SmzeMSGTwrOKdE= +github.com/go-chi/cors v1.2.0/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= github.com/hashicorp/golang-lru v0.5.5-0.20200511160909-eb529947af53 h1:mcyf48FjrlX8JRXvy5v3LPeXBv+Um6WvoKS+kknfgIk= github.com/hashicorp/golang-lru v0.5.5-0.20200511160909-eb529947af53/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/plugins/traefik/vendor/github.com/go-chi/stampede/http.go b/plugins/traefik/vendor/github.com/go-chi/stampede/http.go index f0d92d6d4..1b5dc7125 100644 --- a/plugins/traefik/vendor/github.com/go-chi/stampede/http.go +++ b/plugins/traefik/vendor/github.com/go-chi/stampede/http.go @@ -11,6 +11,17 @@ import ( "time" ) +var stripOutHeaders = []string{ + "Access-Control-Allow-Credentials", + "Access-Control-Allow-Headers", + "Access-Control-Allow-Methods", + "Access-Control-Allow-Origin", + "Access-Control-Expose-Headers", + "Access-Control-Max-Age", + "Access-Control-Request-Headers", + "Access-Control-Request-Method", +} + func Handler(cacheSize int, ttl time.Duration, paths ...string) func(next http.Handler) http.Handler { keyFunc := func(r *http.Request) uint64 { // Read the request payload, and then setup buffer for future reader @@ -110,8 +121,21 @@ func HandlerWithKey(cacheSize int, ttl time.Duration, keyFunc ...func(r *http.Re panic("stampede: handler received unexpected response value type") } - for k, v := range resp.headers { - w.Header().Set(k, strings.Join(v, ", ")) + header := w.Header() + + nextHeader: + for k := range resp.headers { + for _, match := range stripOutHeaders { + // Prevent any header in stripOutHeaders to override the current + // value of that header. This is important when you don't want a + // header to affect all subsequent requests (for instance, when + // working with several CORS domains, you don't want the first domain + // to be recorded an to be printed in all responses) + if match == k { + continue nextHeader + } + } + header[k] = resp.headers[k] } w.WriteHeader(resp.status) diff --git a/plugins/traefik/vendor/go.uber.org/zap/CHANGELOG.md b/plugins/traefik/vendor/go.uber.org/zap/CHANGELOG.md index fdfef8808..794ee303e 100644 --- a/plugins/traefik/vendor/go.uber.org/zap/CHANGELOG.md +++ b/plugins/traefik/vendor/go.uber.org/zap/CHANGELOG.md @@ -1,4 +1,16 @@ # Changelog +All notable changes to this project will be documented in this file. + +This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## 1.19.1 (8 Sep 2021) + +### Fixed +* [#1001][]: JSON: Fix complex number encoding with negative imaginary part. Thanks to @hemantjadon. +* [#1003][]: JSON: Fix inaccurate precision when encoding float32. + +[#1001]: https://github.com/uber-go/zap/pull/1001 +[#1003]: https://github.com/uber-go/zap/pull/1003 ## 1.19.0 (9 Aug 2021) diff --git a/plugins/traefik/vendor/go.uber.org/zap/go.mod b/plugins/traefik/vendor/go.uber.org/zap/go.mod index 9455c99cc..3480ab4e1 100644 --- a/plugins/traefik/vendor/go.uber.org/zap/go.mod +++ b/plugins/traefik/vendor/go.uber.org/zap/go.mod @@ -7,7 +7,7 @@ require ( github.com/pkg/errors v0.8.1 github.com/stretchr/testify v1.7.0 go.uber.org/atomic v1.7.0 - go.uber.org/goleak v1.1.10 + go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 go.uber.org/multierr v1.6.0 gopkg.in/yaml.v2 v2.2.8 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect diff --git a/plugins/traefik/vendor/go.uber.org/zap/go.sum b/plugins/traefik/vendor/go.uber.org/zap/go.sum index 9031a6131..1658da435 100644 --- a/plugins/traefik/vendor/go.uber.org/zap/go.sum +++ b/plugins/traefik/vendor/go.uber.org/zap/go.sum @@ -14,31 +14,48 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= -go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q7xh/zOyNnYUtDKaQ3x0E= -golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/plugins/traefik/vendor/go.uber.org/zap/zapcore/json_encoder.go b/plugins/traefik/vendor/go.uber.org/zap/zapcore/json_encoder.go index 5cf7d917e..af220d9b4 100644 --- a/plugins/traefik/vendor/go.uber.org/zap/zapcore/json_encoder.go +++ b/plugins/traefik/vendor/go.uber.org/zap/zapcore/json_encoder.go @@ -128,6 +128,11 @@ func (enc *jsonEncoder) AddFloat64(key string, val float64) { enc.AppendFloat64(val) } +func (enc *jsonEncoder) AddFloat32(key string, val float32) { + enc.addKey(key) + enc.AppendFloat32(val) +} + func (enc *jsonEncoder) AddInt64(key string, val int64) { enc.addKey(key) enc.AppendInt64(val) @@ -228,7 +233,11 @@ func (enc *jsonEncoder) AppendComplex128(val complex128) { // Because we're always in a quoted string, we can use strconv without // special-casing NaN and +/-Inf. enc.buf.AppendFloat(r, 64) - enc.buf.AppendByte('+') + // If imaginary part is less than 0, minus (-) sign is added by default + // by AppendFloat. + if i >= 0 { + enc.buf.AppendByte('+') + } enc.buf.AppendFloat(i, 64) enc.buf.AppendByte('i') enc.buf.AppendByte('"') @@ -293,7 +302,6 @@ func (enc *jsonEncoder) AppendUint64(val uint64) { } func (enc *jsonEncoder) AddComplex64(k string, v complex64) { enc.AddComplex128(k, complex128(v)) } -func (enc *jsonEncoder) AddFloat32(k string, v float32) { enc.AddFloat64(k, float64(v)) } func (enc *jsonEncoder) AddInt(k string, v int) { enc.AddInt64(k, int64(v)) } func (enc *jsonEncoder) AddInt32(k string, v int32) { enc.AddInt64(k, int64(v)) } func (enc *jsonEncoder) AddInt16(k string, v int16) { enc.AddInt64(k, int64(v)) } diff --git a/plugins/traefik/vendor/golang.org/x/net/context/go17.go b/plugins/traefik/vendor/golang.org/x/net/context/go17.go index d20f52b7d..344bd1433 100644 --- a/plugins/traefik/vendor/golang.org/x/net/context/go17.go +++ b/plugins/traefik/vendor/golang.org/x/net/context/go17.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.7 // +build go1.7 package context diff --git a/plugins/traefik/vendor/golang.org/x/net/context/go19.go b/plugins/traefik/vendor/golang.org/x/net/context/go19.go index d88bd1db1..64d31ecc3 100644 --- a/plugins/traefik/vendor/golang.org/x/net/context/go19.go +++ b/plugins/traefik/vendor/golang.org/x/net/context/go19.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.9 // +build go1.9 package context diff --git a/plugins/traefik/vendor/golang.org/x/net/context/pre_go17.go b/plugins/traefik/vendor/golang.org/x/net/context/pre_go17.go index 0f35592df..5270db5db 100644 --- a/plugins/traefik/vendor/golang.org/x/net/context/pre_go17.go +++ b/plugins/traefik/vendor/golang.org/x/net/context/pre_go17.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !go1.7 // +build !go1.7 package context diff --git a/plugins/traefik/vendor/golang.org/x/net/context/pre_go19.go b/plugins/traefik/vendor/golang.org/x/net/context/pre_go19.go index b105f80be..1f9715341 100644 --- a/plugins/traefik/vendor/golang.org/x/net/context/pre_go19.go +++ b/plugins/traefik/vendor/golang.org/x/net/context/pre_go19.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !go1.9 // +build !go1.9 package context diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr.go index 0a73e277e..4bdaaaf1a 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go index 14dbb3ad4..0d30e0a0f 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd // +build aix darwin dragonfly freebsd netbsd openbsd package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go index bac66811d..623cf30f4 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (arm || mips || mipsle || 386) && linux // +build arm mips mipsle 386 // +build linux diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go index 27be0efac..1ba43101f 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (arm64 || amd64 || ppc64 || ppc64le || mips64 || mips64le || riscv64 || s390x) && linux // +build arm64 amd64 ppc64 ppc64le mips64 mips64le riscv64 s390x // +build linux diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go index 7dedd430e..d3dbe1b8e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build amd64 -// +build solaris +//go:build amd64 && solaris +// +build amd64,solaris package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go index 8328b7d19..1d9f2ed62 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!zos package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_unix.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_unix.go index c2b2b6595..aa1b06203 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_unix.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_zos_s390x.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_zos_s390x.go new file mode 100644 index 000000000..98be146bc --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/cmsghdr_zos_s390x.go @@ -0,0 +1,25 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package socket + +import "syscall" + +func (h *cmsghdr) set(l, lvl, typ int) { + h.Len = int32(l) + h.Level = int32(lvl) + h.Type = int32(typ) +} + +func controlHeaderLen() int { + return syscall.CmsgLen(0) +} + +func controlMessageLen(dataLen int) int { + return syscall.CmsgLen(dataLen) +} + +func controlMessageSpace(dataLen int) int { + return syscall.CmsgSpace(dataLen) +} diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/error_unix.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/error_unix.go index f14872d3d..78f412904 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/error_unix.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/error_unix.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_32bit.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_32bit.go index 05d6082d1..1f42d034d 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_32bit.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_32bit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (arm || mips || mipsle || 386) && (darwin || dragonfly || freebsd || linux || netbsd || openbsd) // +build arm mips mipsle 386 // +build darwin dragonfly freebsd linux netbsd openbsd diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_64bit.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_64bit.go index dfeda752b..3dc5def2b 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_64bit.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_64bit.go @@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (arm64 || amd64 || ppc64 || ppc64le || mips64 || mips64le || riscv64 || s390x) && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || zos) // +build arm64 amd64 ppc64 ppc64le mips64 mips64le riscv64 s390x -// +build aix darwin dragonfly freebsd linux netbsd openbsd +// +build aix darwin dragonfly freebsd linux netbsd openbsd zos package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_solaris_64bit.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_solaris_64bit.go index 8d17a40c4..f7da2bc4d 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_solaris_64bit.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_solaris_64bit.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build amd64 -// +build solaris +//go:build amd64 && solaris +// +build amd64,solaris package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_stub.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_stub.go index a746e90e3..14caf5248 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/iovec_stub.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!zos package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go index 1a7f2792f..113e773cd 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !aix && !linux && !netbsd // +build !aix,!linux,!netbsd package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go index f1100683a..5025a0f75 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || linux || netbsd // +build aix linux netbsd package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_bsd.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_bsd.go index 77f44c1f1..25f6847f9 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_bsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_bsd.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd // +build aix darwin dragonfly freebsd netbsd openbsd package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go index c5562dd66..5b8e00f1c 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || netbsd // +build aix darwin dragonfly freebsd netbsd package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_linux_32bit.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_linux_32bit.go index a7a5987c8..2e09e2669 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_linux_32bit.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_linux_32bit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (arm || mips || mipsle || 386) && linux // +build arm mips mipsle 386 // +build linux diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go index e731833a2..c9c592ddb 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build (arm64 || amd64 || ppc64 || ppc64le || mips64 || mips64le || riscv64 || s390x) && linux // +build arm64 amd64 ppc64 ppc64le mips64 mips64le riscv64 s390x // +build linux diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_solaris_64bit.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_solaris_64bit.go index 6465b2073..3098f5d78 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_solaris_64bit.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_solaris_64bit.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build amd64 -// +build solaris +//go:build amd64 && solaris +// +build amd64,solaris package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_stub.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_stub.go index 873490a7a..eb79151f6 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_stub.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!zos package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_zos_s390x.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_zos_s390x.go new file mode 100644 index 000000000..324e9ee7d --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/msghdr_zos_s390x.go @@ -0,0 +1,36 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build s390x && zos +// +build s390x,zos + +package socket + +import "unsafe" + +func (h *msghdr) pack(vs []iovec, bs [][]byte, oob []byte, sa []byte) { + for i := range vs { + vs[i].set(bs[i]) + } + if len(vs) > 0 { + h.Iov = &vs[0] + h.Iovlen = int32(len(vs)) + } + if len(oob) > 0 { + h.Control = (*byte)(unsafe.Pointer(&oob[0])) + h.Controllen = uint32(len(oob)) + } + if sa != nil { + h.Name = (*byte)(unsafe.Pointer(&sa[0])) + h.Namelen = uint32(len(sa)) + } +} + +func (h *msghdr) controllen() int { + return int(h.Controllen) +} + +func (h *msghdr) flags() int { + return int(h.Flags) +} diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/norace.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/norace.go index 9519ffbba..de0ad420f 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/norace.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/norace.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !race // +build !race package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/race.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/race.go index df60c62ff..f0a28a625 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/race.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/race.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build race // +build race package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn.go index b07b89005..87e81071c 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn.go @@ -17,18 +17,45 @@ type Conn struct { c syscall.RawConn } +// tcpConn is an interface implemented by net.TCPConn. +// It can be used for interface assertions to check if a net.Conn is a TCP connection. +type tcpConn interface { + SyscallConn() (syscall.RawConn, error) + SetLinger(int) error +} + +var _ tcpConn = (*net.TCPConn)(nil) + +// udpConn is an interface implemented by net.UDPConn. +// It can be used for interface assertions to check if a net.Conn is a UDP connection. +type udpConn interface { + SyscallConn() (syscall.RawConn, error) + ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *net.UDPAddr, err error) +} + +var _ udpConn = (*net.UDPConn)(nil) + +// ipConn is an interface implemented by net.IPConn. +// It can be used for interface assertions to check if a net.Conn is an IP connection. +type ipConn interface { + SyscallConn() (syscall.RawConn, error) + ReadMsgIP(b, oob []byte) (n, oobn, flags int, addr *net.IPAddr, err error) +} + +var _ ipConn = (*net.IPConn)(nil) + // NewConn returns a new raw connection. func NewConn(c net.Conn) (*Conn, error) { var err error var cc Conn switch c := c.(type) { - case *net.TCPConn: + case tcpConn: cc.network = "tcp" cc.c, err = c.SyscallConn() - case *net.UDPConn: + case udpConn: cc.network = "udp" cc.c, err = c.SyscallConn() - case *net.IPConn: + case ipConn: cc.network = "ip" cc.c, err = c.SyscallConn() default: diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go index d01fc4c7d..5d90de118 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux // +build linux package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_msg.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_msg.go index d5ae3f8e1..dfed9a8da 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_msg.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_msg.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows zos package socket @@ -24,7 +25,7 @@ func (c *Conn) recvMsg(m *Message, flags int) error { var n int fn := func(s uintptr) bool { n, operr = recvmsg(s, &h, flags) - if operr == syscall.EAGAIN { + if operr == syscall.EAGAIN || operr == syscall.EWOULDBLOCK { return false } return true @@ -61,7 +62,7 @@ func (c *Conn) sendMsg(m *Message, flags int) error { var n int fn := func(s uintptr) bool { n, operr = sendmsg(s, &h, flags) - if operr == syscall.EAGAIN { + if operr == syscall.EAGAIN || operr == syscall.EWOULDBLOCK { return false } return true diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go index fe5bb942b..02f328556 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !linux // +build !linux package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go index b8cea6fe5..dd785877b 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows,!zos package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_bsd.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_bsd.go index d432835b4..b6cd77088 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_bsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_bsd.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || openbsd // +build aix darwin dragonfly freebsd openbsd package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_const_unix.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_const_unix.go index 43797d6e5..f077b2f11 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_const_unix.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_const_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_const_zos.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_const_zos.go new file mode 100644 index 000000000..304862954 --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_const_zos.go @@ -0,0 +1,18 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build zos +// +build zos + +package socket + +import "syscall" + +const ( + sysAF_UNSPEC = syscall.AF_UNSPEC + sysAF_INET = syscall.AF_INET + sysAF_INET6 = syscall.AF_INET6 + + sysSOCK_RAW = syscall.SOCK_RAW +) diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_linkname.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_linkname.go index 61c3f38a5..21734af4b 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_linkname.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_linkname.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || (go1.12 && darwin) // +build aix go1.12,darwin package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_linux.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_linux.go index 8b03cd6de..76f5b8ae5 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_linux.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_linux.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux && !s390x && !386 // +build linux,!s390x,!386 package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_linux_riscv64.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_linux_riscv64.go index 64f69f1dc..5b128fbb2 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_linux_riscv64.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_linux_riscv64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build riscv64 // +build riscv64 package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_posix.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_posix.go index 22eae809c..25ded2176 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_posix.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_posix.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows zos package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_stub.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_stub.go index 8e1e07427..dc7bb389b 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_stub.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows,!zos package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_unix.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_unix.go index 0eb71283f..c98ebae54 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_unix.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build dragonfly || freebsd || (linux && !s390x && !386) || netbsd || openbsd // +build dragonfly freebsd linux,!s390x,!386 netbsd openbsd package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_zos_s390x.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_zos_s390x.go new file mode 100644 index 000000000..1e38b9223 --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_zos_s390x.go @@ -0,0 +1,38 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package socket + +import ( + "syscall" + "unsafe" +) + +func syscall_syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) +func syscall_syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) + +func probeProtocolStack() int { + return 4 // sizeof(int) on GOOS=zos GOARCH=s390x +} + +func getsockopt(s uintptr, level, name int, b []byte) (int, error) { + l := uint32(len(b)) + _, _, errno := syscall_syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0) + return int(l), errnoErr(errno) +} + +func setsockopt(s uintptr, level, name int, b []byte) error { + _, _, errno := syscall_syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0) + return errnoErr(errno) +} + +func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { + n, _, errno := syscall_syscall(syscall.SYS___RECVMSG_A, s, uintptr(unsafe.Pointer(h)), uintptr(flags)) + return int(n), errnoErr(errno) +} + +func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { + n, _, errno := syscall_syscall(syscall.SYS___SENDMSG_A, s, uintptr(unsafe.Pointer(h)), uintptr(flags)) + return int(n), errnoErr(errno) +} diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_zos_s390x.s b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_zos_s390x.s new file mode 100644 index 000000000..60d5839c2 --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/sys_zos_s390x.s @@ -0,0 +1,11 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "textflag.h" + +TEXT ·syscall_syscall(SB),NOSPLIT,$0 + JMP syscall·_syscall(SB) + +TEXT ·syscall_syscall6(SB),NOSPLIT,$0 + JMP syscall·_syscall6(SB) diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_aix_ppc64.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_aix_ppc64.go index 93d923ad7..79f3bdd5b 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_aix_ppc64.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_aix_ppc64.go @@ -2,6 +2,7 @@ // cgo -godefs defs_aix.go // Added for go1.11 compatibility +//go:build aix // +build aix package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_linux_riscv64.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_linux_riscv64.go index 8640c03e4..12ec2e42b 100644 --- a/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_linux_riscv64.go +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_linux_riscv64.go @@ -1,6 +1,7 @@ // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs defs_linux.go +//go:build riscv64 // +build riscv64 package socket diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_openbsd_mips64.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_openbsd_mips64.go new file mode 100644 index 000000000..011283240 --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_openbsd_mips64.go @@ -0,0 +1,50 @@ +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs defs_openbsd.go + +package socket + +type iovec struct { + Base *byte + Len uint64 +} + +type msghdr struct { + Name *byte + Namelen uint32 + Iov *iovec + Iovlen uint32 + Control *byte + Controllen uint32 + Flags int32 +} + +type cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type sockaddrInet struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type sockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +const ( + sizeofIovec = 0x10 + sizeofMsghdr = 0x30 + + sizeofSockaddrInet = 0x10 + sizeofSockaddrInet6 = 0x1c +) diff --git a/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_zos_s390x.go b/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_zos_s390x.go new file mode 100644 index 000000000..514ca3754 --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/internal/socket/zsys_zos_s390x.go @@ -0,0 +1,32 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package socket + +type iovec struct { + Base *byte + Len uint64 +} + +type msghdr struct { + Name *byte + Iov *iovec + Control *byte + Flags int32 + Namelen uint32 + Iovlen int32 + Controllen uint32 +} + +type cmsghdr struct { + Len int32 + Level int32 + Type int32 +} + +const ( + sizeofCmsghdr = 12 + sizeofSockaddrInet = 16 + sizeofSockaddrInet6 = 28 +) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/control_bsd.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/control_bsd.go index 69c4f553c..6fef740f2 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/control_bsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/control_bsd.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd // +build aix darwin dragonfly freebsd netbsd openbsd package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/control_pktinfo.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/control_pktinfo.go index 425338f35..0e748dbdc 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/control_pktinfo.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/control_pktinfo.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin || linux || solaris // +build darwin linux solaris package ipv4 @@ -12,11 +13,13 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" ) func marshalPacketInfo(b []byte, cm *ControlMessage) []byte { m := socket.ControlMessage(b) - m.MarshalHeader(iana.ProtocolIP, sysIP_PKTINFO, sizeofInetPktinfo) + m.MarshalHeader(iana.ProtocolIP, unix.IP_PKTINFO, sizeofInetPktinfo) if cm != nil { pi := (*inetPktinfo)(unsafe.Pointer(&m.Data(sizeofInetPktinfo)[0])) if ip := cm.Src.To4(); ip != nil { diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/control_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/control_stub.go index a0c049d68..f27322c3e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/control_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/control_stub.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows,!zos package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/control_unix.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/control_unix.go index b27fa4903..edce30f12 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/control_unix.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/control_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/control_zos.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/control_zos.go new file mode 100644 index 000000000..de11c42e5 --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/control_zos.go @@ -0,0 +1,88 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ipv4 + +import ( + "net" + "unsafe" + + "golang.org/x/net/internal/iana" + "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" +) + +func marshalPacketInfo(b []byte, cm *ControlMessage) []byte { + m := socket.ControlMessage(b) + m.MarshalHeader(iana.ProtocolIP, unix.IP_PKTINFO, sizeofInetPktinfo) + if cm != nil { + pi := (*inetPktinfo)(unsafe.Pointer(&m.Data(sizeofInetPktinfo)[0])) + if ip := cm.Src.To4(); ip != nil { + copy(pi.Addr[:], ip) + } + if cm.IfIndex > 0 { + pi.setIfindex(cm.IfIndex) + } + } + return m.Next(sizeofInetPktinfo) +} + +func parsePacketInfo(cm *ControlMessage, b []byte) { + pi := (*inetPktinfo)(unsafe.Pointer(&b[0])) + cm.IfIndex = int(pi.Ifindex) + if len(cm.Dst) < net.IPv4len { + cm.Dst = make(net.IP, net.IPv4len) + } + copy(cm.Dst, pi.Addr[:]) +} + +func setControlMessage(c *socket.Conn, opt *rawOpt, cf ControlFlags, on bool) error { + opt.Lock() + defer opt.Unlock() + if so, ok := sockOpts[ssoReceiveTTL]; ok && cf&FlagTTL != 0 { + if err := so.SetInt(c, boolint(on)); err != nil { + return err + } + if on { + opt.set(FlagTTL) + } else { + opt.clear(FlagTTL) + } + } + if so, ok := sockOpts[ssoPacketInfo]; ok { + if cf&(FlagSrc|FlagDst|FlagInterface) != 0 { + if err := so.SetInt(c, boolint(on)); err != nil { + return err + } + if on { + opt.set(cf & (FlagSrc | FlagDst | FlagInterface)) + } else { + opt.clear(cf & (FlagSrc | FlagDst | FlagInterface)) + } + } + } else { + if so, ok := sockOpts[ssoReceiveDst]; ok && cf&FlagDst != 0 { + if err := so.SetInt(c, boolint(on)); err != nil { + return err + } + if on { + opt.set(FlagDst) + } else { + opt.clear(FlagDst) + } + } + if so, ok := sockOpts[ssoReceiveInterface]; ok && cf&FlagInterface != 0 { + if err := so.SetInt(c, boolint(on)); err != nil { + return err + } + if on { + opt.set(FlagInterface) + } else { + opt.clear(FlagInterface) + } + } + } + return nil +} diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/icmp_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/icmp_stub.go index 21bb29ab3..cd4ee6e1c 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/icmp_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/icmp_stub.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !linux // +build !linux package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/payload_cmsg.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/payload_cmsg.go index e7614661d..1bb370e25 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/payload_cmsg.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/payload_cmsg.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/payload_nocmsg.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/payload_nocmsg.go index 1116256f2..53f0794eb 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/payload_nocmsg.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/payload_nocmsg.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!zos package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sockopt_posix.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sockopt_posix.go index dea64519d..eb07c1c02 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sockopt_posix.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sockopt_posix.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows zos package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sockopt_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sockopt_stub.go index 37d4806b3..cf036893b 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sockopt_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sockopt_stub.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows,!zos package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_aix.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_aix.go index 3d1201e6d..7b65dd6ef 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_aix.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_aix.go @@ -3,6 +3,7 @@ // license that can be found in the LICENSE file. // Added for go1.11 compatibility +//go:build aix // +build aix package ipv4 @@ -13,26 +14,28 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" ) var ( ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, + ctlTTL: {unix.IP_RECVTTL, 1, marshalTTL, parseTTL}, + ctlDst: {unix.IP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, + ctlInterface: {unix.IP_RECVINTERFACE, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, } sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 1}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 1}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVDSTADDR, Len: 4}}, - ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVIF, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, + ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TOS, Len: 4}}, + ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TTL, Len: 4}}, + ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_TTL, Len: 1}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_IF, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_LOOP, Len: 1}}, + ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVTTL, Len: 4}}, + ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVDSTADDR, Len: 4}}, + ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVINTERFACE, Len: 4}}, + ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_HDRINCL, Len: 4}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, } ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreq.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreq.go index 76d670aca..22322b387 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreq.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreq.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || windows // +build aix darwin dragonfly freebsd netbsd openbsd solaris windows package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreq_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreq_stub.go index 6dc339ce6..fde640142 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreq_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreq_stub.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !aix && !darwin && !dragonfly && !freebsd && !netbsd && !openbsd && !solaris && !windows // +build !aix,!darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!windows package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreqn.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreqn.go index 1f24f69f3..fbfe4af69 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreqn.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreqn.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin || freebsd || linux // +build darwin freebsd linux package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreqn_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreqn_stub.go index 48ef55624..dcb15f25a 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreqn_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_asmreqn_stub.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !darwin && !freebsd && !linux // +build !darwin,!freebsd,!linux package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_bpf.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_bpf.go index 5c03dce3b..fb11e324e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_bpf.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_bpf.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux // +build linux package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_bpf_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_bpf_stub.go index 5c9864271..fc53a0d33 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_bpf_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_bpf_stub.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !linux // +build !linux package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_bsd.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_bsd.go index 58256dd9d..e8299b414 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_bsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_bsd.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build netbsd || openbsd // +build netbsd openbsd package ipv4 @@ -12,26 +13,28 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" ) var ( ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, + ctlTTL: {unix.IP_RECVTTL, 1, marshalTTL, parseTTL}, + ctlDst: {unix.IP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, + ctlInterface: {unix.IP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, } sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 1}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 1}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVDSTADDR, Len: 4}}, - ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVIF, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, + ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TOS, Len: 4}}, + ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TTL, Len: 4}}, + ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_TTL, Len: 1}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_IF, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_LOOP, Len: 1}}, + ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVTTL, Len: 4}}, + ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVDSTADDR, Len: 4}}, + ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVIF, Len: 4}}, + ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_HDRINCL, Len: 4}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, } ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_darwin.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_darwin.go index ac213c735..f6bf8eddb 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_darwin.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_darwin.go @@ -11,34 +11,36 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" ) var ( ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - ctlPacketInfo: {sysIP_PKTINFO, sizeofInetPktinfo, marshalPacketInfo, parsePacketInfo}, + ctlTTL: {unix.IP_RECVTTL, 1, marshalTTL, parseTTL}, + ctlDst: {unix.IP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, + ctlInterface: {unix.IP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, + ctlPacketInfo: {unix.IP_PKTINFO, sizeofInetPktinfo, marshalPacketInfo, parsePacketInfo}, } sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 1}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: sizeofIPMreqn}, typ: ssoTypeIPMreqn}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 4}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVDSTADDR, Len: 4}}, - ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVIF, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoStripHeader: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_STRIPHDR, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoPacketInfo: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVPKTINFO, Len: 4}}, + ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TOS, Len: 4}}, + ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TTL, Len: 4}}, + ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_TTL, Len: 1}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_IF, Len: sizeofIPMreqn}, typ: ssoTypeIPMreqn}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_LOOP, Len: 4}}, + ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVTTL, Len: 4}}, + ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVDSTADDR, Len: 4}}, + ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVIF, Len: 4}}, + ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_HDRINCL, Len: 4}}, + ssoStripHeader: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_STRIPHDR, Len: 4}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoPacketInfo: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVPKTINFO, Len: 4}}, } ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_dragonfly.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_dragonfly.go index 859764f33..f34925c05 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_dragonfly.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_dragonfly.go @@ -10,26 +10,28 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" ) var ( ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, + ctlTTL: {unix.IP_RECVTTL, 1, marshalTTL, parseTTL}, + ctlDst: {unix.IP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, + ctlInterface: {unix.IP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, } sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 1}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 4}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVDSTADDR, Len: 4}}, - ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVIF, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, + ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TOS, Len: 4}}, + ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TTL, Len: 4}}, + ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_TTL, Len: 1}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_IF, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_LOOP, Len: 4}}, + ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVTTL, Len: 4}}, + ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVDSTADDR, Len: 4}}, + ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVIF, Len: 4}}, + ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_HDRINCL, Len: 4}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, } ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_freebsd.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_freebsd.go index 482873d9a..cba906302 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_freebsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_freebsd.go @@ -13,38 +13,40 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" ) var ( ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, + ctlTTL: {unix.IP_RECVTTL, 1, marshalTTL, parseTTL}, + ctlDst: {unix.IP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, + ctlInterface: {unix.IP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, } sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 1}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 4}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVDSTADDR, Len: 4}}, - ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVIF, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TOS, Len: 4}}, + ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TTL, Len: 4}}, + ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_TTL, Len: 1}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_IF, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_LOOP, Len: 4}}, + ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVTTL, Len: 4}}, + ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVDSTADDR, Len: 4}}, + ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVIF, Len: 4}}, + ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_HDRINCL, Len: 4}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, } ) func init() { freebsdVersion, _ = syscall.SysctlUint32("kern.osreldate") if freebsdVersion >= 1000000 { - sockOpts[ssoMulticastInterface] = &sockOpt{Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: sizeofIPMreqn}, typ: ssoTypeIPMreqn} + sockOpts[ssoMulticastInterface] = &sockOpt{Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_IF, Len: sizeofIPMreqn}, typ: ssoTypeIPMreqn} } if runtime.GOOS == "freebsd" && runtime.GOARCH == "386" { archs, _ := syscall.Sysctl("kern.supported_archs") diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_linux.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_linux.go index cf755c7fb..a0631ac92 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_linux.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_linux.go @@ -11,31 +11,32 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + "golang.org/x/sys/unix" ) var ( ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_TTL, 1, marshalTTL, parseTTL}, - ctlPacketInfo: {sysIP_PKTINFO, sizeofInetPktinfo, marshalPacketInfo, parsePacketInfo}, + ctlTTL: {unix.IP_TTL, 1, marshalTTL, parseTTL}, + ctlPacketInfo: {unix.IP_PKTINFO, sizeofInetPktinfo, marshalPacketInfo, parsePacketInfo}, } sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 4}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: sizeofIPMreqn}, typ: ssoTypeIPMreqn}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 4}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoPacketInfo: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_PKTINFO, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolReserved, Name: sysICMP_FILTER, Len: sizeofICMPFilter}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TOS, Len: 4}}, + ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TTL, Len: 4}}, + ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_TTL, Len: 4}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_IF, Len: sizeofIPMreqn}, typ: ssoTypeIPMreqn}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_LOOP, Len: 4}}, + ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVTTL, Len: 4}}, + ssoPacketInfo: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_PKTINFO, Len: 4}}, + ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_HDRINCL, Len: 4}}, + ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolReserved, Name: unix.ICMP_FILTER, Len: sizeofICMPFilter}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, ssoAttachFilter: {Option: socket.Option{Level: unix.SOL_SOCKET, Name: unix.SO_ATTACH_FILTER, Len: unix.SizeofSockFprog}}, } ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_solaris.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_solaris.go index 832fef1e2..b79b69583 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_solaris.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_solaris.go @@ -11,29 +11,31 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" ) var ( ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 4, marshalTTL, parseTTL}, - ctlPacketInfo: {sysIP_PKTINFO, sizeofInetPktinfo, marshalPacketInfo, parsePacketInfo}, + ctlTTL: {unix.IP_RECVTTL, 4, marshalTTL, parseTTL}, + ctlPacketInfo: {unix.IP_PKTINFO, sizeofInetPktinfo, marshalPacketInfo, parsePacketInfo}, } sockOpts = map[int]sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 1}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 1}}, - ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVTTL, Len: 4}}, - ssoPacketInfo: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_RECVPKTINFO, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TOS, Len: 4}}, + ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TTL, Len: 4}}, + ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_TTL, Len: 1}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_IF, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_LOOP, Len: 1}}, + ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVTTL, Len: 4}}, + ssoPacketInfo: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVPKTINFO, Len: 4}}, + ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_HDRINCL, Len: 4}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, } ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_ssmreq.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_ssmreq.go index eeced7f31..6a4e7abf9 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_ssmreq.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_ssmreq.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin || freebsd || linux || solaris // +build darwin freebsd linux solaris package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_ssmreq_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_ssmreq_stub.go index c0921674b..157159fd5 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_ssmreq_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_ssmreq_stub.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !darwin && !freebsd && !linux && !solaris // +build !darwin,!freebsd,!linux,!solaris package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_stub.go index b9c85b334..d55085165 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_stub.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows,!zos package ipv4 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_windows.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_windows.go index b0913d539..c5e950633 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_windows.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_windows.go @@ -7,34 +7,15 @@ package ipv4 import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/windows" ) const ( - // See ws2tcpip.h. - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_DONTFRAGMENT = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0xf - sysIP_DROP_SOURCE_MEMBERSHIP = 0x10 - sysIP_PKTINFO = 0x13 - - sizeofInetPktinfo = 0x8 sizeofIPMreq = 0x8 sizeofIPMreqSource = 0xc ) -type inetPktinfo struct { - Addr [4]byte - Ifindex int32 -} - type ipMreq struct { Multiaddr [4]byte Interface [4]byte @@ -51,17 +32,13 @@ var ( ctlOpts = [ctlMax]ctlOpt{} sockOpts = map[int]*sockOpt{ - ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, - ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, - ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 4}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 4}}, - ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, + ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_TOS, Len: 4}}, + ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_TTL, Len: 4}}, + ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_MULTICAST_TTL, Len: 4}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_MULTICAST_IF, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_MULTICAST_LOOP, Len: 4}}, + ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_HDRINCL, Len: 4}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, } ) - -func (pi *inetPktinfo) setIfindex(i int) { - pi.Ifindex = int32(i) -} diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_zos.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_zos.go new file mode 100644 index 000000000..be2064098 --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/sys_zos.go @@ -0,0 +1,57 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ipv4 + +import ( + "net" + "syscall" + "unsafe" + + "golang.org/x/net/internal/iana" + "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" +) + +var ( + ctlOpts = [ctlMax]ctlOpt{ + ctlPacketInfo: {unix.IP_PKTINFO, sizeofInetPktinfo, marshalPacketInfo, parsePacketInfo}, + } + + sockOpts = map[int]*sockOpt{ + ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_TTL, Len: 1}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_IF, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_LOOP, Len: 1}}, + ssoPacketInfo: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVPKTINFO, Len: 4}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.MCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + } +) + +func (pi *inetPktinfo) setIfindex(i int) { + pi.Ifindex = uint32(i) +} + +func (gr *groupReq) setGroup(grp net.IP) { + sa := (*sockaddrInet4)(unsafe.Pointer(&gr.Group)) + sa.Family = syscall.AF_INET + sa.Len = sizeofSockaddrInet4 + copy(sa.Addr[:], grp) +} + +func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { + sa := (*sockaddrInet4)(unsafe.Pointer(&gsr.Group)) + sa.Family = syscall.AF_INET + sa.Len = sizeofSockaddrInet4 + copy(sa.Addr[:], grp) + sa = (*sockaddrInet4)(unsafe.Pointer(&gsr.Source)) + sa.Family = syscall.AF_INET + sa.Len = sizeofSockaddrInet4 + copy(sa.Addr[:], src) +} diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_aix_ppc64.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_aix_ppc64.go index c741d5c8e..42a81863c 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_aix_ppc64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_aix_ppc64.go @@ -2,28 +2,16 @@ // cgo -godefs defs_aix.go // Added for go1.11 compatibility +//go:build aix // +build aix package ipv4 const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 sysIP_RECVIF = 0x20 sysIP_RECVTTL = 0x22 - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sizeofIPMreq = 0x8 ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_darwin.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_darwin.go index e05a251ba..d14b87171 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_darwin.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_darwin.go @@ -4,38 +4,9 @@ package ipv4 const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 sysIP_RECVIF = 0x14 - sysIP_STRIPHDR = 0x17 sysIP_RECVTTL = 0x18 - sysIP_BOUND_IF = 0x19 - sysIP_PKTINFO = 0x1a - sysIP_RECVPKTINFO = 0x1a - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_MULTICAST_IFINDEX = 0x42 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go index 6d65e9fcb..9631421da 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go @@ -4,24 +4,10 @@ package ipv4 const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 sysIP_RECVIF = 0x14 sysIP_RECVTTL = 0x41 - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sizeofIPMreq = 0x8 ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go index 136e2b8f1..9a0e3283d 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go @@ -4,39 +4,9 @@ package ipv4 const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go index 4f730f19e..143623bbd 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go @@ -4,39 +4,9 @@ package ipv4 const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go index 4f730f19e..143623bbd 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go @@ -4,39 +4,9 @@ package ipv4 const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm64.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm64.go index ecebf3272..1be70237f 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm64.go @@ -4,39 +4,9 @@ package ipv4 const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_386.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_386.go index 1c7fdfa13..8c5795ea6 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_386.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_386.go @@ -4,56 +4,7 @@ package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go index a04e78518..7b40aa1b6 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go @@ -4,56 +4,7 @@ package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go index 1c7fdfa13..8c5795ea6 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go @@ -4,56 +4,7 @@ package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go index a04e78518..7b40aa1b6 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go @@ -4,56 +4,7 @@ package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go index 1c7fdfa13..8c5795ea6 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go @@ -4,56 +4,7 @@ package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go index a04e78518..7b40aa1b6 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go @@ -4,56 +4,7 @@ package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go index a04e78518..7b40aa1b6 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go @@ -4,56 +4,7 @@ package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go index 1c7fdfa13..8c5795ea6 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go @@ -4,56 +4,7 @@ package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go index 3c5ea5473..2c9e7e3cb 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go @@ -4,56 +4,7 @@ package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go index a04e78518..7b40aa1b6 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go @@ -4,56 +4,7 @@ package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go index a04e78518..7b40aa1b6 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go @@ -4,56 +4,7 @@ package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_riscv64.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_riscv64.go index e626134a8..b31766a02 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_riscv64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_riscv64.go @@ -1,61 +1,13 @@ // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs defs_linux.go +//go:build riscv64 // +build riscv64 package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go index a04e78518..7b40aa1b6 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go @@ -4,56 +4,7 @@ package ipv4 const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 + sysIP_RECVTTL = 0xc sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet = 0x10 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_netbsd.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_netbsd.go index 8cfc648ad..df99ef693 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_netbsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_netbsd.go @@ -4,23 +4,10 @@ package ipv4 const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 sysIP_RECVIF = 0x14 sysIP_RECVTTL = 0x17 - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sizeofIPMreq = 0x8 ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_openbsd.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_openbsd.go index 37629cb0a..9052a9bd4 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_openbsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_openbsd.go @@ -4,23 +4,10 @@ package ipv4 const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 sysIP_RECVIF = 0x1e sysIP_RECVTTL = 0x1f - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sizeofIPMreq = 0x8 ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_solaris.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_solaris.go index cb80a308b..1cdc45c27 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_solaris.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_solaris.go @@ -4,49 +4,10 @@ package ipv4 const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 sysIP_RECVIF = 0x9 - sysIP_RECVSLLA = 0xa sysIP_RECVTTL = 0xb - sysIP_MULTICAST_IF = 0x10 - sysIP_MULTICAST_TTL = 0x11 - sysIP_MULTICAST_LOOP = 0x12 - sysIP_ADD_MEMBERSHIP = 0x13 - sysIP_DROP_MEMBERSHIP = 0x14 - sysIP_BLOCK_SOURCE = 0x15 - sysIP_UNBLOCK_SOURCE = 0x16 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x17 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x18 - sysIP_NEXTHOP = 0x19 - - sysIP_PKTINFO = 0x1a - sysIP_RECVPKTINFO = 0x1a - sysIP_DONTFRAG = 0x1b - - sysIP_BOUND_IF = 0x41 - sysIP_UNSPEC_SRC = 0x42 - sysIP_BROADCAST_TTL = 0x43 - sysIP_DHCPINIT_IF = 0x45 - - sysIP_REUSEADDR = 0x104 - sysIP_DONTROUTE = 0x105 - sysIP_BROADCAST = 0x106 - - sysMCAST_JOIN_GROUP = 0x29 - sysMCAST_LEAVE_GROUP = 0x2a - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_JOIN_SOURCE_GROUP = 0x2d - sysMCAST_LEAVE_SOURCE_GROUP = 0x2e - sizeofSockaddrStorage = 0x100 sizeofSockaddrInet = 0x10 sizeofInetPktinfo = 0xc diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_zos_s390x.go b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_zos_s390x.go new file mode 100644 index 000000000..692abf688 --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/ipv4/zsys_zos_s390x.go @@ -0,0 +1,56 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Hand edited based on zerrors_zos_s390x.go +// TODO(Bill O'Farrell): auto-generate. + +package ipv4 + +const ( + sizeofIPMreq = 8 + sizeofSockaddrInet4 = 16 + sizeofSockaddrStorage = 128 + sizeofGroupReq = 136 + sizeofGroupSourceReq = 264 + sizeofInetPktinfo = 8 +) + +type sockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte + Zero [8]uint8 +} + +type inetPktinfo struct { + Addr [4]byte + Ifindex uint32 +} + +type sockaddrStorage struct { + Len uint8 + Family byte + ss_pad1 [6]byte + ss_align int64 + ss_pad2 [112]byte +} + +type groupReq struct { + Interface uint32 + reserved uint32 + Group sockaddrStorage +} + +type groupSourceReq struct { + Interface uint32 + reserved uint32 + Group sockaddrStorage + Source sockaddrStorage +} + +type ipMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go index 9fd9eb15e..2733ddbe2 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin // +build darwin package ipv6 @@ -11,11 +12,13 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" ) func marshal2292HopLimit(b []byte, cm *ControlMessage) []byte { m := socket.ControlMessage(b) - m.MarshalHeader(iana.ProtocolIPv6, sysIPV6_2292HOPLIMIT, 4) + m.MarshalHeader(iana.ProtocolIPv6, unix.IPV6_2292HOPLIMIT, 4) if cm != nil { socket.NativeEndian.PutUint32(m.Data(4), uint32(cm.HopLimit)) } @@ -24,7 +27,7 @@ func marshal2292HopLimit(b []byte, cm *ControlMessage) []byte { func marshal2292PacketInfo(b []byte, cm *ControlMessage) []byte { m := socket.ControlMessage(b) - m.MarshalHeader(iana.ProtocolIPv6, sysIPV6_2292PKTINFO, sizeofInet6Pktinfo) + m.MarshalHeader(iana.ProtocolIPv6, unix.IPV6_2292PKTINFO, sizeofInet6Pktinfo) if cm != nil { pi := (*inet6Pktinfo)(unsafe.Pointer(&m.Data(sizeofInet6Pktinfo)[0])) if ip := cm.Src.To16(); ip != nil && ip.To4() == nil { @@ -39,7 +42,7 @@ func marshal2292PacketInfo(b []byte, cm *ControlMessage) []byte { func marshal2292NextHop(b []byte, cm *ControlMessage) []byte { m := socket.ControlMessage(b) - m.MarshalHeader(iana.ProtocolIPv6, sysIPV6_2292NEXTHOP, sizeofSockaddrInet6) + m.MarshalHeader(iana.ProtocolIPv6, unix.IPV6_2292NEXTHOP, sizeofSockaddrInet6) if cm != nil { sa := (*sockaddrInet6)(unsafe.Pointer(&m.Data(sizeofSockaddrInet6)[0])) sa.setSockaddr(cm.NextHop, cm.IfIndex) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go index 8c221b598..242219419 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/control_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/control_stub.go index 1d773cbcc..b7e8643fc 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/control_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/control_stub.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows,!zos package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/control_unix.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/control_unix.go index 0971a008b..63e475db8 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/control_unix.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/control_unix.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/icmp_bsd.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/icmp_bsd.go index b03025cdc..120bf8775 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/icmp_bsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/icmp_bsd.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd // +build aix darwin dragonfly freebsd netbsd openbsd package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/icmp_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/icmp_stub.go index 370e51acd..d60136a90 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/icmp_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/icmp_stub.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows,!zos package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/icmp_zos.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/icmp_zos.go new file mode 100644 index 000000000..ddf8f093f --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/icmp_zos.go @@ -0,0 +1,29 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ipv6 + +func (f *icmpv6Filter) accept(typ ICMPType) { + f.Filt[typ>>5] |= 1 << (uint32(typ) & 31) + +} + +func (f *icmpv6Filter) block(typ ICMPType) { + f.Filt[typ>>5] &^= 1 << (uint32(typ) & 31) + +} + +func (f *icmpv6Filter) setAll(block bool) { + for i := range f.Filt { + if block { + f.Filt[i] = 0 + } else { + f.Filt[i] = 1<<32 - 1 + } + } +} + +func (f *icmpv6Filter) willBlock(typ ICMPType) bool { + return f.Filt[typ>>5]&(1<<(uint32(typ)&31)) == 0 +} diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/payload_cmsg.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/payload_cmsg.go index 284a04278..b0692e430 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/payload_cmsg.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/payload_cmsg.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/payload_nocmsg.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/payload_nocmsg.go index c5a4c9675..cd0ff5083 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/payload_nocmsg.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/payload_nocmsg.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!zos package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sockopt_posix.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sockopt_posix.go index 824c623cc..37c628713 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sockopt_posix.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sockopt_posix.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows zos package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sockopt_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sockopt_stub.go index 0a87a93bb..32fd8664c 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sockopt_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sockopt_stub.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows,!zos package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_aix.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_aix.go index bce7091fb..a47182afb 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_aix.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_aix.go @@ -3,6 +3,7 @@ // license that can be found in the LICENSE file. // Added for go1.11 compatibility +//go:build aix // +build aix package ipv6 @@ -14,32 +15,34 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" ) var ( ctlOpts = [ctlMax]ctlOpt{ - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, - ctlNextHop: {sysIPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop}, - ctlPathMTU: {sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, + ctlTrafficClass: {unix.IPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, + ctlHopLimit: {unix.IPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, + ctlPacketInfo: {unix.IPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, + ctlNextHop: {unix.IPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop}, + ctlPathMTU: {unix.IPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, } sockOpts = map[int]*sockOpt{ - ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_TCLASS, Len: 4}}, - ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_UNICAST_HOPS, Len: 4}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_IF, Len: 4}}, - ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_HOPS, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_LOOP, Len: 4}}, - ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVTCLASS, Len: 4}}, - ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVHOPLIMIT, Len: 4}}, - ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPKTINFO, Len: 4}}, - ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPATHMTU, Len: 4}}, - ssoPathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}}, - ssoChecksum: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_CHECKSUM, Len: 4}}, - ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: sysICMP6_FILTER, Len: sizeofICMPv6Filter}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_JOIN_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_LEAVE_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, + ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_TCLASS, Len: 4}}, + ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_UNICAST_HOPS, Len: 4}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_IF, Len: 4}}, + ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_HOPS, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_LOOP, Len: 4}}, + ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVTCLASS, Len: 4}}, + ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVHOPLIMIT, Len: 4}}, + ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPKTINFO, Len: 4}}, + ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPATHMTU, Len: 4}}, + ssoPathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}}, + ssoChecksum: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_CHECKSUM, Len: 4}}, + ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: unix.ICMP6_FILTER, Len: sizeofICMPv6Filter}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_JOIN_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_LEAVE_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, } ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_asmreq.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_asmreq.go index 8c3934c3e..6ff9950d1 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_asmreq.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_asmreq.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_asmreq_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_asmreq_stub.go index 87ae48181..485290cb8 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_asmreq_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_asmreq_stub.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows // +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_bpf.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_bpf.go index 90ef4dfaf..b5661fb8f 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_bpf.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_bpf.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux // +build linux package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_bpf_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_bpf_stub.go index eb9f83162..cb0066187 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_bpf_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_bpf_stub.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !linux // +build !linux package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_bsd.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_bsd.go index e416eaa1f..bde41a6ce 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_bsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_bsd.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build dragonfly || netbsd || openbsd // +build dragonfly netbsd openbsd package ipv6 @@ -12,32 +13,34 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" ) var ( ctlOpts = [ctlMax]ctlOpt{ - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, - ctlNextHop: {sysIPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop}, - ctlPathMTU: {sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, + ctlTrafficClass: {unix.IPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, + ctlHopLimit: {unix.IPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, + ctlPacketInfo: {unix.IPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, + ctlNextHop: {unix.IPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop}, + ctlPathMTU: {unix.IPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, } sockOpts = map[int]*sockOpt{ - ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_TCLASS, Len: 4}}, - ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_UNICAST_HOPS, Len: 4}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_IF, Len: 4}}, - ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_HOPS, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_LOOP, Len: 4}}, - ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVTCLASS, Len: 4}}, - ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVHOPLIMIT, Len: 4}}, - ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPKTINFO, Len: 4}}, - ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPATHMTU, Len: 4}}, - ssoPathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}}, - ssoChecksum: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_CHECKSUM, Len: 4}}, - ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: sysICMP6_FILTER, Len: sizeofICMPv6Filter}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_JOIN_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_LEAVE_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, + ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_TCLASS, Len: 4}}, + ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_UNICAST_HOPS, Len: 4}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_IF, Len: 4}}, + ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_HOPS, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_LOOP, Len: 4}}, + ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVTCLASS, Len: 4}}, + ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVHOPLIMIT, Len: 4}}, + ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPKTINFO, Len: 4}}, + ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPATHMTU, Len: 4}}, + ssoPathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}}, + ssoChecksum: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_CHECKSUM, Len: 4}}, + ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: unix.ICMP6_FILTER, Len: sizeofICMPv6Filter}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_JOIN_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_LEAVE_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, } ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_darwin.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_darwin.go index 12cc5cb2c..b80ec8064 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_darwin.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_darwin.go @@ -11,36 +11,38 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" ) var ( ctlOpts = [ctlMax]ctlOpt{ - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, - ctlNextHop: {sysIPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop}, - ctlPathMTU: {sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, + ctlTrafficClass: {unix.IPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, + ctlHopLimit: {unix.IPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, + ctlPacketInfo: {unix.IPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, + ctlNextHop: {unix.IPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop}, + ctlPathMTU: {unix.IPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, } sockOpts = map[int]*sockOpt{ - ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_UNICAST_HOPS, Len: 4}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_IF, Len: 4}}, - ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_HOPS, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_LOOP, Len: 4}}, - ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_TCLASS, Len: 4}}, - ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVTCLASS, Len: 4}}, - ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVHOPLIMIT, Len: 4}}, - ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPKTINFO, Len: 4}}, - ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPATHMTU, Len: 4}}, - ssoPathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}}, - ssoChecksum: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_CHECKSUM, Len: 4}}, - ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: sysICMP6_FILTER, Len: sizeofICMPv6Filter}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_UNICAST_HOPS, Len: 4}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_IF, Len: 4}}, + ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_HOPS, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_LOOP, Len: 4}}, + ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_TCLASS, Len: 4}}, + ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVTCLASS, Len: 4}}, + ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVHOPLIMIT, Len: 4}}, + ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPKTINFO, Len: 4}}, + ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPATHMTU, Len: 4}}, + ssoPathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}}, + ssoChecksum: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_CHECKSUM, Len: 4}}, + ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: unix.ICMP6_FILTER, Len: sizeofICMPv6Filter}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, } ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_freebsd.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_freebsd.go index 85a9f5d07..6282cf977 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_freebsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_freebsd.go @@ -13,36 +13,38 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/unix" ) var ( ctlOpts = [ctlMax]ctlOpt{ - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, - ctlNextHop: {sysIPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop}, - ctlPathMTU: {sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, + ctlTrafficClass: {unix.IPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, + ctlHopLimit: {unix.IPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, + ctlPacketInfo: {unix.IPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, + ctlNextHop: {unix.IPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop}, + ctlPathMTU: {unix.IPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, } sockOpts = map[int]sockOpt{ - ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_TCLASS, Len: 4}}, - ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_UNICAST_HOPS, Len: 4}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_IF, Len: 4}}, - ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_HOPS, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_LOOP, Len: 4}}, - ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVTCLASS, Len: 4}}, - ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVHOPLIMIT, Len: 4}}, - ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPKTINFO, Len: 4}}, - ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPATHMTU, Len: 4}}, - ssoPathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}}, - ssoChecksum: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_CHECKSUM, Len: 4}}, - ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: sysICMP6_FILTER, Len: sizeofICMPv6Filter}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_TCLASS, Len: 4}}, + ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_UNICAST_HOPS, Len: 4}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_IF, Len: 4}}, + ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_HOPS, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_LOOP, Len: 4}}, + ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVTCLASS, Len: 4}}, + ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVHOPLIMIT, Len: 4}}, + ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPKTINFO, Len: 4}}, + ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPATHMTU, Len: 4}}, + ssoPathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}}, + ssoChecksum: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_CHECKSUM, Len: 4}}, + ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: unix.ICMP6_FILTER, Len: sizeofICMPv6Filter}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, } ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_linux.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_linux.go index 96e8093a3..82e212100 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_linux.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_linux.go @@ -11,36 +11,37 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + "golang.org/x/sys/unix" ) var ( ctlOpts = [ctlMax]ctlOpt{ - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, - ctlPathMTU: {sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, + ctlTrafficClass: {unix.IPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, + ctlHopLimit: {unix.IPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, + ctlPacketInfo: {unix.IPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, + ctlPathMTU: {unix.IPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, } sockOpts = map[int]*sockOpt{ - ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_TCLASS, Len: 4}}, - ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_UNICAST_HOPS, Len: 4}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_IF, Len: 4}}, - ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_HOPS, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_LOOP, Len: 4}}, - ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVTCLASS, Len: 4}}, - ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVHOPLIMIT, Len: 4}}, - ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPKTINFO, Len: 4}}, - ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPATHMTU, Len: 4}}, - ssoPathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}}, - ssoChecksum: {Option: socket.Option{Level: iana.ProtocolReserved, Name: sysIPV6_CHECKSUM, Len: 4}}, - ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: sysICMPV6_FILTER, Len: sizeofICMPv6Filter}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, - ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_TCLASS, Len: 4}}, + ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_UNICAST_HOPS, Len: 4}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_IF, Len: 4}}, + ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_HOPS, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_LOOP, Len: 4}}, + ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVTCLASS, Len: 4}}, + ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVHOPLIMIT, Len: 4}}, + ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPKTINFO, Len: 4}}, + ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPATHMTU, Len: 4}}, + ssoPathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}}, + ssoChecksum: {Option: socket.Option{Level: iana.ProtocolReserved, Name: unix.IPV6_CHECKSUM, Len: 4}}, + ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: unix.ICMPV6_FILTER, Len: sizeofICMPv6Filter}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, ssoAttachFilter: {Option: socket.Option{Level: unix.SOL_SOCKET, Name: unix.SO_ATTACH_FILTER, Len: unix.SizeofSockFprog}}, } ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_ssmreq.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_ssmreq.go index 9b52e978c..023488a49 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_ssmreq.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_ssmreq.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin freebsd linux solaris +//go:build aix || darwin || freebsd || linux || solaris || zos +// +build aix darwin freebsd linux solaris zos package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_ssmreq_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_ssmreq_stub.go index d5bc1108c..acdf2e5cf 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_ssmreq_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_ssmreq_stub.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!freebsd,!linux,!solaris +//go:build !aix && !darwin && !freebsd && !linux && !solaris && !zos +// +build !aix,!darwin,!freebsd,!linux,!solaris,!zos package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_stub.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_stub.go index 4f252d09f..5807bba39 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_stub.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_stub.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows +//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows && !zos +// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows,!zos package ipv6 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_windows.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_windows.go index fc36b018b..fda8a2994 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_windows.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_windows.go @@ -10,18 +10,11 @@ import ( "golang.org/x/net/internal/iana" "golang.org/x/net/internal/socket" + + "golang.org/x/sys/windows" ) const ( - // See ws2tcpip.h. - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PKTINFO = 0x13 - sizeofSockaddrInet6 = 0x1c sizeofIPv6Mreq = 0x14 @@ -55,12 +48,12 @@ var ( ctlOpts = [ctlMax]ctlOpt{} sockOpts = map[int]*sockOpt{ - ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_UNICAST_HOPS, Len: 4}}, - ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_IF, Len: 4}}, - ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_HOPS, Len: 4}}, - ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_LOOP, Len: 4}}, - ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_JOIN_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, - ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_LEAVE_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, + ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: windows.IPV6_UNICAST_HOPS, Len: 4}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: windows.IPV6_MULTICAST_IF, Len: 4}}, + ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: windows.IPV6_MULTICAST_HOPS, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: windows.IPV6_MULTICAST_LOOP, Len: 4}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: windows.IPV6_JOIN_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: windows.IPV6_LEAVE_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, } ) diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_zos.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_zos.go new file mode 100644 index 000000000..d4567f908 --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/sys_zos.go @@ -0,0 +1,70 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ipv6 + +import ( + "net" + "syscall" + "unsafe" + + "golang.org/x/net/internal/iana" + "golang.org/x/net/internal/socket" +) + +var ( + ctlOpts = [ctlMax]ctlOpt{ + ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, + ctlPacketInfo: {sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, + ctlPathMTU: {sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, + } + + sockOpts = map[int]*sockOpt{ + ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_TCLASS, Len: 4}}, + ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_UNICAST_HOPS, Len: 4}}, + ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_IF, Len: 4}}, + ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_HOPS, Len: 4}}, + ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_LOOP, Len: 4}}, + ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVTCLASS, Len: 4}}, + ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVHOPLIMIT, Len: 4}}, + ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPKTINFO, Len: 4}}, + ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPATHMTU, Len: 4}}, + ssoChecksum: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_CHECKSUM, Len: 4}}, + ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: sysICMP6_FILTER, Len: sizeofICMPv6Filter}}, + ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq}, + ssoJoinSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, + } +) + +func (sa *sockaddrInet6) setSockaddr(ip net.IP, i int) { + sa.Family = syscall.AF_INET6 + copy(sa.Addr[:], ip) + sa.Scope_id = uint32(i) +} + +func (pi *inet6Pktinfo) setIfindex(i int) { + pi.Ifindex = uint32(i) +} + +func (gr *groupReq) setGroup(grp net.IP) { + sa := (*sockaddrInet6)(unsafe.Pointer(&gr.Group)) + sa.Family = syscall.AF_INET6 + sa.Len = sizeofSockaddrInet6 + copy(sa.Addr[:], grp) +} + +func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { + sa := (*sockaddrInet6)(unsafe.Pointer(&gsr.Group)) + sa.Family = syscall.AF_INET6 + sa.Len = sizeofSockaddrInet6 + copy(sa.Addr[:], grp) + sa = (*sockaddrInet6)(unsafe.Pointer(&gsr.Source)) + sa.Family = syscall.AF_INET6 + sa.Len = sizeofSockaddrInet6 + copy(sa.Addr[:], src) +} diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_aix_ppc64.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_aix_ppc64.go index bf44e338b..869f4b2bc 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_aix_ppc64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_aix_ppc64.go @@ -2,45 +2,17 @@ // cgo -godefs defs_aix.go // Added for go1.11 compatibility +//go:build aix // +build aix package ipv6 const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysICMP6_FILTER = 0x26 - - sysIPV6_CHECKSUM = 0x27 - sysIPV6_V6ONLY = 0x25 - - sysIPV6_RTHDRDSTOPTS = 0x37 - - sysIPV6_RECVPKTINFO = 0x23 - sysIPV6_RECVHOPLIMIT = 0x29 - sysIPV6_RECVRTHDR = 0x33 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_RECVDSTOPTS = 0x38 - - sysIPV6_USE_MIN_MTU = 0x2c - sysIPV6_RECVPATHMTU = 0x2f - sysIPV6_PATHMTU = 0x2e - + sysIPV6_PATHMTU = 0x2e sysIPV6_PKTINFO = 0x21 sysIPV6_HOPLIMIT = 0x28 sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x34 - sysIPV6_DSTOPTS = 0x36 - sysIPV6_RTHDR = 0x32 - - sysIPV6_RECVTCLASS = 0x2a - sysIPV6_TCLASS = 0x2b - sysIPV6_DONTFRAG = 0x2d sizeofSockaddrStorage = 0x508 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_darwin.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_darwin.go index 555744afd..a1211729e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_darwin.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_darwin.go @@ -4,72 +4,11 @@ package ipv6 const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - sysIPV6_2292PKTINFO = 0x13 - sysIPV6_2292HOPLIMIT = 0x14 - sysIPV6_2292NEXTHOP = 0x15 - sysIPV6_2292HOPOPTS = 0x16 - sysIPV6_2292DSTOPTS = 0x17 - sysIPV6_2292RTHDR = 0x18 - - sysIPV6_2292PKTOPTIONS = 0x19 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RECVTCLASS = 0x23 - sysIPV6_TCLASS = 0x24 - - sysIPV6_RTHDRDSTOPTS = 0x39 - - sysIPV6_RECVPKTINFO = 0x3d - - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - + sysIPV6_TCLASS = 0x24 + sysIPV6_PATHMTU = 0x2c sysIPV6_PKTINFO = 0x2e sysIPV6_HOPLIMIT = 0x2f sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_AUTOFLOWLABEL = 0x3b - - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PREFER_TEMPADDR = 0x3f - - sysIPV6_MSFILTER = 0x4a - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysIPV6_BOUND_IF = 0x7d - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go index cf3cc1024..512db656e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go @@ -4,51 +4,11 @@ package ipv6 const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RTHDRDSTOPTS = 0x23 - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - + sysIPV6_PATHMTU = 0x2c sysIPV6_PKTINFO = 0x2e sysIPV6_HOPLIMIT = 0x2f sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_RECVTCLASS = 0x39 - - sysIPV6_AUTOFLOWLABEL = 0x3b - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PREFER_TEMPADDR = 0x3f - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 sizeofSockaddrInet6 = 0x1c sizeofInet6Pktinfo = 0x14 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go index 73f31b260..46a62b885 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go @@ -4,63 +4,11 @@ package ipv6 const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RTHDRDSTOPTS = 0x23 - - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - + sysIPV6_PATHMTU = 0x2c sysIPV6_PKTINFO = 0x2e sysIPV6_HOPLIMIT = 0x2f sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_RECVTCLASS = 0x39 - - sysIPV6_AUTOFLOWLABEL = 0x3b - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PREFER_TEMPADDR = 0x3f - - sysIPV6_BINDANY = 0x40 - - sysIPV6_MSFILTER = 0x4a - - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go index 490ce7cf1..e475f5111 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go @@ -4,63 +4,11 @@ package ipv6 const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RTHDRDSTOPTS = 0x23 - - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - + sysIPV6_PATHMTU = 0x2c sysIPV6_PKTINFO = 0x2e sysIPV6_HOPLIMIT = 0x2f sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_RECVTCLASS = 0x39 - - sysIPV6_AUTOFLOWLABEL = 0x3b - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PREFER_TEMPADDR = 0x3f - - sysIPV6_BINDANY = 0x40 - - sysIPV6_MSFILTER = 0x4a - - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go index 490ce7cf1..e475f5111 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go @@ -4,63 +4,11 @@ package ipv6 const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RTHDRDSTOPTS = 0x23 - - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - + sysIPV6_PATHMTU = 0x2c sysIPV6_PKTINFO = 0x2e sysIPV6_HOPLIMIT = 0x2f sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_RECVTCLASS = 0x39 - - sysIPV6_AUTOFLOWLABEL = 0x3b - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PREFER_TEMPADDR = 0x3f - - sysIPV6_BINDANY = 0x40 - - sysIPV6_MSFILTER = 0x4a - - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm64.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm64.go index 47e99ac9d..edaf7f15e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm64.go @@ -4,63 +4,11 @@ package ipv6 const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RTHDRDSTOPTS = 0x23 - - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - + sysIPV6_PATHMTU = 0x2c sysIPV6_PKTINFO = 0x2e sysIPV6_HOPLIMIT = 0x2f sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_RECVTCLASS = 0x39 - - sysIPV6_AUTOFLOWLABEL = 0x3b - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PREFER_TEMPADDR = 0x3f - - sysIPV6_BINDANY = 0x40 - - sysIPV6_MSFILTER = 0x4a - - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 sizeofSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_386.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_386.go index bde4a8f8f..bb579ea1c 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_386.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_386.go @@ -4,85 +4,11 @@ package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go index 992ac9ec5..9500f7d5e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go @@ -4,85 +4,11 @@ package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go index bde4a8f8f..bb579ea1c 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go @@ -4,85 +4,11 @@ package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go index 992ac9ec5..9500f7d5e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go @@ -4,85 +4,11 @@ package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mips.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mips.go index bde4a8f8f..bb579ea1c 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mips.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mips.go @@ -4,85 +4,11 @@ package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go index 992ac9ec5..9500f7d5e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go @@ -4,85 +4,11 @@ package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go index 992ac9ec5..9500f7d5e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go @@ -4,85 +4,11 @@ package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mipsle.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mipsle.go index bde4a8f8f..bb579ea1c 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mipsle.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_mipsle.go @@ -4,85 +4,11 @@ package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_ppc.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_ppc.go index 66fd23612..5486c2448 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_ppc.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_ppc.go @@ -4,85 +4,11 @@ package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go index 992ac9ec5..9500f7d5e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go @@ -4,85 +4,11 @@ package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go index 992ac9ec5..9500f7d5e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go @@ -4,85 +4,11 @@ package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_riscv64.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_riscv64.go index 6083ddced..283973e6f 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_riscv64.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_riscv64.go @@ -1,90 +1,17 @@ // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs defs_linux.go +//go:build riscv64 // +build riscv64 package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go index 992ac9ec5..9500f7d5e 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go @@ -4,85 +4,11 @@ package ipv6 const ( - sysIPV6_ADDRFORM = 0x1 - sysIPV6_2292PKTINFO = 0x2 - sysIPV6_2292HOPOPTS = 0x3 - sysIPV6_2292DSTOPTS = 0x4 - sysIPV6_2292RTHDR = 0x5 - sysIPV6_2292PKTOPTIONS = 0x6 - sysIPV6_CHECKSUM = 0x7 - sysIPV6_2292HOPLIMIT = 0x8 - sysIPV6_NEXTHOP = 0x9 - sysIPV6_FLOWINFO = 0xb - - sysIPV6_UNICAST_HOPS = 0x10 - sysIPV6_MULTICAST_IF = 0x11 - sysIPV6_MULTICAST_HOPS = 0x12 - sysIPV6_MULTICAST_LOOP = 0x13 - sysIPV6_ADD_MEMBERSHIP = 0x14 - sysIPV6_DROP_MEMBERSHIP = 0x15 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIPV6_ROUTER_ALERT = 0x16 - sysIPV6_MTU_DISCOVER = 0x17 - sysIPV6_MTU = 0x18 - sysIPV6_RECVERR = 0x19 - sysIPV6_V6ONLY = 0x1a - sysIPV6_JOIN_ANYCAST = 0x1b - sysIPV6_LEAVE_ANYCAST = 0x1c - - sysIPV6_FLOWLABEL_MGR = 0x20 - sysIPV6_FLOWINFO_SEND = 0x21 - - sysIPV6_IPSEC_POLICY = 0x22 - sysIPV6_XFRM_POLICY = 0x23 - - sysIPV6_RECVPKTINFO = 0x31 - sysIPV6_PKTINFO = 0x32 - sysIPV6_RECVHOPLIMIT = 0x33 - sysIPV6_HOPLIMIT = 0x34 - sysIPV6_RECVHOPOPTS = 0x35 - sysIPV6_HOPOPTS = 0x36 - sysIPV6_RTHDRDSTOPTS = 0x37 - sysIPV6_RECVRTHDR = 0x38 - sysIPV6_RTHDR = 0x39 - sysIPV6_RECVDSTOPTS = 0x3a - sysIPV6_DSTOPTS = 0x3b - sysIPV6_RECVPATHMTU = 0x3c - sysIPV6_PATHMTU = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_RECVTCLASS = 0x42 - sysIPV6_TCLASS = 0x43 - - sysIPV6_ADDR_PREFERENCES = 0x48 - - sysIPV6_PREFER_SRC_TMP = 0x1 - sysIPV6_PREFER_SRC_PUBLIC = 0x2 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100 - sysIPV6_PREFER_SRC_COA = 0x4 - sysIPV6_PREFER_SRC_HOME = 0x400 - sysIPV6_PREFER_SRC_CGA = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x800 - - sysIPV6_MINHOPCOUNT = 0x49 - - sysIPV6_ORIGDSTADDR = 0x4a - sysIPV6_RECVORIGDSTADDR = 0x4a - sysIPV6_TRANSPARENT = 0x4b - sysIPV6_UNICAST_IF = 0x4c - - sysICMPV6_FILTER = 0x1 - - sysICMPV6_FILTER_BLOCK = 0x1 - sysICMPV6_FILTER_PASS = 0x2 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3 - sysICMPV6_FILTER_PASSONLY = 0x4 + sysIPV6_NEXTHOP = 0x9 + sysIPV6_PKTINFO = 0x32 + sysIPV6_HOPLIMIT = 0x34 + sysIPV6_PATHMTU = 0x3d + sysIPV6_TCLASS = 0x43 sizeofKernelSockaddrStorage = 0x80 sizeofSockaddrInet6 = 0x1c diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_netbsd.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_netbsd.go index e39571e07..524c97fbc 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_netbsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_netbsd.go @@ -4,47 +4,11 @@ package ipv6 const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_IPSEC_POLICY = 0x1c - - sysIPV6_RTHDRDSTOPTS = 0x23 - - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - sysIPV6_PATHMTU = 0x2c - + sysIPV6_PATHMTU = 0x2c sysIPV6_PKTINFO = 0x2e sysIPV6_HOPLIMIT = 0x2f sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_RECVTCLASS = 0x39 - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 sizeofSockaddrInet6 = 0x1c sizeofInet6Pktinfo = 0x14 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_openbsd.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_openbsd.go index cc1899a63..5e7bdedc9 100644 --- a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_openbsd.go +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_openbsd.go @@ -4,56 +4,11 @@ package ipv6 const ( - sysIPV6_UNICAST_HOPS = 0x4 - sysIPV6_MULTICAST_IF = 0x9 - sysIPV6_MULTICAST_HOPS = 0xa - sysIPV6_MULTICAST_LOOP = 0xb - sysIPV6_JOIN_GROUP = 0xc - sysIPV6_LEAVE_GROUP = 0xd - sysIPV6_PORTRANGE = 0xe - sysICMP6_FILTER = 0x12 - - sysIPV6_CHECKSUM = 0x1a - sysIPV6_V6ONLY = 0x1b - - sysIPV6_RTHDRDSTOPTS = 0x23 - - sysIPV6_RECVPKTINFO = 0x24 - sysIPV6_RECVHOPLIMIT = 0x25 - sysIPV6_RECVRTHDR = 0x26 - sysIPV6_RECVHOPOPTS = 0x27 - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_USE_MIN_MTU = 0x2a - sysIPV6_RECVPATHMTU = 0x2b - - sysIPV6_PATHMTU = 0x2c - + sysIPV6_PATHMTU = 0x2c sysIPV6_PKTINFO = 0x2e sysIPV6_HOPLIMIT = 0x2f sysIPV6_NEXTHOP = 0x30 - sysIPV6_HOPOPTS = 0x31 - sysIPV6_DSTOPTS = 0x32 - sysIPV6_RTHDR = 0x33 - - sysIPV6_AUTH_LEVEL = 0x35 - sysIPV6_ESP_TRANS_LEVEL = 0x36 - sysIPV6_ESP_NETWORK_LEVEL = 0x37 - sysIPSEC6_OUTSA = 0x38 - sysIPV6_RECVTCLASS = 0x39 - - sysIPV6_AUTOFLOWLABEL = 0x3b - sysIPV6_IPCOMP_LEVEL = 0x3c - sysIPV6_TCLASS = 0x3d - sysIPV6_DONTFRAG = 0x3e - sysIPV6_PIPEX = 0x3f - - sysIPV6_RTABLE = 0x1021 - - sysIPV6_PORTRANGE_DEFAULT = 0x0 - sysIPV6_PORTRANGE_HIGH = 0x1 - sysIPV6_PORTRANGE_LOW = 0x2 sizeofSockaddrInet6 = 0x1c sizeofInet6Pktinfo = 0x14 diff --git a/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_zos_s390x.go b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_zos_s390x.go new file mode 100644 index 000000000..3f980691f --- /dev/null +++ b/plugins/traefik/vendor/golang.org/x/net/ipv6/zsys_zos_s390x.go @@ -0,0 +1,106 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Hand edited based on zerrors_zos_s390x.go +// TODO(Bill O'Farrell): auto-generate. + +package ipv6 + +const ( + sysIPV6_ADDR_PREFERENCES = 32 + sysIPV6_CHECKSUM = 19 + sysIPV6_DONTFRAG = 29 + sysIPV6_DSTOPTS = 23 + sysIPV6_HOPLIMIT = 11 + sysIPV6_HOPOPTS = 22 + sysIPV6_JOIN_GROUP = 5 + sysIPV6_LEAVE_GROUP = 6 + sysIPV6_MULTICAST_HOPS = 9 + sysIPV6_MULTICAST_IF = 7 + sysIPV6_MULTICAST_LOOP = 4 + sysIPV6_NEXTHOP = 20 + sysIPV6_PATHMTU = 12 + sysIPV6_PKTINFO = 13 + sysIPV6_PREFER_SRC_CGA = 0x10 + sysIPV6_PREFER_SRC_COA = 0x02 + sysIPV6_PREFER_SRC_HOME = 0x01 + sysIPV6_PREFER_SRC_NONCGA = 0x20 + sysIPV6_PREFER_SRC_PUBLIC = 0x08 + sysIPV6_PREFER_SRC_TMP = 0x04 + sysIPV6_RECVDSTOPTS = 28 + sysIPV6_RECVHOPLIMIT = 14 + sysIPV6_RECVHOPOPTS = 26 + sysIPV6_RECVPATHMTU = 16 + sysIPV6_RECVPKTINFO = 15 + sysIPV6_RECVRTHDR = 25 + sysIPV6_RECVTCLASS = 31 + sysIPV6_RTHDR = 21 + sysIPV6_RTHDRDSTOPTS = 24 + sysIPV6_RTHDR_TYPE_0 = 0 + sysIPV6_TCLASS = 30 + sysIPV6_UNICAST_HOPS = 3 + sysIPV6_USE_MIN_MTU = 18 + sysIPV6_V6ONLY = 10 + + sysMCAST_JOIN_GROUP = 40 + sysMCAST_LEAVE_GROUP = 41 + sysMCAST_JOIN_SOURCE_GROUP = 42 + sysMCAST_LEAVE_SOURCE_GROUP = 43 + sysMCAST_BLOCK_SOURCE = 44 + sysMCAST_UNBLOCK_SOURCE = 45 + + sysICMP6_FILTER = 0x1 + + sizeofSockaddrStorage = 128 + sizeofICMPv6Filter = 32 + sizeofInet6Pktinfo = 20 + sizeofIPv6Mtuinfo = 32 + sizeofSockaddrInet6 = 28 + sizeofGroupReq = 136 + sizeofGroupSourceReq = 264 +) + +type sockaddrStorage struct { + Len uint8 + Family byte + ss_pad1 [6]byte + ss_align int64 + ss_pad2 [112]byte +} + +type sockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte + Scope_id uint32 +} + +type inet6Pktinfo struct { + Addr [16]byte + Ifindex uint32 +} + +type ipv6Mtuinfo struct { + Addr sockaddrInet6 + Mtu uint32 +} + +type groupReq struct { + Interface uint32 + reserved uint32 + Group sockaddrStorage +} + +type groupSourceReq struct { + Interface uint32 + reserved uint32 + Group sockaddrStorage + Source sockaddrStorage +} + +type icmpv6Filter struct { + Filt [8]uint32 +} diff --git a/plugins/traefik/vendor/modules.txt b/plugins/traefik/vendor/modules.txt index ec1ffedb5..b00d21562 100644 --- a/plugins/traefik/vendor/modules.txt +++ b/plugins/traefik/vendor/modules.txt @@ -4,7 +4,7 @@ github.com/armon/go-metrics github.com/buraksezer/connpool # github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72 github.com/buraksezer/consistent -# github.com/buraksezer/olric v0.4.1-0.20211125194525-6be543336717 +# github.com/buraksezer/olric v0.4.1-0.20211130141003-a889ee19dcd9 github.com/buraksezer/olric github.com/buraksezer/olric/client github.com/buraksezer/olric/config @@ -55,7 +55,7 @@ github.com/darkweak/souin/helpers github.com/darkweak/souin/plugins/souin/configuration github.com/darkweak/souin/rfc github.com/darkweak/souin/tests -# github.com/dgraph-io/badger/v3 v3.2103.1 +# github.com/dgraph-io/badger/v3 v3.2103.2 github.com/dgraph-io/badger/v3 github.com/dgraph-io/badger/v3/fb github.com/dgraph-io/badger/v3/options @@ -70,7 +70,7 @@ github.com/dgraph-io/ristretto/z github.com/dgraph-io/ristretto/z/simd # github.com/dustin/go-humanize v1.0.0 github.com/dustin/go-humanize -# github.com/go-chi/stampede v0.4.5 +# github.com/go-chi/stampede v0.5.0 github.com/go-chi/stampede github.com/go-chi/stampede/singleflight # github.com/gogo/protobuf v1.3.2 @@ -87,7 +87,7 @@ github.com/golang/protobuf/proto github.com/golang/snappy # github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c github.com/google/btree -# github.com/google/flatbuffers v1.12.0 +# github.com/google/flatbuffers v1.12.1 github.com/google/flatbuffers/go # github.com/google/uuid v1.3.0 github.com/google/uuid @@ -140,7 +140,7 @@ go.opencensus.io/trace/tracestate go.uber.org/atomic # go.uber.org/multierr v1.6.0 go.uber.org/multierr -# go.uber.org/zap v1.19.0 +# go.uber.org/zap v1.19.1 ## explicit go.uber.org/zap go.uber.org/zap/buffer @@ -151,7 +151,7 @@ go.uber.org/zap/zapcore # golang.org/x/crypto v0.0.0-20201001193750-eb9a90e9f9cb golang.org/x/crypto/ed25519 golang.org/x/crypto/ed25519/internal/edwards25519 -# golang.org/x/net v0.0.0-20201021035429-f5854403a974 +# golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 golang.org/x/net/bpf golang.org/x/net/context golang.org/x/net/internal/iana @@ -160,7 +160,7 @@ golang.org/x/net/internal/timeseries golang.org/x/net/ipv4 golang.org/x/net/ipv6 golang.org/x/net/trace -# golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 +# golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/sync/errgroup golang.org/x/sync/semaphore # golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e diff --git a/plugins/tyk/docker-compose.yml.test b/plugins/tyk/docker-compose.yml.test index 1a755b236..7d560a0ef 100644 --- a/plugins/tyk/docker-compose.yml.test +++ b/plugins/tyk/docker-compose.yml.test @@ -10,7 +10,7 @@ services: tyk-gateway: image: tykio/tyk-gateway:v3.2.2-rc5 ports: - - "8080:8080" + - "4443:8080" depends_on: - tyk-redis volumes: diff --git a/plugins/tyk/go.mod b/plugins/tyk/go.mod index 62a67af4e..7e798ae56 100644 --- a/plugins/tyk/go.mod +++ b/plugins/tyk/go.mod @@ -5,22 +5,20 @@ go 1.16 require ( github.com/TykTechnologies/gojsonschema v0.0.0-20170222154038-dcb3e4bb7990 // indirect github.com/TykTechnologies/tyk v2.9.5+incompatible - github.com/buraksezer/olric v0.4.1-0.20211125194525-6be543336717 github.com/clbanning/mxj v1.8.4 // indirect github.com/darkweak/souin v1.5.10 - github.com/franela/goblin v0.0.0-20210519012713-85d372ac71e2 // indirect + github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf // indirect github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8 // indirect - github.com/google/uuid v1.3.0 github.com/hashicorp/terraform v1.0.1 // indirect github.com/lonelycode/go-uuid v0.0.0-20141202165402-ed3ca8a15a93 // indirect github.com/lonelycode/osin v0.0.0-20160423095202-da239c9dacb6 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect + github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pmylund/go-cache v2.1.0+incompatible // indirect github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect - go.uber.org/zap v1.19.0 + go.uber.org/zap v1.19.1 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ) replace ( diff --git a/plugins/tyk/go.sum b/plugins/tyk/go.sum index 0bf4a15a6..058c67185 100644 --- a/plugins/tyk/go.sum +++ b/plugins/tyk/go.sum @@ -100,8 +100,8 @@ github.com/buraksezer/connpool v0.4.0 h1:fNLvWu0FOtJxL7Sqetm6+040mhZWVs8c6vrke14 github.com/buraksezer/connpool v0.4.0/go.mod h1:qPiG7gKXo+EjrwG/yqn2StZM4ek6gcYnnGgFIVKN6b0= github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72 h1:fUmDBbSvv1uOzo/t8WaxZMVb7BxJ8JECo5lGoR9c5bA= github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72/go.mod h1:OEE5igu/CDjGegM1Jn6ZMo7R6LlV/JChAkjfQQIRLpg= -github.com/buraksezer/olric v0.4.1-0.20211125194525-6be543336717 h1:uyCe3KrznXq2YGMrB4wxGf9UyZOzBHmsylPgkUzf8xo= -github.com/buraksezer/olric v0.4.1-0.20211125194525-6be543336717/go.mod h1:jSgaKtv7MphQyVPqS2qGoecZKGqiL2YYmyQx9LUJk6Y= +github.com/buraksezer/olric v0.4.1-0.20211130141003-a889ee19dcd9 h1:oyFU+vboRDFCfHjecXS6GleoBwNoxG6Bk2tAAHl+kBA= +github.com/buraksezer/olric v0.4.1-0.20211130141003-a889ee19dcd9/go.mod h1:jSgaKtv7MphQyVPqS2qGoecZKGqiL2YYmyQx9LUJk6Y= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -126,8 +126,8 @@ github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgraph-io/badger/v3 v3.2103.1 h1:zaX53IRg7ycxVlkd5pYdCeFp1FynD6qBGQoQql3R3Hk= -github.com/dgraph-io/badger/v3 v3.2103.1/go.mod h1:dULbq6ehJ5K0cGW/1TQ9iSfUk0gbSiToDWmWmTsJ53E= +github.com/dgraph-io/badger/v3 v3.2103.2 h1:dpyM5eCJAtQCBcMCZcT4UBZchuTJgCywerHHgmxfxM8= +github.com/dgraph-io/badger/v3 v3.2103.2/go.mod h1:RHo4/GmYcKKh5Lxu63wLEMHJ70Pac2JqZRYGhlyAo2M= github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -148,16 +148,18 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/evanphx/json-patch v0.0.0-20190203023257-5858425f7550/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/franela/goblin v0.0.0-20210519012713-85d372ac71e2 h1:cZqz+yOJ/R64LcKjNQOdARott/jP7BnUQ9Ah7KaZCvw= -github.com/franela/goblin v0.0.0-20210519012713-85d372ac71e2/go.mod h1:VzmDKDJVZI3aJmnRI9VjAn9nJ8qPPsN1fqzr9dqInIo= +github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf h1:NrF81UtW8gG2LBGkXFQFqlfNnvMt9WdB46sfdJY4oqc= +github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf/go.mod h1:VzmDKDJVZI3aJmnRI9VjAn9nJ8qPPsN1fqzr9dqInIo= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8 h1:a9ENSRDFBUPkJ5lCgVZh26+ZbGyoVJG7yb5SSzF5H54= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-chi/stampede v0.4.5 h1:/qEiOLkpBstcdVnlYfg7TEWfL4It3ruXYDKpJkmkZMQ= -github.com/go-chi/stampede v0.4.5/go.mod h1:26lupLoxsX2qfPW6QCOEj8Gb1/KWpbH5XysNAoNojsU= +github.com/go-chi/cors v1.2.0 h1:tV1g1XENQ8ku4Bq3K9ub2AtgG+p16SmzeMSGTwrOKdE= +github.com/go-chi/cors v1.2.0/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= +github.com/go-chi/stampede v0.5.0 h1:pby7lUVANhFHbjcorWiYhm/NVPyYnnLcBlpxbDpJrAI= +github.com/go-chi/stampede v0.5.0/go.mod h1:UFRS0DzmgIqq/LevhSX67qtc0hkykVdLHRc5MJxfgBQ= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -217,8 +219,8 @@ github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/flatbuffers v1.12.0 h1:/PtAHvnBY4Kqnx/xCQ3OIV9uYcSFGScBsWI3Oogeh6w= -github.com/google/flatbuffers v1.12.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= +github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -428,6 +430,8 @@ github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/packer-community/winrmcp v0.0.0-20180921211025-c76d91c1e7db/go.mod h1:f6Izs6JvFTdnRbziASagjZ2vmf55NSIkC/weStxCHqk= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c h1:Lgl0gzECD8GnQ5QCWA8o6BtfL6mDH5rQgM4/fX3avOs= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -516,6 +520,7 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= @@ -533,14 +538,14 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= -go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.19.0 h1:mZQZefskPPCMIBCSEH0v2/iUqqLrYtaeqwD6FUGUnFE= -go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -576,7 +581,6 @@ golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -586,6 +590,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -627,8 +632,9 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200930145003-4acb6c075d10/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -644,8 +650,9 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200930132711-30421366ff76/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -670,7 +677,6 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -689,8 +695,13 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -720,7 +731,6 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -751,8 +761,8 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/plugins/tyk/main.go b/plugins/tyk/main.go index 7d9154d48..4f1475c8f 100644 --- a/plugins/tyk/main.go +++ b/plugins/tyk/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "net/http" "strings" "time" @@ -32,42 +33,48 @@ func getInstanceFromRequest(r *http.Request) *souinInstance { // SouinResponseHandler stores the response before sent to the client if possible, only returns otherwise func SouinResponseHandler(rw http.ResponseWriter, res *http.Response, _ *http.Request) { req := res.Request + fmt.Println("SouinResponseHandler ?", res, req.URL.Path) req.Response = res currentInstance := getInstanceFromRequest(req) + if currentInstance == nil { + rw.Header().Set("Cache-Status", "Souin; fwd=uri-miss") + return + } + if b, _ := currentInstance.HandleInternally(req); b { + return + } currentInstance.Retriever.SetMatchedURLFromRequest(req) if !plugins.CanHandle(res.Request, currentInstance.Retriever) { rw.Header().Set("Cache-Status", "Souin; fwd=uri-miss") return } - if !strings.Contains(req.Header.Get("Cache-Control"), "no-cache") { - retriever := currentInstance.Retriever - key := rfc.GetCacheKey(req) - r, _ := rfc.CachedResponse( - retriever.GetProvider(), - req, - key, - retriever.GetTransport(), - false, - ) - - if r != nil { - rh := r.Header - rfc.HitCache(&rh, retriever.GetMatchedURL().TTL.Duration) - r.Header = rh - for _, v := range []string{"Age", "Cache-Status"} { - h := r.Header.Get(v) - if h != "" { - rw.Header().Set(v, h) - } + retriever := currentInstance.Retriever + key := rfc.GetCacheKey(req) + r, _ := rfc.CachedResponse( + retriever.GetProvider(), + req, + key, + retriever.GetTransport(), + false, + ) + + if r != nil { + rh := r.Header + rfc.HitCache(&rh, retriever.GetMatchedURL().TTL.Duration) + r.Header = rh + for _, v := range []string{"Age", "Cache-Status"} { + h := r.Header.Get(v) + if h != "" { + rw.Header().Set(v, h) } - } else { - r, _ = retriever.GetTransport().UpdateCacheEventually(req) } - - res = r + } else { + r, _ = retriever.GetTransport().UpdateCacheEventually(req) } + res = r + currentCtx = nil } @@ -76,15 +83,15 @@ func SouinRequestHandler(rw http.ResponseWriter, r *http.Request) { // TODO remove these lines once Tyk patch the // ctx.GetDefinition(r) currentInstance := getInstanceFromRequest(r) - if !plugins.CanHandle(r, currentInstance.Retriever) { - return - } if b, handler := currentInstance.HandleInternally(r); b { handler(rw, r) return } + if currentInstance == nil || !plugins.CanHandle(r, currentInstance.Retriever) { + fmt.Println("currentInstance request is null ?", currentInstance, r.URL) + return + } r.Header.Set("Date", time.Now().UTC().Format(time.RFC1123)) - currentInstance.Retriever.SetMatchedURLFromRequest(r) coalescing.ServeResponse(rw, r, currentInstance.Retriever, plugins.DefaultSouinPluginCallback, currentInstance.RequestCoalescing, func(_ http.ResponseWriter, _ *http.Request) error { return nil }) diff --git a/plugins/tyk/override/providers/abstractProvider.go b/plugins/tyk/override/providers/abstractProvider.go index 59c25902c..f963e60c9 100644 --- a/plugins/tyk/override/providers/abstractProvider.go +++ b/plugins/tyk/override/providers/abstractProvider.go @@ -4,7 +4,6 @@ import ( "net/http" "strings" - "github.com/darkweak/souin/cache/types" "github.com/darkweak/souin/configurationtypes" ) @@ -13,9 +12,8 @@ const VarySeparator = "{-VARY-}" const stalePrefix = "STALE_" // InitializeProvider allow to generate the providers array according to the configuration -func InitializeProvider(configuration configurationtypes.AbstractConfigurationInterface) types.AbstractProviderInterface { - var r types.AbstractProviderInterface - r, _ = EmbeddedOlricConnectionFactory(configuration) +func InitializeProvider(configuration configurationtypes.AbstractConfigurationInterface) *Cache { + r, _ := CacheConnectionFactory(configuration) e := r.Init() if e != nil { panic(e) diff --git a/plugins/tyk/override/providers/cacheProvider.go b/plugins/tyk/override/providers/cacheProvider.go new file mode 100644 index 000000000..4e41d846f --- /dev/null +++ b/plugins/tyk/override/providers/cacheProvider.go @@ -0,0 +1,106 @@ +package providers + +import ( + "net/http" + "regexp" + "strings" + "time" + + t "github.com/darkweak/souin/configurationtypes" + "github.com/patrickmn/go-cache" +) + +// Cache provider type +type Cache struct { + *cache.Cache + stale time.Duration +} + +// CacheConnectionFactory function create new Cache instance +func CacheConnectionFactory(c t.AbstractConfigurationInterface) (*Cache, error) { + provider := cache.New(1*time.Second, 2*time.Second) + return &Cache{Cache: provider, stale: c.GetDefaultCache().GetStale()}, nil +} + +// ListKeys method returns the list of existing keys +func (provider *Cache) ListKeys() []string { + items := provider.Items() + keys := make([]string, 0, len(items)) + for k := range items { + keys = append(keys, k) + } + + return keys +} + +// Get method returns the populated response if exists, empty response then +func (provider *Cache) Get(key string) []byte { + result, found := provider.Cache.Get(key) + + if !found { + return []byte{} + } + + return result.([]byte) +} + +// Prefix method returns the populated response if exists, empty response then +func (provider *Cache) Prefix(key string, req *http.Request) []byte { + var result []byte + + for k, v := range provider.Items() { + if k == key { + return v.Object.([]byte) + } + + if !strings.HasPrefix(key, k) { + continue + } + + if varyVoter(key, req, k) { + result = v.Object.([]byte) + } + } + + return result +} + +// Set method will store the response in Cache provider +func (provider *Cache) Set(key string, value []byte, url t.URL, duration time.Duration) { + if duration == 0 { + duration = url.TTL.Duration + } + + provider.Cache.Set(key, value, duration) + provider.Cache.Set(stalePrefix+key, value, provider.stale+duration) +} + +// Delete method will delete the response in Cache provider if exists corresponding to key param +func (provider *Cache) Delete(key string) { + provider.Cache.Delete(key) +} + +// DeleteMany method will delete the responses in Cache provider if exists corresponding to the regex key param +func (provider *Cache) DeleteMany(key string) { + re, e := regexp.Compile(key) + + if e != nil { + return + } + + for k := range provider.Items() { + if re.MatchString(k) { + provider.Delete(k) + } + } +} + +// Init method will +func (provider *Cache) Init() error { + return nil +} + +// Reset method will reset or close provider +func (provider *Cache) Reset() { + provider.Cache.Flush() +} diff --git a/plugins/tyk/override/providers/embeddedOlricProvider.go b/plugins/tyk/override/providers/embeddedOlricProvider.go deleted file mode 100644 index 50fa4a48e..000000000 --- a/plugins/tyk/override/providers/embeddedOlricProvider.go +++ /dev/null @@ -1,233 +0,0 @@ -package providers - -import ( - "context" - "fmt" - "io/ioutil" - "net/http" - "os" - "time" - - "github.com/buraksezer/olric" - "github.com/buraksezer/olric/config" - "github.com/buraksezer/olric/query" - t "github.com/darkweak/souin/configurationtypes" - "github.com/google/uuid" - "go.uber.org/zap" - "gopkg.in/yaml.v3" -) - -// EmbeddedOlric provider type -type EmbeddedOlric struct { - dm *olric.DMap - db *olric.Olric - stale time.Duration -} - -func tryToLoadConfiguration(olricInstance *config.Config, olricConfiguration t.CacheProvider, logger *zap.Logger) (*config.Config, bool) { - var e error - isAlreadyLoaded := false - if olricConfiguration.Configuration == nil && olricConfiguration.Path != "" { - if olricInstance, e = config.Load(olricConfiguration.Path); e == nil { - isAlreadyLoaded = true - } - } else if olricConfiguration.Configuration != nil { - tmpFile := "/tmp/" + uuid.NewString() + ".yml" - yamlConfig, e := yaml.Marshal(olricConfiguration.Configuration) - defer func() { - if e = os.RemoveAll(tmpFile); e != nil { - logger.Error("Impossible to remove the temporary file") - } - }() - if e = ioutil.WriteFile( - tmpFile, - yamlConfig, - 0600, - ); e != nil { - logger.Error("Impossible to create the embedded Olric config from the given one") - } - - if olricInstance, e = config.Load(tmpFile); e == nil { - isAlreadyLoaded = true - } else { - logger.Error("Impossible to create the embedded Olric config from the given one") - } - } - - return olricInstance, isAlreadyLoaded -} - -// EmbeddedOlricConnectionFactory function create new EmbeddedOlric instance -func EmbeddedOlricConnectionFactory(configuration t.AbstractConfigurationInterface) (*EmbeddedOlric, error) { - var olricInstance *config.Config - loaded := false - - if olricInstance, loaded = tryToLoadConfiguration(olricInstance, configuration.GetDefaultCache().GetOlric(), configuration.GetLogger()); !loaded { - olricInstance = config.New("local") - olricInstance.DMaps.MaxInuse = 512 << 20 - } - - started, cancel := context.WithCancel(context.Background()) - olricInstance.Started = func() { - defer cancel() - configuration.GetLogger().Info("Embedded Olric is ready") - } - - db, err := olric.New(olricInstance) - if err != nil { - return nil, err - } - - ch := make(chan error, 1) - go func() { - if err = db.Start(); err != nil { - fmt.Printf("Impossible to start the embedded Olric instance: %v\n", err) - ch <- err - } - }() - - select { - case err = <-ch: - return nil, err - case <-started.Done(): - } - dm, e := db.NewDMap("souin-map") - - return &EmbeddedOlric{ - dm: dm, - db: db, - stale: configuration.GetDefaultCache().GetStale(), - }, e -} - -// ListKeys method returns the list of existing keys -func (provider *EmbeddedOlric) ListKeys() []string { - c, err := provider.dm.Query(query.M{ - "$onKey": query.M{ - "$regexMatch": "", - "$options": query.M{ - "$onValue": query.M{ - "$ignore": true, - }, - }, - }, - }) - if c != nil { - defer c.Close() - } - if err != nil { - fmt.Printf("An error occurred while trying to list keys in Olric: %s\n", err) - return []string{} - } - - keys := []string{} - _ = c.Range(func(key string, _ interface{}) bool { - keys = append(keys, key) - return true - }) - - return keys -} - -// Prefix method returns the populated response if exists, empty response then -func (provider *EmbeddedOlric) Prefix(key string, req *http.Request) []byte { - c, err := provider.dm.Query(query.M{ - "$onKey": query.M{ - "$regexMatch": "^" + key, - }, - }) - if c != nil { - defer c.Close() - } - if err != nil { - fmt.Printf("An error occurred while trying to retrieve data in Olric: %s\n", err) - return []byte{} - } - - res := []byte{} - _ = c.Range(func(k string, v interface{}) bool { - if varyVoter(key, req, k) { - res = v.([]byte) - return false - } - - return true - }) - - return res -} - -// Get method returns the populated response if exists, empty response then -func (provider *EmbeddedOlric) Get(key string) []byte { - val2, err := provider.dm.Get(key) - - if err != nil { - return []byte{} - } - - return val2.([]byte) -} - -// Set method will store the response in EmbeddedOlric provider -func (provider *EmbeddedOlric) Set(key string, value []byte, url t.URL, duration time.Duration) { - if duration == 0 { - duration = url.TTL.Duration - } - - if err := provider.dm.PutEx(key, value, duration); err != nil { - panic(err) - } - - if err := provider.dm.PutEx(stalePrefix+key, value, provider.stale+duration); err != nil { - panic(err) - } -} - -// Delete method will delete the response in EmbeddedOlric provider if exists corresponding to key param -func (provider *EmbeddedOlric) Delete(key string) { - go func() { - err := provider.dm.Delete(key) - if err != nil { - panic(err) - } - }() -} - -// DeleteMany method will delete the responses in EmbeddedOlric provider if exists corresponding to the regex key param -func (provider *EmbeddedOlric) DeleteMany(key string) { - go func() { - c, err := provider.dm.Query(query.M{ - "$onKey": query.M{ - "$regexMatch": key, - "$options": query.M{ - "$onValue": query.M{ - "$ignore": true, - }, - }, - }, - }) - - if c == nil || err != nil { - return - } - - err = c.Range(func(key string, _ interface{}) bool { - provider.Delete(key) - return true - }) - - if err != nil { - panic(err) - } - }() -} - -// Init method will initialize EmbeddedOlric provider if needed -func (provider *EmbeddedOlric) Init() error { - return nil -} - -// Reset method will reset or close provider -func (provider *EmbeddedOlric) Reset() { - _ = provider.db.Shutdown(context.Background()) -} diff --git a/plugins/tyk/override/providers/embeddedOlricProvider_test.go b/plugins/tyk/override/providers/embeddedOlricProvider_test.go deleted file mode 100644 index c30861263..000000000 --- a/plugins/tyk/override/providers/embeddedOlricProvider_test.go +++ /dev/null @@ -1,125 +0,0 @@ -package providers - -import ( - "fmt" - "testing" - "time" - - "github.com/darkweak/souin/cache/types" - "github.com/darkweak/souin/configurationtypes" - "github.com/darkweak/souin/errors" - "github.com/darkweak/souin/tests" -) - -const BYTEKEY = "MyByteKey" -const NONEXISTENTKEY = "NonexistentKey" -const EMBEDDEDOLRICVALUE = "My first data" - -func mockEmbeddedConfiguration(c func() string, key string) (types.AbstractProviderInterface, configurationtypes.URL) { - return tests.GetCacheProviderClientAndMatchedURL( - key, - func() configurationtypes.AbstractConfigurationInterface { - return tests.MockConfiguration(c) - }, - func(config configurationtypes.AbstractConfigurationInterface) (types.AbstractProviderInterface, error) { - provider, _ := EmbeddedOlricConnectionFactory(config) - _ = provider.Init() - - return provider, nil - }, - ) -} - -func getEmbeddedOlricClientAndMatchedURL(key string) (types.AbstractProviderInterface, configurationtypes.URL) { - return mockEmbeddedConfiguration(tests.EmbeddedOlricConfiguration, key) -} - -func getEmbeddedOlricWithoutYAML(key string) (types.AbstractProviderInterface, configurationtypes.URL) { - return mockEmbeddedConfiguration(tests.EmbeddedOlricPlainConfigurationWithoutAdditionalYAML, key) -} - -func TestIShouldBeAbleToReadAndWriteDataInEmbeddedOlric(t *testing.T) { - client, u := getEmbeddedOlricClientAndMatchedURL("Test") - defer client.Reset() - client.Set("Test", []byte(EMBEDDEDOLRICVALUE), u, time.Duration(10)*time.Second) - time.Sleep(3 * time.Second) - res := client.Get("Test") - if EMBEDDEDOLRICVALUE != string(res) { - errors.GenerateError(t, fmt.Sprintf("%s not corresponding to %s", res, EMBEDDEDOLRICVALUE)) - } -} - -func TestIShouldBeAbleToReadAndWriteDataInEmbeddedOlricWithoutYAML(t *testing.T) { - client, u := getEmbeddedOlricWithoutYAML("Test") - defer client.Reset() - client.Set("Test", []byte(EMBEDDEDOLRICVALUE), u, time.Duration(10)*time.Second) - time.Sleep(3 * time.Second) - res := client.Get("Test") - if EMBEDDEDOLRICVALUE != string(res) { - errors.GenerateError(t, fmt.Sprintf("%s not corresponding to %s", res, EMBEDDEDOLRICVALUE)) - } -} - -func TestEmbeddedOlric_GetRequestInCache(t *testing.T) { - client, _ := getEmbeddedOlricClientAndMatchedURL(NONEXISTENTKEY) - defer client.Reset() - res := client.Get(NONEXISTENTKEY) - if string(res) != "" { - errors.GenerateError(t, fmt.Sprintf("Key %s should not exist", NONEXISTENTKEY)) - } -} - -func TestEmbeddedOlric_SetRequestInCache_OneByte(t *testing.T) { - client, u := getEmbeddedOlricClientAndMatchedURL(BYTEKEY) - defer client.Reset() - client.Set(BYTEKEY, []byte{65}, u, time.Duration(20)*time.Second) -} - -func TestEmbeddedOlric_SetRequestInCache_TTL(t *testing.T) { - key := "MyEmptyKey" - client, matchedURL := getEmbeddedOlricClientAndMatchedURL(key) - defer client.Reset() - nv := []byte("Hello world") - setValueThenVerify(client, key, nv, matchedURL, time.Duration(20)*time.Second, t) -} - -func verifyNewValueAfterSet(client types.AbstractProviderInterface, key string, value []byte, t *testing.T) { - newValue := client.Get(key) - - if len(newValue) != len(value) { - errors.GenerateError(t, fmt.Sprintf("Key %s should be equals to %s, %s provided", key, value, newValue)) - } -} - -func setValueThenVerify(client types.AbstractProviderInterface, key string, value []byte, matchedURL configurationtypes.URL, ttl time.Duration, t *testing.T) { - client.Set(key, value, matchedURL, ttl) - time.Sleep(1 * time.Second) - verifyNewValueAfterSet(client, key, value, t) -} - -func TestEmbeddedOlric_SetRequestInCache_NoTTL(t *testing.T) { - client, matchedURL := getEmbeddedOlricClientAndMatchedURL(BYTEKEY) - defer client.Reset() - nv := []byte("New value") - setValueThenVerify(client, BYTEKEY, nv, matchedURL, 0, t) -} - -func TestEmbeddedOlric_DeleteRequestInCache(t *testing.T) { - client, _ := getEmbeddedOlricClientAndMatchedURL(BYTEKEY) - defer client.Reset() - client.Delete(BYTEKEY) - time.Sleep(1 * time.Second) - if 0 < len(client.Get(BYTEKEY)) { - errors.GenerateError(t, fmt.Sprintf("Key %s should not exist", BYTEKEY)) - } -} - -func TestEmbeddedOlric_Init(t *testing.T) { - client, _ := EmbeddedOlricConnectionFactory(tests.MockConfiguration(tests.EmbeddedOlricConfiguration)) - err := client.Init() - defer client.Reset() - - if nil != err { - errors.GenerateError(t, "Impossible to init EmbeddedOlric provider") - } -} diff --git a/plugins/tyk/tyk.json b/plugins/tyk/tyk.json index 757df7b71..e26e7d9f2 100644 --- a/plugins/tyk/tyk.json +++ b/plugins/tyk/tyk.json @@ -41,7 +41,15 @@ }, "enable_batch_request_support": true, "souin": { + "api": { + "souin": { + "enable": true + } + }, "default_cache": { + "regex": { + "exclude": "/test2.*" + }, "ttl": "10s" } }